Subversion Repositories DashDisplay

Rev

Rev 28 | Blame | Compare with Previous | Last modification | View Log | Download | RSS feed

  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.  
  13. #include "stm32l1xx_hal.h"
  14.  
  15.  
  16.  
  17.  
  18. #define TX_USART_BUFF_SIZ 1024
  19. #define RX_USART_BUFF_SIZ 1024
  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. extern usart_ctl uc3;
  40.  
  41.  
  42.  
  43.  
  44.  
  45. /* returns the number of characters received by the Rx USART */
  46. extern uint16_t SerialCharsReceived(usart_ctl * instance);
  47.  
  48. extern inline uint8_t PollSerial(usart_ctl * instance);
  49. extern uint8_t GetCharSerial(usart_ctl * instance);
  50. extern inline void EnableSerialRxInterrupt(usart_ctl * instance);
  51.  
  52. extern void UART_IRQHandler(usart_ctl * instance);
  53.  
  54. extern void PutCharSerial(usart_ctl * instance,uint8_t c);
  55. extern void ResetTxBuffer(usart_ctl * instance);
  56. extern void ResetRxBuffer(usart_ctl * instance);
  57. extern void FlushSerial(usart_ctl * instance);
  58. extern uint8_t  TxBufferEmpty(usart_ctl * instance);
  59. extern void init_usart_ctl(usart_ctl * instance, USART_TypeDef * hardware);
  60.  
  61.  
  62.  
  63. #endif /* INC_SERIAL_H_ */
  64.