RA Flexible Software Package Documentation  Release v5.6.0

 
Parallel Data Capture (r_pdc)

Functions

fsp_err_t R_PDC_Open (capture_ctrl_t *const p_ctrl, capture_cfg_t const *const p_cfg)
 Powers on PDC, handles required initialization described in the hardware manual. More...
 
fsp_err_t R_PDC_Close (capture_ctrl_t *const p_ctrl)
 Stops and closes the transfer interface, disables and powers off the PDC, clears internal driver data and disables interrupts. More...
 
fsp_err_t R_PDC_CaptureStart (capture_ctrl_t *const p_ctrl, uint8_t *const p_buffer)
 Starts a capture. Enables interrupts. More...
 
fsp_err_t R_PDC_StatusGet (capture_ctrl_t *const p_ctrl, capture_status_t *p_status)
 
fsp_err_t R_PDC_CallbackSet (capture_ctrl_t *const p_ctrl, void(*p_callback)(capture_callback_args_t *), void const *const p_context, capture_callback_args_t *const p_callback_memory)
 

Detailed Description

Driver for the PDC peripheral on RA MCUs. This module implements the CAPTURE Interface.

Overview

The PDC peripheral supports interfacing with external cameras by accepting timing and data signals in order to capture incoming data. A callback is invoked every time a frame of data is accepted.

Features

Configuration

Build Time Configurations for r_pdc

The following build time configurations are defined in fsp_cfg/r_pdc_cfg.h:

ConfigurationOptionsDefaultDescription
Parameter Checking
  • Default (BSP)
  • Enabled
  • Disabled
Default (BSP) If selected code for parameter checking is included in the build.

Configurations for Graphics > Parallel Data Capture (r_pdc)

This module can be added to the Stacks tab via New Stack > Graphics > Parallel Data Capture (r_pdc).

ConfigurationOptionsDefaultDescription
General
NameName must be a valid C symbolg_pdc0 Module name.
Input
Input > Signal polarity
HSYNC
  • High
  • Low
High Specify the active polarity of the HSYNC signal.
VSYNC
  • High
  • Low
High Specify the active polarity of the VSYNC signal.
Input > Capture Specifications
Number of pixels to capture horizontallyValue must be an integer greater than 0640 Specify the number of horizontal pixels to capture.
Number of lines to capture verticallyValue must be an integer greater than 0480 Specify the number of vertical pixels to capture.
Horizontal pixel to start capture fromValue must be an integer0 Specify the horizontal pixel to start capturing image data from. Allows an image smaller than the native resolution of a camera to be captured.
Line to start capture fromValue must be an integer0 Specify the vertical line to start capturing image data from. Allows an image smaller than the native resolution of a camera to be captured.
Bytes per pixelValue must be an integer greater than 02 Specify the number of bytes per pixel of the captured image data.
Clock divider
  • CLK/2
  • CLK/4
  • CLK/6
  • CLK/8
  • CLK/10
  • CLK/12
  • CLK/14
  • CLK/16
CLK/2 Specify the clock divider for clock frequency of the clock input PCKO to the PDC peripheral.
Endianess
  • Little
  • Big
Little Specify the endianness of the captured image data.
Output
Output > Buffer
Number of image buffersValue must be an integer greater than 01 Specify the number of buffers to create.
Interrupts
CallbackName must be a valid C symbolg_pdc_user_callback A user callback function must be provided. This callback is invoked for every successful frame capture and any error conditions
PDC Interrupt PriorityMCU Specific OptionsSelect the PDC interrupt priority.
DTC Interrupt PriorityMCU Specific OptionsSelect the DTC interrupt priority.

Clock Configuration

The PDC peripheral module uses the PCLKB as its clock source. The maximum clock to the camera module is PCLKB / 2.

Pin Configuration

The PCKO pin is a clock output and should be connected to the clock input of the camera. The PIXCLK pin is a clock input and should be connected to the output pixel clock of the camera. Likewise, the HSYNC and VSYNC pins must be connected to the horizontal and vertical sync signals of the camera, respectively. The PIXD0-PIXD7 pins are the 8-bit data bus input and should be connected to the relevant output pins of the camera.

Note
Camera control and serial communication pins must be configured separately and are not controlled by this module.

Usage Notes

Interrupt Configuration

Enabling Transfer Modules

PDC setup with external camera

Examples

Basic Example

