Rev 4 | Rev 7 | Go to most recent revision | Details | Compare with Previous | Last modification | View Log | RSS feed
| Rev | Author | Line No. | Line |
|---|---|---|---|
| 2 | mjames | 1 | /* |
| 2 | * serial.h |
||
| 3 | * |
||
| 4 | * Created on: 4 Jan 2016 |
||
| 5 | * Author: Mike |
||
| 6 | */ |
||
| 7 | |||
| 8 | #ifndef INC_SERIAL_H_ |
||
| 9 | #define INC_SERIAL_H_ |
||
| 10 | |||
| 11 | #include "main.h" |
||
| 12 | |||
| 13 | typedef struct { |
||
| 5 | mjames | 14 | UART_HandleTypeDef * Handle; |
| 2 | mjames | 15 | |
| 16 | volatile uint8_t tx_usart_buff[TX_USART_BUFF_SIZ]; |
||
| 17 | volatile unsigned int tx_usart_in_Ptr; |
||
| 18 | volatile unsigned int tx_usart_out_Ptr; |
||
| 19 | volatile uint8_t tx_usart_running; |
||
| 20 | volatile uint16_t tx_usart_count; |
||
| 21 | |||
| 22 | volatile uint8_t rx_usart_buff[RX_USART_BUFF_SIZ]; |
||
| 23 | volatile unsigned int rx_usart_in_Ptr; |
||
| 24 | volatile unsigned int rx_usart_out_Ptr; |
||
| 25 | volatile uint8_t rx_usart_buffer_full; |
||
| 26 | } usart_ctl; |
||
| 27 | |||
| 28 | #if defined SERIAL_UART1 |
||
| 29 | extern usart_ctl uc1; |
||
| 30 | #endif |
||
| 31 | #if defined SERIAL_UART2 |
||
| 32 | extern usart_ctl uc2; |
||
| 33 | #endif |
||
| 34 | #if defined SERIAL_UART3 |
||
| 35 | extern usart_ctl uc3; |
||
| 36 | #endif |
||
| 37 | |||
| 38 | |||
| 39 | |||
| 40 | |||
| 41 | |||
| 42 | |||
| 43 | /* returns the number of characters received by the Rx USART */ |
||
| 44 | extern uint16_t SerialCharsReceived(usart_ctl * instance); |
||
| 45 | |||
| 3 | mjames | 46 | extern uint8_t PollSerial(usart_ctl * instance); |
| 2 | mjames | 47 | extern uint8_t GetCharSerial(usart_ctl * instance); |
| 3 | mjames | 48 | extern void EnableSerialRxInterrupt(usart_ctl * instance); |
| 2 | mjames | 49 | |
| 50 | extern void UART_IRQHandler(usart_ctl * instance); |
||
| 51 | |||
| 52 | extern void PutCharSerial(usart_ctl * instance,uint8_t c); |
||
| 53 | extern void ResetTxBuffer(usart_ctl * instance); |
||
| 54 | extern void ResetRxBuffer(usart_ctl * instance); |
||
| 55 | extern void FlushSerial(usart_ctl * instance); |
||
| 56 | extern uint8_t TxBufferEmpty(usart_ctl * instance); |
||
| 4 | mjames | 57 | ///@brief wait until the USART buffer is empty and all characters are sent |
| 58 | extern void TxWaitEmpty(usart_ctl *instance); |
||
| 2 | mjames | 59 | |
| 60 | |||
| 4 | mjames | 61 | extern void init_usart_ctl(usart_ctl * instance, |
| 5 | mjames | 62 | UART_HandleTypeDef * usart); |
| 2 | mjames | 63 | |
| 5 | mjames | 64 | extern void setBaud(usart_ctl * instance, uint32_t baud); |
| 4 | mjames | 65 | |
| 2 | mjames | 66 | #endif /* INC_SERIAL_H_ */ |