BSP430  20141115
Board Support Package for MSP430 microcontrollers
 All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Macros Modules Pages
Data Structures | Macros | Typedefs | Functions
eusci.h File Reference

Hardware presentation/abstraction for eUSCI. More...

#include <bsp430/periph.h>
#include <bsp430/serial_.h>

Go to the source code of this file.

Data Structures

struct  sBSP430hplEUSCIA
 
struct  sBSP430hplEUSCIB
 

Macros

#define BSP430_MODULE_EUSCI
 
#define BSP430_EUSCI_UART_MAX_BAUD   1000000UL
 
#define configBSP430_HAL_EUSCI_A0   0
 
#define BSP430_HAL_EUSCI_A0   (&xBSP430hal_EUSCI_A0_)
 
#define configBSP430_HAL_EUSCI_A1   0
 
#define BSP430_HAL_EUSCI_A1   (&xBSP430hal_EUSCI_A1_)
 
#define configBSP430_HAL_EUSCI_A2   0
 
#define BSP430_HAL_EUSCI_A2   (&xBSP430hal_EUSCI_A2_)
 
#define configBSP430_HAL_EUSCI_A3   0
 
#define BSP430_HAL_EUSCI_A3   (&xBSP430hal_EUSCI_A3_)
 
#define configBSP430_HAL_EUSCI_B0   0
 
#define BSP430_HAL_EUSCI_B0   (&xBSP430hal_EUSCI_B0_)
 
#define configBSP430_HAL_EUSCI_B1   0
 
#define BSP430_HAL_EUSCI_B1   (&xBSP430hal_EUSCI_B1_)
 
#define configBSP430_HPL_EUSCI_A0   (configBSP430_HAL_EUSCI_A0 - 0)
 
#define BSP430_PERIPH_EUSCI_A0   ((tBSP430periphHandle)(BSP430_PERIPH_EUSCI_A0_BASEADDRESS_))
 
#define configBSP430_HPL_EUSCI_A1   (configBSP430_HAL_EUSCI_A1 - 0)
 
#define BSP430_PERIPH_EUSCI_A1   ((tBSP430periphHandle)(BSP430_PERIPH_EUSCI_A1_BASEADDRESS_))
 
#define configBSP430_HPL_EUSCI_A2   (configBSP430_HAL_EUSCI_A2 - 0)
 
#define BSP430_PERIPH_EUSCI_A2   ((tBSP430periphHandle)(BSP430_PERIPH_EUSCI_A2_BASEADDRESS_))
 
#define configBSP430_HPL_EUSCI_A3   (configBSP430_HAL_EUSCI_A3 - 0)
 
#define BSP430_PERIPH_EUSCI_A3   ((tBSP430periphHandle)(BSP430_PERIPH_EUSCI_A3_BASEADDRESS_))
 
#define BSP430_HPL_EUSCI_A0   ((volatile sBSP430hplEUSCIA *)BSP430_PERIPH_EUSCI_A0)
 
#define BSP430_HPL_EUSCI_A1   ((volatile sBSP430hplEUSCIA *)BSP430_PERIPH_EUSCI_A1)
 
#define BSP430_HPL_EUSCI_A2   ((volatile sBSP430hplEUSCIA *)BSP430_PERIPH_EUSCI_A2)
 
#define BSP430_HPL_EUSCI_A3   ((volatile sBSP430hplEUSCIA *)BSP430_PERIPH_EUSCI_A3)
 
#define configBSP430_HAL_EUSCI_A0_ISR   (configBSP430_HAL_EUSCI_A0 - 0)
 
#define configBSP430_HAL_EUSCI_A1_ISR   (configBSP430_HAL_EUSCI_A1 - 0)
 
#define configBSP430_HAL_EUSCI_A2_ISR   (configBSP430_HAL_EUSCI_A2 - 0)
 
#define configBSP430_HAL_EUSCI_A3_ISR   (configBSP430_HAL_EUSCI_A3 - 0)
 
#define configBSP430_HPL_EUSCI_B0   (configBSP430_HAL_EUSCI_B0 - 0)
 
#define BSP430_PERIPH_EUSCI_B0   ((tBSP430periphHandle)(BSP430_PERIPH_EUSCI_B0_BASEADDRESS_))
 
#define configBSP430_HPL_EUSCI_B1   (configBSP430_HAL_EUSCI_B1 - 0)
 
#define BSP430_PERIPH_EUSCI_B1   ((tBSP430periphHandle)(BSP430_PERIPH_EUSCI_B1_BASEADDRESS_))
 
