MODSERIAL with support for more devices
Fork of MODSERIAL by
Device/MODSERIAL_NUCLEO_F303K8.h@42:06e6d21166a4, 2016-07-01 (annotated)
- Committer:
- ducky64
- Date:
- Fri Jul 01 01:13:49 2016 +0000
- Revision:
- 42:06e6d21166a4
Nucleo F303K8 support
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
ducky64 | 42:06e6d21166a4 | 1 | #if defined(TARGET_NUCLEO_F303K8) |
ducky64 | 42:06e6d21166a4 | 2 | |
ducky64 | 42:06e6d21166a4 | 3 | #define MODSERIAL_IRQ_REG ((USART_TypeDef*)_base)->CR1 |
ducky64 | 42:06e6d21166a4 | 4 | /** |
ducky64 | 42:06e6d21166a4 | 5 | * TCIE probably isn't the optimal definition (since it waits for transmission |
ducky64 | 42:06e6d21166a4 | 6 | * complete before firing, as opposed to TXEIE which fires as soon as the buffer |
ducky64 | 42:06e6d21166a4 | 7 | * is empty and able to accept another frame to transmit), but this is what |
ducky64 | 42:06e6d21166a4 | 8 | * STM32F3's serial_api.c expects (and breaks if using TXEIE). |
ducky64 | 42:06e6d21166a4 | 9 | * But if serial_api.c changes to TXEIE this (probably) will also need to be |
ducky64 | 42:06e6d21166a4 | 10 | * updated. |
ducky64 | 42:06e6d21166a4 | 11 | */ |
ducky64 | 42:06e6d21166a4 | 12 | #define DISABLE_TX_IRQ MODSERIAL_IRQ_REG &= ~USART_CR1_TCIE |
ducky64 | 42:06e6d21166a4 | 13 | #define DISABLE_RX_IRQ MODSERIAL_IRQ_REG &= ~USART_CR1_RXNEIE |
ducky64 | 42:06e6d21166a4 | 14 | #define ENABLE_TX_IRQ MODSERIAL_IRQ_REG |= USART_CR1_TCIE |
ducky64 | 42:06e6d21166a4 | 15 | #define ENABLE_RX_IRQ MODSERIAL_IRQ_REG |= USART_CR1_RXNEIE |
ducky64 | 42:06e6d21166a4 | 16 | |
ducky64 | 42:06e6d21166a4 | 17 | #define MODSERIAL_READ_REG ((USART_TypeDef*)_base)->RDR |
ducky64 | 42:06e6d21166a4 | 18 | #define MODSERIAL_WRITE_REG ((USART_TypeDef*)_base)->TDR |
ducky64 | 42:06e6d21166a4 | 19 | #define MODSERIAL_READABLE ((((USART_TypeDef*)_base)->ISR & USART_ISR_RXNE) != 0) |
ducky64 | 42:06e6d21166a4 | 20 | #define MODSERIAL_WRITABLE ((((USART_TypeDef*)_base)->ISR & USART_ISR_TXE) != 0) |
ducky64 | 42:06e6d21166a4 | 21 | |
ducky64 | 42:06e6d21166a4 | 22 | #define RESET_TX_FIFO while(0 == 1) |
ducky64 | 42:06e6d21166a4 | 23 | #define RESET_RX_FIFO while(MODSERIAL_READABLE) char dummy = MODSERIAL_READ_REG |
ducky64 | 42:06e6d21166a4 | 24 | |
ducky64 | 42:06e6d21166a4 | 25 | #define RX_IRQ_ENABLED ((MODSERIAL_IRQ_REG & USART_CR1_RXNEIE) != 0) |
ducky64 | 42:06e6d21166a4 | 26 | #define TX_IRQ_ENABLED ((MODSERIAL_IRQ_REG & USART_CR1_TCIE) != 0) |
ducky64 | 42:06e6d21166a4 | 27 | |
ducky64 | 42:06e6d21166a4 | 28 | #endif |