Port of TI's CC3100 Websock camera demo. Using FreeRTOS, mbedTLS, also parts of Arducam for cams ov5642 and 0v2640. Can also use MT9D111. Work in progress. Be warned some parts maybe a bit flacky. This is for Seeed Arch max only, for an M3, see the demo for CM3 using the 0v5642 aducam mini.

Dependencies:   mbed

Committer:
dflet
Date:
Tue Sep 15 15:39:38 2015 +0000
Revision:
21:38c6b11aa348
Parent:
14:90603ea1e85b
Removed some debug. Did some more work on the MT9D111 camera, which now works in jpeg mode.

Who changed what in which revision?

UserRevisionLine numberNew contents of line
dflet 0:50cedd586816 1 //*****************************************************************************
dflet 0:50cedd586816 2 // camera_app.h
dflet 0:50cedd586816 3 //
dflet 0:50cedd586816 4 // camera application macro & API's prototypes
dflet 0:50cedd586816 5 //
dflet 0:50cedd586816 6 // Copyright (C) 2014 Texas Instruments Incorporated - http://www.ti.com/
dflet 0:50cedd586816 7 //
dflet 0:50cedd586816 8 //
dflet 0:50cedd586816 9 // Redistribution and use in source and binary forms, with or without
dflet 0:50cedd586816 10 // modification, are permitted provided that the following conditions
dflet 0:50cedd586816 11 // are met:
dflet 0:50cedd586816 12 //
dflet 0:50cedd586816 13 // Redistributions of source code must retain the above copyright
dflet 0:50cedd586816 14 // notice, this list of conditions and the following disclaimer.
dflet 0:50cedd586816 15 //
dflet 0:50cedd586816 16 // Redistributions in binary form must reproduce the above copyright
dflet 0:50cedd586816 17 // notice, this list of conditions and the following disclaimer in the
dflet 0:50cedd586816 18 // documentation and/or other materials provided with the
dflet 0:50cedd586816 19 // distribution.
dflet 0:50cedd586816 20 //
dflet 0:50cedd586816 21 // Neither the name of Texas Instruments Incorporated nor the names of
dflet 0:50cedd586816 22 // its contributors may be used to endorse or promote products derived
dflet 0:50cedd586816 23 // from this software without specific prior written permission.
dflet 0:50cedd586816 24 //
dflet 0:50cedd586816 25 // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
dflet 0:50cedd586816 26 // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
dflet 0:50cedd586816 27 // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
dflet 0:50cedd586816 28 // A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
dflet 0:50cedd586816 29 // OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
dflet 0:50cedd586816 30 // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
dflet 0:50cedd586816 31 // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
dflet 0:50cedd586816 32 // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
dflet 0:50cedd586816 33 // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
dflet 0:50cedd586816 34 // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
dflet 0:50cedd586816 35 // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
dflet 0:50cedd586816 36 //
dflet 0:50cedd586816 37 //*****************************************************************************
dflet 0:50cedd586816 38
dflet 0:50cedd586816 39 #ifndef __CAMERA_APP_H__
dflet 0:50cedd586816 40 #define __CAMERA_APP_H__
dflet 0:50cedd586816 41
dflet 0:50cedd586816 42 //*****************************************************************************
dflet 0:50cedd586816 43 //
dflet 0:50cedd586816 44 // If building with a C++ compiler, make all of the definitions in this header
dflet 0:50cedd586816 45 // have a C binding.
dflet 0:50cedd586816 46 //
dflet 0:50cedd586816 47 //*****************************************************************************
dflet 0:50cedd586816 48 #ifdef __cplusplus
dflet 0:50cedd586816 49 extern "C"
dflet 0:50cedd586816 50 {
dflet 0:50cedd586816 51 #endif /* __cplusplus */
dflet 0:50cedd586816 52
dflet 0:50cedd586816 53 #define UART_COMMAND_IMG_CAPTURE ('x')
dflet 0:50cedd586816 54 #define LOWER_TO_UPPER_CASE (32)
dflet 0:50cedd586816 55
dflet 0:50cedd586816 56 #define DISABLE (0)
dflet 0:50cedd586816 57 #define ENABLE (1)
dflet 0:50cedd586816 58 #define SL_VERSION_LENGTH (11)
dflet 0:50cedd586816 59
dflet 0:50cedd586816 60 extern int PIXELS_IN_X_AXIS;
dflet 0:50cedd586816 61 extern int PIXELS_IN_X_AXIS;
dflet 0:50cedd586816 62 extern int FRAME_SIZE_IN_BYTES;
dflet 21:38c6b11aa348 63
dflet 21:38c6b11aa348 64 #define NUM_OF_1KB_BUFFERS 25
dflet 0:50cedd586816 65
dflet 0:50cedd586816 66
dflet 0:50cedd586816 67 #define BYTES_PER_PIXEL (2) // RGB 565
dflet 0:50cedd586816 68
dflet 0:50cedd586816 69 #define ONE_KB (1024)
dflet 0:50cedd586816 70 #define IMAGE_BUF_SIZE (ONE_KB * NUM_OF_1KB_BUFFERS)
dflet 0:50cedd586816 71
dflet 12:7d75ba5deed1 72 #define NUM_OF_4B_CHUNKS ((IMAGE_BUF_SIZE - ONE_KB)/(sizeof(unsigned int)))
dflet 0:50cedd586816 73 #define NUM_OF_1KB_CHUNKS (IMAGE_BUF_SIZE/ONE_KB)
dflet 0:50cedd586816 74 #define NUM_OF_4B_CHUNKS_IN_1KB (ONE_KB/(sizeof(unsigned int)))
dflet 0:50cedd586816 75
dflet 0:50cedd586816 76 #define MAX_EMAIL_ID_LENGTH 34
dflet 0:50cedd586816 77 #define SMTP_BUF_LEN 1024
dflet 0:50cedd586816 78
dflet 9:b7c6e7303df5 79 //#define CAM_BT_CORRECT_EN 0x00001000
dflet 0:50cedd586816 80
dflet 0:50cedd586816 81 typedef enum opcd{
dflet 0:50cedd586816 82 START_CAPTURE = 1,
dflet 0:50cedd586816 83 STOP_CAPTURE,
dflet 0:50cedd586816 84 IMG_FMT,
dflet 0:50cedd586816 85 IMG_SIZE,
dflet 0:50cedd586816 86 EXIT
dflet 0:50cedd586816 87 }e_opcode;
dflet 0:50cedd586816 88
dflet 0:50cedd586816 89 typedef struct cmd_struct{
dflet 0:50cedd586816 90 int opcode;
dflet 0:50cedd586816 91 char email_id[MAX_EMAIL_ID_LENGTH];
dflet 0:50cedd586816 92 }s_cmd_struct;
dflet 0:50cedd586816 93
dflet 0:50cedd586816 94 //******************************************************************************
dflet 0:50cedd586816 95 // APIs
dflet 0:50cedd586816 96 //******************************************************************************
dflet 0:50cedd586816 97
dflet 14:90603ea1e85b 98 uint32_t StartCamera(char **WriteBuffer);
dflet 0:50cedd586816 99 int SetCameraResolution(int width, int height);
dflet 0:50cedd586816 100 void InitCameraComponents(int width, int height);
dflet 0:50cedd586816 101
dflet 6:37fb696395d7 102 static void CamControllerInit(void);
dflet 6:37fb696395d7 103 static void CameraIntHandler(void);
dflet 14:90603ea1e85b 104 uint32_t CaptureImage(char **WriteBuffer);
dflet 12:7d75ba5deed1 105 void DMAConfig(void);
dflet 14:90603ea1e85b 106 void DCMI_MspInit(DCMI_HandleTypeDef* hdcmi);
dflet 6:37fb696395d7 107
dflet 6:37fb696395d7 108 /****************************************************************************/
dflet 6:37fb696395d7 109 /* LOCAL FUNCTION PROTOTYPES */
dflet 6:37fb696395d7 110 /****************************************************************************/
dflet 6:37fb696395d7 111 //#ifdef ENABLE_JPEG
dflet 6:37fb696395d7 112 static int CreateJpegHeader(char *header, int width, int height,
dflet 6:37fb696395d7 113 int format, int restart_int, int qscale);
dflet 6:37fb696395d7 114 static int DefineRestartIntervalMarker(char *pbuf, int ri);
dflet 6:37fb696395d7 115 static int DefineHuffmanTableMarkerAC(char *pbuf, unsigned int *htable, int class_id);
dflet 6:37fb696395d7 116 static int DefineHuffmanTableMarkerDC(char *pbuf, unsigned int *htable, int class_id);
dflet 6:37fb696395d7 117 static int DefineQuantizationTableMarker (unsigned char *pbuf, int qscale, int format);
dflet 6:37fb696395d7 118 static int ScanHeaderMarker(char *pbuf, int format);
dflet 6:37fb696395d7 119 static int FrameHeaderMarker(char *pbuf, int width, int height, int format);
dflet 6:37fb696395d7 120 static int JfifApp0Marker(char *pbuf);
dflet 6:37fb696395d7 121 //#endif
dflet 6:37fb696395d7 122
dflet 0:50cedd586816 123 //*****************************************************************************
dflet 0:50cedd586816 124 //
dflet 0:50cedd586816 125 // Mark the end of the C bindings section for C++ compilers.
dflet 0:50cedd586816 126 //
dflet 0:50cedd586816 127 //*****************************************************************************
dflet 0:50cedd586816 128 #ifdef __cplusplus
dflet 0:50cedd586816 129 }
dflet 0:50cedd586816 130 #endif /* __cplusplus */
dflet 0:50cedd586816 131 #endif /* __CAMERA_APP_H__ */
dflet 0:50cedd586816 132
dflet 0:50cedd586816 133 //*****************************************************************************
dflet 0:50cedd586816 134 //
dflet 0:50cedd586816 135 // Close the Doxygen group.
dflet 0:50cedd586816 136 //! @}
dflet 0:50cedd586816 137 //
dflet 0:50cedd586816 138 //*****************************************************************************
dflet 0:50cedd586816 139