ChibiOS/HAL
6.1.0
|
Generic EXT Driver. More...
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.
Macros | |
#define | EXT_MAX_CHANNELS 20 |
Available number of EXT channels. More... | |
EXT channel modes | |
#define | EXT_CH_MODE_EDGES_MASK 3U |
Mask of edges field. More... | |
#define | EXT_CH_MODE_DISABLED 0U |
Channel disabled. More... | |
#define | EXT_CH_MODE_RISING_EDGE 1U |
Rising edge callback. More... | |
#define | EXT_CH_MODE_FALLING_EDGE 2U |
Falling edge callback. More... | |
#define | EXT_CH_MODE_BOTH_EDGES 3U |
Both edges callback. More... | |
#define | EXT_CH_MODE_LOW_LEVEL 5U |
low level callback. More... | |
#define | EXT_CH_MODE_AUTOSTART 4U |
Channel started automatically on driver start. More... | |
Macro Functions | |
#define | extChannelEnableI(extp, channel) ext_lld_channel_enable(extp, channel) |
Enables an EXT channel. More... | |
#define | extChannelDisableI(extp, channel) ext_lld_channel_disable(extp, channel) |
Disables an EXT channel. More... | |
#define | extSetChannelMode(extp, channel, extcp) |
Changes the operation mode of a channel. More... | |
PLATFORM configuration options | |
#define | PLATFORM_EXT_USE_EXT1 FALSE |
EXT driver enable switch. More... | |
Typedefs | |
typedef struct EXTDriver | EXTDriver |
Type of a structure representing a EXT driver. More... | |
typedef uint32_t | expchannel_t |
EXT channel identifier. More... | |
typedef void(* | extcallback_t) (EXTDriver *extp, expchannel_t channel) |
Type of an EXT generic notification callback. More... | |
Data Structures | |
struct | EXTChannelConfig |
Channel configuration structure. More... | |
struct | EXTConfig |
Driver configuration structure. More... | |
struct | EXTDriver |
Structure representing an EXT driver. More... | |
Functions | |
void | extInit (void) |
EXT Driver initialization. More... | |
void | extObjectInit (EXTDriver *extp) |
Initializes the standard part of a EXTDriver structure. More... | |
void | extStart (EXTDriver *extp, const EXTConfig *config) |
Configures and activates the EXT peripheral. More... | |
void | extStop (EXTDriver *extp) |
Deactivates the EXT peripheral. More... | |
void | extChannelEnable (EXTDriver *extp, expchannel_t channel) |
Enables an EXT channel. More... | |
void | extChannelDisable (EXTDriver *extp, expchannel_t channel) |
Disables an EXT channel. More... | |
void | extSetChannelModeI (EXTDriver *extp, expchannel_t channel, const EXTChannelConfig *extcp) |
Changes the operation mode of a channel. More... | |
void | ext_lld_init (void) |
Low level EXT driver initialization. More... | |
void | ext_lld_start (EXTDriver *extp) |
Configures and activates the EXT peripheral. More... | |
void | ext_lld_stop (EXTDriver *extp) |
Deactivates the EXT peripheral. More... | |
void | ext_lld_channel_enable (EXTDriver *extp, expchannel_t channel) |
Enables an EXT channel. More... | |
void | ext_lld_channel_disable (EXTDriver *extp, expchannel_t channel) |
Disables an EXT channel. More... | |
Enumerations |
Variables | |
EXTDriver | EXTD1 |
EXT1 driver identifier. More... | |
#define EXT_CH_MODE_EDGES_MASK 3U |
Mask of edges field.
Definition at line 38 of file hal_ext.h.
Referenced by extChannelDisable(), and extChannelEnable().
#define EXT_CH_MODE_DISABLED 0U |
Channel disabled.
Definition at line 39 of file hal_ext.h.
Referenced by extChannelDisable(), and extChannelEnable().
#define EXT_CH_MODE_AUTOSTART 4U |
#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 94 of file hal_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 104 of file hal_ext.h.
Referenced by extChannelDisable().
#define extSetChannelMode | ( | extp, | |
channel, | |||
extcp | |||
) |
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 |
#define EXT_MAX_CHANNELS 20 |
Available number of EXT channels.
Definition at line 37 of file hal_ext_lld.h.
Referenced by extChannelDisable(), extChannelEnable(), and extSetChannelModeI().
#define PLATFORM_EXT_USE_EXT1 FALSE |
EXT driver enable switch.
If set to TRUE
the support for EXT1 is included.
FALSE
. Definition at line 53 of file hal_ext_lld.h.
typedef uint32_t expchannel_t |
EXT channel identifier.
Definition at line 68 of file hal_ext_lld.h.
typedef void(* extcallback_t) (EXTDriver *extp, expchannel_t channel) |
Type of an EXT generic notification callback.
[in] | extp | pointer to the EXPDriver object triggering the callback |
Definition at line 76 of file hal_ext_lld.h.
enum extstate_t |
void extInit | ( | void | ) |
EXT Driver initialization.
halInit()
, there is no need to explicitly initialize the driver.Definition at line 56 of file hal_ext.c.
References ext_lld_init().
Referenced by halInit().
void extObjectInit | ( | EXTDriver * | extp | ) |
Initializes the standard part of a EXTDriver
structure.
[out] | extp | pointer to the EXTDriver object |
Definition at line 68 of file hal_ext.c.
References EXTDriver::config, EXT_STOP, and EXTDriver::state.
Referenced by ext_lld_init().
Configures and activates the EXT peripheral.
extChannelEnable()
in order to activate them.Definition at line 84 of file hal_ext.c.
References EXTDriver::config, EXT_ACTIVE, ext_lld_start(), EXT_STOP, osalDbgAssert, osalDbgCheck, osalSysLock(), osalSysUnlock(), and EXTDriver::state.
void extStop | ( | EXTDriver * | extp | ) |
Deactivates the EXT peripheral.
[in] | extp | pointer to the EXTDriver object |
Definition at line 104 of file hal_ext.c.
References EXTDriver::config, EXT_ACTIVE, ext_lld_stop(), EXT_STOP, osalDbgAssert, osalDbgCheck, osalSysLock(), osalSysUnlock(), and EXTDriver::state.
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 129 of file hal_ext.c.
References EXTConfig::channels, EXTDriver::config, EXT_ACTIVE, EXT_CH_MODE_DISABLED, EXT_CH_MODE_EDGES_MASK, EXT_MAX_CHANNELS, extChannelEnableI, EXTChannelConfig::mode, osalDbgAssert, osalDbgCheck, osalSysLock(), osalSysUnlock(), and EXTDriver::state.
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 151 of file hal_ext.c.
References EXTConfig::channels, EXTDriver::config, EXT_ACTIVE, EXT_CH_MODE_DISABLED, EXT_CH_MODE_EDGES_MASK, EXT_MAX_CHANNELS, extChannelDisableI, EXTChannelConfig::mode, osalDbgAssert, osalDbgCheck, osalSysLock(), osalSysUnlock(), and EXTDriver::state.
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 181 of file hal_ext.c.
References EXTConfig::channels, EXTDriver::config, EXT_ACTIVE, ext_lld_channel_enable(), EXT_MAX_CHANNELS, osalDbgAssert, osalDbgCheck, and EXTDriver::state.
void ext_lld_init | ( | void | ) |
Low level EXT driver initialization.
Definition at line 65 of file hal_ext_lld.c.
References extObjectInit().
Referenced by extInit().
void ext_lld_start | ( | EXTDriver * | extp | ) |
Configures and activates the EXT peripheral.
[in] | extp | pointer to the EXTDriver object |
Definition at line 80 of file hal_ext_lld.c.
References EXT_STOP, and EXTDriver::state.
Referenced by extStart().
void ext_lld_stop | ( | EXTDriver * | extp | ) |
Deactivates the EXT peripheral.
[in] | extp | pointer to the EXTDriver object |
Definition at line 101 of file hal_ext_lld.c.
References EXT_ACTIVE, and EXTDriver::state.
Referenced by extStop().
void ext_lld_channel_enable | ( | EXTDriver * | extp, |
expchannel_t | channel | ||
) |
Enables an EXT channel.
[in] | extp | pointer to the EXTDriver object |
[in] | channel | channel to be enabled |
Definition at line 123 of file hal_ext_lld.c.
Referenced by extSetChannelModeI().
void ext_lld_channel_disable | ( | EXTDriver * | extp, |
expchannel_t | channel | ||
) |
Disables an EXT channel.
[in] | extp | pointer to the EXTDriver object |
[in] | channel | channel to be disabled |
Definition at line 138 of file hal_ext_lld.c.
EXTDriver EXTD1 |
EXT1 driver identifier.
Definition at line 41 of file hal_ext_lld.c.