1 /* 2 * Copyright (c) 2015-2019, Texas Instruments Incorporated 3 * All rights reserved. 4 * 5 * Redistribution and use in source and binary forms, with or without 6 * modification, are permitted provided that the following conditions 7 * are met: 8 * 9 * * Redistributions of source code must retain the above copyright 10 * notice, this list of conditions and the following disclaimer. 11 * 12 * * Redistributions in binary form must reproduce the above copyright 13 * notice, this list of conditions and the following disclaimer in the 14 * documentation and/or other materials provided with the distribution. 15 * 16 * * Neither the name of Texas Instruments Incorporated nor the names of 17 * its contributors may be used to endorse or promote products derived 18 * from this software without specific prior written permission. 19 * 20 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 21 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, 22 * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR 23 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR 24 * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, 25 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, 26 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; 27 * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, 28 * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR 29 * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, 30 * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 31 */ 32 /** ============================================================================ 33 * @file CameraCC32XXDMA.h 34 * 35 * @brief Camera driver implementation for a CC32XX Camera controller 36 * 37 * The Camera header file should be included in an application as follows: 38 * @code 39 * #include <ti/drivers/Camera.h> 40 * #include <ti/drivers/Camera/CameraCC32XXDMA.h> 41 * @endcode 42 * 43 * Refer to @ref Camera.h for a complete description of APIs & example of use. 44 * 45 * ============================================================================ 46 */ 47 48 #ifndef ti_drivers_Camera_CameraCC32XXDMA__include 49 #define ti_drivers_Camera_CameraCC32XXDMA__include 50 51 #include <stdint.h> 52 #include <stdbool.h> 53 #include <ti/drivers/Camera.h> 54 #include <ti/drivers/dpl/HwiP.h> 55 #include <ti/drivers/dpl/SemaphoreP.h> 56 57 #ifdef __cplusplus 58 extern "C" { 59 #endif 60 61 /** 62 * @addtogroup Camera_STATUS 63 * CameraCC32XXDMA_STATUS_* macros are command codes only defined in the 64 * CameraCC32XXDMA.h driver implementation and need to: 65 * @code 66 * #include <ti/drivers/camera/CameraCC32XXDMA.h> 67 * @endcode 68 * @{ 69 */ 70 71 /* Add CameraCC32XXDMA_STATUS_* macros here */ 72 73 /** @}*/ 74 75 /** 76 * @addtogroup Camera_CMD 77 * CameraCC32XXDMA_CMD_* macros are command codes only defined in the 78 * CameraCC32XXDMA.h driver implementation and need to: 79 * @code 80 * #include <ti/drivers/camera/CameraCC32XXDMA.h> 81 * @endcode 82 * @{ 83 */ 84 85 /* Add CameraCC32XXDMA_CMD_* macros here */ 86 87 /** @}*/ 88 89 /* CC32XX camera DMA transfer size */ 90 #define CameraCC32XXDMA_DMA_TRANSFER_SIZE 64 91 92 /* Camera function table pointer */ 93 extern const Camera_FxnTable CameraCC32XXDMA_fxnTable; 94 95 /*! 96 * @brief CameraCC32XXDMA Hardware attributes 97 * 98 * These fields, with the exception of intPriority, 99 * are used by driverlib APIs and therefore must be populated by 100 * driverlib macro definitions. For CC32XXWare these definitions are found in: 101 * - inc/hw_memmap.h 102 * - inc/hw_ints.h 103 * 104 * intPriority is the Camera peripheral's interrupt priority, as defined by the 105 * underlying OS. It is passed unmodified to the underlying OS's interrupt 106 * handler creation code, so you need to refer to the OS documentation 107 * for usage. If the driver uses the ti.dpl interface 108 * instead of making OS calls directly, then the HwiP port handles the 109 * interrupt priority in an OS specific way. In the case of the SYS/BIOS 110 * port, intPriority is passed unmodified to Hwi_create(). 111 * 112 * A sample structure is shown below: 113 * @code 114 * const CameraCC32XXDMA_HWAttrs CameraCC32XXDMAHWAttrs[] = { 115 * { 116 * .baseAddr = CAMERA_BASE, 117 * .intNum = INT_CAMERA, 118 * .intPriority = (~0), 119 * .channelIndex = UDMA_CH22_CAMERA 120 * } 121 * }; 122 * @endcode 123 */ 124 typedef struct { 125 /*! Camera Peripheral's base address */ 126 uint32_t baseAddr; 127 /*! Camera Peripheral's interrupt vector */ 128 uint32_t intNum; 129 /*! Camera Peripheral's interrupt priority */ 130 uint32_t intPriority; 131 /*! uDMA controlTable channel index */ 132 unsigned long channelIndex; 133 } CameraCC32XXDMA_HWAttrs; 134 135 /*! 136 * @brief CameraCC32XXDMA Object 137 * 138 * The application must not access any member variables of this structure! 139 */ 140 typedef struct { 141 /* Camera control variables */ 142 bool opened; /* Has the obj been opened */ 143 Camera_CaptureMode operationMode; /* Mode of operation of Camera */ 144 145 /* Camera capture variables */ 146 Camera_Callback captureCallback; /* Pointer to capture callback */ 147 uint32_t captureTimeout; /* Timeout for capture semaphore */ 148 void *captureBuf; /* Buffer data pointer */ 149 size_t bufferlength; /* Input Buffer length*/ 150 size_t frameLength; /* Captured frame length */ 151 152 bool cameraDMA_PingPongMode; /* DMA ping pong mode */ 153 size_t cameraDMAxIntrRcvd; /* Number of DMA interrupts*/ 154 bool inUse; /* Camera in Use */ 155 156 /* Camera OS objects */ 157 SemaphoreP_Handle captureSem; 158 HwiP_Handle hwiHandle; 159 } CameraCC32XXDMA_Object, *CameraCC32XXDMA_Handle; 160 161 #ifdef __cplusplus 162 } 163 #endif 164 165 #endif /* ti_drivers_Camera_CameraCC32XXDMA__include */ 166