#define BSP430_HPL_EUSCI_B0   ((volatile sBSP430hplEUSCIB *)BSP430_PERIPH_EUSCI_B0)
 
#define BSP430_HPL_EUSCI_B1   ((volatile sBSP430hplEUSCIB *)BSP430_PERIPH_EUSCI_B1)
 
#define configBSP430_HAL_EUSCI_B0_ISR   (configBSP430_HAL_EUSCI_B0 - 0)
 
#define configBSP430_HAL_EUSCI_B1_ISR   (configBSP430_HAL_EUSCI_B1 - 0)
 

Typedefs

typedef struct sBSP430hplEUSCIA sBSP430hplEUSCIA
 
typedef struct sBSP430hplEUSCIB sBSP430hplEUSCIB
 

Functions

hBSP430halSERIAL hBSP430eusciOpenUART (hBSP430halSERIAL hal, unsigned char ctl0_byte, unsigned char ctl1_byte, unsigned long baud)
 
hBSP430halSERIAL hBSP430eusciOpenSPI (hBSP430halSERIAL hal, unsigned char ctl0_byte, unsigned char ctl1_byte, unsigned int prescaler)
 
hBSP430halSERIAL hBSP430eusciOpenI2C (hBSP430halSERIAL hal, unsigned char ctl0_byte, unsigned char ctl1_byte, unsigned int prescaler)
 
int iBSP430eusciSetReset_rh (hBSP430halSERIAL hal, int resetp)
 
int iBSP430eusciSetHold_rh (hBSP430halSERIAL hal, int holdp)
 
int iBSP430eusciClose (hBSP430halSERIAL hal)
 
void vBSP430eusciWakeupTransmit_rh (hBSP430halSERIAL device)
 
void vBSP430eusciFlush_ni (hBSP430halSERIAL device)
 
int iBSP430eusciUARTrxByte_rh (hBSP430halSERIAL device)
 
int iBSP430eusciUARTtxByte_rh (hBSP430halSERIAL device, uint8_t c)
 
int iBSP430eusciUARTtxData_rh (hBSP430halSERIAL device, const uint8_t *data, size_t len)
 
int iBSP430eusciUARTtxASCIIZ_rh (hBSP430halSERIAL device, const char *str)
 
int iBSP430eusciSPITxRx_rh (hBSP430halSERIAL hal, const uint8_t *tx_data, size_t tx_len, size_t rx_len, uint8_t *rx_data)
 
int iBSP430eusciI2CsetAddresses_rh (hBSP430halSERIAL hal, int own_address, int slave_address)
 
int iBSP430eusciI2CrxData_rh (hBSP430halSERIAL hal, uint8_t *rx_data, size_t rx_len)
 
int iBSP430eusciI2CtxData_rh (hBSP430halSERIAL hal, const uint8_t *tx_data, size_t tx_len)
 
static BSP430_CORE_INLINE volatile sBSP430hplEUSCIAxBSP430hplLookupEUSCIA (tBSP430periphHandle periph)
 
static BSP430_CORE_INLINE volatile sBSP430hplEUSCIBxBSP430hplLookupEUSCIB (tBSP430periphHandle periph)
 
static BSP430_CORE_INLINE hBSP430halSERIAL hBSP430eusciLookup (tBSP430periphHandle periph)
 
const char * xBSP430eusciName (tBSP430periphHandle periph)
 

Detailed Description

Hardware presentation/abstraction for eUSCI.

The Enhanced Universal Serial Communication Interface is available in the 5xx/6xx/FR5xx family, primarily on FRAM devices. See bsp430/periph/usci.h and bsp430/periph/usci5.h for related peripherals in other families.

Conventional peripheral handles are BSP430_PERIPH_EUSCI_A0, BSP430_PERIPH_EUSCI_B0, and others dependent on availability.

Module Configuration Options

Substitute other instance names (e.g., B0) as necessary.

Hardware Presentation Layer

Like previous USCI modules, eUSCI supports an A variant with UART and SPI capabilities, and a B variant with SPI and I2C capabilities. Unlike previous modules the register maps for the two variants are not compatible; in particular introduction of certain I2C capabilities causes some SPI registers to be placed at different offsets in the A and B variables.

This module defines sBSP430hplEUSCIA as the HPL structure for the A variant, and sBSP430hplEUSCIB as the HPL structure for the B variant.

Hardware Adaptation Layer

The eUSCI hardware adaptation layer uses the sBSP430halSERIAL structure from the generic serial adaptation layer. It can also be accessed directly using the functions defined in this module. Both A and B variants are supported by the same HAL structure.

