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
usci.h File Reference

Hardware presentation/abstraction for USCI_A/USCI_B on 2xx/4xx devices. More...

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

Go to the source code of this file.

Data Structures

struct  sBSP430hplUSCI
 

Macros

#define BSP430_MODULE_USCI   defined(__MSP430_HAS_USCI__)
 
#define BSP430_USCI_UART_MAX_BAUD   1000000UL
 
#define configBSP430_HAL_USCI_A0   0
 
#define BSP430_HAL_USCI_A0   (&xBSP430hal_USCI_A0_)
 
#define configBSP430_HAL_USCI_A1   0
 
#define BSP430_HAL_USCI_A1   (&xBSP430hal_USCI_A1_)
 
#define configBSP430_HAL_USCI_B0   0
 
#define BSP430_HAL_USCI_B0   (&xBSP430hal_USCI_B0_)
 
#define configBSP430_HAL_USCI_B1   0
 
#define BSP430_HAL_USCI_B1   (&xBSP430hal_USCI_B1_)
 
#define configBSP430_HPL_USCI_A0   (configBSP430_HAL_USCI_A0 - 0)
 
#define BSP430_PERIPH_USCI_A0   ((tBSP430periphHandle)(BSP430_PERIPH_USCI_A0_BASEADDRESS_))
 
#define configBSP430_HPL_USCI_A1   (configBSP430_HAL_USCI_A1 - 0)
 
#define BSP430_PERIPH_USCI_A1   ((tBSP430periphHandle)(BSP430_PERIPH_USCI_A1_BASEADDRESS_))
 
#define configBSP430_HPL_USCI_B0   (configBSP430_HAL_USCI_B0 - 0)
 
#define BSP430_PERIPH_USCI_B0   ((tBSP430periphHandle)(BSP430_PERIPH_USCI_B0_BASEADDRESS_))
 
#define configBSP430_HPL_USCI_B1   (configBSP430_HAL_USCI_B1 - 0)
 
#define BSP430_PERIPH_USCI_B1   ((tBSP430periphHandle)(BSP430_PERIPH_USCI_B1_BASEADDRESS_))
 
#define BSP430_HPL_USCI_A0   ((volatile sBSP430hplUSCI *)BSP430_PERIPH_USCI_A0)
 
#define BSP430_HPL_USCI_A1   ((volatile sBSP430hplUSCI *)BSP430_PERIPH_USCI_A1)
 
#define BSP430_HPL_USCI_B0   ((volatile sBSP430hplUSCI *)BSP430_PERIPH_USCI_B0)
 
#define BSP430_HPL_USCI_B1   ((volatile sBSP430hplUSCI *)BSP430_PERIPH_USCI_B1)
 
#define configBSP430_HAL_USCI_AB0RX_ISR   ((configBSP430_HAL_USCI_A0 - 0) || (configBSP430_HAL_USCI_B0 - 0))
 
#define configBSP430_HAL_USCI_AB0TX_ISR   ((configBSP430_HAL_USCI_A0 - 0) | (configBSP430_HAL_USCI_B0 - 0))
 
#define configBSP430_HAL_USCI_AB1RX_ISR   ((configBSP430_HAL_USCI_A1 - 0) || (configBSP430_HAL_USCI_B1 - 0))
 
#define configBSP430_HAL_USCI_AB1TX_ISR   ((configBSP430_HAL_USCI_A1 - 0) | (configBSP430_HAL_USCI_B1 - 0))
 

Typedefs

typedef struct sBSP430hplUSCI sBSP430hplUSCI
 

Functions

hBSP430halSERIAL hBSP430usciOpenUART (hBSP430halSERIAL hal, unsigned char ctl0_byte, unsigned char ctl1_byte, unsigned long baud)
 
hBSP430halSERIAL hBSP430usciOpenSPI (hBSP430halSERIAL hal, unsigned char ctl0_byte, unsigned char ctl1_byte, unsigned int prescaler)
 
hBSP430halSERIAL hBSP430usciOpenI2C (hBSP430halSERIAL hal, unsigned char ctl0_byte, unsigned char ctl1_byte, unsigned int prescaler)
 
int iBSP430usciSetReset_rh (hBSP430halSERIAL hal, int resetp)
 
int iBSP430usciSetHold_rh (hBSP430halSERIAL hal, int holdp)
 
int iBSP430usciClose (hBSP430halSERIAL xUSCI)
 
void vBSP430usciWakeupTransmit_rh (hBSP430halSERIAL device)
 
void vBSP430usciFlush_ni (hBSP430halSERIAL device)
 
