ChibiOS/RT
2.5.1
EXT Driver
Collaboration diagram for EXT Driver:

Detailed Description

Generic EXT Driver.

This module implements a generic EXT (EXTernal) driver.

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

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

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 61 of file ext.c.

Referenced by halInit().

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 73 of file ext.c.

References EXT_STOP.

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 89 of file ext.c.

References chDbgAssert, chDbgCheck, chSysLock, chSysUnlock, EXT_ACTIVE, and EXT_STOP.

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

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

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

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 184 of file ext.c.

References chDbgAssert, chDbgCheck, and EXT_ACTIVE.


Define Documentation

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

Rising edge callback.

Definition at line 44 of file ext.h.

#define EXT_CH_MODE_FALLING_EDGE   2

Falling edge callback.

Definition at line 45 of file ext.h.

#define EXT_CH_MODE_BOTH_EDGES   3

Both edges callback.

Definition at line 46 of file ext.h.

#define EXT_CH_MODE_AUTOSTART   4

Channel started automatically on driver start.

Definition at line 48 of file 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 96 of file 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 106 of file ext.h.

Referenced by extChannelDisable().

#define extSetChannelMode (   extp,
  channel,
  extcp 
)
Value:
{                           \
  chSysLock();                                                              \
  extSetChannelModeI(extp, channel, extcp);                                 \
  chSysUnlock();                                                            \
}

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 122 of file ext.h.


Typedef Documentation

typedef struct EXTDriver EXTDriver

Type of a structure representing a EXT driver.

Definition at line 76 of file ext.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 67 of file ext.h.