This is a basic example of minimal use of the PDC in an application. This example shows how this driver can be used for capturing data from an external I/O device such as an image sensor.

void g_pdc_user_callback (capture_callback_args_t * p_args)
{
{
g_capture_ready = true;
}
}
void basic_example (void)
{
fsp_err_t err;
/* Initialize the PDC module */
err = R_PDC_Open(&g_pdc0_ctrl, &g_pdc0_cfg);
/* Handle any errors. This function should be defined by the user. */
assert(FSP_SUCCESS == err);
/* Initialize the camera module at this point. This implementation is camera vendor specific. */
camera_module_initialization();
/* Initialize capture ready flag to false. This gets set to true in PDC callback upon successful frame capture. */
g_capture_ready = false;
err = R_PDC_CaptureStart(&g_pdc0_ctrl, g_user_buffer);
assert(FSP_SUCCESS == err);
uint32_t timeout_ms = PDC_DELAY_MS;
/* Since there is nothing else to do, block until Callback triggers*/
while ((true != g_capture_ready) && timeout_ms)
{
timeout_ms--;;
}
if (0U == timeout_ms)
{
__BKPT(0);
}
}
static void camera_module_initialization (void)
{
/* Camera vendor specific initialization to be done here */
}

Data Structures

struct  pdc_extended_cfg_t
 
struct  pdc_instance_ctrl_t
 

Enumerations

enum  pdc_event_t
 
enum  pdc_clock_division_t
 
enum  pdc_endian_t
 
enum  pdc_hsync_polarity_t
 
enum  pdc_vsync_polarity_t
 

Data Structure Documentation

◆ pdc_extended_cfg_t

struct pdc_extended_cfg_t

Extended configuration structure for PDC.

Data Fields
pdc_clock_division_t clock_division Clock divider.
pdc_endian_t endian Endian of capture data.
pdc_hsync_polarity_t hsync_polarity Polarity of HSYNC input.
pdc_vsync_polarity_t vsync_polarity Polarity of VSYNC input.
uint8_t pdc_ipl PDC interrupt priority.
uint8_t transfer_req_ipl Transfer interrupt priority.
IRQn_Type pdc_irq PDC IRQ number.
IRQn_Type transfer_req_irq Transfer request IRQ number.
transfer_instance_t const * p_lower_lvl_transfer Pointer to the transfer instance the PDC should use.

◆ pdc_instance_ctrl_t

struct pdc_instance_ctrl_t

PDC instance control block. DO NOT INITIALIZE.

Enumeration Type Documentation

◆ pdc_event_t

PDC events

Enumerator
PDC_EVENT_TRANSFER_COMPLETE 

Complete frame transferred by DMAC/DTC.

PDC_EVENT_RX_DATA_READY 

Receive data ready interrupt.

PDC_EVENT_FRAME_END 

Frame end interrupt.

PDC_EVENT_ERR_OVERRUN 

Overrun interrupt.

PDC_EVENT_ERR_UNDERRUN 

Underrun interrupt.

PDC_EVENT_ERR_V_SET 

Vertical line setting error interrupt.

PDC_EVENT_ERR_H_SET 

Horizontal byte number setting error interrupt.

◆ pdc_clock_division_t

Clock divider applied to PDC clock to provide PCKO output frequency

Enumerator
PDC_CLOCK_DIVISION_2 

CLK / 2.

PDC_CLOCK_DIVISION_4 

CLK / 4.

PDC_CLOCK_DIVISION_6 

CLK / 6.

PDC_CLOCK_DIVISION_8 

CLK / 8.

PDC_CLOCK_DIVISION_10 

CLK / 10.

PDC_CLOCK_DIVISION_12 

CLK / 12.

PDC_CLOCK_DIVISION_14 

CLK / 14.

PDC_CLOCK_DIVISION_16 

CLK / 16.

◆ pdc_endian_t

Endian of captured data

Enumerator
PDC_ENDIAN_LITTLE 

Data is in little endian format.

PDC_ENDIAN_BIG 

Data is in big endian format.

◆ pdc_hsync_polarity_t

Polarity of input HSYNC signal

Enumerator
PDC_HSYNC_POLARITY_HIGH 

HSYNC signal is active high.

PDC_HSYNC_POLARITY_LOW 

HSYNC signal is active low.

◆ pdc_vsync_polarity_t