int iBSP430usciUARTrxByte_rh (hBSP430halSERIAL device)
 
int iBSP430usciUARTtxByte_rh (hBSP430halSERIAL device, uint8_t c)
 
int iBSP430usciUARTtxData_rh (hBSP430halSERIAL device, const uint8_t *data, size_t len)
 
int iBSP430usciUARTtxASCIIZ_rh (hBSP430halSERIAL device, const char *str)
 
int iBSP430usciSPITxRx_rh (hBSP430halSERIAL hal, const uint8_t *tx_data, size_t tx_len, size_t rx_len, uint8_t *rx_data)
 
int iBSP430usciI2CsetAddresses_rh (hBSP430halSERIAL hal, int own_address, int slave_address)
 
int iBSP430usciI2CrxData_rh (hBSP430halSERIAL hal, uint8_t *rx_data, size_t rx_len)
 
int iBSP430usciI2CtxData_rh (hBSP430halSERIAL hal, const uint8_t *tx_data, size_t tx_len)
 
static BSP430_CORE_INLINE volatile sBSP430hplUSCIxBSP430hplLookupUSCI (tBSP430periphHandle periph)
 
static BSP430_CORE_INLINE hBSP430halSERIAL hBSP430usciLookup (tBSP430periphHandle periph)
 
const char * xBSP430usciName (tBSP430periphHandle periph)
 

Detailed Description

Hardware presentation/abstraction for USCI_A/USCI_B on 2xx/4xx devices.

This version of the Universial Serial Communications Interface is available in the 2xx and 4xx families. See bsp430/periph/usci5.h and bsp430/periph/eusci.h for related peripherals in other families.

Conventional peripheral handles are BSP430_PERIPH_USCI_A0, BSP430_PERIPH_USCI_B0, and others dependent on availability.

Module Configuration Options

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

Hardware Presentation Layer

USCI supports an A variant with UART and SPI capabilities, and a B variant with SPI and I2C capabilities. The register maps for the two variants are compatible, and sBSP430hplUSCI is used for both variants. This structure is not compatible with the next generation USCI module.

Hardware Adaptation Layer

The USCI HAL 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 a USCI instance enables both the transmission and reception interrupt service routines by default. Although transmission and receiption interrupts are distinct and shared by both the A and B variants of a specific instance, this is obscured by the generic serial adaptation layer, with distinct callbacks for each event on each instance.

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

Macro Definition Documentation

#define BSP430_HAL_USCI_A0   (&xBSP430hal_USCI_A0_)

sBSP430halSERIAL HAL handle for BSP430_PERIPH_USCI_A0.

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

Dependency:
configBSP430_HAL_USCI_A0
#define BSP430_HAL_USCI_A1   (&xBSP430hal_USCI_A1_)

sBSP430halSERIAL HAL handle for BSP430_PERIPH_USCI_A1.

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

Dependency:
configBSP430_HAL_USCI_A1
#define BSP430_HAL_USCI_B0   (&xBSP430hal_USCI_B0_)

sBSP430halSERIAL HAL handle for BSP430_PERIPH_USCI_B0.

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

Dependency:
configBSP430_HAL_USCI_B0
#define BSP430_HAL_USCI_B1   (&xBSP430hal_USCI_B1_)

sBSP430halSERIAL HAL handle for BSP430_PERIPH_USCI_B1.

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

Dependency:
configBSP430_HAL_USCI_B1
#define BSP430_HPL_USCI_A0   ((volatile sBSP430hplUSCI *)BSP430_PERIPH_USCI_A0)

sBSP430hplUSCI HPL pointer for BSP430_PERIPH_USCI_A0.

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

Dependency:
configBSP430_HPL_USCI_A0
#define BSP430_HPL_USCI_A1   ((volatile sBSP430hplUSCI *)BSP430_PERIPH_USCI_A1)

sBSP430hplUSCI HPL pointer for BSP430_PERIPH_USCI_A1.

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

Dependency:
configBSP430_HPL_USCI_A1
#define BSP430_HPL_USCI_B0   ((volatile sBSP430hplUSCI *)BSP430_PERIPH_USCI_B0)

sBSP430hplUSCI HPL pointer for BSP430_PERIPH_USCI_B0.

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

Dependency:
configBSP430_HPL_USCI_B0
#define BSP430_HPL_USCI_B1   ((volatile sBSP430hplUSCI *)BSP430_PERIPH_USCI_B1)

sBSP430hplUSCI HPL pointer for BSP430_PERIPH_USCI_B1.

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

