S32 SDK

Detailed Description

Trigger MUX Control Peripheral Driver.

Overview

This section describes the programing interface of the TRGMUX driver. The TRGMUX driver configures the TRGMUX (Trigger Mux Control). The Trigger MUX module allows software to configure the trigger inputs for various peripherals.

TRGMUX Driver model building

TRGMUX can be seen as a collection of muxes, each mux allowing to select one output from a list of input signals that are common to all muxes. The TRGMUX registers are identical as structure and all bitfields can be read/written using the TRGMUX driver API.

TRGMUX Initialization

The TRGMUX_DRV_Init() function is used to initialize the TRGMUX IP. The function receives as parameter a pointer to the trgmux_user_config_t structure. This structure contains a variable number of mappings between a trgmux trigger source and a trgmux target modules.

TRGMUX API

After initialization, the driver allows the reconfiguration of the source trigger for a given target module using TRGMUX_DRV_SetTrigSourceForTargetModule(). Also, by using TRGMUX_DRV_SetLockForTargetModule(), a given target module can be locked, such that it cannot be updated until a reset.

Data Structures

struct  trgmux_inout_mapping_config_t
 Configuration structure for pairing source triggers with target modules. More...
 
struct  trgmux_user_config_t
 User configuration structure for the TRGMUX driver. More...
 

Functions

status_t TRGMUX_DRV_Init (const uint32_t instance, const trgmux_user_config_t *const trgmuxUserConfig)
 Initialize a TRGMUX instance for operation. More...
 
status_t TRGMUX_DRV_Deinit (const uint32_t instance)
 Reset to default values the source triggers corresponding to all target modules, if none of the target modules is locked. More...
 
status_t TRGMUX_DRV_SetTrigSourceForTargetModule (const uint32_t instance, const trgmux_trigger_source_t triggerSource, const trgmux_target_module_t targetModule)
 Configure a source trigger for a selected target module. More...
 
trgmux_trigger_source_t TRGMUX_DRV_GetTrigSourceForTargetModule (const uint32_t instance, const trgmux_target_module_t targetModule)
 Get the source trigger configured for a target module. More...
 
void TRGMUX_DRV_SetLockForTargetModule (const uint32_t instance, const trgmux_target_module_t targetModule)
 Locks the TRGMUX register of a target module. More...
 
bool TRGMUX_DRV_GetLockForTargetModule (const uint32_t instance, const trgmux_target_module_t targetModule)
 Get the Lock bit status of the TRGMUX register of a target module. More...
 

Function Documentation

status_t TRGMUX_DRV_Deinit ( const uint32_t  instance)

Reset to default values the source triggers corresponding to all target modules, if none of the target modules is locked.

Parameters
[in]instanceThe TRGMUX instance number.
Returns
Execution status:
STATUS_SUCCESS
STATUS_ERROR - if at least one of the target module register is locked.

Definition at line 121 of file trgmux_driver.c.

bool TRGMUX_DRV_GetLockForTargetModule ( const uint32_t  instance,
const trgmux_target_module_t  targetModule 
)

Get the Lock bit status of the TRGMUX register of a target module.

This function gets the value of the LK bit from the TRGMUX register corresponding to the selected target module.

Parameters
[in]instanceThe TRGMUX instance number.
[in]targetModuleOne of the values in the trgmux_target_module_t enumeration
Returns
true - if the selected targetModule register is locked
false - if the selected targetModule register is not locked

Definition at line 210 of file trgmux_driver.c.

trgmux_trigger_source_t TRGMUX_DRV_GetTrigSourceForTargetModule ( const uint32_t  instance,
const trgmux_target_module_t  targetModule 
)

Get the source trigger configured for a target module.

This function returns the TRGMUX source trigger linked to a selected target module.

Parameters
[in]instanceThe TRGMUX instance number.
[in]targetModuleOne of the values in the trgmux_target_module_t enumeration.
Returns
Enum value corresponding to the trigger source configured for the selected target module.

Definition at line 175 of file trgmux_driver.c.

status_t TRGMUX_DRV_Init ( const uint32_t  instance,
const trgmux_user_config_t *const  trgmuxUserConfig 
)

Initialize a TRGMUX instance for operation.

This function first resets the source triggers of all TRGMUX target modules to their default values, then configures the TRGMUX with all the user defined in-out mappings. If at least one of the target modules is locked, the function will not change any of the TRGMUX target modules and return error code. This example shows how to set up the trgmux_user_config_t parameters and how to call the TRGMUX_DRV_Init() function with the required parameters:

1 trgmux_user_config_t trgmuxConfig;
2 trgmux_inout_mapping_config_t trgmuxInoutMappingConfig[] =
3 {
4  {TRGMUX_TRIG_SOURCE_TRGMUX_IN9, TRGMUX_TARGET_MODULE_DMA_CH0, false},
5  {TRGMUX_TRIG_SOURCE_FTM1_EXT_TRIG, TRGMUX_TARGET_MODULE_TRGMUX_OUT4, true}
6 };
7 
8 trgmuxConfig.numInOutMappingConfigs = 2;
9 trgmuxConfig.inOutMappingConfig = trgmuxInoutMappingConfig;
10 
11 TRGMUX_DRV_Init(instance, &trgmuxConfig);
Parameters
[in]instanceThe TRGMUX instance number.
[in]trgmuxUserConfigPointer to the user configuration structure.
Returns
Execution status:
STATUS_SUCCESS
STATUS_ERROR - if at least one of the target module register is locked.

Definition at line 76 of file trgmux_driver.c.

void TRGMUX_DRV_SetLockForTargetModule ( const uint32_t  instance,
const trgmux_target_module_t  targetModule 
)

Locks the TRGMUX register of a target module.

This function sets the LK bit of the TRGMUX register corresponding to the selected target module. Please note that some TRGMUX registers can contain up to 4 SEL bitfields, meaning that these registers can be used to configure up to 4 target modules independently. Because the LK bit is only one per register, the configuration of all target modules referred from that register will be locked.

Parameters
[in]instanceThe TRGMUX instance number.
[in]targetModuleOne of the values in the trgmux_target_module_t enumeration

Definition at line 192 of file trgmux_driver.c.

status_t TRGMUX_DRV_SetTrigSourceForTargetModule ( const uint32_t  instance,
const trgmux_trigger_source_t  triggerSource,
const trgmux_target_module_t  targetModule 
)

Configure a source trigger for a selected target module.

This function configures a TRGMUX link between a source trigger and a target module, if the requested target module is not locked.

Parameters
[in]instanceThe TRGMUX instance number.
[in]triggerSourceOne of the values in the trgmux_trigger_source_t enumeration
[in]targetModuleOne of the values in the trgmux_target_module_t enumeration
Returns
Execution status:
STATUS_SUCCESS
STATUS_ERROR - if requested target module is locked

Definition at line 142 of file trgmux_driver.c.