|
ChibiOS/RT
2.5.1 |
|
Generic EXT Driver.
This module implements a generic EXT (EXTernal) driver.
HAL_USE_EXT option must be enabled in halconf.h.The driver implements a state machine internally, not all the driver functionalities can be used in any moment, any transition not explicitly shown in the following diagram has to be considered an error and shall be captured by an assertion (if enabled).
This driver abstracts generic external interrupt sources, a callback is invoked when a programmable transition is detected on one of the configured channels. Several channel modes are possible.
Functions | |
| void | extInit (void) |
| EXT Driver initialization. | |
| void | extObjectInit (EXTDriver *extp) |
Initializes the standard part of a EXTDriver structure. | |
| void | extStart (EXTDriver *extp, const EXTConfig *config) |
| Configures and activates the EXT peripheral. | |
| void | extStop (EXTDriver *extp) |
| Deactivates the EXT peripheral. | |
| void | extChannelEnable (EXTDriver *extp, expchannel_t channel) |
| Enables an EXT channel. | |
| void | extChannelDisable (EXTDriver *extp, expchannel_t channel) |
| Disables an EXT channel. | |
| void | extSetChannelModeI (EXTDriver *extp, expchannel_t channel, const EXTChannelConfig *extcp) |
| Changes the operation mode of a channel. | |
EXT channel modes | |
| #define | EXT_CH_MODE_EDGES_MASK 3 |
| Mask of edges field. | |
| #define | EXT_CH_MODE_DISABLED 0 |
| Channel disabled. | |
| #define | EXT_CH_MODE_RISING_EDGE 1 |
| Rising edge callback. | |
| #define | EXT_CH_MODE_FALLING_EDGE 2 |
| Falling edge callback. | |
| #define | EXT_CH_MODE_BOTH_EDGES 3 |
| Both edges callback. | |
| #define | EXT_CH_MODE_AUTOSTART 4 |
| Channel started automatically on driver start. | |
Macro Functions | |
| #define | extChannelEnableI(extp, channel) ext_lld_channel_enable(extp, channel) |
| Enables an EXT channel. | |
| #define | extChannelDisableI(extp, channel) ext_lld_channel_disable(extp, channel) |
| Disables an EXT channel. | |
| #define | extSetChannelMode(extp, channel, extcp) |
| Changes the operation mode of a channel. | |
Typedefs | |
| typedef struct EXTDriver | EXTDriver |
| Type of a structure representing a EXT driver. | |
Enumerations | |
| enum | extstate_t { EXT_UNINIT = 0, EXT_STOP = 1, EXT_ACTIVE = 2 } |
| Driver state machine possible states. More... | |
| void extInit | ( | void | ) |
EXT Driver initialization.
halInit(), there is no need to explicitly initialize the driver.Definition at line 61 of file ext.c.
Referenced by halInit().
| void extObjectInit | ( | EXTDriver * | extp | ) |
| void extStart | ( | EXTDriver * | extp, |
| const EXTConfig * | config | ||
| ) |
Configures and activates the EXT peripheral.
extChannelEnable() in order to activate them.| [in] | extp | pointer to the EXTDriver object |
| [in] | config | pointer to the EXTConfig object |
Definition at line 89 of file ext.c.
References chDbgAssert, chDbgCheck, chSysLock, chSysUnlock, EXT_ACTIVE, and EXT_STOP.
| void extStop | ( | EXTDriver * | extp | ) |
Deactivates the EXT peripheral.
| [in] | extp | pointer to the EXTDriver object |
Definition at line 109 of file ext.c.
References chDbgAssert, chDbgCheck, chSysLock, chSysUnlock, EXT_ACTIVE, and EXT_STOP.
| void extChannelEnable | ( | EXTDriver * | extp, |
| expchannel_t | channel | ||
| ) |
Enables an EXT channel.
EXT_CH_MODE_DISABLED mode.| [in] | extp | pointer to the EXTDriver object |
| [in] | channel | channel to be enabled |
Definition at line 130 of file ext.c.
References chDbgAssert, chDbgCheck, chSysLock, chSysUnlock, EXT_ACTIVE, EXT_CH_MODE_DISABLED, EXT_CH_MODE_EDGES_MASK, and extChannelEnableI.
| void extChannelDisable | ( | EXTDriver * | extp, |
| expchannel_t | channel | ||
| ) |
Disables an EXT channel.
EXT_CH_MODE_DISABLED mode.| [in] | extp | pointer to the EXTDriver object |
| [in] | channel | channel to be disabled |
Definition at line 153 of file ext.c.
References chDbgAssert, chDbgCheck, chSysLock, chSysUnlock, EXT_ACTIVE, EXT_CH_MODE_DISABLED, EXT_CH_MODE_EDGES_MASK, and extChannelDisableI.
| void extSetChannelModeI | ( | EXTDriver * | extp, |
| expchannel_t | channel, | ||
| const EXTChannelConfig * | extcp | ||
| ) |
Changes the operation mode of a channel.
const qualifier in extStart() but it is intentional. const. | [in] | extp | pointer to the EXTDriver object |
| [in] | channel | channel to be changed |
| [in] | extcp | new configuration for the channel |
Definition at line 184 of file ext.c.
References chDbgAssert, chDbgCheck, and EXT_ACTIVE.
| #define EXT_CH_MODE_EDGES_MASK 3 |
Mask of edges field.
Definition at line 42 of file ext.h.
Referenced by extChannelDisable(), and extChannelEnable().
| #define EXT_CH_MODE_DISABLED 0 |
Channel disabled.
Definition at line 43 of file ext.h.
Referenced by extChannelDisable(), and extChannelEnable().
| #define EXT_CH_MODE_AUTOSTART 4 |
| #define extChannelEnableI | ( | extp, | |
| channel | |||
| ) | ext_lld_channel_enable(extp, channel) |
Enables an EXT channel.
| [in] | extp | pointer to the EXTDriver object |
| [in] | channel | channel to be enabled |
Definition at line 96 of file ext.h.
Referenced by extChannelEnable().
| #define extChannelDisableI | ( | extp, | |
| channel | |||
| ) | ext_lld_channel_disable(extp, channel) |
Disables an EXT channel.
| [in] | extp | pointer to the EXTDriver object |
| [in] | channel | channel to be disabled |
Definition at line 106 of file ext.h.
Referenced by extChannelDisable().
| #define extSetChannelMode | ( | extp, | |
| channel, | |||
| extcp | |||
| ) |
{ \
chSysLock(); \
extSetChannelModeI(extp, channel, extcp); \
chSysUnlock(); \
}
Changes the operation mode of a channel.
const qualifier in extStart() but it is intentional. This function cannot be used if the configuration structure is declared const.| [in] | extp | pointer to the EXTDriver object |
| [in] | channel | channel to be changed |
| [in] | extcp | new configuration for the channel |
| enum extstate_t |