MCUXpresso SDK API Reference Manual  Rev. 0
NXP Semiconductors
 All Data Structures Functions Variables Typedefs Enumerations Enumerator Groups Pages
FlexIO Camera Driver

Overview

The MCUXpresso SDK provides a driver for the camera function using Flexible I/O.

FlexIO Camera driver includes functional APIs and eDMA transactional APIs. Functional APIs target low level APIs. Users can use functional APIs for FlexIO Camera initialization/configuration/operation purpose. Using the functional API requires knowledge of the FlexIO Camera peripheral and how to organize functional APIs to meet the requirements of the application. All functional API use the FLEXIO_CAMERA_Type * as the first parameter. FlexIO Camera functional operation groups provide the functional APIs set.

eDMA transactional APIs target high-level APIs. Users can use the transactional API to enable the peripheral quickly and can also use in the application if the code size and performance of transactional APIs satisfy requirements. If the code size and performance are critical requirements, see the transactional API implementation and write custom code. All transactional APIs use the flexio_camera_edma_handle_t as the second parameter. Users need to initialize the handle by calling the FLEXIO_CAMERA_TransferCreateHandleEDMA() API.

eDMA transactional APIs support asynchronous receive. This means that the functions FLEXIO_CAMERA_TransferReceiveEDMA() set up an interrupt for data receive. When the receive is complete, the upper layer is notified through a callback function with the status kStatus_FLEXIO_CAMERA_RxIdle.

Typical use case

FlexIO Camera Receive using eDMA method