Enabling the HAL layer for an eUSCI instance enables the corresponding interrupt structure by default. eUSCI does not support a secondary ISR.

Homepage
http://github.com/pabigot/bsp430

Macro Definition Documentation

#define BSP430_EUSCI_UART_MAX_BAUD   1000000UL

Maximum baud rate acceptable for UART mode.

Not to say you can actually get this to work, but the API will reject configuration of a UART rate above this.

#define BSP430_HAL_EUSCI_A0   (&xBSP430hal_EUSCI_A0_)

sBSP430halSERIAL HAL handle for BSP430_PERIPH_EUSCI_A0.

This pointer may be used only if configBSP430_HAL_EUSCI_A0 is defined to a true value.

Dependency:
configBSP430_HAL_EUSCI_A0
#define BSP430_HAL_EUSCI_A1   (&xBSP430hal_EUSCI_A1_)

sBSP430halSERIAL HAL handle for BSP430_PERIPH_EUSCI_A1.

This pointer may be used only if configBSP430_HAL_EUSCI_A1 is defined to a true value.

Dependency:
configBSP430_HAL_EUSCI_A1
#define BSP430_HAL_EUSCI_A2   (&xBSP430hal_EUSCI_A2_)

sBSP430halSERIAL HAL handle for BSP430_PERIPH_EUSCI_A2.

This pointer may be used only if configBSP430_HAL_EUSCI_A2 is defined to a true value.

Dependency:
configBSP430_HAL_EUSCI_A2
#define BSP430_HAL_EUSCI_A3   (&xBSP430hal_EUSCI_A3_)

sBSP430halSERIAL HAL handle for BSP430_PERIPH_EUSCI_A3.

This pointer may be used only if configBSP430_HAL_EUSCI_A3 is defined to a true value.

Dependency:
configBSP430_HAL_EUSCI_A3
#define BSP430_HAL_EUSCI_B0   (&xBSP430hal_EUSCI_B0_)

sBSP430halSERIAL HAL handle for BSP430_PERIPH_EUSCI_B0.

This pointer may be used only if configBSP430_HAL_EUSCI_B0 is defined to a true value.

Dependency:
configBSP430_HAL_EUSCI_B0
#define BSP430_HAL_EUSCI_B1   (&xBSP430hal_EUSCI_B1_)

sBSP430halSERIAL HAL handle for BSP430_PERIPH_EUSCI_B1.

This pointer may be used only if configBSP430_HAL_EUSCI_B1 is defined to a true value.

Dependency:
configBSP430_HAL_EUSCI_B1
#define BSP430_HPL_EUSCI_A0   ((volatile sBSP430hplEUSCIA *)BSP430_PERIPH_EUSCI_A0)

sBSP430hplEUSCIA HPL pointer for BSP430_PERIPH_EUSCI_A0.

This pointer to a volatile structure overlaying the EUSCI_A0 peripheral register map may be used only if configBSP430_HPL_EUSCI_A0 is defined to a true value.

Dependency:
configBSP430_HPL_EUSCI_A0
#define BSP430_HPL_EUSCI_A1   ((volatile sBSP430hplEUSCIA *)BSP430_PERIPH_EUSCI_A1)

sBSP430hplEUSCIA HPL pointer for BSP430_PERIPH_EUSCI_A1.

This pointer to a volatile structure overlaying the EUSCI_A1 peripheral register map may be used only if configBSP430_HPL_EUSCI_A1 is defined to a true value.

Dependency:
configBSP430_HPL_EUSCI_A1
#define BSP430_HPL_EUSCI_A2   ((volatile sBSP430hplEUSCIA *)BSP430_PERIPH_EUSCI_A2)

sBSP430hplEUSCIA HPL pointer for BSP430_PERIPH_EUSCI_A2.

This pointer to a volatile structure overlaying the EUSCI_A2 peripheral register map may be used only if configBSP430_HPL_EUSCI_A2 is defined to a true value.

Dependency:
configBSP430_HPL_EUSCI_A2
#define BSP430_HPL_EUSCI_A3   ((volatile sBSP430hplEUSCIA *)BSP430_PERIPH_EUSCI_A3)

sBSP430hplEUSCIA HPL pointer for BSP430_PERIPH_EUSCI_A3.

This pointer to a volatile structure overlaying the EUSCI_A3 peripheral register map may be used only if configBSP430_HPL_EUSCI_A3 is defined to a true value.

