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