TI's CC3100 websocket camera demo with Arducam mini ov5642 and freertos. Should work with other M3's. Work in progress test demo.

Dependencies:   mbed

Embed: (wiki syntax)

« Back to documentation index

Show/hide line numbers camera_app.h Source File

camera_app.h

00001 //*****************************************************************************
00002 // camera_app.h
00003 //
00004 // camera application macro & API's prototypes
00005 //
00006 // Copyright (C) 2014 Texas Instruments Incorporated - http://www.ti.com/ 
00007 // 
00008 // 
00009 //  Redistribution and use in source and binary forms, with or without 
00010 //  modification, are permitted provided that the following conditions 
00011 //  are met:
00012 //
00013 //    Redistributions of source code must retain the above copyright 
00014 //    notice, this list of conditions and the following disclaimer.
00015 //
00016 //    Redistributions in binary form must reproduce the above copyright
00017 //    notice, this list of conditions and the following disclaimer in the 
00018 //    documentation and/or other materials provided with the   
00019 //    distribution.
00020 //
00021 //    Neither the name of Texas Instruments Incorporated nor the names of
00022 //    its contributors may be used to endorse or promote products derived
00023 //    from this software without specific prior written permission.
00024 //
00025 //  THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 
00026 //  "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 
00027 //  LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
00028 //  A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 
00029 //  OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 
00030 //  SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 
00031 //  LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
00032 //  DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
00033 //  THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 
00034 //  (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 
00035 //  OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
00036 //
00037 //*****************************************************************************
00038 
00039 #ifndef __CAMERA_APP_H__
00040 #define __CAMERA_APP_H__
00041 
00042 //*****************************************************************************
00043 //
00044 // If building with a C++ compiler, make all of the definitions in this header
00045 // have a C binding.
00046 //
00047 //*****************************************************************************
00048 #ifdef __cplusplus
00049 extern "C"
00050 {
00051 #endif /* __cplusplus */
00052 
00053 #define UART_COMMAND_IMG_CAPTURE                    ('x')
00054 #define LOWER_TO_UPPER_CASE                         (32)
00055 
00056 #define DISABLE                           (0)
00057 #define ENABLE                            (1)
00058 #define SL_VERSION_LENGTH                 (11)
00059 
00060 extern int PIXELS_IN_X_AXIS; 
00061 extern int PIXELS_IN_X_AXIS;
00062 extern int FRAME_SIZE_IN_BYTES;
00063 
00064 #define NUM_OF_1KB_BUFFERS      10
00065 
00066 
00067 #define BYTES_PER_PIXEL             (2)       // RGB 565 
00068 
00069 #define ONE_KB                      (1024)
00070 #define IMAGE_BUF_SIZE              (ONE_KB * NUM_OF_1KB_BUFFERS)
00071 
00072 //#define NUM_OF_4B_CHUNKS            ((IMAGE_BUF_SIZE)/(sizeof(unsigned int)))
00073 #define NUM_OF_4B_CHUNKS            ((IMAGE_BUF_SIZE - ONE_KB)/(sizeof(unsigned int)))
00074 #define NUM_OF_1KB_CHUNKS           (IMAGE_BUF_SIZE/ONE_KB)
00075 #define NUM_OF_4B_CHUNKS_IN_1KB     (ONE_KB/(sizeof(unsigned int)))
00076 
00077 #define MAX_EMAIL_ID_LENGTH         34
00078 #define SMTP_BUF_LEN                1024
00079 
00080 //#define CAM_BT_CORRECT_EN   0x00001000
00081 
00082 typedef enum opcd{
00083     START_CAPTURE = 1,
00084     STOP_CAPTURE,
00085     IMG_FMT,
00086     IMG_SIZE,
00087     EXIT
00088 }e_opcode;
00089 
00090 typedef struct cmd_struct{
00091     int    opcode;
00092     char    email_id[MAX_EMAIL_ID_LENGTH];
00093 }s_cmd_struct;
00094 
00095 //******************************************************************************
00096 // APIs
00097 //******************************************************************************
00098 
00099 void getCamId(void);
00100 
00101 unsigned short StartCamera(char **WriteBuffer);
00102 int SetCameraResolution(int width, int height);
00103 void InitCameraComponents(int width, int height);
00104 
00105 static void CamControllerInit(void);
00106 static void CameraIntHandler(void);
00107 uint16_t CaptureImage(char **WriteBuffer);
00108 uint8_t read_fifo_burst(void);
00109 
00110 /****************************************************************************/
00111 /*                      LOCAL FUNCTION PROTOTYPES                           */
00112 /****************************************************************************/
00113 //#ifdef ENABLE_JPEG
00114 static int CreateJpegHeader(char *header, int width, int height,
00115                             int format, int restart_int, int qscale);
00116 static int DefineRestartIntervalMarker(char *pbuf, int ri);
00117 static int DefineHuffmanTableMarkerAC(char *pbuf, unsigned int *htable, int class_id);
00118 static int DefineHuffmanTableMarkerDC(char *pbuf, unsigned int *htable, int class_id);
00119 static int DefineQuantizationTableMarker (unsigned char *pbuf, int qscale, int format);
00120 static int ScanHeaderMarker(char *pbuf, int format);
00121 static int FrameHeaderMarker(char *pbuf, int width, int height, int format);
00122 static int JfifApp0Marker(char *pbuf);
00123 //#endif
00124 
00125 //*****************************************************************************
00126 //
00127 // Mark the end of the C bindings section for C++ compilers.
00128 //
00129 //*****************************************************************************
00130 #ifdef __cplusplus
00131 }
00132 #endif /* __cplusplus */
00133 #endif /* __CAMERA_APP_H__ */
00134 
00135 //*****************************************************************************
00136 //
00137 // Close the Doxygen group.
00138 //! @}
00139 //
00140 //*****************************************************************************
00141 
00142