MODSERIAL with support for more devices

Fork of MODSERIAL by Erik -

Committer:
cduck
Date:
Wed Apr 26 06:50:40 2017 +0000
Revision:
43:8c8d13e1840b
Parent:
41:d8422efe4761
Update device definitions to be compatible with current versions of mbed; ; Replaces _serial.index with _serial.serial.index if DEVICE_SERIAL_ASYNCH is #defined.

Who changed what in which revision?

UserRevisionLine numberNew contents of line
Gary Servin 41:d8422efe4761 1 #if defined(TARGET_PAC_F401RB)
Gary Servin 41:d8422efe4761 2
Gary Servin 41:d8422efe4761 3 #define MODSERIAL_IRQ_REG ((USART_TypeDef*)_base)->CR1
Gary Servin 41:d8422efe4761 4 #define DISABLE_TX_IRQ MODSERIAL_IRQ_REG &= ~USART_CR1_TXEIE
Gary Servin 41:d8422efe4761 5 #define DISABLE_RX_IRQ MODSERIAL_IRQ_REG &= ~USART_CR1_RXNEIE
Gary Servin 41:d8422efe4761 6 #define ENABLE_TX_IRQ MODSERIAL_IRQ_REG |= USART_CR1_TXEIE
Gary Servin 41:d8422efe4761 7 #define ENABLE_RX_IRQ MODSERIAL_IRQ_REG |= USART_CR1_RXNEIE
Gary Servin 41:d8422efe4761 8
Gary Servin 41:d8422efe4761 9 #define MODSERIAL_READ_REG ((USART_TypeDef*)_base)->DR
Gary Servin 41:d8422efe4761 10 #define MODSERIAL_WRITE_REG ((USART_TypeDef*)_base)->DR
Gary Servin 41:d8422efe4761 11 #define MODSERIAL_READABLE ((((USART_TypeDef*)_base)->SR & USART_SR_RXNE) != 0)
Gary Servin 41:d8422efe4761 12 #define MODSERIAL_WRITABLE ((((USART_TypeDef*)_base)->SR & USART_SR_TXE) != 0)
Gary Servin 41:d8422efe4761 13
Gary Servin 41:d8422efe4761 14 #define RESET_TX_FIFO while(0 == 1)
Gary Servin 41:d8422efe4761 15 #define RESET_RX_FIFO while(MODSERIAL_READABLE) char dummy = MODSERIAL_READ_REG
Gary Servin 41:d8422efe4761 16
Gary Servin 41:d8422efe4761 17 #define RX_IRQ_ENABLED ((MODSERIAL_IRQ_REG & USART_CR1_RXNEIE) != 0)
Gary Servin 41:d8422efe4761 18 #define TX_IRQ_ENABLED ((MODSERIAL_IRQ_REG & USART_CR1_TXEIE) != 0)
Gary Servin 41:d8422efe4761 19
Gary Servin 41:d8422efe4761 20 #endif