Subversion Repositories libSerial

Rev

Rev 13 | 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.  
  9.  
  10. /* Includes ------------------------------------------------------------------*/
  11. #include "stm32f1xx_hal.h"
  12.  
  13.  
  14. #pragma once
  15.  
  16. #include <stdint.h>
  17.  
  18. #if defined __cplusplus
  19. extern "C"
  20. {
  21. #endif
  22.  
  23.  
  24. struct usart_ctl
  25. {
  26.         /// @brief UART handle
  27.         UART_HandleTypeDef *Handle;
  28.         /// @brief Locally maintained transmit buffer
  29.        
  30.         volatile uint8_t * tx_usart_buff;
  31.         uint16_t  tx_usart_buff_size;
  32.         uint16_t rx_usart_buff_size;
  33.         volatile uint16_t tx_usart_in_Ptr;
  34.         volatile uint16_t tx_usart_out_Ptr;
  35.         volatile uint16_t tx_usart_overruns;
  36.         /// @brief Set when the usart is transmitting
  37.         volatile uint8_t tx_usart_running;
  38.        
  39.         /// @brief Locally maintained receive buffer
  40.         volatile uint8_t * rx_usart_buff;
  41.         volatile uint16_t rx_usart_in_Ptr;
  42.         volatile uint16_t rx_usart_out_Ptr;
  43.         /// @brief Set when the receiver buffer is full
  44.         volatile uint8_t rx_usart_buffer_full;
  45. } ;
  46.  
  47.  
  48.  
  49. #if defined SERIAL_UART1
  50. extern struct usart_ctl uc1;
  51. #endif
  52. #if defined SERIAL_UART2
  53. extern struct usart_ctl uc2;
  54. #endif
  55. #if defined SERIAL_UART3
  56. extern struct usart_ctl uc3;
  57. #endif
  58. #if defined SERIAL_UART4
  59. extern struct usart_ctl uc4;
  60. #endif
  61. #if defined SERIAL_UART5
  62. extern struct usart_ctl uc5;
  63. #endif
  64. /// @brief Establish this instance as being in control of a USART
  65. /// @param instance  Pointer to usart_ctl structure
  66. /// @param usart Handle to usart maintained by HAL
  67. /// @param tx_buffer Statically allocated memory for Tx buffer
  68. /// @param rx_buffer Statically allocated memory for Rx buffer
  69. /// @param rx_buffer_size Rx Buffer size
  70. /// @param tx_buffer_size Tx Buffer size
  71. extern void init_usart_ctl(struct usart_ctl *instance,
  72.                                                    UART_HandleTypeDef *usart,
  73.                                                    volatile uint8_t * tx_buffer,
  74.                                                    volatile uint8_t * rx_buffer,
  75.                                                    uint16_t tx_buffer_size,
  76.                                                    uint16_t rx_buffer_size);
  77.  
  78.  
  79.  
  80. #if defined __cplusplus
  81. }
  82. #endif
  83.  
  84. #include "serialCalls.h"
  85.  
  86.