ChibiOS/HAL  6.1.0
EXT Driver

Generic EXT Driver. More...

Collaboration diagram for EXT Driver:

Detailed Description

Generic EXT Driver.

This module implements a generic EXT (EXTernal) driver.

Note
This driver is obsolete. Use the Event and Callback functions of the PAL Driver driver instead.
Precondition
In order to use the EXT driver the HAL_USE_EXT option must be enabled in halconf.h.

Driver State Machine

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).

dot_inline_dotgraph_3.png

EXT Operations.

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...
 

Macro Definition Documentation

#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_RISING_EDGE   1U

Rising edge callback.

Definition at line 40 of file hal_ext.h.

#define EXT_CH_MODE_FALLING_EDGE   2U

Falling edge callback.

Definition at line 41 of file hal_ext.h.

#define EXT_CH_MODE_BOTH_EDGES   3U

Both edges callback.

Definition at line 42 of file hal_ext.h.

#define EXT_CH_MODE_LOW_LEVEL   5U

low level callback.

Definition at line 43 of file hal_ext.h.

#define EXT_CH_MODE_AUTOSTART   4U

Channel started automatically on driver start.

Definition at line 45 of file hal_ext.h.

#define extChannelEnableI (   extp,
  channel 
)    ext_lld_channel_enable(extp, channel)

Enables an EXT channel.

Parameters
[in]extppointer to the EXTDriver object
[in]channelchannel to be enabled
Function Class:This is an I-Class API, this function can be invoked from within a system lock zone by both threads and interrupt handlers.

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.

Parameters
[in]extppointer to the EXTDriver object
[in]channelchannel to be disabled
Function Class:This is an I-Class API, this function can be invoked from within a system lock zone by both threads and interrupt handlers.

Definition at line 104 of file hal_ext.h.

Referenced by extChannelDisable().

#define extSetChannelMode (   extp,
  channel,
  extcp 
)
Value:
{ \
extSetChannelModeI(extp, channel, extcp); \
}
static void osalSysUnlock(void)
Leaves a critical zone from thread context.
Definition: osal.h:540
static void osalSysLock(void)
Enters a critical zone from thread context.
Definition: osal.h:530
void extSetChannelModeI(EXTDriver *extp, expchannel_t channel, const EXTChannelConfig *extcp)
Changes the operation mode of a channel.
Definition: hal_ext.c:181

Changes the operation mode of a channel.

Note
This function attempts to write over the current configuration structure that must have been not declared constant. This violates the const qualifier in extStart() but it is intentional. This function cannot be used if the configuration structure is declared const.
Parameters
[in]extppointer to the EXTDriver object
[in]channelchannel to be changed
[in]extcpnew configuration for the channel
Function Class:Normal API, this function can be invoked by regular system threads but not from within a lock zone.

Definition at line 120 of file hal_ext.h.

#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.

Note
The default is FALSE.

Definition at line 53 of file hal_ext_lld.h.

Typedef Documentation

typedef struct EXTDriver EXTDriver

Type of a structure representing a EXT driver.

Definition at line 74 of file hal_ext.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.

Parameters
[in]extppointer to the EXPDriver object triggering the callback

Definition at line 76 of file hal_ext_lld.h.

Enumeration Type Documentation

enum extstate_t

Driver state machine possible states.

Enumerator
EXT_UNINIT 

Not initialized.

EXT_STOP 

Stopped.

EXT_ACTIVE 

Active.

Definition at line 65 of file hal_ext.h.

Function Documentation

void extInit ( void  )

EXT Driver initialization.

Note
This function is implicitly invoked by halInit(), there is no need to explicitly initialize the driver.
Function Class:Initializer, this function just initializes an object and can be invoked before the kernel is initialized.

Definition at line 56 of file hal_ext.c.

References ext_lld_init().

Referenced by halInit().

Here is the call graph for this function:

void extObjectInit ( EXTDriver extp)

Initializes the standard part of a EXTDriver structure.

Parameters
[out]extppointer to the EXTDriver object
Function Class:Initializer, this function just initializes an object and can be invoked before the kernel is initialized.

Definition at line 68 of file hal_ext.c.

References EXTDriver::config, EXT_STOP, and EXTDriver::state.

Referenced by ext_lld_init().

void extStart ( EXTDriver extp,
const EXTConfig config 
)

Configures and activates the EXT peripheral.

Postcondition
After activation all EXT channels are in the disabled state, use extChannelEnable() in order to activate them.
Parameters
[in]extppointer to the EXTDriver object
[in]configpointer to the EXTConfig object
Function Class:Normal API, this function can be invoked by regular system threads but not from within a lock zone.

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.

Here is the call graph for this function:

void extStop ( EXTDriver extp)

Deactivates the EXT peripheral.

Parameters
[in]extppointer to the EXTDriver object
Function Class:Normal API, this function can be invoked by regular system threads but not from within a lock zone.

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.

Here is the call graph for this function:

void extChannelEnable ( EXTDriver extp,
expchannel_t  channel 
)

Enables an EXT channel.

Precondition
The channel must not be in EXT_CH_MODE_DISABLED mode.
Parameters
[in]extppointer to the EXTDriver object
[in]channelchannel to be enabled
Function Class:Normal API, this function can be invoked by regular system threads but not from within a lock zone.

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.

Here is the call graph for this function:

void extChannelDisable ( EXTDriver extp,
expchannel_t  channel 
)

Disables an EXT channel.

Precondition
The channel must not be in EXT_CH_MODE_DISABLED mode.
Parameters
[in]extppointer to the EXTDriver object
[in]channelchannel to be disabled
Function Class:Normal API, this function can be invoked by regular system threads but not from within a lock zone.

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.

Here is the call graph for this function:

void extSetChannelModeI ( EXTDriver extp,
expchannel_t  channel,
const EXTChannelConfig extcp 
)

Changes the operation mode of a channel.

Note
This function attempts to write over the current configuration structure that must have been not declared constant. This violates the const qualifier in extStart() but it is intentional.
This function cannot be used if the configuration structure is declared const.
The effect of this function on constant configuration structures is not defined.
Parameters
[in]extppointer to the EXTDriver object
[in]channelchannel to be changed
[in]extcpnew configuration for the channel
Function Class:This is an I-Class API, this function can be invoked from within a system lock zone by both threads and interrupt handlers.

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.

Here is the call graph for this function:

void ext_lld_init ( void  )

Low level EXT driver initialization.

Function Class:Not an API, this function is for internal use only.

Definition at line 65 of file hal_ext_lld.c.

References extObjectInit().

Referenced by extInit().

Here is the call graph for this function:

void ext_lld_start ( EXTDriver extp)

Configures and activates the EXT peripheral.

Parameters
[in]extppointer to the EXTDriver object
Function Class:Not an API, this function is for internal use only.

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.

Parameters
[in]extppointer to the EXTDriver object
Function Class:Not an API, this function is for internal use only.

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.

Parameters
[in]extppointer to the EXTDriver object
[in]channelchannel to be enabled
Function Class:Not an API, this function is for internal use only.

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.

Parameters
[in]extppointer to the EXTDriver object
[in]channelchannel to be disabled
Function Class:Not an API, this function is for internal use only.

Definition at line 138 of file hal_ext_lld.c.

Variable Documentation

EXTDriver EXTD1

EXT1 driver identifier.

Definition at line 41 of file hal_ext_lld.c.