TI's CC3100 websocket camera demo with Arducam mini ov5642 and freertos. Should work with other M3's. Work in progress test demo.
cc3100_netcfg.cpp
00001 /* 00002 * netcfg.c - CC31xx/CC32xx Host Driver Implementation 00003 * 00004 * Copyright (C) 2014 Texas Instruments Incorporated - http://www.ti.com/ 00005 * 00006 * 00007 * Redistribution and use in source and binary forms, with or without 00008 * modification, are permitted provided that the following conditions 00009 * are met: 00010 * 00011 * Redistributions of source code must retain the above copyright 00012 * notice, this list of conditions and the following disclaimer. 00013 * 00014 * Redistributions in binary form must reproduce the above copyright 00015 * notice, this list of conditions and the following disclaimer in the 00016 * documentation and/or other materials provided with the 00017 * distribution. 00018 * 00019 * Neither the name of Texas Instruments Incorporated nor the names of 00020 * its contributors may be used to endorse or promote products derived 00021 * from this software without specific prior written permission. 00022 * 00023 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 00024 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 00025 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 00026 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 00027 * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 00028 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 00029 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 00030 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 00031 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 00032 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 00033 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 00034 * 00035 */ 00036 00037 00038 00039 /*****************************************************************************/ 00040 /* Include files */ 00041 /*****************************************************************************/ 00042 #include "cc3100_simplelink.h" 00043 #include "cc3100_protocol.h" 00044 #include "cc3100_driver.h" 00045 00046 #include "cc3100_netcfg.h" 00047 00048 namespace mbed_cc3100 { 00049 00050 cc3100_netcfg::cc3100_netcfg(cc3100_driver &driver) 00051 : _driver(driver) 00052 { 00053 00054 } 00055 00056 cc3100_netcfg::~cc3100_netcfg() 00057 { 00058 00059 } 00060 00061 /*****************************************************************************/ 00062 /* sl_NetCfgSet */ 00063 /*****************************************************************************/ 00064 typedef union { 00065 _NetCfgSetGet_t Cmd; 00066 _BasicResponse_t Rsp; 00067 } _SlNetCfgMsgSet_u; 00068 00069 #if _SL_INCLUDE_FUNC(sl_NetCfgSet) 00070 const _SlCmdCtrl_t _SlNetCfgSetCmdCtrl = { 00071 SL_OPCODE_DEVICE_NETCFG_SET_COMMAND, 00072 sizeof(_NetCfgSetGet_t), 00073 sizeof(_BasicResponse_t) 00074 }; 00075 00076 int32_t cc3100_netcfg::sl_NetCfgSet(const uint8_t ConfigId, const uint8_t ConfigOpt, const uint8_t ConfigLen, const uint8_t *pValues) 00077 { 00078 _SlNetCfgMsgSet_u Msg; 00079 _SlCmdExt_t CmdExt; 00080 00081 _driver._SlDrvResetCmdExt(&CmdExt); 00082 CmdExt.TxPayloadLen = (ConfigLen+3) & (~3); 00083 CmdExt.pTxPayload = (uint8_t *)pValues; 00084 00085 Msg.Cmd.ConfigId = ConfigId; 00086 Msg.Cmd.ConfigLen = ConfigLen; 00087 Msg.Cmd.ConfigOpt = ConfigOpt; 00088 00089 VERIFY_RET_OK(_driver._SlDrvCmdOp((_SlCmdCtrl_t *)&_SlNetCfgSetCmdCtrl, &Msg, &CmdExt)); 00090 00091 return (int16_t)Msg.Rsp.status; 00092 } 00093 #endif 00094 00095 uint32_t cc3100_netcfg::SL_IPV4_VAL(uint8_t add_3,uint8_t add_2,uint8_t add_1,uint8_t add_0){ 00096 00097 return((((uint32_t)add_3 << 24) & 0xFF000000) | (((uint32_t)add_2 << 16) & 0xFF0000) | (((uint32_t)add_1 << 8) & 0xFF00) | ((uint32_t)add_0 & 0xFF) ); 00098 } 00099 00100 uint8_t cc3100_netcfg::SL_IPV4_BYTE(uint32_t val,uint8_t index){ 00101 00102 return( (val >>= (index*8)) & 0xFF ); 00103 } 00104 00105 /*****************************************************************************/ 00106 /* sl_NetCfgGet */ 00107 /*****************************************************************************/ 00108 typedef union { 00109 _NetCfgSetGet_t Cmd; 00110 _NetCfgSetGet_t Rsp; 00111 } _SlNetCfgMsgGet_u; 00112 00113 #if _SL_INCLUDE_FUNC(sl_NetCfgGet) 00114 const _SlCmdCtrl_t _SlNetCfgGetCmdCtrl = { 00115 SL_OPCODE_DEVICE_NETCFG_GET_COMMAND, 00116 sizeof(_NetCfgSetGet_t), 00117 sizeof(_NetCfgSetGet_t) 00118 }; 00119 00120 int32_t cc3100_netcfg::sl_NetCfgGet(const uint8_t ConfigId, uint8_t *pConfigOpt,uint8_t *pConfigLen, uint8_t *pValues) 00121 { 00122 _SlNetCfgMsgGet_u Msg; 00123 _SlCmdExt_t CmdExt; 00124 00125 if (*pConfigLen == 0) { 00126 return SL_EZEROLEN; 00127 } 00128 00129 _driver._SlDrvResetCmdExt(&CmdExt); 00130 CmdExt.RxPayloadLen = *pConfigLen; 00131 CmdExt.pRxPayload = (uint8_t *)pValues; 00132 00133 Msg.Cmd.ConfigLen = *pConfigLen; 00134 Msg.Cmd.ConfigId = ConfigId; 00135 00136 if( pConfigOpt ) { 00137 Msg.Cmd.ConfigOpt = (uint16_t)*pConfigOpt; 00138 } 00139 VERIFY_RET_OK(_driver._SlDrvCmdOp((_SlCmdCtrl_t *)&_SlNetCfgGetCmdCtrl, &Msg, &CmdExt)); 00140 00141 if( pConfigOpt ) { 00142 *pConfigOpt = (uint8_t)Msg.Rsp.ConfigOpt; 00143 } 00144 if (CmdExt.RxPayloadLen < CmdExt.ActualRxPayloadLen) { 00145 *pConfigLen = (uint8_t)CmdExt.RxPayloadLen; 00146 if( SL_MAC_ADDRESS_GET == ConfigId ) 00147 { 00148 return SL_RET_CODE_OK; /* sp fix */ 00149 } 00150 else 00151 { 00152 return SL_ESMALLBUF; 00153 } 00154 } 00155 else 00156 { 00157 *pConfigLen = (uint8_t)CmdExt.ActualRxPayloadLen; 00158 } 00159 00160 return (int16_t)Msg.Rsp.Status; 00161 } 00162 #endif 00163 00164 }//namespace mbed_cc3100
Generated on Wed Jul 13 2022 15:58:45 by 1.7.2