RZ/A Flexible Software Package Documentation  Release v3.0.0

 
Camera Data Receiving Unit (r_cru)

Functions

fsp_err_t R_CRU_Open (cru_ctrl_t *const p_api_ctrl, cru_cfg_t const *const p_cfg)
 
fsp_err_t R_CRU_Close (cru_ctrl_t *const p_api_ctrl)
 
fsp_err_t R_CRU_CaptureStart (cru_ctrl_t *const p_api_ctrl)
 
fsp_err_t R_CRU_CaptureStop (cru_ctrl_t *const p_api_ctrl)
 
fsp_err_t R_CRU_StatusGet (cru_ctrl_t *const p_api_ctrl, camera_status_t *p_status)
 

Detailed Description

Driver for the CRU peripheral on RZ MPUs. This module implements the Camera Interface.

Overview

The CRU supports interfacing with external cameras by accepting data signals in order to capture incoming data

Features

Feature Options
Input color formats RGB565, RGB888, YCbCr420(8bit), YCbCr420(10bit), YCbCr422(8bit), YCbCr422(10bit), RAW8, RAW10, RAW12, RAW12
Datalanes one, two, four
Maximum resolution Up to 2800 x 4095 pixels
Interrupts Frame Start, Frame End, Scan Line

Configuration

Build Time Configurations for r_cru

The following build time configurations are defined in fsp_cfg/r_cru_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 > CRU Driver on r_cru

This module can be added to the Stacks tab via New Stack > Graphics > CRU Driver on r_cru.

ConfigurationOptionsDefaultDescription
General > NameName must be a valid C symbolg_cru0 Module name.
Input > Capture Specifications > Number of pixels to capture horizontallyValue must be an integer greater than 01280 Specify the number of horizontal pixels to capture.
Input > Capture Specifications > Number of lines to capture verticallyValue must be an integer greater than 0720 Specify the number of vertical pixels to capture.
Input > Capture Specifications > 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.
Input > Capture Specifications > 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.
Input > Timing Custom > Timing
  • User custom
  • Over 360Mbps
  • 360 Mbps
  • 250 Mbps
  • 125 Mbps
  • 80 Mbps
Over 360Mbps If User Custom is selected, any value can be set as each parameter
Input > Timing Custom > T_INITValue must be an integer0 If User Custom is selected, any value can be set as this parameter
Input > Timing Custom > TCLK_MISSValue must be an integer0 If User Custom is selected, any value can be set as this parameter
Input > Timing Custom > TCLK_SETTLEValue must be an integer0 If User Custom is selected, any value can be set as this parameter
Input > Timing Custom > THS_SETTLEValue must be an integer0 If User Custom is selected, any value can be set as this parameter
Input > Timing Custom > TCLK_PREPAREValue must be an integer0 If User Custom is selected, any value can be set as this parameter
Input > Timing Custom > THS_PREPAREValue must be an integer0 If User Custom is selected, any value can be set as this parameter
Input > Color format
  • YUV420(8bit)
  • YUV420(10bit)
  • YUV422(8bit)
  • YUV422(10bit)
  • RGB565
  • RGB888
  • RAW8
  • RAW10
  • RAW12
  • RAW14
YUV422(8bit) Select the input color format.
Input > Number of datalanes
  • use 1 datalane
  • use 2 datalanes
  • use 4 datalanes
use 2 datalanes Select a number of datalanes.
Output > Buffer > Image buffer sectionThis property must be a valid section nameUNCACHED_BSS Specify the RAM section for the image data buffer. Typically .bss (internal RAM) or .sdram. When Arm Compiler 6 is used to place this memory in on-chip SRAM, the section name must be .bss or start with .bss. to avoid consuming unnecessary ROM space.
Output > Buffer > Number of image buffersValue must be an integer between 0 and 81 Specify the number of buffers to create.When user select 0,the buffer set in user application can be used.
Output > Color format
  • YUV420 (YUYV)
  • YUV420 (UYVY)
  • YUV422 (YUYV)
  • YUV422 (UYVY)
  • RGB888 24bit
  • RGB888 32bit(Upper 8bit is 0)
  • ARGB8888
  • BGRA8888
YUV422 (YUYV) Select the output color format.
Interrupts > Image Conversion > Enable Interrupt > Frame Start interrupt
  • Enable
  • Disable
Disable Enable or Disable Image Conversion interrupt
Interrupts > Image Conversion > Enable Interrupt > Frame End Interrupt
  • Enable
  • Disable
