hal_serial_lld.h 4.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119
  1. /*
  2. ChibiOS - Copyright (C) 2006..2018 Giovanni Di Sirio
  3. Licensed under the Apache License, Version 2.0 (the "License");
  4. you may not use this file except in compliance with the License.
  5. You may obtain a copy of the License at
  6. http://www.apache.org/licenses/LICENSE-2.0
  7. Unless required by applicable law or agreed to in writing, software
  8. distributed under the License is distributed on an "AS IS" BASIS,
  9. WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  10. See the License for the specific language governing permissions and
  11. limitations under the License.
  12. */
  13. /**
  14. * @file hal_serial_lld.h
  15. * @brief PLATFORM serial subsystem low level driver header.
  16. *
  17. * @addtogroup SERIAL
  18. * @{
  19. */
  20. #ifndef HAL_SERIAL_LLD_H
  21. #define HAL_SERIAL_LLD_H
  22. #if (HAL_USE_SERIAL == TRUE) || defined(__DOXYGEN__)
  23. /*===========================================================================*/
  24. /* Driver constants. */
  25. /*===========================================================================*/
  26. /*===========================================================================*/
  27. /* Driver pre-compile time settings. */
  28. /*===========================================================================*/
  29. /**
  30. * @name PLATFORM configuration options
  31. * @{
  32. */
  33. /**
  34. * @brief USART1 driver enable switch.
  35. * @details If set to @p TRUE the support for USART1 is included.
  36. * @note The default is @p FALSE.
  37. */
  38. #if !defined(PLATFORM_SERIAL_USE_USART1) || defined(__DOXYGEN__)
  39. #define PLATFORM_SERIAL_USE_USART1 FALSE
  40. #endif
  41. /** @} */
  42. /*===========================================================================*/
  43. /* Derived constants and error checks. */
  44. /*===========================================================================*/
  45. /*===========================================================================*/
  46. /* Driver data structures and types. */
  47. /*===========================================================================*/
  48. /**
  49. * @brief PLATFORM Serial Driver configuration structure.
  50. * @details An instance of this structure must be passed to @p sdStart()
  51. * in order to configure and start a serial driver operations.
  52. * @note This structure content is architecture dependent, each driver
  53. * implementation defines its own version and the custom static
  54. * initializers.
  55. */
  56. typedef struct {
  57. /**
  58. * @brief Bit rate.
  59. */
  60. uint32_t speed;
  61. /* End of the mandatory fields.*/
  62. } SerialConfig;
  63. /**
  64. * @brief @p SerialDriver specific data.
  65. */
  66. #define _serial_driver_data \
  67. _base_asynchronous_channel_data \
  68. /* Driver state.*/ \
  69. sdstate_t state; \
  70. /* Input queue.*/ \
  71. input_queue_t iqueue; \
  72. /* Output queue.*/ \
  73. output_queue_t oqueue; \
  74. /* Input circular buffer.*/ \
  75. uint8_t ib[SERIAL_BUFFERS_SIZE]; \
  76. /* Output circular buffer.*/ \
  77. uint8_t ob[SERIAL_BUFFERS_SIZE]; \
  78. /* End of the mandatory fields.*/
  79. /*===========================================================================*/
  80. /* Driver macros. */
  81. /*===========================================================================*/
  82. /*===========================================================================*/
  83. /* External declarations. */
  84. /*===========================================================================*/
  85. #if (PLATFORM_SERIAL_USE_USART1 == TRUE) && !defined(__DOXYGEN__)
  86. extern SerialDriver SD1;
  87. #endif
  88. #ifdef __cplusplus
  89. extern "C" {
  90. #endif
  91. void sd_lld_init(void);
  92. void sd_lld_start(SerialDriver *sdp, const SerialConfig *config);
  93. void sd_lld_stop(SerialDriver *sdp);
  94. #ifdef __cplusplus
  95. }
  96. #endif
  97. #endif /* HAL_USE_SERIAL == TRUE */
  98. #endif /* HAL_SERIAL_LLD_H */
  99. /** @} */