SparkFun cc3000 on Nucleo F401RE with rtos

Dependencies:   NVIC_set_all_priorities SDFileSystem cc3000_hostdriver_mbedsocket mbed-rtos mbed-src

Fork of CC3000Project by Vergil Cola

Committer:
vpcola
Date:
Thu Oct 16 13:41:56 2014 +0000
Revision:
9:2ba1a5c87e73
Parent:
8:71a0638eaa90
Updated spi access using mutex to prevent contention on the same SPI bus;

Who changed what in which revision?

UserRevisionLine numberNew contents of line
Kojto 0:db8738fc21e8 1 /* mbed Microcontroller Library
Kojto 0:db8738fc21e8 2 * Copyright (c) 2006-2013 ARM Limited
Kojto 0:db8738fc21e8 3 *
Kojto 0:db8738fc21e8 4 * Licensed under the Apache License, Version 2.0 (the "License");
Kojto 0:db8738fc21e8 5 * you may not use this file except in compliance with the License.
Kojto 0:db8738fc21e8 6 * You may obtain a copy of the License at
Kojto 0:db8738fc21e8 7 *
Kojto 0:db8738fc21e8 8 * http://www.apache.org/licenses/LICENSE-2.0
Kojto 0:db8738fc21e8 9 *
Kojto 0:db8738fc21e8 10 * Unless required by applicable law or agreed to in writing, software
Kojto 0:db8738fc21e8 11 * distributed under the License is distributed on an "AS IS" BASIS,
Kojto 0:db8738fc21e8 12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
Kojto 0:db8738fc21e8 13 * See the License for the specific language governing permissions and
Kojto 0:db8738fc21e8 14 * limitations under the License.
Kojto 0:db8738fc21e8 15 */
Kojto 0:db8738fc21e8 16 #include "mbed.h"
vpcola 9:2ba1a5c87e73 17 #include "rtos.h"
Kojto 0:db8738fc21e8 18 #include "cc3000.h"
Kojto 0:db8738fc21e8 19 #include "main.h"
Kojto 0:db8738fc21e8 20
Kojto 0:db8738fc21e8 21 using namespace mbed_cc3000;
Kojto 0:db8738fc21e8 22
Kojto 0:db8738fc21e8 23 /* cc3000 module declaration specific for user's board. Check also init() */
Kojto 0:db8738fc21e8 24 #if (MY_BOARD == WIGO)
Kojto 4:2304a105c87f 25 cc3000 wifi(PTA16, PTA13, PTD0, SPI(PTD2, PTD3, PTC5), "ssid", "key", WPA2, false);
Kojto 0:db8738fc21e8 26 Serial pc(USBTX, USBRX);
Kojto 0:db8738fc21e8 27 #elif (MY_BOARD == WIFI_DIPCORTEX)
Kojto 4:2304a105c87f 28 cc3000 wifi(p28, p27, p30, SPI(p21, p14, p37), "ssid", "key", WPA2, false);
Kojto 0:db8738fc21e8 29 Serial pc(UART_TX, UART_RX);
Kojto 4:2304a105c87f 30 #elif (MY_BOARD == MBED_BOARD_EXAMPLE)
Kojto 4:2304a105c87f 31 cc3000 wifi(p9, p10, p8, SPI(p5, p6, p7), "ssid", "key", WPA2, false);
Kojto 4:2304a105c87f 32 Serial pc(USBTX, USBRX);
vpcola 8:71a0638eaa90 33 #elif (MY_BOARD == SPARK_FUN)
vpcola 9:2ba1a5c87e73 34 Mutex sparkFunMutex;
vpcola 9:2ba1a5c87e73 35 cc3000 wifi(PA_10, PA_8, PB_6, SPI(PA_7, PA_6, PA_5), sparkFunMutex, "ssid", "key", WPA2, false);
vpcola 8:71a0638eaa90 36 Serial pc(USBTX, USBRX);
Kojto 0:db8738fc21e8 37 #else
Kojto 0:db8738fc21e8 38
Kojto 0:db8738fc21e8 39 #endif
Kojto 0:db8738fc21e8 40
Kojto 0:db8738fc21e8 41 /**
Kojto 4:2304a105c87f 42 * \brief Hello World
Kojto 0:db8738fc21e8 43 * \param none
Kojto 0:db8738fc21e8 44 * \return int
Kojto 0:db8738fc21e8 45 */
Kojto 0:db8738fc21e8 46 int main() {
Kojto 0:db8738fc21e8 47 init(); /* board dependent init */
Kojto 0:db8738fc21e8 48 pc.baud(115200);
Kojto 0:db8738fc21e8 49
Kojto 0:db8738fc21e8 50 printf("cc3000 Hello World demo. \r\n");
Kojto 4:2304a105c87f 51 wifi.init();
Kojto 4:2304a105c87f 52 if (wifi.connect() == -1) {
Kojto 4:2304a105c87f 53 printf("Failed to connect. Please verify connection details and try again. \r\n");
Kojto 4:2304a105c87f 54 } else {
Kojto 4:2304a105c87f 55 printf("IP address: %s \r\n",wifi.getIPAddress());
Kojto 4:2304a105c87f 56 printf("\r\ncc3000 connected to the Internet. Demo completed. \r\n");
Kojto 0:db8738fc21e8 57 }
Kojto 1:c3a27e2adf93 58
Kojto 0:db8738fc21e8 59 wifi.disconnect();
Kojto 0:db8738fc21e8 60 }
Kojto 0:db8738fc21e8 61