Details | Last modification | View Log | RSS feed
Rev | Author | Line No. | Line |
---|---|---|---|
3 | 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 | |||
12 | |||
7 | mjames | 13 | #include "stm32l1xx_hal.h" |
3 | mjames | 14 | |
15 | |||
16 | |||
17 | |||
18 | #define TX_USART_BUFF_SIZ 256 |
||
19 | #define RX_USART_BUFF_SIZ 4096 |
||
20 | |||
21 | typedef struct { |
||
22 | USART_TypeDef *Instance; |
||
23 | |||
24 | volatile uint8_t tx_usart_buff[TX_USART_BUFF_SIZ]; |
||
25 | volatile unsigned int tx_usart_in_Ptr; |
||
26 | volatile unsigned int tx_usart_out_Ptr; |
||
27 | volatile uint8_t tx_usart_running; |
||
28 | volatile uint16_t tx_usart_count; |
||
29 | |||
30 | volatile uint8_t rx_usart_buff[RX_USART_BUFF_SIZ]; |
||
31 | volatile unsigned int rx_usart_in_Ptr; |
||
32 | volatile unsigned int rx_usart_out_Ptr; |
||
33 | volatile uint8_t rx_usart_buffer_full; |
||
34 | } usart_ctl; |
||
35 | |||
36 | |||
37 | extern usart_ctl uc1; |
||
38 | extern usart_ctl uc2; |
||
39 | |||
40 | |||
41 | |||
42 | |||
43 | /* returns the number of characters received by the Rx USART */ |
||
44 | extern uint16_t SerialCharsReceived(usart_ctl * instance); |
||
45 | |||
46 | extern inline uint8_t PollSerial(usart_ctl * instance); |
||
47 | extern uint8_t GetCharSerial(usart_ctl * instance); |
||
48 | extern inline void EnableSerialRxInterrupt(usart_ctl * instance); |
||
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); |
||
57 | extern void init_usart_ctl(usart_ctl * instance, USART_TypeDef * hardware); |
||
58 | |||
59 | |||
60 | |||
61 | #endif /* INC_SERIAL_H_ */ |