BSP430
20141115
Board Support Package for MSP430 microcontrollers
|
Basic support for MSP430 Tag-Length-Value device descriptors. More...
#include <bsp430/core.h>
Go to the source code of this file.
Data Structures | |
struct | sBSP430tlvEntry |
struct | sBSP430tlvTable2xx |
struct | sBSP430tlvTable5xx |
struct | sBSP430tlvDIERECORD |
struct | sBSP430tlvREFCAL |
struct | sBPS430tlvADCCAL |
struct | sBSP430tlvDCO |
struct | sBPS430tlvADC |
Typedefs | |
typedef struct sBSP430tlvEntry | sBSP430tlvEntry |
typedef struct sBSP430tlvTable2xx | sBSP430tlvTable2xx |
typedef struct sBSP430tlvTable5xx | sBSP430tlvTable5xx |
typedef sBSP430tlvTable5xx | sBSP430tlvTable |
typedef struct sBSP430tlvDIERECORD | sBSP430tlvDIERECORD |
typedef struct sBSP430tlvREFCAL | sBSP430tlvREFCAL |
typedef struct sBPS430tlvADCCAL | sBSP430tlvADCCAL |
typedef struct sBSP430tlvDCO | sBSP430tlvDCO |
typedef struct sBPS430tlvADC | sBSP430tlvADC |
Functions | |
unsigned int | uiBSP430tlvChecksum (const unsigned char *data, size_t len) |
Basic support for MSP430 Tag-Length-Value device descriptors.
Two families of MSP430 use TLV descriptors for various purposes:
The layout of the device descriptor table and the algorithm used for checksum on them differ between these two implementations. The C preprocessor symbol BSP430_TLV_IS_5XX may be used to identify the supported implementation in user code.
#define BSP430_TLV (configBSP430_TLV - 0) |
Indicate that the TLV interface is available on the platform. The value is true iff configBSP430_TLV is true.
This flag is defined only if configBSP430_TLV is true.
#define BSP430_TLV_ENTRY_IS_ADC | ( | ep_ | ) | ((TLV_ADC10CAL == (ep_)->tag) || (TLV_ADC12CAL == (ep_)->tag)) |
Check whether a TLV entry corresponds to an ADC.
On 5xx/6xx MCUs this may be either TLV_ADC10CAL or TLV_ADC12CAL. No MCU has both.
On 2xx MCUs, the tag value is not constant across the family for either peripheral type, so an ADC is detected by a tag that is neither TAG_DCO_30 nor TAG_EMPTY.
#define BSP430_TLV_IS_5XX defined(__MSP430_HAS_MSP430XV2_CPU__) |
Flag used to determine which variant of TLV structure is used.
The functional presence symbol __MSP430_HAS_TLV__
is missing from certain headers that support TLV. For the purposes of this module, the standard BSP430 approach of using the MCU header functional presence symbol __MSP430_HAS_MSP430XV2_CPU__
is used to identify MCUs that follow the 5xx/6xx/FR5xx interface; the 2xx interface is assumed for all other MCUs.
#define BSP430_TLV_NEXT_ENTRY | ( | ep_ | ) | ((sBSP430tlvEntry *)(sizeof(sBSP430tlvEntry) + (ep_)->len + (unsigned char *)(ep_))) |
Return a pointer to the next entry in the table.
#define BSP430_TLV_TABLE_DATA_OFFSET 4 |
Offset from start of TLV table to skip past the CRC value
#define BSP430_TLV_TABLE_IS_VALID | ( | ) |
Check whether the table is valid.
This references BSP430_TLV_TABLE_START and TLV_END and other constants to verify that the stored checksum matches the checksum calculated over the data area of the descriptor table.
#define BSP430_TLV_TABLE_PREFIX_LENGTH 8 |
Offset from start of TLV table to the first sBSP430tlvEntry entry in the table.
#define BSP430_TLV_TABLE_START ((const unsigned char *)TLV_START - BSP430_TLV_TABLE_PREFIX_LENGTH) |
The offset of the device descriptor table.
This begins with the CRC and any other family-specific prefix information. The value has type const unsigned char *
, and may be cast to sBSP430tlvTable to access relevant information.
#define configBSP430_TLV 0 |
Define to a true value to indicate intent to use the TLV interface.
#define TAG_DCO_30 (0x01) |
(2xx) Tag for DCO30 Calibration Data
#define TAG_EMPTY (0xFE) |
(2xx) Tag for Empty Data Field in Calibration Data
#define TLV_ADC10CAL (0x13) |
ADC10 calibration
#define TLV_ADC12CAL (0x11) |
ADC12 calibration
#define TLV_BLANK (0x05) |
Blank descriptor
#define TLV_DIERECORD (0x08) |
Die Record
#define TLV_END (TLV_START - BSP430_TLV_TABLE_PREFIX_LENGTH + (4 << ((const sBSP430tlvTable *)BSP430_TLV_TABLE_START)->info_len_lg2) - 1) |
Integer corresponding to the address of the last byte in the TLV table.
It is normally part of the MCU header, but is missing in some cases. It can be reconstructed from the encoded table length.
#define TLV_LDTAG (0x01) |
Legacy descriptor (1xx, 2xx, 4xx families)
#define TLV_PDTAG (0x02) |
Peripheral discovery descriptor
#define TLV_REFCAL (0x12) |
REF calibration
#define TLV_START (BSP430_TLV_TABLE_PREFIX_LENGTH + *(const unsigned int *)0x0FF4) |
Integer corresponding to address of first TLV table entry.
This constant is normally part of the MCU header, but is missing in some cases. It can be reconstructed from the address stored in 0xFF4 on 5xx-family MCUs. It is normally 0x1A08
.
#define TLV_TAGEXT (0xFE) |
Tag extender
typedef struct sBPS430tlvADC sBSP430tlvADC |
TLV entry for TAG_ADC10_1 and TAG_ADC12_1 on 2xx MCUs
These are ADC gain and offset calibration constants, as well as constants for the internal temperature sensor. The tag values are not defined on all MCUs, and the observed value is 8
on some and 0x10
on others. The address of sBSP430tlvADC::cal_adc_gain_factor is fixed at 0x10DC
.
When processing a 2xx descriptor table, it is reasonable to assume that any tag that is not TAG_DCO_30 nor TAG_EMPTY corresponds to an ADC structure.
typedef struct sBPS430tlvADCCAL sBSP430tlvADCCAL |
TLV entry for TLV_ADCCAL, TLV_ADC12CAL, and TLV_ADC10CAL on 5xx MCUs
These are ADC gain and offset calibration constants, as well as constants for the internal temperature sensor. See the family user guide for details.
typedef struct sBSP430tlvDCO sBSP430tlvDCO |
TLV entry for TAG_DCO_30 on 2xx MCUs.
These are BC2 calibration constants for fixed frequencies of MCLK. The TAG_DCO_30 is not defined on all MCUs, but all observed MCUs have used a tag value 1
for this when a tag is present. The address of sBSP430tlvDCO::caldco_16mhz is fixed at 0x10F8
.
typedef struct sBSP430tlvDIERECORD sBSP430tlvDIERECORD |
TLV entry for TLV_DIERECORD on 5xx MCUs.
This structure is not described in the users' guide, but can be found in certain MCU data sheets, including the one for the MSP430F5438a
typedef struct sBSP430tlvEntry sBSP430tlvEntry |
Fixed header for all TLV entries. This is immediately followed by entry-specific data.
typedef struct sBSP430tlvREFCAL sBSP430tlvREFCAL |
TLV entry for TLV_REFCAL on 5xx MCUs.
These are the constants for ADC adjustment based on the internal reference voltage. See the family user guide for details.
typedef sBSP430tlvTable5xx sBSP430tlvTable |
Typedef for the family-specific TLV table structure for this MCU.
typedef struct sBSP430tlvTable2xx sBSP430tlvTable2xx |
The complete device descriptor table including the header, as supported on 2xx devices. The address of the table is 0x10C0
.
typedef struct sBSP430tlvTable5xx sBSP430tlvTable5xx |
The complete device descriptor table including the header, as supported on 5xx/6xx/FR5xx devices. The address of sBSP430tlvTable5::entry is available as TLV_START in the MCU header, and can be read from memory at address 0x0FF4
.
unsigned int uiBSP430tlvChecksum | ( | const unsigned char * | data, |
size_t | len | ||
) |
Calculate the TLV-compatible checksum for a region of memory.
The algorithm that is used is family-specific.
Other families do not explicitly support the TLV infrastructure, though it may be used for application purposes.
data
= TLV_START-4, and the length of the region is len
= 5+TLV_END-TLV_START
.data | The address of the data over which the checksum is calculated. |
len | The number of octets in the data that contribute to the checksum. |