PageRenderTime 28ms CodeModel.GetById 18ms RepoModel.GetById 0ms app.codeStats 0ms

/os/hal/platforms/STM32/ext_lld.h

https://bitbucket.org/minux/chibios
C Header | 153 lines | 44 code | 21 blank | 88 comment | 1 complexity | 1a75c60d2dc83d7da05bc6f7f1bb2f22 MD5 | raw file
  1. /*
  2. ChibiOS/RT - Copyright (C) 2006-2013 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 STM32/ext_lld.h
  15. * @brief STM32 EXT subsystem low level driver header.
  16. *
  17. * @addtogroup EXT
  18. * @{
  19. */
  20. #ifndef _EXT_LLD_H_
  21. #define _EXT_LLD_H_
  22. #if HAL_USE_EXT || defined(__DOXYGEN__)
  23. /*===========================================================================*/
  24. /* Driver constants. */
  25. /*===========================================================================*/
  26. /**
  27. * @brief Available number of EXT channels.
  28. */
  29. #define EXT_MAX_CHANNELS STM32_EXTI_NUM_CHANNELS
  30. /**
  31. * @name STM32-specific EXT channel modes
  32. * @{
  33. */
  34. #define EXT_MODE_GPIO_MASK 0xF0 /**< @brief Port field mask. */
  35. #define EXT_MODE_GPIO_OFF 4 /**< @brief Port field offset. */
  36. #define EXT_MODE_GPIOA 0x00 /**< @brief GPIOA identifier. */
  37. #define EXT_MODE_GPIOB 0x10 /**< @brief GPIOB identifier. */
  38. #define EXT_MODE_GPIOC 0x20 /**< @brief GPIOC identifier. */
  39. #define EXT_MODE_GPIOD 0x30 /**< @brief GPIOD identifier. */
  40. #define EXT_MODE_GPIOE 0x40 /**< @brief GPIOE identifier. */
  41. #define EXT_MODE_GPIOF 0x50 /**< @brief GPIOF identifier. */
  42. #define EXT_MODE_GPIOG 0x60 /**< @brief GPIOG identifier. */
  43. #define EXT_MODE_GPIOH 0x70 /**< @brief GPIOH identifier. */
  44. #define EXT_MODE_GPIOI 0x80 /**< @brief GPIOI identifier. */
  45. /** @} */
  46. /*===========================================================================*/
  47. /* Driver pre-compile time settings. */
  48. /*===========================================================================*/
  49. /*===========================================================================*/
  50. /* Derived constants and error checks. */
  51. /*===========================================================================*/
  52. /*===========================================================================*/
  53. /* Driver data structures and types. */
  54. /*===========================================================================*/
  55. /**
  56. * @brief EXT channel identifier.
  57. */
  58. typedef uint32_t expchannel_t;
  59. /**
  60. * @brief Type of an EXT generic notification callback.
  61. *
  62. * @param[in] extp pointer to the @p EXPDriver object triggering the
  63. * callback
  64. */
  65. typedef void (*extcallback_t)(EXTDriver *extp, expchannel_t channel);
  66. /**
  67. * @brief Channel configuration structure.
  68. */
  69. typedef struct {
  70. /**
  71. * @brief Channel mode.
  72. */
  73. uint32_t mode;
  74. /**
  75. * @brief Channel callback.
  76. * @details In the STM32 implementation a @p NULL callback pointer is
  77. * valid and configures the channel as an event sources instead
  78. * of an interrupt source.
  79. */
  80. extcallback_t cb;
  81. } EXTChannelConfig;
  82. /**
  83. * @brief Driver configuration structure.
  84. * @note It could be empty on some architectures.
  85. */
  86. typedef struct {
  87. /**
  88. * @brief Channel configurations.
  89. */
  90. EXTChannelConfig channels[EXT_MAX_CHANNELS];
  91. /* End of the mandatory fields.*/
  92. } EXTConfig;
  93. /**
  94. * @brief Structure representing an EXT driver.
  95. */
  96. struct EXTDriver {
  97. /**
  98. * @brief Driver state.
  99. */
  100. extstate_t state;
  101. /**
  102. * @brief Current configuration data.
  103. */
  104. const EXTConfig *config;
  105. /* End of the mandatory fields.*/
  106. };
  107. /*===========================================================================*/
  108. /* Driver macros. */
  109. /*===========================================================================*/
  110. /*===========================================================================*/
  111. /* External declarations. */
  112. /*===========================================================================*/
  113. #if !defined(__DOXYGEN__)
  114. extern EXTDriver EXTD1;
  115. #endif
  116. #ifdef __cplusplus
  117. extern "C" {
  118. #endif
  119. void ext_lld_init(void);
  120. void ext_lld_start(EXTDriver *extp);
  121. void ext_lld_stop(EXTDriver *extp);
  122. void ext_lld_channel_enable(EXTDriver *extp, expchannel_t channel);
  123. void ext_lld_channel_disable(EXTDriver *extp, expchannel_t channel);
  124. #ifdef __cplusplus
  125. }
  126. #endif
  127. #endif /* HAL_USE_EXT */
  128. #endif /* _EXT_LLD_H_ */
  129. /** @} */