|
| 1 | +/* |
| 2 | +* Copyright (c) 2020 - 2025 Renesas Electronics Corporation and/or its affiliates |
| 3 | +* |
| 4 | +* SPDX-License-Identifier: BSD-3-Clause |
| 5 | +*/ |
| 6 | + |
| 7 | +/*******************************************************************************************************************//** |
| 8 | + * @addtogroup CEU |
| 9 | + * @{ |
| 10 | + **********************************************************************************************************************/ |
| 11 | + |
| 12 | +#ifndef R_CEU_H |
| 13 | +#define R_CEU_H |
| 14 | + |
| 15 | +#include "bsp_api.h" |
| 16 | +#include "r_capture_api.h" |
| 17 | +#include "r_ceu.h" |
| 18 | + |
| 19 | +/* Common macro for FSP header files. There is also a corresponding FSP_FOOTER macro at the end of this file. */ |
| 20 | +FSP_HEADER |
| 21 | + |
| 22 | +/*********************************************************************************************************************** |
| 23 | + * Macro definitions |
| 24 | + **********************************************************************************************************************/ |
| 25 | + |
| 26 | +/*********************************************************************************************************************** |
| 27 | + * Typedef definitions |
| 28 | + **********************************************************************************************************************/ |
| 29 | + |
| 30 | +/** Capture mode */ |
| 31 | +typedef enum e_ceu_capture_mode |
| 32 | +{ |
| 33 | + CEU_CAPTURE_MODE_SINGLE = 0U, ///< Single image capture |
| 34 | + CEU_CAPTURE_MODE_CONTINUOUS = 1U, ///< Continuous image capture |
| 35 | +} ceu_capture_mode_t; |
| 36 | + |
| 37 | +/** Data bus width */ |
| 38 | +typedef enum e_ceu_data_bus_size |
| 39 | +{ |
| 40 | + CEU_DATA_BUS_SIZE_8_BIT = 0U, ///< Data bus is 8-bit |
| 41 | + CEU_DATA_BUS_SIZE_16_BIT = 1U, ///< Data bus is 16-bit |
| 42 | +} ceu_data_bus_size_t; |
| 43 | + |
| 44 | +/** Polarity of input HSYNC signal */ |
| 45 | +typedef enum e_ceu_hsync_polarity |
| 46 | +{ |
| 47 | + CEU_HSYNC_POLARITY_HIGH = 0U, ///< HSYNC signal is active high |
| 48 | + CEU_HSYNC_POLARITY_LOW = 1U, ///< HSYNC signal is active low |
| 49 | +} ceu_hsync_polarity_t; |
| 50 | + |
| 51 | +/** Polarity of input VSYNC signal */ |
| 52 | +typedef enum e_ceu_vsync_polarity |
| 53 | +{ |
| 54 | + CEU_VSYNC_POLARITY_HIGH = 0U, ///< VSYNC signal is active high |
| 55 | + CEU_VSYNC_POLARITY_LOW = 1U, ///< VSYNC signal is active low |
| 56 | +} ceu_vsync_polarity_t; |
| 57 | + |
| 58 | +typedef enum e_ceu_burst_transfer_mode |
| 59 | +{ |
| 60 | + CEU_BURST_TRANSFER_MODE_X1 = (0u), ///< Transferred to the bus in 32-byte units */ |
| 61 | + CEU_BURST_TRANSFER_MODE_X2 = (1u), ///< Transferred to the bus in 64-byte units */ |
| 62 | + CEU_BURST_TRANSFER_MODE_X4 = (2u), ///< Transferred to the bus in 128-byte units */ |
| 63 | + CEU_BURST_TRANSFER_MODE_X8 = (3u) ///< Transferred to the bus in 256-byte units */ |
| 64 | +} ceu_burst_transfer_mode_t; |
| 65 | + |
| 66 | +typedef enum e_ceu_event |
| 67 | +{ |
| 68 | + CEU_EVENT_NONE = 0x00000000, // No event, default state |
| 69 | + CEU_EVENT_FRAME_END = 0x00000001, ///< Frame end event (CPE) |
| 70 | + CEU_EVENT_HD = 0x00000100, ///< (Not Used) HD received (HD) |
| 71 | + CEU_EVENT_VD = 0x00000200, ///< VD received (VD) |
| 72 | + CEU_EVENT_CRAM_OVERFLOW = 0x00010000, ///< Data overflowed in the CRAM buffer (CDTOF) |
| 73 | + CEU_EVENT_HD_MISMATCH = 0x00020000, ///< HD mismatch (IGHS) |
| 74 | + CEU_EVENT_VD_MISMATCH = 0x00040000, ///< VD mismatch (IGVS) |
| 75 | + CEU_EVENT_VD_ERROR = 0x00100000, ///< Invalid VD condition (VBP) |
| 76 | + CEU_EVENT_FIREWALL = 0x00800000, ///< Data write address exceeds firewall (FWF) |
| 77 | + CEU_EVENT_HD_MISSING = 0x01000000, ///< HD was expected but not input (NHD) |
| 78 | + CEU_EVENT_VD_MISSING = 0x02000000, ///< VD was expected but not input (NVD) |
| 79 | +} ceu_event_t; |
| 80 | + |
| 81 | +/** Capture mode for CEU. */ |
| 82 | +typedef enum e_ceu_capture_format |
| 83 | +{ |
| 84 | + CEU_CAPTURE_FORMAT_DATA_SYNCHRONOUS = 0x1, ///< Raw formatted data. |
| 85 | + CEU_CAPTURE_FORMAT_DATA_ENABLE = 0x2 ///< JPG formatted data |
| 86 | +} ceu_capture_format_t; |
| 87 | + |
| 88 | +/** Swap bits configuration */ |
| 89 | +typedef struct st_ceu_byte_swapping_t |
| 90 | +{ |
| 91 | + uint8_t swap_8bit_units : 1; ///< Byte swapping in 8-bit units |
| 92 | + uint8_t swap_16bit_units : 1; ///< Byte swapping in 16-bit units |
| 93 | + uint8_t swap_32bit_units : 1; ///< Byte swapping in 32-bit units |
| 94 | +} ceu_byte_swapping_t; |
| 95 | + |
| 96 | +/** Edge information for latching signals */ |
| 97 | +typedef struct st_ceu_edge_info_t |
| 98 | +{ |
| 99 | + uint8_t dsel : 1; ///< Sets the edge for fetching the image data (D15 to D0) from an external module. |
| 100 | + uint8_t hdsel : 1; ///< Sets the edge for capturing hd from external module. |
| 101 | + uint8_t vdsel : 1; ///< Sets the edge for capturing vd from external module. |
| 102 | +} ceu_edge_info_t; |
| 103 | + |
| 104 | +/** Extended configuration structure for CEU. */ |
| 105 | +typedef struct st_ceu_extended_cfg |
| 106 | +{ |
| 107 | + ceu_capture_format_t capture_format; ///< Capture format for incoming data |
| 108 | + ceu_data_bus_size_t data_bus_width; ///< Size of camera data bus |
| 109 | + ceu_edge_info_t edge_info; |
| 110 | + ceu_hsync_polarity_t hsync_polarity; ///< Polarity of HSYNC input |
| 111 | + ceu_vsync_polarity_t vsync_polarity; ///< Polarity of VSYNC input |
| 112 | + uint32_t image_area_size; ///< Image capture size. Used when setting firewall address for Data Enable Fetch mode. |
| 113 | + ceu_byte_swapping_t byte_swapping; ///< Controls byte swapping in 8-bit, 16-bit and 32-bit units |
| 114 | + ceu_burst_transfer_mode_t burst_mode; ///< Bus transfer data size |
| 115 | + uint32_t interrupts_enabled; ///< Enabled interrupt events bit mask |
| 116 | + uint8_t ceu_ipl; ///< PDC interrupt priority |
| 117 | + IRQn_Type ceu_irq; ///< PDC IRQ number |
| 118 | +} ceu_extended_cfg_t; |
| 119 | + |
| 120 | +/** CEU instance control block. DO NOT INITIALIZE. */ |
| 121 | +typedef struct st_ceu_instance_ctrl |
| 122 | +{ |
| 123 | + capture_cfg_t const * p_cfg; // Pointer to the configuration structure |
| 124 | + uint32_t open; // Indicates whether or not the driver is open called. |
| 125 | + uint8_t * p_buffer; // Pointer to buffer currently in use |
| 126 | + uint32_t image_area_size; // Size of capture area for image (Used for Data Enable Fetch) |
| 127 | + uint32_t interrupts_enabled; // Interrupts enabled bitmask |
| 128 | + void (* p_callback)(capture_callback_args_t *); // Pointer to callback that is called when an ceu_event_t occurs. |
| 129 | + capture_callback_args_t * p_callback_memory; // Pointer to non-secure memory that can be used to pass arguments to a callback in non-secure memory. |
| 130 | + void const * p_context; // Pointer to context to be passed into callback function |
| 131 | +} ceu_instance_ctrl_t; |
| 132 | + |
| 133 | +/********************************************************************************************************************** |
| 134 | + * Exported global variables |
| 135 | + **********************************************************************************************************************/ |
| 136 | + |
| 137 | +/** @cond INC_HEADER_DEFS_SEC */ |
| 138 | +/** Filled in Interface API structure for this Instance. */ |
| 139 | +extern const capture_api_t g_ceu_on_capture; |
| 140 | + |
| 141 | +/** @endcond */ |
| 142 | + |
| 143 | +/*********************************************************************************************************************** |
| 144 | + * Public APIs |
| 145 | + **********************************************************************************************************************/ |
| 146 | +fsp_err_t R_CEU_Open(capture_ctrl_t * const p_ctrl, capture_cfg_t const * const p_cfg); |
| 147 | + |
| 148 | +fsp_err_t R_CEU_Close(capture_ctrl_t * const p_ctrl); |
| 149 | + |
| 150 | +fsp_err_t R_CEU_CaptureStart(capture_ctrl_t * const p_ctrl, uint8_t * const p_buffer); |
| 151 | + |
| 152 | +fsp_err_t R_CEU_CallbackSet(capture_ctrl_t * const p_ctrl, |
| 153 | + void ( * p_callback)(capture_callback_args_t *), |
| 154 | + void const * const p_context, |
| 155 | + capture_callback_args_t * const p_callback_memory); |
| 156 | + |
| 157 | +fsp_err_t R_CEU_StatusGet(capture_ctrl_t * const p_ctrl, capture_status_t * p_status); |
| 158 | + |
| 159 | +typedef uint32_t my_uint_t; |
| 160 | + |
| 161 | +/* Common macro for FSP header files. There is also a corresponding FSP_HEADER macro at the top of this file. */ |
| 162 | +FSP_FOOTER |
| 163 | + |
| 164 | +#endif // R_CEU_H |
| 165 | + |
| 166 | +/*******************************************************************************************************************//** |
| 167 | + * @} (end defgroup CEU) |
| 168 | + **********************************************************************************************************************/ |
0 commit comments