ChibiOS/HAL  6.1.0
hal_ext_lld.h
Go to the documentation of this file.
1 /*
2  ChibiOS - Copyright (C) 2006..2018 Giovanni Di Sirio
3 
4  Licensed under the Apache License, Version 2.0 (the "License");
5  you may not use this file except in compliance with the License.
6  You may obtain a copy of the License at
7 
8  http://www.apache.org/licenses/LICENSE-2.0
9 
10  Unless required by applicable law or agreed to in writing, software
11  distributed under the License is distributed on an "AS IS" BASIS,
12  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  See the License for the specific language governing permissions and
14  limitations under the License.
15 */
16 
17 /**
18  * @file hal_ext_lld.h
19  * @brief PLATFORM EXT subsystem low level driver header.
20  *
21  * @addtogroup EXT
22  * @{
23  */
24 
25 #ifndef HAL_EXT_LLD_H
26 #define HAL_EXT_LLD_H
27 
28 #if (HAL_USE_EXT == TRUE) || defined(__DOXYGEN__)
29 
30 /*===========================================================================*/
31 /* Driver constants. */
32 /*===========================================================================*/
33 
34 /**
35  * @brief Available number of EXT channels.
36  */
37 #define EXT_MAX_CHANNELS 20
38 
39 /*===========================================================================*/
40 /* Driver pre-compile time settings. */
41 /*===========================================================================*/
42 
43 /**
44  * @name PLATFORM configuration options
45  * @{
46  */
47 /**
48  * @brief EXT driver enable switch.
49  * @details If set to @p TRUE the support for EXT1 is included.
50  * @note The default is @p FALSE.
51  */
52 #if !defined(PLATFORM_EXT_USE_EXT1) || defined(__DOXYGEN__)
53 #define PLATFORM_EXT_USE_EXT1 FALSE
54 #endif
55 /** @} */
56 
57 /*===========================================================================*/
58 /* Derived constants and error checks. */
59 /*===========================================================================*/
60 
61 /*===========================================================================*/
62 /* Driver data structures and types. */
63 /*===========================================================================*/
64 
65 /**
66  * @brief EXT channel identifier.
67  */
68 typedef uint32_t expchannel_t;
69 
70 /**
71  * @brief Type of an EXT generic notification callback.
72  *
73  * @param[in] extp pointer to the @p EXPDriver object triggering the
74  * callback
75  */
76 typedef void (*extcallback_t)(EXTDriver *extp, expchannel_t channel);
77 
78 /**
79  * @brief Channel configuration structure.
80  */
81 typedef struct {
82  /**
83  * @brief Channel mode.
84  */
85  uint32_t mode;
86  /**
87  * @brief Channel callback.
88  * @details In the STM32 implementation a @p NULL callback pointer is
89  * valid and configures the channel as an event sources instead
90  * of an interrupt source.
91  */
94 
95 /**
96  * @brief Driver configuration structure.
97  * @note It could be empty on some architectures.
98  */
99 typedef struct {
100  /**
101  * @brief Channel configurations.
102  */
104  /* End of the mandatory fields.*/
105 } EXTConfig;
106 
107 /**
108  * @brief Structure representing an EXT driver.
109  */
110 struct EXTDriver {
111  /**
112  * @brief Driver state.
113  */
115  /**
116  * @brief Current configuration data.
117  */
119  /* End of the mandatory fields.*/
120 };
121 
122 /*===========================================================================*/
123 /* Driver macros. */
124 /*===========================================================================*/
125 
126 /*===========================================================================*/
127 /* External declarations. */
128 /*===========================================================================*/
129 
130 #if (PLATFORM_EXT_USE_EXT1 == TRUE) && !defined(__DOXYGEN__)
131 extern EXTDriver EXTD1;
132 #endif
133 
134 #ifdef __cplusplus
135 extern "C" {
136 #endif
137  void ext_lld_init(void);
138  void ext_lld_start(EXTDriver *extp);
139  void ext_lld_stop(EXTDriver *extp);
140  void ext_lld_channel_enable(EXTDriver *extp, expchannel_t channel);
141  void ext_lld_channel_disable(EXTDriver *extp, expchannel_t channel);
142 #ifdef __cplusplus
143 }
144 #endif
145 
146 #endif /* HAL_USE_EXT == TRUE */
147 
148 #endif /* HAL_EXT_LLD_H */
149 
150 /** @} */
Channel configuration structure.
Definition: hal_ext_lld.h:81
uint32_t expchannel_t
EXT channel identifier.
Definition: hal_ext_lld.h:68
const EXTConfig * config
Current configuration data.
Definition: hal_ext_lld.h:118
void ext_lld_stop(EXTDriver *extp)
Deactivates the EXT peripheral.
Definition: hal_ext_lld.c:101
uint32_t mode
Channel mode.
Definition: hal_ext_lld.h:85
void ext_lld_start(EXTDriver *extp)
Configures and activates the EXT peripheral.
Definition: hal_ext_lld.c:80
#define EXT_MAX_CHANNELS
Available number of EXT channels.
Definition: hal_ext_lld.h:37
extcallback_t cb
Channel callback.
Definition: hal_ext_lld.h:92
void ext_lld_init(void)
Low level EXT driver initialization.
Definition: hal_ext_lld.c:65
void ext_lld_channel_disable(EXTDriver *extp, expchannel_t channel)
Disables an EXT channel.
Definition: hal_ext_lld.c:138
extstate_t state
Driver state.
Definition: hal_ext_lld.h:114
EXTDriver EXTD1
EXT1 driver identifier.
Definition: hal_ext_lld.c:41
void(* extcallback_t)(EXTDriver *extp, expchannel_t channel)
Type of an EXT generic notification callback.
Definition: hal_ext_lld.h:76
extstate_t
Driver state machine possible states.
Definition: hal_ext.h:65
Driver configuration structure.
Definition: hal_ext_lld.h:99
Structure representing an EXT driver.
Definition: hal_ext_lld.h:110
void ext_lld_channel_enable(EXTDriver *extp, expchannel_t channel)
Enables an EXT channel.
Definition: hal_ext_lld.c:123