AM273x MCU+ SDK  08.06.00
CSIRX

CSIRX driver provides API to capture raw data frames from the CSIRX interface.

Features Supported

  • APIs to setup complexio, dphy, common CSIRX settings, context specific CSIRX settings
  • APIs to register callback for different CISRX events including frame complete and "every N lines" interrupts
  • APIs to setup CSIRX in debug mode to generate test data without connecting a sensor

SysConfig Features

Note
It is strongly recommend to use SysConfig where it is available instead of using direct SW API calls. This will help simplify the SW application and also catch common mistakes early in the development cycle.
  • Comprehensive CSIRX configuration for complexio, dphy, common config and context specifc config via SysConfig
  • SysConfig generates the CSIRX open related sequence calls
  • User can use SysConfig to setup CSIRX and then they need to call CSIRX APIs mainly to capture frames and recycle buffers.

Features NOT Supported

NA

Important Usage Guidelines

NA

Example Usage

Include the below file to access the APIs

#include <drivers/csirx.h>

Do below to open and configure CSIRX, here we show the usage assuming SysConfig is used. If you dont use SysConfig, then refer the SysConfig generated code form the CSIRX example in the SDK for a sample recommended API sequence call.

/* make sure to include the below file to get access to all CSIRX configuration variables and functions, this file is generate via SysConfig */
#include "ti_drivers_open_close.h"
/* see the file, generated by SysConfig, "ti_drivers_open_close.c", to see the exact CSIRX APIs calls and configuration values that are generated from SysConfig */
/* use below to open all drivers configured via SysConfig including CSIRX */
Drivers_open();
/* === OR ===
/*
* If the "Enable Instance Open in Drivers_open" in SysConfig is unchecked, then call below API to setup the CSIRX.
* Typically this is needed if the CSIRX setup should be done after sensor init or at some specific point in your application
*/
status = Drivers_csirxInstanceOpen(
CONFIG_CSIRX0,
CONFIG_CSIRX0_NUM_CONTEXT,
gConfigCsirx0ContextConfig
);
DebugP_assert(status==SystemP_SUCCESS);

Given below is a sample CSIRX buffer definition, which we will use to capture data into. Double buffers or ping and pong buffers are used, so that CSIRX can continue capture to pong buffer while the SW processes the ping buffer.

/* max buffer size for ping and ping */
#define MY_CSIRX__FRAME_LINES_MAX (4U)
#define MY_CSIRX__BYTES_PER_LINE_MAX (128U)
/* ping pong buffer, MUST be placed in a memory accessible to both CPU and CSIRX HW */
uint8_t gMyCsirxBuf[2][MY_CSIRX__FRAME_LINES_MAX*MY_CSIRX__BYTES_PER_LINE_MAX] __attribute__((aligned(64), section(".bss.dss_l3")));

Given below is a sample ISR to handle CSIRX interrupts,

/* flag to check if ISR has occured, you can also use semaphore's instead of global variables to block on a interrupt instead */
bool gMyCsirxContextIntrDone = false;
uint8_t gMyCsirxContextId = 0; /* the context that is used to receive CSIRX frames */
/* interrupt callback, we simply count the interrupts in the callback */
/* this ISR is specified via SysConfig */
void my_csirx_commonCallback(CSIRX_Handle handle, void *arg, struct CSIRX_CommonIntr_s *irq)
{
if(irq->isContextIntr[gMyCsirxContextId])
{
CSIRX_ContextIntr contextIntrStatus;
CSIRX_contextGetPendingIntr(handle, gMyCsirxContextId, &contextIntrStatus);
CSIRX_contextClearAllIntr(handle, gMyCsirxContextId);
if(contextIntrStatus.isFrameEndCodeDetect)
{
gMyCsirxContextIntrDone = true;
}
}
}

Finally, given below is how we enable data capture, wait for frames and process the data from the ping and pong buffers.

uint32_t bufId = 0;
/* After the Drivers_open or Drivers_csirxInstanceOpen, CSIRX is setup and configured, and the interface is enabled, however the context is not enabled */
/* Enable the required context(s) by doing below, here we also setup the data output addresses before enabling the CSIRX context */
CSIRX_contextSetPingPongAddress(gCsirxHandle[CONFIG_CSIRX0], gMyCsirxContextId, (uint32_t)gMyCsirxBuf[0], (uint32_t)gMyCsirxBuf[1] );
CSIRX_contextEnable(gCsirxHandle[CONFIG_CSIRX0], gMyCsirxContextId);
while(1)
{
/* wait for one frame to be captured */
while( gMyCsirxContextIntrDone != true )
{
}
gMyCsirxContextIntrDone = false;
/* process data in buffer gMyCsirxBuf[bufId] */
bufId = bufId ^ 1; /* switch between 0 and 1, i.e ping and pong */
}
/* when done disable CSIRX context */
CSIRX_contextDisable(gCsirxHandle[CONFIG_CSIRX0], gMyCsirxContextId);

API

APIs for CSIRX

CSIRX_contextDisable
int32_t CSIRX_contextDisable(CSIRX_Handle handle, uint8_t contextId)
Disable context.
CSIRX_ContextIntr
Context interrupts.
Definition: csirx/v0/csirx.h:969
CSIRX_contextClearAllIntr
int32_t CSIRX_contextClearAllIntr(CSIRX_Handle handle, uint8_t contextId)
Clear all pending context interrupts.
__attribute__
union HsmVer_t_ __attribute__((packed)) HsmVer_t
type for reading HSMRt version.
CSIRX_contextGetPendingIntr
int32_t CSIRX_contextGetPendingIntr(CSIRX_Handle handle, uint8_t contextId, CSIRX_ContextIntr *intrStatus)
Get all pending context interrupts.
CSIRX_contextEnable
int32_t CSIRX_contextEnable(CSIRX_Handle handle, uint8_t contextId)
Enable context.
CSIRX_ContextIntr::isFrameEndCodeDetect
bool isFrameEndCodeDetect
If true, triggers when Frame End sync Code is detected.
Definition: csirx/v0/csirx.h:996
CSIRX_contextSetPingPongAddress
int32_t CSIRX_contextSetPingPongAddress(CSIRX_Handle handle, uint8_t contextId, uint32_t pingAddress, uint32_t pongAddress)
Set context ping and pong address.
csirx.h
CSIRX_Handle
struct CSIRX_Config_s * CSIRX_Handle
CSIRX driver handle.
Definition: csirx/v0/csirx.h:494