Disable Enable or Disable Image Conversion interrupt
Interrupts > Image Conversion > Enable Interrupt > Scan Line interrupt
  • Enable
  • Disable
Disable Enable or Disable Image Conversion interrupt
Interrupts > Image Conversion > Enable Interrupt > Scan Line NumberValue must be an integer between 0 and 40950 Line specification for generating a scan line interrupt.
Interrupts > Image Conversion > CallbackName must be a valid C symbolNULL Set the callback function name for Image Conversion interrupt
Interrupts > Image Conversion > Interrupt PriorityValue must be between 0 and 3124 Select the Image Conversion interrupt priority.
Demosaic > bit extension
  • repeat from the highest 4bits/2bits
  • filled with 0
repeat from the highest 4bits/2bits Bit extension for demosaic(8bit/10bit -> 12bit).
Demosaic > RAW type
  • R (RGRG...)
  • Gr(GRGR...)
  • Gb(GBGB...)
  • B (BGBG...)
R (RGRG...) The 1st pixel type of 1st line when used RAW data as input format
Linearmatrix > Enable
  • enable
  • disable
disable Enable or disable linearmatrix after demosaic.This function can be enabled if input format is RAW data
Linearmatrix > Offset RValue must be an integer between -128 and 1270 Offset R for Linear matrix calculation. Reference manual for details.
Linearmatrix > Offset GValue must be an integer between -128 and 1270 Offset G for Linear matrix calculation. Reference manual for details.
Linearmatrix > Offset BValue must be an integer between -128 and 1270 Offset B for Linear matrix calculation. Reference manual for details.
Linearmatrix > Coefficient RrValue msut be -4 or more and less than 4 1.0 Coefficient Rr for Linear matrix calculation. Reference manual for details.
Linearmatrix > Coefficient RgValue msut be -4 or more and less than 4 0 Coefficient Rg for Linear matrix calculation. Reference manual for details.
Linearmatrix > Coefficient RbValue msut be -4 or more and less than 4 0 Coefficient Rb for Linear matrix calculation. Reference manual for details.
Linearmatrix > Coefficient GrValue msut be -4 or more and less than 4 0 Coefficient Gr for Linear matrix calculation. Reference manual for details.
Linearmatrix > Coefficient GgValue msut be -4 or more and less than 4 1.0 Coefficient Gg for Linear matrix calculation. Reference manual for details.
Linearmatrix > Coefficient GbValue msut be -4 or more and less than 4 0 Coefficient Gb for Linear matrix calculation. Reference manual for details.
Linearmatrix > Coefficient BrValue msut be -4 or more and less than 4 0 Coefficient Br for Linear matrix calculation. Reference manual for details.
Linearmatrix > Coefficient BgValue msut be -4 or more and less than 4 0 Coefficient Bg for Linear matrix calculation. Reference manual for details.
Linearmatrix > Coefficient BbValue msut be -4 or more and less than 4 1.0 Coefficient Bb for Linear matrix calculation. Reference manual for details.
Statistics > Enable
  • enable
  • disable
disable Enable or disable statistics.This function can be enabled if input format is RAW data
Statistics > Buffer numValue must be an integer between 0 and 80 Number of buffers for statistics.When user select 0,the buffer set in user application can be used.
Statistics > Processing unit
  • 16 x 16
  • 32 x 32
  • 64 x 64
  • 128 x 128
16 x 16 processing unit for statistics.
Statistics > Input data bit positionValue must be an integer between 0 and 80 Input data bit position for statistics.If input format is RAW16, [15-n:8-n:]data will be used
Statistics > Horizontal start positionValue must be an integer between 0 and 3760 Horizontal start position for statistics

Usage Notes

Interrupt Configuration

CRU setup with external camera

Examples

Basic Example

This is a basic example of minimal use of the CRU 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 basic_example (void)
{
/* Open the CRU driver */
g_cru_on_cru.open(&g_cru_ctrl, &g_cru_cfg);
/* Start capture */
g_cru_on_cru.captureStart(&g_cru_ctrl);
}

Data Structures

struct  statistics_cfg_t
 
struct  linearmatrix_cfg_t
 
struct  cru_extended_cfg_t
 
struct  cru_instance_ctrl_t
 

Enumerations

enum  cru_color_input_format_t
 
enum  cru_color_output_format_t
 
enum  cru_datalane_t
 
enum  cru_interrupt_enable_t
 
enum  cru_event_image_conv_int_t
 

Data Structure Documentation

◆ statistics_cfg_t

struct statistics_cfg_t

Statistics configuration parameters

