46 #ifndef BSP430_SERIAL_H
47 #define BSP430_SERIAL_H
66 #ifndef configBSP430_SERIAL_USE_USCI
67 #define configBSP430_SERIAL_USE_USCI defined(__MSP430_HAS_USCI__)
77 #ifndef configBSP430_SERIAL_USE_USCI5
78 #define configBSP430_SERIAL_USE_USCI5 defined(__MSP430_HAS_USCI_A0__)
88 #ifndef configBSP430_SERIAL_USE_EUSCI
89 #define configBSP430_SERIAL_USE_EUSCI (defined(__MSP430_HAS_EUSCI_A0__) || defined(__MSP430_HAS_EUSCI_B0__))
103 #ifndef configBSP430_SERIAL_ENABLE_UART
104 #define configBSP430_SERIAL_ENABLE_UART (configBSP430_CONSOLE - 0)
118 #ifndef configBSP430_SERIAL_ENABLE_SPI
119 #define configBSP430_SERIAL_ENABLE_SPI 0
134 #ifndef BSP430_SERIAL_SPI_BUS_SPEED_HZ
135 #define BSP430_SERIAL_SPI_BUS_SPEED_HZ 4000000UL
149 #ifndef configBSP430_SERIAL_ENABLE_I2C
150 #define configBSP430_SERIAL_ENABLE_I2C 0
167 #ifndef BSP430_SERIAL_I2C_BUS_SPEED_HZ
168 #define BSP430_SERIAL_I2C_BUS_SPEED_HZ 400000UL
177 #define BSP430_SERIAL \
178 ((configBSP430_SERIAL_ENABLE_UART - 0) \
179 || (configBSP430_SERIAL_ENABLE_SPI - 0) \
180 || (configBSP430_SERIAL_ENABLE_I2C - 0))
184 #if defined(BSP430_DOXYGEN) || (BSP430_SERIAL - 0)
204 #define BSP430_SERIAL_ADJUST_CTL0_INITIALIZER(_i) (((_i) >= 0x100) ? ((_i) >> 8) : (_i))
222 #if defined(BSP430_DOXYGEN) || (configBSP430_SERIAL_ENABLE_UART - 0)
260 unsigned char ctl0_byte,
261 unsigned char ctl1_byte,
264 return hal->dispatch->openUART(hal, ctl0_byte, ctl1_byte, baud);
282 return hal->dispatch->uartRxByte_rh(hal);
302 return hal->dispatch->uartTxByte_rh(hal, c);
323 const uint8_t * data,
326 return hal->dispatch->uartTxData_rh(hal, data, len);
348 return hal->dispatch->uartTxASCIIZ_rh(hal, str);
352 #if defined(BSP430_DOXYGEN) || (configBSP430_SERIAL_ENABLE_SPI - 0)
401 unsigned char ctl0_byte,
402 unsigned char ctl1_byte,
403 unsigned int prescaler)
405 return hal->dispatch->openSPI(hal, ctl0_byte, ctl1_byte, prescaler);
448 const uint8_t * tx_data,
453 return hal->dispatch->spiTxRx_rh(hal, tx_data, tx_len, rx_len, rx_data);
468 #ifndef BSP430_I2C_SPIN_LIMIT
469 #define BSP430_I2C_SPIN_LIMIT 65536
484 #define BSP430_I2C_ERRFLAG_PROTOCOL 0x4000
499 #define BSP430_I2C_ERRFLAG_SPINLIMIT 0x2000
501 #if defined(BSP430_DOXYGEN) || (configBSP430_SERIAL_ENABLE_I2C - 0)
540 unsigned char ctl0_byte,
541 unsigned char ctl1_byte,
542 unsigned int prescaler)
544 return hal->dispatch->openI2C(hal, ctl0_byte, ctl1_byte, prescaler);
572 return hal->dispatch->i2cSetAddresses_rh(hal, own_address, slave_address);
607 const uint8_t * tx_data,
610 return hal->dispatch->i2cTxData_rh(hal, tx_data, tx_len);
649 return hal->dispatch->i2cRxData_rh(hal, rx_data, rx_len);
706 return hal->dispatch->setReset_rh(hal, resetp);
737 return hal->dispatch->setHold_rh(hal, holdp);
754 return hal->dispatch->close(hal);
774 hal->dispatch->wakeupTransmit_rh(hal);
799 hal->dispatch->flush_ni(hal);
814 return hal->dispatch->rate(hal);
819 #if (configBSP430_SERIAL_USE_USCI - 0)
822 #if (configBSP430_SERIAL_USE_USCI5 - 0)
825 #if (configBSP430_SERIAL_USE_EUSCI - 0)
841 #if (configBSP430_SERIAL_USE_USCI - 0)
846 #if (configBSP430_SERIAL_USE_USCI5 - 0)
851 #if (configBSP430_SERIAL_USE_EUSCI - 0)
static BSP430_CORE_INLINE hBSP430halSERIAL hBSP430serialOpenSPI(hBSP430halSERIAL hal, unsigned char ctl0_byte, unsigned char ctl1_byte, unsigned int prescaler)
Definition: serial.h:400
static BSP430_CORE_INLINE int iBSP430uartTxASCIIZ_rh(hBSP430halSERIAL hal, const char *str)
Definition: serial.h:346
static BSP430_CORE_INLINE hBSP430halSERIAL hBSP430usciLookup(tBSP430periphHandle periph)
Definition: usci.h:701
static BSP430_CORE_INLINE int iBSP430serialClose(hBSP430halSERIAL hal)
Definition: serial.h:752
static BSP430_CORE_INLINE int iBSP430i2cTxData_rh(hBSP430halSERIAL hal, const uint8_t *tx_data, size_t tx_len)
Definition: serial.h:606
const char * xBSP430serialName(tBSP430periphHandle periph)
static BSP430_CORE_INLINE int iBSP430i2cRxData_rh(hBSP430halSERIAL hal, uint8_t *rx_data, size_t rx_len)
Definition: serial.h:645
static BSP430_CORE_INLINE unsigned long ulBSP430serialRate(hBSP430halSERIAL hal)
Definition: serial.h:812
static BSP430_CORE_INLINE int iBSP430serialSetReset_rh(hBSP430halSERIAL hal, int resetp)
Definition: serial.h:703
static BSP430_CORE_INLINE void vBSP430serialFlush_ni(hBSP430halSERIAL hal)
Definition: serial.h:797
static BSP430_CORE_INLINE hBSP430halSERIAL hBSP430serialOpenI2C(hBSP430halSERIAL hal, unsigned char ctl0_byte, unsigned char ctl1_byte, unsigned int prescaler)
Definition: serial.h:539
static BSP430_CORE_INLINE hBSP430halSERIAL hBSP430serialOpenUART(hBSP430halSERIAL hal, unsigned char ctl0_byte, unsigned char ctl1_byte, unsigned long baud)
Definition: serial.h:259
Common header included by all BSP430 leaf headers.
Definition: serial_.h:193
static BSP430_CORE_INLINE hBSP430halSERIAL hBSP430serialLookup(tBSP430periphHandle periph)
Definition: serial.h:838
static BSP430_CORE_INLINE hBSP430halSERIAL hBSP430usci5Lookup(tBSP430periphHandle periph)
Definition: usci5.h:1169
static BSP430_CORE_INLINE int iBSP430uartTxByte_rh(hBSP430halSERIAL hal, uint8_t c)
Definition: serial.h:300
static BSP430_CORE_INLINE int iBSP430spiTxRx_rh(hBSP430halSERIAL hal, const uint8_t *tx_data, size_t tx_len, size_t rx_len, uint8_t *rx_data)
Definition: serial.h:447
static BSP430_CORE_INLINE int iBSP430serialSetHold_rh(hBSP430halSERIAL hal, int holdp)
Definition: serial.h:734
#define BSP430_CORE_INLINE
Definition: core.h:439
Generic peripheral support for MSP430 MCUs.
unsigned int uiBSP430serialSMCLKPrescaler(unsigned long freq_Hz)
static BSP430_CORE_INLINE int iBSP430uartTxData_rh(hBSP430halSERIAL hal, const uint8_t *data, size_t len)
Definition: serial.h:322
static BSP430_CORE_INLINE hBSP430halSERIAL hBSP430eusciLookup(tBSP430periphHandle periph)
Definition: eusci.h:1018
Hardware presentation/abstraction for USCI_A/USCI_B on 2xx/4xx devices.
static BSP430_CORE_INLINE void vBSP430serialWakeupTransmit_rh(hBSP430halSERIAL hal)
Definition: serial.h:772
int tBSP430periphHandle
Definition: periph.h:106
static BSP430_CORE_INLINE int iBSP430i2cSetAddresses_rh(hBSP430halSERIAL hal, int own_address, int slave_address)
Definition: serial.h:568
Hardware presentation/abstraction for eUSCI.
Structures for abstracted serial interface.
Hardware presentation/abstraction for USCI_A/USCI_B on 5xx/6xx devices.
static BSP430_CORE_INLINE int iBSP430uartRxByte_rh(hBSP430halSERIAL hal)
Definition: serial.h:280