Subversion Repositories libSerial

Rev

Rev 8 | Rev 12 | 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. #pragma once
  9.  
  10. #include "main.h"
  11. typedef struct
  12. {
  13.         UART_HandleTypeDef *Handle;
  14.  
  15.         volatile uint8_t tx_usart_buff[TX_USART_BUFF_SIZ];
  16.         volatile unsigned int tx_usart_in_Ptr;
  17.         volatile unsigned int tx_usart_out_Ptr;
  18.         volatile unsigned int tx_usart_overruns;
  19.         volatile uint8_t tx_usart_running;
  20.        
  21.         volatile uint8_t rx_usart_buff[RX_USART_BUFF_SIZ];
  22.         volatile unsigned int rx_usart_in_Ptr;
  23.         volatile unsigned int rx_usart_out_Ptr;
  24.         volatile uint8_t rx_usart_buffer_full;
  25. } usart_ctl;
  26.  
  27.  
  28.  
  29. #if defined SERIAL_UART1
  30. extern usart_ctl uc1;
  31. #endif
  32. #if defined SERIAL_UART2
  33. extern usart_ctl uc2;
  34. #endif
  35. #if defined SERIAL_UART3
  36. extern usart_ctl uc3;
  37. #endif
  38. #if defined SERIAL_UART4
  39. extern usart_ctl uc4;
  40. #endif
  41. #if defined SERIAL_UART5
  42. extern usart_ctl uc5;
  43. #endif
  44.  
  45. ///@brief  returns the number of characters in the recieve buffer
  46. extern uint16_t SerialCharsReceived(usart_ctl *instance);
  47. ///@brief Get the amount of free space in the transmit buffer.
  48. extern uint16_t SerialTransmitSpace(usart_ctl *instance);
  49.  
  50. extern uint8_t PollSerial(usart_ctl *instance);
  51. extern uint8_t GetCharSerial(usart_ctl *instance);
  52. extern void EnableSerialRxInterrupt(usart_ctl *instance);
  53.  
  54. extern void UART_IRQHandler(usart_ctl *instance);
  55.  
  56. extern void PutCharSerial(usart_ctl *instance, uint8_t c);
  57. extern void ResetTxBuffer(usart_ctl *instance);
  58. extern void ResetRxBuffer(usart_ctl *instance);
  59. extern void FlushSerial(usart_ctl *instance);
  60. extern uint8_t TxBufferEmpty(usart_ctl *instance);
  61. ///@brief  wait until the USART buffer is empty and all characters are sent
  62. extern void TxWaitEmpty(usart_ctl *instance);
  63.  
  64. extern void init_usart_ctl(usart_ctl *instance,
  65.                                                    UART_HandleTypeDef *usart);
  66.  
  67. extern void setBaud(usart_ctl *instance, uint32_t baud);
  68.