Kinetis SDK v.1.3 API Reference Manual  Rev. 0
Freescale Semiconductor, Inc.
 All Data Structures Functions Variables Typedefs Enumerations Enumerator Groups Pages

Overview

The section describes the programming interface of the AOI Peripheral driver.

Overview

The AOI peripheral driver configures the AOI (AND/OR/INVERT) module and handles the initialization and configuration of the AOI module.

Initialization

To initialize the AOI module, call the AOI_DRV_Init() function. After initialization, the AOI module is set to a reset state.

// Initialize AOI module.
AOI_DRV_Init(instance);

Event output configuration

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.

Call diagram

  1. Call the AOI_DRV_Init() function to initialize AOI to a known state.
  2. Optionally, call the AOI_DRV_SetEventLogic() function to configure the Boolean evaluation in all product terms in one event. Use the configuration structure, aoi_event_config_t and number of the event, when calling this function.
  3. Optionally, call the AOI_DRV_SetProductTermLogic() function to configure the Boolean evaluation associated with all inputs in one product and in one event. Use the configuration structure, aoi_product_term_config_t and the product term and number of the event when calling this function.
  4. Finally, the AOI works properly.

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.

/* aoi_test.c
#include <stdint.h>
#include <stdbool.h>
#include <stdio.h>
#include "board.h"
#include "fsl_cmp_driver.h"
#include "fsl_device_registers.h"
#include "fsl_aoi_driver.h"
#include "fsl_pit_driver.h"
#include "fsl_xbar_driver.h"
#define DEMO_CMP0_INSTANCE (0U)
#define DEMO_PIT0_INSTANCE (0U)

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

Data Structure Documentation

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

Field Documentation

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

Field Documentation

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

Function Documentation

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:

status = AOI_DRV_Init();
switch (status)
{
//...
}
Parameters
instanceThe instance number of the AOI peripheral
Returns
kStatus_AOI_Success indicating successful initialization
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.

Parameters
instanceThe instance number of the AOI peripheral
Returns
kStatus_AOI_Success indicating successful de-initialization
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:

aoi_event_config_t aoiEventConfig;
aoiEventConfig.PT0AC = kAoiConfigInputSignal;
aoiEventConfig.PT0BC = kAoiConfigLogicZero;
aoiEventConfig.PT0CC = kAoiConfigLogicZero;
aoiEventConfig.PT0DC = kAoiConfigLogicZero;
aoiEventConfig.PT1BC = kAoiConfigLogicZero;
aoiEventConfig.PT1CC = kAoiConfigLogicZero;
aoiEventConfig.PT1DC = kAoiConfigInputSignal;
aoiEventConfig.PT2AC = kAoiConfigInputSignal;
aoiEventConfig.PT2BC = kAoiConfigInputSignal;
aoiEventConfig.PT2CC = kAoiConfigInputSignal;
aoiEventConfig.PT2DC = kAoiConfigLogicOne;
aoiEventConfig.PT3AC = kAoiConfigLogicOne;
aoiEventConfig.PT3BC = kAoiConfigLogicOne;
aoiEventConfig.PT3CC = kAoiConfigLogicOne;
aoiEventConfig.PT3DC = kAoiConfigLogicOne;
aoi_status_t status;
// In the function call below, the value of "2" indicates event #2 is being used.
status = AOI_DRV_ConfigEventLogic(0, 2, &aoiEventConfig);
switch (status)
{
//...
}
Parameters
instanceThe instance number of the AOI peripheral
eventEvent which will be configured of type aoi_event_index_t.
eventConfigPtrPointer 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.
Returns
An error code or kStatus_AOI_Success.
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:

aoi_product_term_config_t productTermConfigStruct;
aoi_status_t status;
productTermConfigStruct.PTAC = kAoiConfigLogicZero;
productTermConfigStruct.PTBC = kAoiConfigInputSignal;
productTermConfigStruct.PTCC = kAoiConfigInvInputSignal;
productTermConfigStruct.PTDC = kAoiConfigLogicOne;
// Configure product term 1 of event 3
status = AOI_DRV_ConfigProductTermLogic(0, 3, kAoiTerm1, &productTermConfigStruct);
switch (status)
{
//...
}
Parameters
instanceThe instance number of the AOI peripheral
eventEvent which will be configured of type aoi_event_index_t.
productTermProduct term which will be configured of type aoi_product_term_t.
productTermConfigPtrPointer 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.
Returns
An error code or kStatus_AOI_Success.

Variable Documentation

AOI_Type* const g_aoiBase[]