hal_uart_lld.c 5.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191
  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_uart_lld.c
  15. * @brief PLATFORM UART subsystem low level driver source.
  16. *
  17. * @addtogroup UART
  18. * @{
  19. */
  20. #include "hal.h"
  21. #if (HAL_USE_UART == TRUE) || defined(__DOXYGEN__)
  22. /*===========================================================================*/
  23. /* Driver local definitions. */
  24. /*===========================================================================*/
  25. /*===========================================================================*/
  26. /* Driver exported variables. */
  27. /*===========================================================================*/
  28. /**
  29. * @brief UART1 driver identifier.
  30. */
  31. #if (PLATFORM_UART_USE_UART1 == TRUE) || defined(__DOXYGEN__)
  32. UARTDriver UARTD1;
  33. #endif
  34. /*===========================================================================*/
  35. /* Driver local variables and types. */
  36. /*===========================================================================*/
  37. /*===========================================================================*/
  38. /* Driver local functions. */
  39. /*===========================================================================*/
  40. /*===========================================================================*/
  41. /* Driver interrupt handlers. */
  42. /*===========================================================================*/
  43. /*===========================================================================*/
  44. /* Driver exported functions. */
  45. /*===========================================================================*/
  46. /**
  47. * @brief Low level UART driver initialization.
  48. *
  49. * @notapi
  50. */
  51. void uart_lld_init(void) {
  52. #if PLATFORM_UART_USE_UART1 == TRUE
  53. /* Driver initialization.*/
  54. uartObjectInit(&UARTD1);
  55. #endif
  56. }
  57. /**
  58. * @brief Configures and activates the UART peripheral.
  59. *
  60. * @param[in] uartp pointer to the @p UARTDriver object
  61. *
  62. * @notapi
  63. */
  64. void uart_lld_start(UARTDriver *uartp) {
  65. if (uartp->state == UART_STOP) {
  66. /* Enables the peripheral.*/
  67. #if PLATFORM_UART_USE_UART1 == TRUE
  68. if (&UARTD1 == uartp) {
  69. }
  70. #endif
  71. }
  72. /* Configures the peripheral.*/
  73. }
  74. /**
  75. * @brief Deactivates the UART peripheral.
  76. *
  77. * @param[in] uartp pointer to the @p UARTDriver object
  78. *
  79. * @notapi
  80. */
  81. void uart_lld_stop(UARTDriver *uartp) {
  82. if (uartp->state == UART_READY) {
  83. /* Resets the peripheral.*/
  84. /* Disables the peripheral.*/
  85. #if PLATFORM_UART_USE_UART1 == TRUE
  86. if (&UARTD1 == uartp) {
  87. }
  88. #endif
  89. }
  90. }
  91. /**
  92. * @brief Starts a transmission on the UART peripheral.
  93. * @note The buffers are organized as uint8_t arrays for data sizes below
  94. * or equal to 8 bits else it is organized as uint16_t arrays.
  95. *
  96. * @param[in] uartp pointer to the @p UARTDriver object
  97. * @param[in] n number of data frames to send
  98. * @param[in] txbuf the pointer to the transmit buffer
  99. *
  100. * @notapi
  101. */
  102. void uart_lld_start_send(UARTDriver *uartp, size_t n, const void *txbuf) {
  103. (void)uartp;
  104. (void)n;
  105. (void)txbuf;
  106. }
  107. /**
  108. * @brief Stops any ongoing transmission.
  109. * @note Stopping a transmission also suppresses the transmission callbacks.
  110. *
  111. * @param[in] uartp pointer to the @p UARTDriver object
  112. *
  113. * @return The number of data frames not transmitted by the
  114. * stopped transmit operation.
  115. *
  116. * @notapi
  117. */
  118. size_t uart_lld_stop_send(UARTDriver *uartp) {
  119. (void)uartp;
  120. return 0;
  121. }
  122. /**
  123. * @brief Starts a receive operation on the UART peripheral.
  124. * @note The buffers are organized as uint8_t arrays for data sizes below
  125. * or equal to 8 bits else it is organized as uint16_t arrays.
  126. *
  127. * @param[in] uartp pointer to the @p UARTDriver object
  128. * @param[in] n number of data frames to send
  129. * @param[out] rxbuf the pointer to the receive buffer
  130. *
  131. * @notapi
  132. */
  133. void uart_lld_start_receive(UARTDriver *uartp, size_t n, void *rxbuf) {
  134. (void)uartp;
  135. (void)n;
  136. (void)rxbuf;
  137. }
  138. /**
  139. * @brief Stops any ongoing receive operation.
  140. * @note Stopping a receive operation also suppresses the receive callbacks.
  141. *
  142. * @param[in] uartp pointer to the @p UARTDriver object
  143. *
  144. * @return The number of data frames not received by the
  145. * stopped receive operation.
  146. *
  147. * @notapi
  148. */
  149. size_t uart_lld_stop_receive(UARTDriver *uartp) {
  150. (void)uartp;
  151. return 0;
  152. }
  153. #endif /* HAL_USE_UART == TRUE */
  154. /** @} */