Data Fields
uint8_t statistics Setting for Statistics processing (0: execute, 1:through)
uint8_t * pp_buffer[8] Pointer to array of buffer pointers.
uint8_t num_buffers Number of buffers to use.
uint8_t stunit (0:16x16, 1:32x32, 2:64x64, 3:128x128)

Selection of processing units for statistics processing(0-3)

uint8_t stsadpos Input data bit position selection for adjacent pixel absolute value summation (0-8)
uint16_t sthpos horizontal start position for statistics processing (0-376)

◆ linearmatrix_cfg_t

struct linearmatrix_cfg_t

LenearMatrix configuration parameters

Data Fields
uint8_t linearmatrix Setting for Linear matrix processing (0: execute, 1:through)
int8_t rof R offset value -128(8'h80)~127(8'h7F)
int8_t gof G offset value -128(8'h80)~127(8'h7F)
int8_t bof B offset value -128(8'h80)~127(8'h7F)
int16_t rr Coefficient R of R data for Linear Matrix calculation (-4096(13'h1000)~4095(13'h0FFF))
int16_t rg Coefficient G of R data for Linear Matrix calculation (-4096(13'h1000)~4095(13'h0FFF))
int16_t rb Coefficient B of R data for Linear Matrix calculation (-4096(13'h1000)~4095(13'h0FFF))
int16_t gr Coefficient R of G data for Linear Matrix calculation (-4096(13'h1000)~4095(13'h0FFF))
int16_t gg Coefficient G of G data for Linear Matrix calculation (-4096(13'h1000)~4095(13'h0FFF))
int16_t gb Coefficient B of G data for Linear Matrix calculation (-4096(13'h1000)~4095(13'h0FFF))
int16_t br Coefficient R of B data for Linear Matrix calculation (-4096(13'h1000)~4095(13'h0FFF))
int16_t bg Coefficient G of B data for Linear Matrix calculation (-4096(13'h1000)~4095(13'h0FFF))
int16_t bb Coefficient B of B data for Linear Matrix calculation (-4096(13'h1000)~4095(13'h0FFF))

◆ cru_extended_cfg_t

struct cru_extended_cfg_t

CRU hardware specific configuration

Data Fields
cru_datalane_t num_datalane select number of datalane
cru_color_input_format_t color_input input color format
cru_color_output_format_t color_output output color format
cru_interrupt_enable_t interrupt_enable Interrupt enable table.
uint16_t scan_line_num Line specification for generating a scan line interrupt.
uint8_t image_conv_int_ipl Image conversion interrupt priority.
IRQn_Type image_conv_int_irq Image conversion IRQ number.
statistics_cfg_t statistics_cfg Statistics Configuration.
linearmatrix_cfg_t linearmatrix_cfg LinearMatrix Configuration.
uint8_t rgb_bit_extension

Settings when RGB bit is extended (8bit/10bit -> 12bit) 0: Lower 4bits/2bits are expanded repeatedly from the highest 4bits/2bits 1: Lower 4bits/2bits are filled with zeros

uint8_t rawstarttype 0: R (RGRG...), 1: Gr (GRGR...), 2: Gb (GBGB...), 3: B (BGBG...)

Specify the type of the 1st pixel of the 1st line of RAW data

uint32_t t_init
uint32_t tclk_miss timing parameter, register of CSIDPHYTIM0
uint32_t tclk_settle timing parameter, register of CSIDPHYTIM0
uint32_t ths_settle timing parameter, register of CSIDPHYTIM1
uint32_t tclk_prepare timing parameter, register of CSIDPHYTIM1
uint32_t ths_prepare timing parameter, register of CSIDPHYTIM1

◆ cru_instance_ctrl_t

struct cru_instance_ctrl_t

CRU instance control block.

Data Fields

cru_cfg_t const * p_cfg
 Status of LCDC module. More...
 
uint8_t capture_num
 The buffer number currently used by CRU.
 
void const * p_context
 Placeholder for user data. Passed to the user callback.
 
void(* p_callback )(camera_callback_args_t *p_args)
 Callback provided when a image conversion ISR occurs.
 

Field Documentation

◆ p_cfg

cru_cfg_t const* cru_instance_ctrl_t::p_cfg

Status of LCDC module.

Pointer to the configuration structure

Enumeration Type Documentation

◆ cru_color_input_format_t

CRU color format setting

Enumerator
CRU_COLOR_INPUT_FORMAT_YUV420_8BIT 

YUV420 8bit.

CRU_COLOR_INPUT_FORMAT_YUV420_10BIT 

