hal_pwm_lld.c 6.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220
  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_pwm_lld.c
  15. * @brief PLATFORM PWM subsystem low level driver source.
  16. *
  17. * @addtogroup PWM
  18. * @{
  19. */
  20. #include "hal.h"
  21. #if (HAL_USE_PWM == TRUE) || defined(__DOXYGEN__)
  22. /*===========================================================================*/
  23. /* Driver local definitions. */
  24. /*===========================================================================*/
  25. /*===========================================================================*/
  26. /* Driver exported variables. */
  27. /*===========================================================================*/
  28. /**
  29. * @brief PWMD1 driver identifier.
  30. * @note The driver PWMD1 allocates the complex timer TIM1 when enabled.
  31. */
  32. #if (PLATFORM_PWM_USE_PWM1 == TRUE) || defined(__DOXYGEN__)
  33. PWMDriver PWMD1;
  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 PWM driver initialization.
  49. *
  50. * @notapi
  51. */
  52. void pwm_lld_init(void) {
  53. #if PLATFORM_PWM_USE_PWM1 == TRUE
  54. /* Driver initialization.*/
  55. pwmObjectInit(&PWMD1);
  56. #endif
  57. }
  58. /**
  59. * @brief Configures and activates the PWM peripheral.
  60. * @note Starting a driver that is already in the @p PWM_READY state
  61. * disables all the active channels.
  62. *
  63. * @param[in] pwmp pointer to a @p PWMDriver object
  64. *
  65. * @notapi
  66. */
  67. void pwm_lld_start(PWMDriver *pwmp) {
  68. if (pwmp->state == PWM_STOP) {
  69. /* Clock activation and timer reset.*/
  70. #if PLATFORM_PWM_USE_PWM1 == TRUE
  71. if (&PWMD1 == pwmp) {
  72. }
  73. #endif
  74. }
  75. }
  76. /**
  77. * @brief Deactivates the PWM peripheral.
  78. *
  79. * @param[in] pwmp pointer to a @p PWMDriver object
  80. *
  81. * @notapi
  82. */
  83. void pwm_lld_stop(PWMDriver *pwmp) {
  84. /* If in ready state then disables the PWM clock.*/
  85. if (pwmp->state == PWM_READY) {
  86. #if PLATFORM_PWM_USE_PWM1 == TRUE
  87. if (&PWMD1 == pwmp) {
  88. }
  89. #endif
  90. }
  91. }
  92. /**
  93. * @brief Enables a PWM channel.
  94. * @pre The PWM unit must have been activated using @p pwmStart().
  95. * @post The channel is active using the specified configuration.
  96. * @note The function has effect at the next cycle start.
  97. * @note Channel notification is not enabled.
  98. *
  99. * @param[in] pwmp pointer to a @p PWMDriver object
  100. * @param[in] channel PWM channel identifier (0...channels-1)
  101. * @param[in] width PWM pulse width as clock pulses number
  102. *
  103. * @notapi
  104. */
  105. void pwm_lld_enable_channel(PWMDriver *pwmp,
  106. pwmchannel_t channel,
  107. pwmcnt_t width) {
  108. (void)pwmp;
  109. (void)channel;
  110. (void)width;
  111. }
  112. /**
  113. * @brief Disables a PWM channel and its notification.
  114. * @pre The PWM unit must have been activated using @p pwmStart().
  115. * @post The channel is disabled and its output line returned to the
  116. * idle state.
  117. * @note The function has effect at the next cycle start.
  118. *
  119. * @param[in] pwmp pointer to a @p PWMDriver object
  120. * @param[in] channel PWM channel identifier (0...channels-1)
  121. *
  122. * @notapi
  123. */
  124. void pwm_lld_disable_channel(PWMDriver *pwmp, pwmchannel_t channel) {
  125. (void)pwmp;
  126. (void)channel;
  127. }
  128. /**
  129. * @brief Enables the periodic activation edge notification.
  130. * @pre The PWM unit must have been activated using @p pwmStart().
  131. * @note If the notification is already enabled then the call has no effect.
  132. *
  133. * @param[in] pwmp pointer to a @p PWMDriver object
  134. *
  135. * @notapi
  136. */
  137. void pwm_lld_enable_periodic_notification(PWMDriver *pwmp) {
  138. (void)pwmp;
  139. }
  140. /**
  141. * @brief Disables the periodic activation edge notification.
  142. * @pre The PWM unit must have been activated using @p pwmStart().
  143. * @note If the notification is already disabled then the call has no effect.
  144. *
  145. * @param[in] pwmp pointer to a @p PWMDriver object
  146. *
  147. * @notapi
  148. */
  149. void pwm_lld_disable_periodic_notification(PWMDriver *pwmp) {
  150. (void)pwmp;
  151. }
  152. /**
  153. * @brief Enables a channel de-activation edge notification.
  154. * @pre The PWM unit must have been activated using @p pwmStart().
  155. * @pre The channel must have been activated using @p pwmEnableChannel().
  156. * @note If the notification is already enabled then the call has no effect.
  157. *
  158. * @param[in] pwmp pointer to a @p PWMDriver object
  159. * @param[in] channel PWM channel identifier (0...channels-1)
  160. *
  161. * @notapi
  162. */
  163. void pwm_lld_enable_channel_notification(PWMDriver *pwmp,
  164. pwmchannel_t channel) {
  165. (void)pwmp;
  166. (void)channel;
  167. }
  168. /**
  169. * @brief Disables a channel de-activation edge notification.
  170. * @pre The PWM unit must have been activated using @p pwmStart().
  171. * @pre The channel must have been activated using @p pwmEnableChannel().
  172. * @note If the notification is already disabled then the call has no effect.
  173. *
  174. * @param[in] pwmp pointer to a @p PWMDriver object
  175. * @param[in] channel PWM channel identifier (0...channels-1)
  176. *
  177. * @notapi
  178. */
  179. void pwm_lld_disable_channel_notification(PWMDriver *pwmp,
  180. pwmchannel_t channel) {
  181. (void)pwmp;
  182. (void)channel;
  183. }
  184. #endif /* HAL_USE_PWM == TRUE */
  185. /** @} */