Dependency:
configBSP430_HPL_USCI_B1
#define BSP430_MODULE_USCI   defined(__MSP430_HAS_USCI__)

Defined on inclusion of <bsp430/periph/usci.h>. The value evaluates to true if the target MCU supports the Universal Serial Communications Interface (2xx/4xx version), 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_USCI_A0   ((tBSP430periphHandle)(BSP430_PERIPH_USCI_A0_BASEADDRESS_))

Handle for the raw USCI_A0 device.

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

Dependency:
configBSP430_HPL_USCI_A0
#define BSP430_PERIPH_USCI_A1   ((tBSP430periphHandle)(BSP430_PERIPH_USCI_A1_BASEADDRESS_))

Handle for the raw USCI_A1 device.

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

Dependency:
configBSP430_HPL_USCI_A1
#define BSP430_PERIPH_USCI_B0   ((tBSP430periphHandle)(BSP430_PERIPH_USCI_B0_BASEADDRESS_))

Handle for the raw USCI_B0 device.

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

Dependency:
configBSP430_HPL_USCI_B0
#define BSP430_PERIPH_USCI_B1   ((tBSP430periphHandle)(BSP430_PERIPH_USCI_B1_BASEADDRESS_))

Handle for the raw USCI_B1 device.

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

Dependency:
configBSP430_HPL_USCI_B1
#define BSP430_USCI_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.

Typedef Documentation

Register map for USCI_A/USCI_B peripheral on a MSP430 2xx/4xx MCU.

Function Documentation

static BSP430_CORE_INLINE hBSP430halSERIAL hBSP430usciLookup ( tBSP430periphHandle  periph)
static

Get the HAL handle for a specific USCI instance.

Parameters
periphThe handle identifier, such as BSP430_PERIPH_USCI_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_USCI_A0).
hBSP430halSERIAL hBSP430usciOpenI2C ( hBSP430halSERIAL  hal,
unsigned char  ctl0_byte,
unsigned char  ctl1_byte,
unsigned int  prescaler 
)

USCI-specific implementation of hBSP430serialOpenI2C()

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

USCI-specific implementation of hBSP430serialOpenSPI()

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

USCI-specific implementation of hBSP430serialOpenUART()

int iBSP430usciClose ( hBSP430halSERIAL  xUSCI)

USCI-specific implementation of iBSP430serialClose()

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

USCI-specific implementation of iBSP430i2cRxData_rh()

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

USCI-specific implementation of iBSP430i2cSetAddresses_rh()

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

USCI-specific implementation of iBSP430i2cTxData_rh()

int iBSP430usciSetHold_rh ( hBSP430halSERIAL  hal,
int  holdp 
)

USCI-specific implementation of iBSP430serialSetHold_rh()

int iBSP430usciSetReset_rh ( hBSP430halSERIAL  hal,
int  resetp 
)

USCI-specific implementation of iBSP430serialSetReset_rh()

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

USCI-specific implementation of iBSP430spiTxRx_rh()

int iBSP430usciUARTrxByte_rh ( hBSP430halSERIAL  device)

USCI-specific implementation of iBSP430uartRxByte_rh()

int iBSP430usciUARTtxASCIIZ_rh ( hBSP430halSERIAL  device,
const char *  str 
)

USCI-specific implementation of iBSP430uartTxASCIIZ_rh()

int iBSP430usciUARTtxByte_rh ( hBSP430halSERIAL  device,
uint8_t  c 
)

USCI-specific implementation of iBSP430uartTxByte_rh()

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

USCI-specific implementation of iBSP430uartTxData_rh()

void vBSP430usciFlush_ni ( hBSP430halSERIAL  device)

USCI-specific implementation of vBSP430serialFlush_ni()

void vBSP430usciWakeupTransmit_rh ( hBSP430halSERIAL  device)

USCI-specific implementation of vBSP430serialWakeupTransmit_rh()

static BSP430_CORE_INLINE volatile sBSP430hplUSCI* xBSP430hplLookupUSCI ( tBSP430periphHandle  periph)
static

Get the HPL handle for a specific USCI instance.

Parameters
periphThe handle identifier, such as BSP430_PERIPH_USCI_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_USCI_A0).
const char* xBSP430usciName ( tBSP430periphHandle  periph)

Get a human-readable identifier for the USCI peripheral

Parameters
periphThe handle identifier, such as BSP430_PERIPH_USCI_A0.
Returns
The short name of the port, e.g. "USCI_A0". If the peripheral is not recognized as a USCI device, a null pointer is returned.