YUV420 10bit.

CRU_COLOR_INPUT_FORMAT_YUV422_8BIT 

YUV422 8bit.

CRU_COLOR_INPUT_FORMAT_YUV422_10BIT 

YUV422 10bit.

CRU_COLOR_INPUT_FORMAT_RGB565 

RGB565.

CRU_COLOR_INPUT_FORMAT_RGB888 

RGB888.

CRU_COLOR_INPUT_FORMAT_RAW8 

RAW8.

CRU_COLOR_INPUT_FORMAT_RAW10 

RAW10.

CRU_COLOR_INPUT_FORMAT_RAW12 

RAW12.

CRU_COLOR_INPUT_FORMAT_RAW14 

RAW14.

◆ cru_color_output_format_t

Color order setting

Enumerator
CRU_COLOR_OUTPUT_FORMAT_YUV420_YUYV 

YUV420 YUYV.

CRU_COLOR_OUTPUT_FORMAT_YUV420_UYVY 

YUV420 UYVY.

CRU_COLOR_OUTPUT_FORMAT_YUV422_YUYV 

YUV422 YUYV.

CRU_COLOR_OUTPUT_FORMAT_YUV422_UYVY 

YUV422 UYVY.

CRU_COLOR_OUTPUT_FORMAT_RGB888_24BIT 

RGB888 24BIT.

CRU_COLOR_OUTPUT_FORMAT_RGB888_32BIT 

RGB888 32BIT (Upper 8bit is 0x00)

CRU_COLOR_OUTPUT_FORMAT_ARGB8888 

ARGB8888.

CRU_COLOR_OUTPUT_FORMAT_BGRA8888 

BGRA888.

◆ cru_datalane_t

Enumerator
CRU_DATALANE_1 

use one datalane

CRU_DATALANE_2 

use two datalane

CRU_DATALANE_4 

use four datalane

◆ cru_interrupt_enable_t

CRU interrupt enable

◆ cru_event_image_conv_int_t

CRU events table for image conv int

Enumerator
CRU_EVENT_FRAME_START 

Interrupt for Frame Start.

CRU_EVENT_FRAME_END 

Interrupt for Frame End.

CRU_EVENT_SCAN_LINE 

Interrupt for Scan Line.

Function Documentation

◆ R_CRU_Open()

fsp_err_t R_CRU_Open ( cru_ctrl_t *const  p_api_ctrl,
cru_cfg_t const *const  p_cfg 
)

 Initializes the CRU modules and enables interrupts

Return values
FSP_SUCCESSInitializes the CRU modules.
FSP_ERR_ASSERTIONPointer to the control block is NULL.
FSP_ERR_ALREADY_OPENCRU module is already open
FSP_ERR_INVALID_ARGUMENTInvalid argument error
FSP_ERR_INVALID_ALIGNMENTInput buffer alignment

◆ R_CRU_Close()

fsp_err_t R_CRU_Close ( cru_ctrl_t *const  p_api_ctrl)

Close the capture while the CRU module is operating

Return values
FSP_SUCCESSClose the CRU module
FSP_ERR_ASSERTIONPointer to the control block is NULL.
FSP_ERR_NOT_OPENCRU module is not open

◆ R_CRU_CaptureStart()

fsp_err_t R_CRU_CaptureStart ( cru_ctrl_t *const  p_api_ctrl)

Start a capture. It is only possible when CRU is open.

Return values
FSP_SUCCESSstart a capture.
FSP_ERR_ASSERTIONPointer to the control block is NULL.
FSP_ERR_INVALID_MODECRU module is not CAMERA_STATE_IN_PROGRESS

◆ R_CRU_CaptureStop()

fsp_err_t R_CRU_CaptureStop ( cru_ctrl_t *const  p_api_ctrl)

Stop a capture. It is only possible when CRU is running.

Return values
FSP_SUCCESSstop a capture.
FSP_ERR_ASSERTIONPointer to the control block is NULL.
FSP_ERR_INVALID_MODECRU module is not CAMERA_STATE_BUSY

◆ R_CRU_StatusGet()

fsp_err_t R_CRU_StatusGet ( cru_ctrl_t *const  p_api_ctrl,
camera_status_t p_status 
)

Get the camera status, CAMERA module status and buffer address. It is only possible when CRU is running.

Return values
FSP_SUCCESSstop a capture.
FSP_ERR_ASSERTIONPointer to the control block is NULL.
FSP_ERR_INVALID_MODECRU module is not CAMERA_STATE_BUSY