Kinetis SDK v.1.3 API Reference Manual
Rev. 0
Freescale Semiconductor, Inc.
|
The section describes the programming interface of the AOI Peripheral driver.
The AOI peripheral driver configures the AOI (AND/OR/INVERT) module and handles the initialization and configuration of the AOI module.
To initialize the AOI module, call the AOI_DRV_Init() function. After initialization, the AOI module is set to a reset state.
The AOI module provides a universal boolean function generator using a four-term sum of products expression with each product term containing true or complement values of the four selected event inputs (A, B, C, D). The AOI is a highly programmable module for creating combinational boolean outputs for use as hardware triggers. Each selected input term in each product term can be configured to produce a logical 0 or 1 or pass the true or complement of the selected event input. To configure the selected AOI module event, call the API of the AOI_DRV_SetEventLogic() function. To configure only one product term logic, call the AOI_DRV_SetProductTermLogic() function. The AOI module does not support any special modes of operation.
If you want to stop the AOI module, call the void AOI_DRV_Deinit() function. This clears the AOI module configuration and disables the clock gate.
This is an example to initialize and configure the AOI driver for a possible use case. Because the AOI module function is directly connected with an XBAR (Inter-peripheral crossbar) module, other peripheral (PIT, CMP and XBAR) drivers are used to show full functionality of AOI module.
/****************************************************************************** Definition
cmp_state_t demoCmpStateStruct;
void XBAR_PrintMsg(void);
int main(void) { cmp_comparator_config_t demoCmpUserConfigStruct; cmp_sample_filter_config_t demoCmpSampleFilterConfigStruct; cmp_dac_config_t demoCmpDacConfigStruct;
pit_user_config_t demoPitInitStruct;
aoi_event_config_t demoEventLogicStruct;
xbar_control_config_t demoControlConfigStruct; xbar_state_t xbarStatePtr;
hardware_init(); dbg_uart_init();
printf("XBAR and AOI Demo: Start...\r\n");
/* Init the CMP0 comparator. CMP_DRV_StructInitUserConfigDefault(&demoCmpUserConfigStruct, kCmpInputChn1, kCmpInputChnDac); demoCmpUserConfigStruct.risingIntEnable = false; demoCmpUserConfigStruct.fallingIntEnable = false; CMP_DRV_Init(DEMO_CMP0_INSTANCE, &demoCmpUserConfigStruct, &demoCmpStateStruct);
/* Configure the internal DAC when in used. demoCmpDacConfigStruct.dacValue = 32U; /* 0U - 63U demoCmpDacConfigStruct.refVoltSrcMode = kCmpDacRefVoltSrcOf2; CMP_DRV_ConfigDacChn(DEMO_CMP0_INSTANCE, &demoCmpDacConfigStruct);
/* Configure the CMP Sample/Filter Mode. demoCmpSampleFilterConfigStruct.workMode = kCmpContinuousMode; CMP_DRV_ConfigSampleFilter(DEMO_CMP0_INSTANCE, &demoCmpSampleFilterConfigStruct);
/* Init pit module and disable run in debug PIT_DRV_Init(DEMO_PIT0_INSTANCE, false);
/* Initialize PIT timer 0 demoPitInitStruct.isInterruptEnabled = true, demoPitInitStruct.isTimerChained = false, demoPitInitStruct.periodUs = 0; PIT_DRV_InitChannel(DEMO_PIT0_INSTANCE, 0, &demoPitInitStruct);
/* Set timer0 period and start it. PIT_DRV_SetTimerPeriodByUs(DEMO_PIT0_INSTANCE, 0, 500000);
/* Init the AOI module AOI_DRV_Init(AOI_IDX);
/* Configure the AOI event demoEventLogicStruct.PT0AC = kAoiConfigInvInputSignal; /* CMP0 output demoEventLogicStruct.PT0BC = kAoiConfigInputSignal; /* PIT0 output demoEventLogicStruct.PT0CC = kAoiConfigLogicOne; demoEventLogicStruct.PT0DC = kAoiConfigLogicOne;
demoEventLogicStruct.PT1AC = kAoiConfigLogicZero; demoEventLogicStruct.PT1BC = kAoiConfigLogicOne; demoEventLogicStruct.PT1CC = kAoiConfigLogicOne; demoEventLogicStruct.PT1DC = kAoiConfigLogicOne;
demoEventLogicStruct.PT2AC = kAoiConfigLogicZero; demoEventLogicStruct.PT2BC = kAoiConfigLogicOne; demoEventLogicStruct.PT2CC = kAoiConfigLogicOne; demoEventLogicStruct.PT2DC = kAoiConfigLogicOne;
demoEventLogicStruct.PT3AC = kAoiConfigLogicZero; demoEventLogicStruct.PT3BC = kAoiConfigLogicOne; demoEventLogicStruct.PT3CC = kAoiConfigLogicOne; demoEventLogicStruct.PT3DC = kAoiConfigLogicOne; AOI_DRV_ConfigEventLogic(AOI_IDX, kAoiEvent0, &demoEventLogicStruct);
/* Init the XBAR module XBAR_DRV_Init(&xbarStatePtr);
/* Configure the XBAR interrupt demoControlConfigStruct.activeEdge = kXbarEdgeRising; demoControlConfigStruct.intDmaReq = kXbarReqIen; XBAR_DRV_ConfigOutControl(0, &demoControlConfigStruct);
/* Configure the XBAR signal connections XBAR_DRV_ConfigSignalConnection(kXbarbInputCMP0_output, kXbarbOutputAOI_IN0); XBAR_DRV_ConfigSignalConnection(kXbarbInputPIT_trigger_0, kXbarbOutputAOI_IN1); XBAR_DRV_ConfigSignalConnection(kXbaraInputAND_OR_INVERT_0, kXbaraOutputDMAMUX18);
/* Start the CMP0 function. CMP_DRV_Start(DEMO_CMP0_INSTANCE);
/* Start the PIT. PIT_DRV_StartTimer(DEMO_PIT0_INSTANCE, 0);
while (1) {
} }
Data Structures | |
struct | aoi_product_term_config_t |
AOI product term configuration structure. More... | |
struct | aoi_event_config_t |
AOI event configuration structure. More... | |
Functions | |
aoi_status_t | AOI_DRV_Init (uint32_t instance) |
Initializes AOI module. More... | |
aoi_status_t | AOI_DRV_Deinit (uint32_t instance) |
De-initializes the AOI module. More... | |
aoi_status_t | AOI_DRV_ConfigEventLogic (uint32_t instance, aoi_event_index_t event, const aoi_event_config_t *eventConfigPtr) |
Configures an AOI event. More... | |
aoi_status_t | AOI_DRV_ConfigProductTermLogic (uint32_t instance, aoi_event_index_t event, aoi_product_term_t productTerm, const aoi_product_term_config_t *productTermConfigPtr) |
Configures an AOI module product term in a specific event. More... | |
Variables | |
AOI_Type *const | g_aoiBase [] |
Table of base addresses for AOI instances. More... | |
struct aoi_product_term_config_t |
Data Fields | |
aoi_input_config_t | PTAC |
PTx_AC configuration. More... | |
aoi_input_config_t | PTBC |
PTx_BC configuration. More... | |
aoi_input_config_t | PTCC |
PTx_CC configuration. More... | |
aoi_input_config_t | PTDC |
PTx_DC configuration. More... | |
aoi_input_config_t aoi_product_term_config_t::PTAC |
aoi_input_config_t aoi_product_term_config_t::PTBC |
aoi_input_config_t aoi_product_term_config_t::PTCC |
aoi_input_config_t aoi_product_term_config_t::PTDC |
struct aoi_event_config_t |
Defines structure AoiEventConfig and use the AOI_DRV_ConfigEventLogic() function to make whole event configuration.
Data Fields | |
aoi_input_config_t | PT1DC |
PT1_DC configuration. More... | |
aoi_input_config_t | PT1CC |
PT1_CC configuration. More... | |
aoi_input_config_t | PT1BC |
PT1_BC configuration. More... | |
aoi_input_config_t | PT1AC |
PT1_AC configuration. More... | |
aoi_input_config_t | PT0DC |
PT0_DC configuration. More... | |
aoi_input_config_t | PT0CC |
PT0_CC configuration. More... | |
aoi_input_config_t | PT0BC |
PT0_BC configuration. More... | |
aoi_input_config_t | PT0AC |
PT0_AC configuration. More... | |
aoi_input_config_t | PT3DC |
PT3_DC configuration. More... | |
aoi_input_config_t | PT3CC |
PT3_CC configuration. More... | |
aoi_input_config_t | PT3BC |
PT3_BC configuration. More... | |
aoi_input_config_t | PT3AC |
PT3_AC configuration. More... | |
aoi_input_config_t | PT2DC |
PT2_DC configuration. More... | |
aoi_input_config_t | PT2CC |
PT2_CC configuration. More... | |
aoi_input_config_t | PT2BC |
PT2_BC configuration. More... | |
aoi_input_config_t | PT2AC |
PT2_AC configuration. More... | |
aoi_input_config_t aoi_event_config_t::PT1DC |
aoi_input_config_t aoi_event_config_t::PT1CC |
aoi_input_config_t aoi_event_config_t::PT1BC |
aoi_input_config_t aoi_event_config_t::PT1AC |
aoi_input_config_t aoi_event_config_t::PT0DC |
aoi_input_config_t aoi_event_config_t::PT0CC |
aoi_input_config_t aoi_event_config_t::PT0BC |
aoi_input_config_t aoi_event_config_t::PT0AC |
aoi_input_config_t aoi_event_config_t::PT3DC |
aoi_input_config_t aoi_event_config_t::PT3CC |
aoi_input_config_t aoi_event_config_t::PT3BC |
aoi_input_config_t aoi_event_config_t::PT3AC |
aoi_input_config_t aoi_event_config_t::PT2DC |
aoi_input_config_t aoi_event_config_t::PT2CC |
aoi_input_config_t aoi_event_config_t::PT2BC |
aoi_input_config_t aoi_event_config_t::PT2AC |
aoi_status_t AOI_DRV_Init | ( | uint32_t | instance | ) |
This function initializes AOI module. It configures all the AOI module inputs of all events to the reset state (kAoiLogicZero).
This is an example to initialize the AOI module:
instance | The instance number of the AOI peripheral |
aoi_status_t AOI_DRV_Deinit | ( | uint32_t | instance | ) |
This function clears all configurations and shuts down the AOI module clock to reduce the power consumption.
instance | The instance number of the AOI peripheral |
aoi_status_t AOI_DRV_ConfigEventLogic | ( | uint32_t | instance, |
aoi_event_index_t | event, | ||
const aoi_event_config_t * | eventConfigPtr | ||
) |
This function configures an AOI event according to the aoiEventConfig structure. This function configures all inputs (A, B, C, and D) of all product terms (0, 1, 2, and 3) of a desired event. This is an example to set up the AOI Event structure:
instance | The instance number of the AOI peripheral |
event | Event which will be configured of type aoi_event_index_t. |
eventConfigPtr | Pointer to type aoi_event_config_t structure. The user is responsible to fill out the members of this structure and pass the pointer to this function. |
aoi_status_t AOI_DRV_ConfigProductTermLogic | ( | uint32_t | instance, |
aoi_event_index_t | event, | ||
aoi_product_term_t | productTerm, | ||
const aoi_product_term_config_t * | productTermConfigPtr | ||
) |
This function configures an AOI module product terms for a specific event. The user has to select the event and the product term which is configured and fill the AoiProductTermConfig configuration structure.
Example:
instance | The instance number of the AOI peripheral |
event | Event which will be configured of type aoi_event_index_t. |
productTerm | Product term which will be configured of type aoi_product_term_t. |
productTermConfigPtr | Pointer to type aoi_product_term_config_t structure. The user is responsible to fill out the members of this structure and pass the pointer to this function. |
AOI_Type* const g_aoiBase[] |