Dependency:
configBSP430_HPL_EUSCI_A3
#define BSP430_HPL_EUSCI_B0   ((volatile sBSP430hplEUSCIB *)BSP430_PERIPH_EUSCI_B0)

sBSP430hplEUSCIB HPL pointer for BSP430_PERIPH_EUSCI_B0.

This pointer to a volatile structure overlaying the EUSCI_B0 peripheral register map may be used only if configBSP430_HPL_EUSCI_B0 is defined to a true value.

Dependency:
configBSP430_HPL_EUSCI_B0
#define BSP430_HPL_EUSCI_B1   ((volatile sBSP430hplEUSCIB *)BSP430_PERIPH_EUSCI_B1)

sBSP430hplEUSCIB HPL pointer for BSP430_PERIPH_EUSCI_B1.

This pointer to a volatile structure overlaying the EUSCI_B1 peripheral register map may be used only if configBSP430_HPL_EUSCI_B1 is defined to a true value.

Dependency:
configBSP430_HPL_EUSCI_B1
#define BSP430_MODULE_EUSCI
Value:
(defined(__MSP430_HAS_EUSCI_A0__) \
|| defined(__MSP430_HAS_EUSCI_B0__))

Defined on inclusion of <bsp430/periph/eusci.h>. The value evaluates to true if the target MCU supports the Enhanced Universal Serial Communcations Interface peripheral, and false if it does not.

C Preprocessor Only:
This macro may have a value that restricts its use to C preprocessor conditional directives.
#define BSP430_PERIPH_EUSCI_A0   ((tBSP430periphHandle)(BSP430_PERIPH_EUSCI_A0_BASEADDRESS_))

Handle for the raw EUSCI_A0 device.

The handle may be used only if configBSP430_HPL_EUSCI_A0 is defined to a true value.

Dependency:
configBSP430_HPL_EUSCI_A0
#define BSP430_PERIPH_EUSCI_A1   ((tBSP430periphHandle)(BSP430_PERIPH_EUSCI_A1_BASEADDRESS_))

Handle for the raw EUSCI_A1 device.

The handle may be used only if configBSP430_HPL_EUSCI_A1 is defined to a true value.

Dependency:
configBSP430_HPL_EUSCI_A1
#define BSP430_PERIPH_EUSCI_A2   ((tBSP430periphHandle)(BSP430_PERIPH_EUSCI_A2_BASEADDRESS_))

Handle for the raw EUSCI_A2 device.

The handle may be used only if configBSP430_HPL_EUSCI_A2 is defined to a true value.

Dependency:
configBSP430_HPL_EUSCI_A2
#define BSP430_PERIPH_EUSCI_A3   ((tBSP430periphHandle)(BSP430_PERIPH_EUSCI_A3_BASEADDRESS_))

Handle for the raw EUSCI_A3 device.

The handle may be used only if configBSP430_HPL_EUSCI_A3 is defined to a true value.

Dependency:
configBSP430_HPL_EUSCI_A3
#define BSP430_PERIPH_EUSCI_B0   ((tBSP430periphHandle)(BSP430_PERIPH_EUSCI_B0_BASEADDRESS_))

Handle for the raw EUSCI_B0 device.

The handle may be used only if configBSP430_HPL_EUSCI_B0 is defined to a true value.

Dependency:
configBSP430_HPL_EUSCI_B0
#define BSP430_PERIPH_EUSCI_B1   ((tBSP430periphHandle)(BSP430_PERIPH_EUSCI_B1_BASEADDRESS_))

Handle for the raw EUSCI_B1 device.

The handle may be used only if configBSP430_HPL_EUSCI_B1 is defined to a true value.

Dependency:
configBSP430_HPL_EUSCI_B1

Typedef Documentation

Register map for eUSCI_A peripheral hardware presentation layer.

Register map for eUSCI_B peripheral hardware presentation layer.

Function Documentation

static BSP430_CORE_INLINE hBSP430halSERIAL hBSP430eusciLookup ( tBSP430periphHandle  periph)
static

Get the HAL handle for a specific EUSCI (A or B) instance.

Parameters
periphThe handle identifier, such as BSP430_PERIPH_EUSCI_A0.
Returns
the HAL handle for the peripheral. A null pointer is returned if the handle does not correspond to a timer for which the HAL interface has been enabled (e.g., with configBSP430_HAL_EUSCI_A0).
hBSP430halSERIAL hBSP430eusciOpenI2C ( hBSP430halSERIAL  hal,
unsigned char  ctl0_byte,
unsigned char  ctl1_byte,
unsigned int  prescaler 
)

eUSCI-specific implementation of hBSP430serialOpenI2C()