Polarity of input VSYNC signal

Enumerator
PDC_VSYNC_POLARITY_HIGH 

VSYNC signal is active high.

PDC_VSYNC_POLARITY_LOW 

VSYNC signal is active low.

Function Documentation

◆ R_PDC_Open()

fsp_err_t R_PDC_Open ( capture_ctrl_t *const  p_ctrl,
capture_cfg_t const *const  p_cfg 
)

Powers on PDC, handles required initialization described in the hardware manual.

Implements capture_api_t::open.

The Open function provides initial configuration for the PDC module. It powers on the module and enables the PCLKO output and the PIXCLK input. Further initialization requires the PIXCLK input to be running in order to be able to reset the PDC as part of its initialization. This clock is input from a camera module and so the reset and further initialization is performed in capture_api_t::captureStart. This function should be called once prior to calling any other PDC API functions. After the PDC is opened the Open function should not be called again without first calling the Close function.

Example:

/* Initialize the PDC module */
err = R_PDC_Open(&g_pdc0_ctrl, &g_pdc0_cfg);
Return values
FSP_SUCCESSInitialization was successful.
FSP_ERR_ASSERTIONOne or more of the following parameters is NULL
  1. p_cfg is NULL
  2. p_api_ctrl is NULL
  3. The pointer to the transfer interface in the p_cfg parameter is NULL
  4. Callback parameter is NULL.
  5. Invalid IRQ number assigned
FSP_ERR_INVALID_ARGUMENTOne or more of the following parameters is incorrect
  1. bytes_per_pixel is zero
  2. x_capture_pixels is zero
  3. y_capture_pixels is zero
  4. x_capture_start_pixel + x_capture_pixels is greater than 4095, OR
  5. y_capture_start_pixel + y_capture_pixels is greater than 4095
FSP_ERR_ALREADY_OPENModule is already open.

◆ R_PDC_Close()

fsp_err_t R_PDC_Close ( capture_ctrl_t *const  p_ctrl)

Stops and closes the transfer interface, disables and powers off the PDC, clears internal driver data and disables interrupts.

Implements capture_api_t::close.

Return values
FSP_SUCCESSSuccessful close.
FSP_ERR_ASSERTIONp_api_ctrl is NULL
FSP_ERR_NOT_OPENOpen has not been successfully called.

◆ R_PDC_CaptureStart()

fsp_err_t R_PDC_CaptureStart ( capture_ctrl_t *const  p_ctrl,
uint8_t *const  p_buffer 
)

Starts a capture. Enables interrupts.

Implements capture_api_t::captureStart.

Sets up the transfer interface to transfer data from the PDC into the specified buffer. Configures the PDC settings as previously set by the capture_api_t::open API. These settings are configured here as the PIXCLK input must be active for the PDC reset operation. When a capture is complete the callback registered during capture_api_t::open API call will be called.

Example:

err = R_PDC_CaptureStart(&g_pdc0_ctrl, g_user_buffer);
assert(FSP_SUCCESS == err);
Return values
FSP_SUCCESSCapture start successful.
FSP_ERR_ASSERTIONOne or more of the following parameters is NULL
  1. p_api_ctrl is NULL
  2. p_buffer is NULL
FSP_ERR_NOT_OPENOpen has not been successfully called.
FSP_ERR_IN_USEPDC transfer is already in progress.
FSP_ERR_TIMEOUTReset operation timed out.
FSP_ERR_NOT_INITIALIZEDCallback function has not been set

◆ R_PDC_StatusGet()

fsp_err_t R_PDC_StatusGet ( capture_ctrl_t *const  p_ctrl,
capture_status_t p_status 
)

Provides the pdc operating status.

Implements capture_api_t::statusGet.

Return values
FSP_SUCCESSInitialization was successful.
FSP_ERR_ASSERTIONOne or more parameters is NULL.
FSP_ERR_NOT_OPENOpen has not been successfully called.

◆ R_PDC_CallbackSet()

fsp_err_t R_PDC_CallbackSet ( capture_ctrl_t *const  p_ctrl,
void(*)(capture_callback_args_t *)  p_callback,
void const *const  p_context,
capture_callback_args_t *const  p_callback_memory 
)

Updates the user callback and has option of providing memory for callback structure.

Implements capture_api_t::callbackSet.

Return values
FSP_ERR_UNSUPPORTEDThis is just a stub at present