hal_serial_lld.c 3.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127
  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.c
  15. * @brief PLATFORM serial subsystem low level driver source.
  16. *
  17. * @addtogroup SERIAL
  18. * @{
  19. */
  20. #include "hal.h"
  21. #if (HAL_USE_SERIAL == TRUE) || defined(__DOXYGEN__)
  22. /*===========================================================================*/
  23. /* Driver local definitions. */
  24. /*===========================================================================*/
  25. /*===========================================================================*/
  26. /* Driver exported variables. */
  27. /*===========================================================================*/
  28. /** @brief USART1 serial driver identifier.*/
  29. #if (PLATFORM_SERIAL_USE_USART1 == TRUE) || defined(__DOXYGEN__)
  30. SerialDriver SD1;
  31. #endif
  32. /*===========================================================================*/
  33. /* Driver local variables and types. */
  34. /*===========================================================================*/
  35. /**
  36. * @brief Driver default configuration.
  37. */
  38. static const SerialConfig default_config = {
  39. 38400
  40. };
  41. /*===========================================================================*/
  42. /* Driver local functions. */
  43. /*===========================================================================*/
  44. /*===========================================================================*/
  45. /* Driver interrupt handlers. */
  46. /*===========================================================================*/
  47. /*===========================================================================*/
  48. /* Driver exported functions. */
  49. /*===========================================================================*/
  50. /**
  51. * @brief Low level serial driver initialization.
  52. *
  53. * @notapi
  54. */
  55. void sd_lld_init(void) {
  56. #if PLATFORM_SERIAL_USE_USART1 == TRUE
  57. sdObjectInit(&SD1, NULL, notify1);
  58. #endif
  59. }
  60. /**
  61. * @brief Low level serial driver configuration and (re)start.
  62. *
  63. * @param[in] sdp pointer to a @p SerialDriver object
  64. * @param[in] config the architecture-dependent serial driver configuration.
  65. * If this parameter is set to @p NULL then a default
  66. * configuration is used.
  67. *
  68. * @notapi
  69. */
  70. void sd_lld_start(SerialDriver *sdp, const SerialConfig *config) {
  71. if (config == NULL) {
  72. config = &default_config;
  73. }
  74. if (sdp->state == SD_STOP) {
  75. #if PLATFORM_SERIAL_USE_USART1 == TRUE
  76. if (&SD1 == sdp) {
  77. }
  78. #endif
  79. }
  80. /* Configures the peripheral.*/
  81. (void)config; /* Warning suppression, remove this.*/
  82. }
  83. /**
  84. * @brief Low level serial driver stop.
  85. * @details De-initializes the USART, stops the associated clock, resets the
  86. * interrupt vector.
  87. *
  88. * @param[in] sdp pointer to a @p SerialDriver object
  89. *
  90. * @notapi
  91. */
  92. void sd_lld_stop(SerialDriver *sdp) {
  93. if (sdp->state == SD_READY) {
  94. #if PLATFORM_SERIAL_USE_USART1 == TRUE
  95. if (&SD1 == sdp) {
  96. }
  97. #endif
  98. }
  99. }
  100. #endif /* HAL_USE_SERIAL == TRUE */
  101. /** @} */