hBSP430halSERIAL hBSP430eusciOpenSPI ( hBSP430halSERIAL  hal,
unsigned char  ctl0_byte,
unsigned char  ctl1_byte,
unsigned int  prescaler 
)

eUSCI-specific implementation of hBSP430serialOpenSPI()

hBSP430halSERIAL hBSP430eusciOpenUART ( hBSP430halSERIAL  hal,
unsigned char  ctl0_byte,
unsigned char  ctl1_byte,
unsigned long  baud 
)

eUSCI-specific implementation of hBSP430serialOpenUART()

int iBSP430eusciClose ( hBSP430halSERIAL  hal)

eUSCI-specific implementation of iBSP430serialClose()

int iBSP430eusciI2CrxData_rh ( hBSP430halSERIAL  hal,
uint8_t *  rx_data,
size_t  rx_len 
)

eUSCI-specific implementation of iBSP430i2cRxData_rh()

int iBSP430eusciI2CsetAddresses_rh ( hBSP430halSERIAL  hal,
int  own_address,
int  slave_address 
)

eUSCI-specific implementation of iBSP430i2cSetAddresses_rh()

int iBSP430eusciI2CtxData_rh ( hBSP430halSERIAL  hal,
const uint8_t *  tx_data,
size_t  tx_len 
)

eUSCI-specific implementation of iBSP430i2cTxData_rh()

int iBSP430eusciSetHold_rh ( hBSP430halSERIAL  hal,
int  holdp 
)

eUSCI-specific implementation of iBSP430serialSetHold_rh()

int iBSP430eusciSetReset_rh ( hBSP430halSERIAL  hal,
int  resetp 
)

eUSCI-specific implementation of iBSP430serialSetReset_rh()

int iBSP430eusciSPITxRx_rh ( hBSP430halSERIAL  hal,
const uint8_t *  tx_data,
size_t  tx_len,
size_t  rx_len,
uint8_t *  rx_data 
)

eUSCI-specific implementation of iBSP430spiTxRx_rh()

int iBSP430eusciUARTrxByte_rh ( hBSP430halSERIAL  device)

eUSCI-specific implementation of iBSP430uartRxByte_rh()

int iBSP430eusciUARTtxASCIIZ_rh ( hBSP430halSERIAL  device,
const char *  str 
)

eUSCI-specific implementation of iBSP430uartTxASCIIZ_rh()

int iBSP430eusciUARTtxByte_rh ( hBSP430halSERIAL  device,
uint8_t  c 
)

eUSCI-specific implementation of iBSP430uartTxByte_rh()

int iBSP430eusciUARTtxData_rh ( hBSP430halSERIAL  device,
const uint8_t *  data,
size_t  len 
)

eUSCI-specific implementation of iBSP430uartTxData_rh()

void vBSP430eusciFlush_ni ( hBSP430halSERIAL  device)

eUSCI-specific implementation of vBSP430serialFlush_ni()

void vBSP430eusciWakeupTransmit_rh ( hBSP430halSERIAL  device)

eUSCI-specific implementation of vBSP430serialWakeupTransmit_rh()

const char* xBSP430eusciName ( tBSP430periphHandle  periph)

Get a human-readable identifier for the EUSCI (A or B) peripheral

Parameters
periphThe handle identifier, such as BSP430_PERIPH_EUSCI_A0.
Returns
The short name of the port, e.g. "EUSCI_A0". If the peripheral is not recognized as a EUSCI-A device, a null pointer is returned.
static BSP430_CORE_INLINE volatile sBSP430hplEUSCIA* xBSP430hplLookupEUSCIA ( tBSP430periphHandle  periph)
static

Get the HPL handle for a specific EUSCIA instance.

Parameters
periphThe handle identifier, such as BSP430_PERIPH_EUSCI_A0.
Returns
A typed pointer that can be used to manipulate the peripheral. A null pointer is returned if the handle does not correspond to a timer for which the HPL interface been enabled (e.g., with configBSP430_HPL_EUSCI_A0).
static BSP430_CORE_INLINE volatile sBSP430hplEUSCIB* xBSP430hplLookupEUSCIB ( tBSP430periphHandle  periph)
static

Get the HPL handle for a specific EUSCIB instance.

Parameters
periphThe handle identifier, such as BSP430_PERIPH_EUSCI_B0.
Returns
A typed pointer that can be used to manipulate the peripheral. A null pointer is returned if the handle does not correspond to a timer for which the HPL interface been enabled (e.g., with configBSP430_HPL_EUSCI_B0).