Temp Fork
Dependencies: MMA8451Q Multi_WS2811 NVIC_set_all_priorities TSI cc3000_hostdriver_mbedsocket mbed
Fork of CubicHand by
Revision 1:587189fb6d87, committed 2014-12-01
- Comitter:
- kalbers
- Date:
- Mon Dec 01 05:43:35 2014 +0000
- Parent:
- 0:5cafe9d0d38b
- Child:
- 2:45b90e8d7d82
- Child:
- 3:5f5d75cba8e1
- Commit message:
- Added more libs and a test program to compile (CC3000 Client program with the glove)
Changed in this revision
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/NVIC_set_all_priorities.lib Mon Dec 01 05:43:35 2014 +0000 @@ -0,0 +1,1 @@ +http://developer.mbed.org/users/frankvnk/code/NVIC_set_all_priorities/#6c8e950d8037
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/init.cpp Mon Dec 01 05:43:35 2014 +0000
@@ -0,0 +1,70 @@
+/* mbed Microcontroller Library
+ * Copyright (c) 2006-2013 ARM Limited
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+#include "main.h"
+#include "mbed.h"
+
+#if (MY_BOARD == WIGO)
+
+#include "NVIC_set_all_priorities.h"
+
+/**
+ * \brief Wi-Go initialization
+ * \param none
+ * \return none
+ */
+void init() {
+ DigitalOut PWR_EN1(PTB2);
+ DigitalOut PWR_EN2(PTB3);
+
+ // Wi-Go set current to 500mA since we're turning on the Wi-Fi
+ PWR_EN1 = 0;
+ PWR_EN2 = 1;
+
+ NVIC_set_all_irq_priorities(0x3);
+ NVIC_SetPriority(SPI0_IRQn, 0x0); // Wi-Fi SPI interrupt must be higher priority than SysTick
+ NVIC_SetPriority(PORTA_IRQn, 0x1);
+ NVIC_SetPriority(SysTick_IRQn, 0x2); // SysTick set to lower priority than Wi-Fi SPI bus interrupt
+ PORTA->PCR[16] |= PORT_PCR_ISF_MASK;
+ PORTA->ISFR |= (1 << 16);
+}
+
+#elif (MY_BOARD == WIFI_DIPCORTEX)
+
+/**
+ * \brief Wifi DipCortex initialization
+ * \param none
+ * \return none
+ */
+void init() {
+ NVIC_SetPriority(SSP1_IRQn, 0x0);
+ NVIC_SetPriority(PIN_INT0_IRQn, 0x1);
+
+ // SysTick set to lower priority than Wi-Fi SPI bus interrupt
+ NVIC_SetPriority(SysTick_IRQn, 0x2);
+}
+
+#else
+
+/**
+ * \brief Place here init routine for your board
+ * \param none
+ * \return none
+ */
+void init() {
+
+}
+
+#endif
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/main.cpp Mon Dec 01 05:43:35 2014 +0000
@@ -0,0 +1,108 @@
+/* mbed Microcontroller Library
+ * Copyright (c) 2006-2013 ARM Limited
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+#include "mbed.h"
+#include "cc3000.h"
+#include "main.h"
+#include "MMA8451Q.h"
+#include "TSISensor.h"
+
+#include "TCPSocketConnection.h"
+#include "TCPSocketServer.h"
+
+using namespace mbed_cc3000;
+
+//#define SSID "wifiisawesome"
+//#define PASSWORD "A915FA24"
+
+#define SSID "CubeNet"
+#define PASSWORD "modelbased"
+
+#define MMA8451_I2C_ADDRESS (0x1d<<1)
+
+/* cc3000 module declaration specific for user's board. Check also init()
+#if (MY_BOARD == WIGO)
+cc3000 wifi(PTA16, PTA13, PTD0, SPI(PTD2, PTD3, PTC5), SSID, PASSWORD, WPA2, false);
+Serial pc(USBTX, USBRX);
+#elif (MY_BOARD == WIFI_DIPCORTEX)
+cc3000 wifi(p28, p27, p30, SPI(p21, p14, p37), SSID, PASSWORD, WPA2, false);
+Serial pc(UART_TX, UART_RX);
+#elif (MY_BOARD == MBED_BOARD_EXAMPLE)
+cc3000 wifi(p9, p10, p8, SPI(p5, p6, p7), SSID, PASSWORD, WPA2, false);
+Serial pc(USBTX, USBRX);
+#else
+
+#endif
+*/
+
+cc3000 wifi(PTD4, PTC9, PTD0, SPI(PTD2, PTD3, PTD1), SSID, PASSWORD, WPA2, false);
+Serial pc(USBTX, USBRX);
+
+MMA8451Q accelerometer(PTE25, PTE24, MMA8451_I2C_ADDRESS);
+TSISensor touchSensor;
+
+/**
+ * \brief TCP client demo
+ * \param none
+ * \return int
+ */
+int main() {
+ float data[4];
+
+ init(); /* board dependent init */
+ pc.baud(115200);
+
+ printf("cc3000 tcp client demo. \r\n");
+ wifi.init();
+ if (wifi.connect() == -1) {
+ printf("Failed to connect. Please verify connection details and try again. \r\n");
+ } else {
+ printf("IP address: %s \r\n", wifi.getIPAddress());
+ }
+
+ const char* ECHO_SERVER_ADDRESS = "192.168.1.33";
+ const int ECHO_SERVER_PORT = 2000;
+
+ TCPSocketConnection socket;
+ while (socket.connect(ECHO_SERVER_ADDRESS, ECHO_SERVER_PORT) < 0) {
+ printf("Unable to connect to (%s) on port (%d) \r\n", ECHO_SERVER_ADDRESS, ECHO_SERVER_PORT);
+ wait(1);
+ }
+ socket.set_blocking(true);
+ printf("Connected!\r\n");
+ char sendb[50];
+ sendb[0] = '$';
+ sendb[1] = 0x0A;
+ sendb[2] = 0x03;
+ sendb[3] = 3;
+ sendb[4] = (sendb[0]+sendb[1]+sendb[2]+sendb[3])%256;
+ sendb[5] = '#';
+ socket.send(sendb, 6);
+ printf("Sent!\r\n");
+ char Buf[100];
+ while(true) {
+ int numReceived = 5;
+ //accelerometer.getAccAllAxis(data);
+ //data[3] = touchSensor.readPercentage();
+ //socket.send_all((char*)data, 4*sizeof(float));
+ //wait(0.2);
+ numReceived = socket.receive(Buf, 99);
+ if(numReceived > 0 && Buf[0] == '$') printf("Accel: %d\r\n", ((int16_t *)Buf)[33]);
+ }
+
+ socket.close();
+ printf("Completed. \r\n");
+ wifi.disconnect();
+}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/main.h Mon Dec 01 05:43:35 2014 +0000 @@ -0,0 +1,28 @@ +/* mbed Microcontroller Library + * Copyright (c) 2006-2013 ARM Limited + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +#ifndef MAIN_H +#define MAIN_H + +#define WIGO 1 +#define WIFI_DIPCORTEX 2 +#define MBED_BOARD_EXAMPLE 3 +#define UNDEFINED 4 + +#define MY_BOARD WIGO + +void init(); + +#endif
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/mbed.bld Mon Dec 01 05:43:35 2014 +0000 @@ -0,0 +1,1 @@ +http://mbed.org/users/mbed_official/code/mbed/builds/4fc01daae5a5 \ No newline at end of file
