![]() |
|
|||
File indexing completed on 2025-05-11 08:22:59
0001 /* 0002 * Copyright (c) 2015, Freescale Semiconductor, Inc. 0003 * Copyright 2016-2020 NXP 0004 * All rights reserved. 0005 * 0006 * SPDX-License-Identifier: BSD-3-Clause 0007 */ 0008 0009 #ifndef _FSL_FLEXIO_CAMERA_H_ 0010 #define _FSL_FLEXIO_CAMERA_H_ 0011 0012 #include "fsl_common.h" 0013 #include "fsl_flexio.h" 0014 /*! 0015 * @addtogroup flexio_camera 0016 * @{ 0017 */ 0018 0019 /******************************************************************************* 0020 * Definitions 0021 ******************************************************************************/ 0022 0023 /*! @name Driver version */ 0024 /*@{*/ 0025 /*! @brief FlexIO Camera driver version 2.1.3. */ 0026 #define FSL_FLEXIO_CAMERA_DRIVER_VERSION (MAKE_VERSION(2, 1, 3)) 0027 /*@}*/ 0028 0029 /*! @brief Define the Camera CPI interface is constantly 8-bit width. */ 0030 #define FLEXIO_CAMERA_PARALLEL_DATA_WIDTH (8U) 0031 0032 /*! @brief Error codes for the Camera driver. */ 0033 enum 0034 { 0035 kStatus_FLEXIO_CAMERA_RxBusy = MAKE_STATUS(kStatusGroup_FLEXIO_CAMERA, 0), /*!< Receiver is busy. */ 0036 kStatus_FLEXIO_CAMERA_RxIdle = MAKE_STATUS(kStatusGroup_FLEXIO_CAMERA, 1), /*!< Camera receiver is idle. */ 0037 }; 0038 0039 /*! @brief Define FlexIO Camera status mask. */ 0040 enum _flexio_camera_status_flags 0041 { 0042 kFLEXIO_CAMERA_RxDataRegFullFlag = 0x1U, /*!< Receive buffer full flag. */ 0043 kFLEXIO_CAMERA_RxErrorFlag = 0x2U, /*!< Receive buffer error flag. */ 0044 }; 0045 0046 /*! 0047 * @brief Define structure of configuring the FlexIO Camera device. 0048 */ 0049 typedef struct _flexio_camera_type 0050 { 0051 FLEXIO_Type *flexioBase; /*!< FlexIO module base address. */ 0052 uint32_t datPinStartIdx; /*!< First data pin (D0) index for flexio_camera. 0053 Then the successive following FLEXIO_CAMERA_DATA_WIDTH-1 pins 0054 are used as D1-D7.*/ 0055 uint32_t pclkPinIdx; /*!< Pixel clock pin (PCLK) index for flexio_camera. */ 0056 uint32_t hrefPinIdx; /*!< Horizontal sync pin (HREF) index for flexio_camera. */ 0057 0058 uint32_t shifterStartIdx; /*!< First shifter index used for flexio_camera data FIFO. */ 0059 uint32_t shifterCount; /*!< The count of shifters that are used as flexio_camera data FIFO. */ 0060 uint32_t timerIdx; /*!< Timer index used for flexio_camera in FlexIO. */ 0061 } FLEXIO_CAMERA_Type; 0062 0063 /*! @brief Define FlexIO Camera user configuration structure. */ 0064 typedef struct _flexio_camera_config 0065 { 0066 bool enablecamera; /*!< Enable/disable FlexIO Camera TX & RX. */ 0067 bool enableInDoze; /*!< Enable/disable FlexIO operation in doze mode*/ 0068 bool enableInDebug; /*!< Enable/disable FlexIO operation in debug mode*/ 0069 bool enableFastAccess; /*!< Enable/disable fast access to FlexIO registers, 0070 fast access requires the FlexIO clock to be at least 0071 twice the frequency of the bus clock. */ 0072 } flexio_camera_config_t; 0073 0074 /*! @brief Define FlexIO Camera transfer structure. */ 0075 typedef struct _flexio_camera_transfer 0076 { 0077 uint32_t dataAddress; /*!< Transfer buffer*/ 0078 uint32_t dataNum; /*!< Transfer num*/ 0079 } flexio_camera_transfer_t; 0080 0081 /******************************************************************************* 0082 * API 0083 ******************************************************************************/ 0084 0085 #if defined(__cplusplus) 0086 extern "C" { 0087 #endif /*_cplusplus*/ 0088 0089 /*! 0090 * @name Initialization and configuration 0091 * @{ 0092 */ 0093 0094 /*! 0095 * @brief Ungates the FlexIO clock, resets the FlexIO module, and configures the FlexIO Camera. 0096 * 0097 * @param base Pointer to FLEXIO_CAMERA_Type structure 0098 * @param config Pointer to flexio_camera_config_t structure 0099 */ 0100 void FLEXIO_CAMERA_Init(FLEXIO_CAMERA_Type *base, const flexio_camera_config_t *config); 0101 0102 /*! 0103 * @brief Resets the FLEXIO_CAMERA shifer and timer config. 0104 * 0105 * @note After calling this API, call FLEXO_CAMERA_Init to use the FlexIO Camera module. 0106 * 0107 * @param base Pointer to FLEXIO_CAMERA_Type structure 0108 */ 0109 void FLEXIO_CAMERA_Deinit(FLEXIO_CAMERA_Type *base); 0110 0111 /*! 0112 * @brief Gets the default configuration to configure the FlexIO Camera. The configuration 0113 * can be used directly for calling the FLEXIO_CAMERA_Init(). 0114 * Example: 0115 @code 0116 flexio_camera_config_t config; 0117 FLEXIO_CAMERA_GetDefaultConfig(&userConfig); 0118 @endcode 0119 * @param config Pointer to the flexio_camera_config_t structure 0120 */ 0121 void FLEXIO_CAMERA_GetDefaultConfig(flexio_camera_config_t *config); 0122 0123 /*! 0124 * @brief Enables/disables the FlexIO Camera module operation. 0125 * 0126 * @param base Pointer to the FLEXIO_CAMERA_Type 0127 * @param enable True to enable, false does not have any effect. 0128 */ 0129 static inline void FLEXIO_CAMERA_Enable(FLEXIO_CAMERA_Type *base, bool enable) 0130 { 0131 if (enable) 0132 { 0133 base->flexioBase->CTRL |= FLEXIO_CTRL_FLEXEN_MASK; 0134 } 0135 } 0136 0137 /*! @} */ 0138 0139 /*! 0140 * @name Status 0141 * @{ 0142 */ 0143 0144 /*! 0145 * @brief Gets the FlexIO Camera status flags. 0146 * 0147 * @param base Pointer to FLEXIO_CAMERA_Type structure 0148 * @return FlexIO shifter status flags 0149 * @arg FLEXIO_SHIFTSTAT_SSF_MASK 0150 * @arg 0 0151 */ 0152 uint32_t FLEXIO_CAMERA_GetStatusFlags(FLEXIO_CAMERA_Type *base); 0153 0154 /*! 0155 * @brief Clears the receive buffer full flag manually. 0156 * 0157 * @param base Pointer to the device. 0158 * @param mask status flag 0159 * The parameter can be any combination of the following values: 0160 * @arg kFLEXIO_CAMERA_RxDataRegFullFlag 0161 * @arg kFLEXIO_CAMERA_RxErrorFlag 0162 */ 0163 void FLEXIO_CAMERA_ClearStatusFlags(FLEXIO_CAMERA_Type *base, uint32_t mask); 0164 0165 /* @} */ 0166 0167 /*! 0168 * @name Interrupts 0169 * @{ 0170 */ 0171 0172 /*! 0173 * @brief Switches on the interrupt for receive buffer full event. 0174 * 0175 * @param base Pointer to the device. 0176 */ 0177 void FLEXIO_CAMERA_EnableInterrupt(FLEXIO_CAMERA_Type *base); 0178 0179 /*! 0180 * @brief Switches off the interrupt for receive buffer full event. 0181 * 0182 * @param base Pointer to the device. 0183 * 0184 */ 0185 void FLEXIO_CAMERA_DisableInterrupt(FLEXIO_CAMERA_Type *base); 0186 0187 /*! @} */ 0188 0189 /*! 0190 * @name DMA support 0191 * @{ 0192 */ 0193 0194 /*! 0195 * @brief Enables/disables the FlexIO Camera receive DMA. 0196 * 0197 * @param base Pointer to FLEXIO_CAMERA_Type structure 0198 * @param enable True to enable, false to disable. 0199 * 0200 * The FlexIO Camera mode can't work without the DMA or eDMA support, 0201 * Usually, it needs at least two DMA or eDMA channels, one for transferring data from 0202 * Camera, such as 0V7670 to FlexIO buffer, another is for transferring data from FlexIO 0203 * buffer to LCD. 0204 * 0205 */ 0206 static inline void FLEXIO_CAMERA_EnableRxDMA(FLEXIO_CAMERA_Type *base, bool enable) 0207 { 0208 FLEXIO_EnableShifterStatusDMA(base->flexioBase, 1UL << base->shifterStartIdx, enable); 0209 } 0210 0211 /*! 0212 * @brief Gets the data from the receive buffer. 0213 * 0214 * @param base Pointer to the device. 0215 * @return data Pointer to the buffer that keeps the data with count of base->shifterCount . 0216 */ 0217 static inline uint32_t FLEXIO_CAMERA_GetRxBufferAddress(FLEXIO_CAMERA_Type *base) 0218 { 0219 return FLEXIO_GetShifterBufferAddress(base->flexioBase, kFLEXIO_ShifterBuffer, (uint8_t)base->shifterStartIdx); 0220 } 0221 0222 /*! @} */ 0223 0224 #if defined(__cplusplus) 0225 } 0226 #endif /*_cplusplus*/ 0227 0228 /*@}*/ 0229 0230 #endif /*_FSL_FLEXIO_CAMERA_H_*/
[ Source navigation ] | [ Diff markup ] | [ Identifier search ] | [ general search ] |
This page was automatically generated by the 2.3.7 LXR engine. The LXR team |
![]() ![]() |