This section describes the programming interface of the XBAR Peripheral driver.
Overview
The XBAR peripheral driver configures the XBAR (Inter-Peripheral Crossbar Switch) and handles initialization and configuration of the XBAR module.
CMP Driver model building
XBAR driver has two parts:
- Signal connection - This part interconnects input and output signals.
- Active edge feature - Some of the outputs provides active edge detection. If an active edge occurs, an interrupt or a DMA request can be called. APIs handle user callbacks for the interrupts. The driver also includes API for clearing and reading status bit.
Initialization
To initialize the XBAR driver, a state structure has to be passed into the initialization function. This block of memory keeps pointers to user's callback functions and parameters to these functions. The XBAR module is initialized by calling the XBAR_DRV_Init() function.
Call diagram
- Call the "XBAR_DRV_Init()" function to initialize the XBAR module. A state structure of the "xbar_state_t" type has to be defined and passed into this function.
- Optionally, call the "XBAR_DRV_ConfigOutControl()" function to set the active edge features, such interrupts or DMA requests. A configuration structure of the "xbar_control_config_t" type is required.
- Optionally, call the "XBAR_DRV_InstallCallback" function to install user's callback function. A pointer to the function of the "xbar_callback_t" type and pointer to a void parameter is required. When the XBAR is configured to enable the interrupt, the installed callback function is called after the interrupt event occurs.
- Call the "XBAR_DRV_ConfigSignalConnection" function to connect the desired signals.
- Finally, the XBAR works properly.
These are the examples to initialize and configure the XBAR driver for typical use cases.
Interrupt Mode:
#include <stdio.h>
#include <stdlib.h>
#include "board.h"
#include "fsl_debug_console.h"
#include "fsl_xbar_driver.h"
void configure_xbar_test_pins(void);
Polling Mode:
#include <stdio.h>
#include <stdlib.h>
#include "board.h"
#include "fsl_debug_console.h"
#include "fsl_xbar_driver.h"
void configure_xbar_test_pins(void);
int main (void)
{
hardware_init();
dbg_uart_init();
printf("XBAR PD TEST: Start...\r\n");
configure_xbar_test_pins();
struct xbar_control_config_t |
This structure keeps the configuration of XBAR control register for one output. Control registers are available only for a few outputs. Not every XBAR module has control registers.
The contents of this structure are internal to the driver and should not be modified by users.
typedef void(* xbar_callback_t)(void *param) |
A prototype for the callback function registered into the XBAR driver.
Defines the XBAR DMA and interrupt configurations.
Enumerator |
---|
kXbarReqDis |
Interrupt and DMA are disabled.
|
kXbarReqIen |
Interrupt enabled, DMA disabled.
|
kXbarReqDen |
DMA enabled, interrupt disabled.
|
This function initializes the XBAR module to a reset state.
- Parameters
-
xbarStatePtr | XBAR input signal. |
- Returns
- An error code or kStatus_XBAR_Success.
void XBAR_DRV_Deinit |
( |
void |
| ) |
|
This function clears all configurations and shuts down the XBAR by disabling interrupt and the clock signal to the modules.
xbar_status_t XBAR_DRV_ConfigSignalConnection |
( |
xbar_input_signal_t |
input, |
|
|
xbar_output_signal_t |
output |
|
) |
| |
This function configures which XBAR input is connected to the selected XBAR output. If more than one XBAR module is available, only the inputs and outputs from the same module can be connected.
Example:
status = XBARA_HAL_ConfigSignalConnection(kXbaraInputVDD, kXbaraOutputCMP0);
switch (status)
{
}
- Parameters
-
input | XBAR input signal. |
output | XBAR output signal. |
- Returns
- An error code or kStatus_XBAR_Success.
This function configures an XBAR control register. The active edge detection and the DMA/IRQ function on the corresponding XBAR output can be set.
Example:
- Parameters
-
outIndex | XBAR output number. |
controlConfigPtr | Pointer to structure that keeps configuration of control register. |
- Returns
- An error code or kStatus_XBAR_Success.
bool XBAR_DRV_GetEdgeDetectionStatus |
( |
uint32_t |
outIndex | ) |
|
This function gets the active edge detect status of the desired XBAR_OUT. If the active edge occurs, the return value is asserted. When the interrupt or the DMA functionality is enabled for the XBAR_OUTx, this field is 1 when the interrupt or DMA request is asserted and 0 when the interrupt or DMA request has been cleared.
- Parameters
-
outIndex | XBAR output number. |
- Returns
- Assertion of edge detection status.
xbar_status_t XBAR_DRV_ClearEdgeDetectionStatus |
( |
uint32_t |
outIndex | ) |
|
This function clears the status flag of edge detection status flag of the XBAR_OUTx.
- Parameters
-
outIndex | XBAR output number. |
- Returns
- An error code or kStatus_XBAR_Success.
This function installs the user-defined callback. When the XBAR interrupt request is configured, the callback is executed inside the ISR.
- Parameters
-
outIndex | XBAR output number. |
userCallback | User-defined callback function. |
callbackParam | The XBAR callback parameter pointer. |
- Returns
- An error code or kStatus_XBAR_Success.
void XBAR_DRV_IRQHandler |
( |
void |
| ) |
|
This function is the driver-defined ISR in the XBAR module. It includes the process for interrupt mode defined by the driver. Currently, it is called inside the system-defined ISR.
XBARA_Type* const g_xbaraBase[] |
const IRQn_Type g_xbarIrqId[] |
xbar_callback_t xbar_state_t::userCallbackFunct[FSL_FEATURE_XBARA_INTERRUPT_COUNT] |
void* xbar_state_t::xbarCallbackParam[FSL_FEATURE_XBARA_INTERRUPT_COUNT] |