Rev 8 | Rev 12 | Go to most recent revision | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed
Rev 8 | Rev 10 | ||
---|---|---|---|
Line 3... | Line 3... | ||
3 | * |
3 | * |
4 | * Created on: 4 Jan 2016 |
4 | * Created on: 4 Jan 2016 |
5 | * Author: Mike |
5 | * Author: Mike |
6 | */ |
6 | */ |
7 | 7 | ||
8 | #ifndef INC_SERIAL_H_ |
- | |
9 | #define INC_SERIAL_H_ |
8 | #pragma once |
10 | 9 | ||
11 | #include "main.h" |
10 | #include "main.h" |
12 | - | ||
13 | typedef struct { |
11 | typedef struct |
- | 12 | { |
|
14 | UART_HandleTypeDef * Handle; |
13 | UART_HandleTypeDef *Handle; |
15 | 14 | ||
16 | volatile uint8_t tx_usart_buff[TX_USART_BUFF_SIZ]; |
15 | volatile uint8_t tx_usart_buff[TX_USART_BUFF_SIZ]; |
17 | volatile unsigned int tx_usart_in_Ptr; |
16 | volatile unsigned int tx_usart_in_Ptr; |
18 | volatile unsigned int tx_usart_out_Ptr; |
17 | volatile unsigned int tx_usart_out_Ptr; |
- | 18 | volatile unsigned int tx_usart_overruns; |
|
19 | volatile uint8_t tx_usart_running; |
19 | volatile uint8_t tx_usart_running; |
20 | volatile uint16_t tx_usart_count; |
- | |
21 | 20 | ||
22 | volatile uint8_t rx_usart_buff[RX_USART_BUFF_SIZ]; |
21 | volatile uint8_t rx_usart_buff[RX_USART_BUFF_SIZ]; |
23 | volatile unsigned int rx_usart_in_Ptr; |
22 | volatile unsigned int rx_usart_in_Ptr; |
24 | volatile unsigned int rx_usart_out_Ptr; |
23 | volatile unsigned int rx_usart_out_Ptr; |
25 | volatile uint8_t rx_usart_buffer_full; |
24 | volatile uint8_t rx_usart_buffer_full; |
26 | } usart_ctl; |
25 | } usart_ctl; |
27 | 26 | ||
- | 27 | ||
- | 28 | ||
28 | #if defined SERIAL_UART1 |
29 | #if defined SERIAL_UART1 |
29 | extern usart_ctl uc1; |
30 | extern usart_ctl uc1; |
30 | #endif |
31 | #endif |
31 | #if defined SERIAL_UART2 |
32 | #if defined SERIAL_UART2 |
32 | extern usart_ctl uc2; |
33 | extern usart_ctl uc2; |
Line 39... | Line 40... | ||
39 | #endif |
40 | #endif |
40 | #if defined SERIAL_UART5 |
41 | #if defined SERIAL_UART5 |
41 | extern usart_ctl uc5; |
42 | extern usart_ctl uc5; |
42 | #endif |
43 | #endif |
43 | 44 | ||
44 | - | ||
45 | - | ||
46 | - | ||
47 | - | ||
48 | ///@brief returns the number of characters in the recieve buffer |
45 | ///@brief returns the number of characters in the recieve buffer |
49 | extern uint16_t SerialCharsReceived(usart_ctl * instance); |
46 | extern uint16_t SerialCharsReceived(usart_ctl *instance); |
50 | ///@brief Get the amount of free space in the transmit buffer. |
47 | ///@brief Get the amount of free space in the transmit buffer. |
51 | extern uint16_t SerialTransmitSpace(usart_ctl * instance); |
48 | extern uint16_t SerialTransmitSpace(usart_ctl *instance); |
52 | - | ||
53 | 49 | ||
54 | extern uint8_t PollSerial(usart_ctl * instance); |
50 | extern uint8_t PollSerial(usart_ctl *instance); |
55 | extern uint8_t GetCharSerial(usart_ctl * instance); |
51 | extern uint8_t GetCharSerial(usart_ctl *instance); |
56 | extern void EnableSerialRxInterrupt(usart_ctl * instance); |
52 | extern void EnableSerialRxInterrupt(usart_ctl *instance); |
57 | 53 | ||
58 | extern void UART_IRQHandler(usart_ctl * instance); |
54 | extern void UART_IRQHandler(usart_ctl *instance); |
59 | 55 | ||
60 | extern void PutCharSerial(usart_ctl * instance,uint8_t c); |
56 | extern void PutCharSerial(usart_ctl *instance, uint8_t c); |
61 | extern void ResetTxBuffer(usart_ctl * instance); |
57 | extern void ResetTxBuffer(usart_ctl *instance); |
62 | extern void ResetRxBuffer(usart_ctl * instance); |
58 | extern void ResetRxBuffer(usart_ctl *instance); |
63 | extern void FlushSerial(usart_ctl * instance); |
59 | extern void FlushSerial(usart_ctl *instance); |
64 | extern uint8_t TxBufferEmpty(usart_ctl * instance); |
60 | extern uint8_t TxBufferEmpty(usart_ctl *instance); |
65 | ///@brief wait until the USART buffer is empty and all characters are sent |
61 | ///@brief wait until the USART buffer is empty and all characters are sent |
66 | extern void TxWaitEmpty(usart_ctl *instance); |
62 | extern void TxWaitEmpty(usart_ctl *instance); |
67 | 63 | ||
- | 64 | extern void init_usart_ctl(usart_ctl *instance, |
|
- | 65 | UART_HandleTypeDef *usart); |
|
68 | 66 | ||
69 | - | ||
70 | extern void init_usart_ctl(usart_ctl * instance, |
- | |
71 | UART_HandleTypeDef * usart); |
- | |
72 | - | ||
73 | extern void setBaud(usart_ctl * instance, uint32_t baud); |
67 | extern void setBaud(usart_ctl *instance, uint32_t baud); |
74 | - | ||
75 | - | ||
76 | extern void sendString(usart_ctl *ctl, char const *string, int length); |
- | |
77 | - | ||
78 | #endif /* INC_SERIAL_H_ */ |
- |