Subversion Repositories libSerial

Rev

Rev 2 | Rev 4 | Go to most recent revision | 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 "main.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. #if defined SERIAL_UART1
  37. extern usart_ctl uc1;
  38. #endif
  39. #if defined SERIAL_UART2
  40. extern usart_ctl uc2;
  41. #endif
  42. #if defined SERIAL_UART3
  43. extern usart_ctl uc3;
  44. #endif
  45.  
  46.  
  47.  
  48.  
  49.  
  50.  
  51. /* returns the number of characters received by the Rx USART */
  52. extern uint16_t SerialCharsReceived(usart_ctl * instance);
  53.  
  54. extern uint8_t PollSerial(usart_ctl * instance);
  55. extern uint8_t GetCharSerial(usart_ctl * instance);
  56. extern void EnableSerialRxInterrupt(usart_ctl * instance);
  57.  
  58. extern void UART_IRQHandler(usart_ctl * instance);
  59.  
  60. extern void PutCharSerial(usart_ctl * instance,uint8_t c);
  61. extern void ResetTxBuffer(usart_ctl * instance);
  62. extern void ResetRxBuffer(usart_ctl * instance);
  63. extern void FlushSerial(usart_ctl * instance);
  64. extern uint8_t  TxBufferEmpty(usart_ctl * instance);
  65. extern void init_usart_ctl(usart_ctl * instance, USART_TypeDef * hardware);
  66.  
  67.  
  68.  
  69. #endif /* INC_SERIAL_H_ */
  70.