volatile uint32_t isEDMAGetOnePictureFinish = false;
edma_handle_t g_edmaHandle;
flexio_camera_edma_handle_t g_cameraEdmaHandle;
edma_config_t edmaConfig;
FLEXIO_CAMERA_Type g_FlexioCameraDevice = {.flexioBase = FLEXIO0,
.datPinStartIdx = 24U, /* fxio_pin 24 -31 are used. */
.pclkPinIdx = 1U, /* fxio_pin 1 is used as pclk pin. */
.hrefPinIdx = 18U, /* flexio_pin 18 is used as href pin. */
.shifterStartIdx = 0U, /* Shifter 0 = 7 are used. */
.shifterCount = 8U,
.timerIdx = 0U};
/* Configure DMAMUX */
DMAMUX_Init(DMAMUX0);
/* Configure DMA */
EDMA_GetDefaultConfig(&edmaConfig);
EDMA_Init(DMA0, &edmaConfig);
DMAMUX_SetSource(DMAMUX0, DMA_CHN_FLEXIO_TO_FRAMEBUFF, (g_FlexioCameraDevice.shifterStartIdx + 1U));
DMAMUX_EnableChannel(DMAMUX0, DMA_CHN_FLEXIO_TO_FRAMEBUFF);
EDMA_CreateHandle(&g_edmaHandle, DMA0, DMA_CHN_FLEXIO_TO_FRAMEBUFF);
FLEXIO_CAMERA_Init(&g_FlexioCameraDevice, &cameraConfig);
/* Clear all the flag. */
FLEXIO_CAMERA_ClearStatusFlags(&g_FlexioCameraDevice,
FLEXIO_CAMERA_TransferCreateHandleEDMA(&g_FlexioCameraDevice, &g_cameraEdmaHandle, FLEXIO_CAMERA_UserCallback, NULL,
&g_edmaHandle);
cameraTransfer.dataAddress = (uint32_t)u16CameraFrameBuffer;
cameraTransfer.dataNum = sizeof(u16CameraFrameBuffer);
FLEXIO_CAMERA_TransferReceiveEDMA(&g_FlexioCameraDevice, &g_cameraEdmaHandle, &cameraTransfer);
while (!(isEDMAGetOnePictureFinish))
{
;
}
/* A callback function is also needed */
void FLEXIO_CAMERA_UserCallback(FLEXIO_CAMERA_Type *base,
flexio_camera_edma_handle_t *handle,
status_t status,
void *userData)
{
userData = userData;
/* eDMA Transfer finished */
{
isEDMAGetOnePictureFinish = true;
}
}

Modules

 FlexIO eDMA Camera Driver
 

Data Structures

struct  FLEXIO_CAMERA_Type
 Define structure of configuring the FlexIO Camera device. More...
 
struct  flexio_camera_config_t
 Define FlexIO Camera user configuration structure. More...
 
struct  flexio_camera_transfer_t
 Define FlexIO Camera transfer structure. More...
 

Macros

#define FLEXIO_CAMERA_PARALLEL_DATA_WIDTH   (8U)
 Define the Camera CPI interface is constantly 8-bit width. More...
 

Enumerations

enum  {
  kStatus_FLEXIO_CAMERA_RxBusy = MAKE_STATUS(kStatusGroup_FLEXIO_CAMERA, 0),
  kStatus_FLEXIO_CAMERA_RxIdle = MAKE_STATUS(kStatusGroup_FLEXIO_CAMERA, 1)
}
 Error codes for the Camera driver. More...
 
enum  _flexio_camera_status_flags {
  kFLEXIO_CAMERA_RxDataRegFullFlag = 0x1U,
  kFLEXIO_CAMERA_RxErrorFlag = 0x2U
}
 Define FlexIO Camera status mask. More...
 

Driver version

#define FSL_FLEXIO_CAMERA_DRIVER_VERSION   (MAKE_VERSION(2, 1, 2))
 FlexIO Camera driver version 2.1.2. More...
 

Initialization and configuration

void FLEXIO_CAMERA_Init (FLEXIO_CAMERA_Type *base, const flexio_camera_config_t *config)
 Ungates the FlexIO clock, resets the FlexIO module, and configures the FlexIO Camera. More...
 
void FLEXIO_CAMERA_Deinit (FLEXIO_CAMERA_Type *base)
 Resets the FLEXIO_CAMERA shifer and timer config. More...
 
void FLEXIO_CAMERA_GetDefaultConfig (flexio_camera_config_t *config)
 Gets the default configuration to configure the FlexIO Camera. More...
 
static void FLEXIO_CAMERA_Enable (FLEXIO_CAMERA_Type *base, bool enable)
 Enables/disables the FlexIO Camera module operation. More...
 

Status

uint32_t FLEXIO_CAMERA_GetStatusFlags (FLEXIO_CAMERA_Type *base)
 Gets the FlexIO Camera status flags. More...
 
void FLEXIO_CAMERA_ClearStatusFlags (FLEXIO_CAMERA_Type *base, uint32_t mask)
 Clears the receive buffer full flag manually. More...
 

Interrupts

void FLEXIO_CAMERA_EnableInterrupt (FLEXIO_CAMERA_Type *base)
 Switches on the interrupt for receive buffer full event. More...
 
void FLEXIO_CAMERA_DisableInterrupt (FLEXIO_CAMERA_Type *base)
 Switches off the interrupt for receive buffer full event. More...
 

DMA support

static void FLEXIO_CAMERA_EnableRxDMA (FLEXIO_CAMERA_Type *base, bool enable)
 Enables/disables the FlexIO Camera receive DMA. More...
 
static uint32_t FLEXIO_CAMERA_GetRxBufferAddress (FLEXIO_CAMERA_Type *base)
 Gets the data from the receive buffer. More...
 

Data Structure Documentation

struct FLEXIO_CAMERA_Type

Data Fields

FLEXIO_Type * flexioBase
 FlexIO module base address. More...
 
uint32_t datPinStartIdx
 First data pin (D0) index for flexio_camera. More...
 
uint32_t pclkPinIdx
 Pixel clock pin (PCLK) index for flexio_camera. More...
 
uint32_t hrefPinIdx
 Horizontal sync pin (HREF) index for flexio_camera. More...
 
uint32_t shifterStartIdx
 First shifter index used for flexio_camera data FIFO. More...
 
uint32_t shifterCount
 The count of shifters that are used as flexio_camera data FIFO. More...
 
uint32_t timerIdx
 Timer index used for flexio_camera in FlexIO. More...
 

Field Documentation

FLEXIO_Type* FLEXIO_CAMERA_Type::flexioBase
uint32_t FLEXIO_CAMERA_Type::datPinStartIdx

Then the successive following FLEXIO_CAMERA_DATA_WIDTH-1 pins are used as D1-D7.

uint32_t FLEXIO_CAMERA_Type::pclkPinIdx
uint32_t FLEXIO_CAMERA_Type::hrefPinIdx
uint32_t FLEXIO_CAMERA_Type::shifterStartIdx
uint32_t FLEXIO_CAMERA_Type::shifterCount
uint32_t FLEXIO_CAMERA_Type::timerIdx
struct flexio_camera_config_t

Data Fields

bool enablecamera
 Enable/disable FlexIO Camera TX & RX. More...
 
bool enableInDoze
 Enable/disable FlexIO operation in doze mode.
 
bool enableInDebug
 Enable/disable FlexIO operation in debug mode.
 
bool enableFastAccess
 
Enable/disable fast access to FlexIO registers,

fast access requires the FlexIO clock to be at least twice the frequency of the bus clock. More...

 

Field Documentation

bool flexio_camera_config_t::enablecamera
bool flexio_camera_config_t::enableFastAccess
struct flexio_camera_transfer_t

Data Fields

uint32_t dataAddress
 Transfer buffer.
 
uint32_t dataNum
 Transfer num.
 

Macro Definition Documentation

#define FSL_FLEXIO_CAMERA_DRIVER_VERSION   (MAKE_VERSION(2, 1, 2))
#define FLEXIO_CAMERA_PARALLEL_DATA_WIDTH   (8U)

Enumeration Type Documentation

anonymous enum
Enumerator
kStatus_FLEXIO_CAMERA_RxBusy 

Receiver is busy.

kStatus_FLEXIO_CAMERA_RxIdle 

Camera receiver is idle.

Enumerator
kFLEXIO_CAMERA_RxDataRegFullFlag 

Receive buffer full flag.

kFLEXIO_CAMERA_RxErrorFlag 

Receive buffer error flag.

Function Documentation

void FLEXIO_CAMERA_Init ( FLEXIO_CAMERA_Type base,
const flexio_camera_config_t config 
)
Parameters
basePointer to FLEXIO_CAMERA_Type structure
configPointer to flexio_camera_config_t structure
void FLEXIO_CAMERA_Deinit ( FLEXIO_CAMERA_Type base)
Note
After calling this API, call FLEXO_CAMERA_Init to use the FlexIO Camera module.
Parameters
basePointer to FLEXIO_CAMERA_Type structure
void FLEXIO_CAMERA_GetDefaultConfig ( flexio_camera_config_t config)

The configuration can be used directly for calling the FLEXIO_CAMERA_Init(). Example:

Parameters
configPointer to the flexio_camera_config_t structure
static void FLEXIO_CAMERA_Enable ( FLEXIO_CAMERA_Type base,
bool  enable 
)
inlinestatic
Parameters
basePointer to the FLEXIO_CAMERA_Type
enableTrue to enable, false does not have any effect.
uint32_t FLEXIO_CAMERA_GetStatusFlags ( FLEXIO_CAMERA_Type base)
Parameters
basePointer to FLEXIO_CAMERA_Type structure
Returns
FlexIO shifter status flags
  • FLEXIO_SHIFTSTAT_SSF_MASK
  • 0
void FLEXIO_CAMERA_ClearStatusFlags ( FLEXIO_CAMERA_Type base,
uint32_t  mask 
)
Parameters
basePointer to the device.
maskstatus flag The parameter can be any combination of the following values:
  • kFLEXIO_CAMERA_RxDataRegFullFlag
  • kFLEXIO_CAMERA_RxErrorFlag
void FLEXIO_CAMERA_EnableInterrupt ( FLEXIO_CAMERA_Type base)
Parameters
basePointer to the device.
void FLEXIO_CAMERA_DisableInterrupt ( FLEXIO_CAMERA_Type base)
Parameters
basePointer to the device.
static void FLEXIO_CAMERA_EnableRxDMA ( FLEXIO_CAMERA_Type base,
bool  enable 
)
inlinestatic
Parameters
basePointer to FLEXIO_CAMERA_Type structure
enableTrue to enable, false to disable.

The FlexIO Camera mode can't work without the DMA or eDMA support, Usually, it needs at least two DMA or eDMA channels, one for transferring data from Camera, such as 0V7670 to FlexIO buffer, another is for transferring data from FlexIO buffer to LCD.

static uint32_t FLEXIO_CAMERA_GetRxBufferAddress ( FLEXIO_CAMERA_Type base)
inlinestatic
Parameters
basePointer to the device.
Returns
data Pointer to the buffer that keeps the data with count of base->shifterCount .