hal_icu_lld.c 4.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187
  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_icu_lld.c
  15. * @brief PLATFORM ADC subsystem low level driver source.
  16. *
  17. * @addtogroup ICU
  18. * @{
  19. */
  20. #include "hal.h"
  21. #if (HAL_USE_ICU == TRUE) || defined(__DOXYGEN__)
  22. /*===========================================================================*/
  23. /* Driver local definitions. */
  24. /*===========================================================================*/
  25. /*===========================================================================*/
  26. /* Driver exported variables. */
  27. /*===========================================================================*/
  28. /**
  29. * @brief ICUD1 driver identifier.
  30. * @note The driver ICUD1 allocates the complex timer TIM1 when enabled.
  31. */
  32. #if (PLATFORM_ICU_USE_ICU1 == TRUE) || defined(__DOXYGEN__)
  33. ICUDriver ICUD1;
  34. #endif
  35. /*===========================================================================*/
  36. /* Driver local variables and types. */
  37. /*===========================================================================*/
  38. /*===========================================================================*/
  39. /* Driver local functions. */
  40. /*===========================================================================*/
  41. /*===========================================================================*/
  42. /* Driver interrupt handlers. */
  43. /*===========================================================================*/
  44. /*===========================================================================*/
  45. /* Driver exported functions. */
  46. /*===========================================================================*/
  47. /**
  48. * @brief Low level ICU driver initialization.
  49. *
  50. * @notapi
  51. */
  52. void icu_lld_init(void) {
  53. #if PLATFORM_ICU_USE_ICU1 == TRUE
  54. /* Driver initialization.*/
  55. icuObjectInit(&ICUD1);
  56. #endif
  57. }
  58. /**
  59. * @brief Configures and activates the ICU peripheral.
  60. *
  61. * @param[in] icup pointer to the @p ICUDriver object
  62. *
  63. * @notapi
  64. */
  65. void icu_lld_start(ICUDriver *icup) {
  66. if (icup->state == ICU_STOP) {
  67. /* Clock activation and timer reset.*/
  68. #if PLATFORM_ICU_USE_ICU1 == TRUE
  69. if (&ICUD1 == icup) {
  70. }
  71. #endif
  72. }
  73. }
  74. /**
  75. * @brief Deactivates the ICU peripheral.
  76. *
  77. * @param[in] icup pointer to the @p ICUDriver object
  78. *
  79. * @notapi
  80. */
  81. void icu_lld_stop(ICUDriver *icup) {
  82. if (icup->state == ICU_READY) {
  83. /* Clock deactivation.*/
  84. #if PLATFORM_ICU_USE_ICU1 == TRUE
  85. if (&ICUD1 == icup) {
  86. }
  87. #endif
  88. }
  89. }
  90. /**
  91. * @brief Starts the input capture.
  92. *
  93. * @param[in] icup pointer to the @p ICUDriver object
  94. *
  95. * @notapi
  96. */
  97. void icu_lld_start_capture(ICUDriver *icup) {
  98. (void)icup;
  99. }
  100. /**
  101. * @brief Waits for a completed capture.
  102. * @note The operation is performed in polled mode.
  103. * @note In order to use this function notifications must be disabled.
  104. *
  105. * @param[in] icup pointer to the @p ICUDriver object
  106. * @return The capture status.
  107. * @retval false if the capture is successful.
  108. * @retval true if a timer overflow occurred.
  109. *
  110. * @notapi
  111. */
  112. bool icu_lld_wait_capture(ICUDriver *icup) {
  113. (void)icup;
  114. return false;
  115. }
  116. /**
  117. * @brief Stops the input capture.
  118. *
  119. * @param[in] icup pointer to the @p ICUDriver object
  120. *
  121. * @notapi
  122. */
  123. void icu_lld_stop_capture(ICUDriver *icup) {
  124. (void)icup;
  125. }
  126. /**
  127. * @brief Enables notifications.
  128. * @pre The ICU unit must have been activated using @p icuStart() and the
  129. * capture started using @p icuStartCapture().
  130. * @note If the notification is already enabled then the call has no effect.
  131. *
  132. * @param[in] icup pointer to the @p ICUDriver object
  133. *
  134. * @api
  135. */
  136. void icu_lld_enable_notifications(ICUDriver *icup) {
  137. (void)icup;
  138. }
  139. /**
  140. * @brief Disables notifications.
  141. * @pre The ICU unit must have been activated using @p icuStart() and the
  142. * capture started using @p icuStartCapture().
  143. * @note If the notification is already disabled then the call has no effect.
  144. *
  145. * @param[in] icup pointer to the @p ICUDriver object
  146. *
  147. * @api
  148. */
  149. void icu_lld_disable_notifications(ICUDriver *icup) {
  150. (void)icup;
  151. }
  152. #endif /* HAL_USE_ICU == TRUE */
  153. /** @} */