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

Embed: (wiki syntax)

« Back to documentation index

Show/hide line numbers mt9d111.h Source File

mt9d111.h

00001 #ifndef __MT9D111_H__
00002 #define __MT9D111_H__
00003 
00004 //*****************************************************************************
00005 //
00006 // If building with a C++ compiler, make all of the definitions in this header
00007 // have a C binding.
00008 //
00009 //*****************************************************************************
00010 #ifdef __cplusplus
00011 extern "C"
00012 {
00013 #endif
00014 
00015 #define MT9D111_ID                      0x1519
00016   /* firmware drivers ID */
00017 #define MON_DRV_ID                      0
00018 #define SEQ_DRV_ID                      1
00019 #define AE_DRV_ID                       2
00020 #define AWB_DRV_ID                      3
00021 #define FD_DRV_ID                       4
00022 #define AF_DRV_ID                       5
00023 #define AFM_DRV_ID                      6
00024 #define MODE_DRV_ID                     7
00025   
00026   /* Monitor driver variables */
00027 #define MON_VER_OFFSET                  12
00028   
00029   /* Sequencer driver variables */
00030 #define SEQ_MODE_OFFSET                 2
00031 #define SEQ_STATE_OFFSET                4
00032   
00033   /* Sequencer Driver states */
00034 #define SEQ_STATE_INIT                  0
00035 #define SEQ_STATE_TO_PREVIEW            1
00036 #define SEQ_STATE_ENTER_PREVIEW         2
00037 #define SEQ_STATE_PREVIEW               3
00038 #define SEQ_STATE_LEAVE_PREVIEW         4
00039 #define SEQ_STATE_TO_CAPTURE            5
00040 #define SEQ_STATE_ENTER_CAPTURE         6
00041 #define SEQ_STATE_CAPTURE               7
00042 #define SEQ_STATE_LEAVE_CAPTURE         8
00043 #define SEQ_STATE_STANDBY               9
00044 
00045 /* pages */
00046 #define PAGE_SENSOR_CORE                0
00047 #define PAGE_IFP1                       1
00048 #define PAGE_IFP2                       2
00049 
00050 #define REG_PAGE                        0xF0
00051 #define REG_VAR_ADDR                    0xC6
00052 #define REG_VAR_DATA                    0xC8 
00053 
00054 /* Bits for Microcontroller variable access using logic address */
00055 #define VAR_LENGTH_16BIT                0
00056 #define VAR_LENGTH_8BIT                 1
00057 #define VAR_LENGTH_SHIFT                15
00058 #define VAR_ADDRESS_TYPE_LOGIC          1
00059 #define VAR_ADDRESS_TYPE_SHIFT          13
00060 #define VAR_DRV_ID_SHIFT                8
00061 #define VAR_ADDRESS_SHIFT               0
00062 
00063 typedef struct MT9D111RegLst
00064 {
00065     unsigned char ucPageAddr;
00066     unsigned char ucRegAddr;
00067     unsigned short usValue;
00068 } s_RegList;
00069 
00070 void getCamId(void);
00071 static int wait_for_seq_state(int state);
00072 static uint16_t read_firmware_var(int id, int offset, int byte);
00073 int Start_still_capture(int frames);
00074 int Stop_still_capture(void);
00075 int cam_power_on(void);
00076 int cam_power_off(void);
00077 void cam_exit_standby(void);
00078 void cam_enter_standby(void);
00079 
00080 /*!
00081     \brief                      This function initilizes the camera sensor
00082 
00083     \param[in]                  None
00084 
00085     \return                     0 - Success
00086                                -1 - Error
00087 
00088     \note
00089     \warning
00090 */
00091 int CameraSensorInit();
00092 
00093 /*!
00094     \brief                      Configures sensor in JPEG mode
00095 
00096     \param[in]                  None
00097 
00098     \return                     0 - Success
00099                                -1 - Error
00100 
00101     \note
00102     \warning
00103 */
00104 int StartSensorInJpegMode(int width, int height);
00105 int StartCaptureCmd(void);
00106 int CameraSensorResolution(int width, int height);
00107 static int RegLstWrite(s_RegList *pRegLst, unsigned int ulNofItems);
00108 //*****************************************************************************
00109 //
00110 // Mark the end of the C bindings section for C++ compilers.
00111 //
00112 //*****************************************************************************
00113 #ifdef __cplusplus
00114 }
00115 #endif
00116 
00117 
00118 #endif //__MT9D111_H__
00119 
00120