cc3000 hello world demo

Dependencies:   NVIC_set_all_priorities cc3000_hostdriver_mbedsocket mbed-src mbed-rtos

Fork of cc3000_hello_world_demo by Martin Kojtal

Committer:
vpcola
Date:
Thu Oct 16 13:22:12 2014 +0000
Revision:
8:71a0638eaa90
Parent:
4:2304a105c87f
Added SparkFun's CC3000 wifi sheild;

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"
Kojto 0:db8738fc21e8 17 #include "cc3000.h"
Kojto 0:db8738fc21e8 18 #include "main.h"
Kojto 0:db8738fc21e8 19
Kojto 0:db8738fc21e8 20 using namespace mbed_cc3000;
Kojto 0:db8738fc21e8 21
Kojto 0:db8738fc21e8 22 /* cc3000 module declaration specific for user's board. Check also init() */
Kojto 0:db8738fc21e8 23 #if (MY_BOARD == WIGO)
Kojto 4:2304a105c87f 24 cc3000 wifi(PTA16, PTA13, PTD0, SPI(PTD2, PTD3, PTC5), "ssid", "key", WPA2, false);
Kojto 0:db8738fc21e8 25 Serial pc(USBTX, USBRX);
Kojto 0:db8738fc21e8 26 #elif (MY_BOARD == WIFI_DIPCORTEX)
Kojto 4:2304a105c87f 27 cc3000 wifi(p28, p27, p30, SPI(p21, p14, p37), "ssid", "key", WPA2, false);
Kojto 0:db8738fc21e8 28 Serial pc(UART_TX, UART_RX);
Kojto 4:2304a105c87f 29 #elif (MY_BOARD == MBED_BOARD_EXAMPLE)
Kojto 4:2304a105c87f 30 cc3000 wifi(p9, p10, p8, SPI(p5, p6, p7), "ssid", "key", WPA2, false);
Kojto 4:2304a105c87f 31 Serial pc(USBTX, USBRX);
vpcola 8:71a0638eaa90 32 #elif (MY_BOARD == SPARK_FUN)
vpcola 8:71a0638eaa90 33 cc3000 wifi(PA_10, PA_8, PB_6, SPI(PA_7, PA_6, PA_5), "ssid", "key", WPA2, false);
vpcola 8:71a0638eaa90 34 Serial pc(USBTX, USBRX);
Kojto 0:db8738fc21e8 35 #else
Kojto 0:db8738fc21e8 36
Kojto 0:db8738fc21e8 37 #endif
Kojto 0:db8738fc21e8 38
Kojto 0:db8738fc21e8 39 /**
Kojto 4:2304a105c87f 40 * \brief Hello World
Kojto 0:db8738fc21e8 41 * \param none
Kojto 0:db8738fc21e8 42 * \return int
Kojto 0:db8738fc21e8 43 */
Kojto 0:db8738fc21e8 44 int main() {
Kojto 0:db8738fc21e8 45 init(); /* board dependent init */
Kojto 0:db8738fc21e8 46 pc.baud(115200);
Kojto 0:db8738fc21e8 47
Kojto 0:db8738fc21e8 48 printf("cc3000 Hello World demo. \r\n");
Kojto 4:2304a105c87f 49 wifi.init();
Kojto 4:2304a105c87f 50 if (wifi.connect() == -1) {
Kojto 4:2304a105c87f 51 printf("Failed to connect. Please verify connection details and try again. \r\n");
Kojto 4:2304a105c87f 52 } else {
Kojto 4:2304a105c87f 53 printf("IP address: %s \r\n",wifi.getIPAddress());
Kojto 4:2304a105c87f 54 printf("\r\ncc3000 connected to the Internet. Demo completed. \r\n");
Kojto 0:db8738fc21e8 55 }
Kojto 1:c3a27e2adf93 56
Kojto 0:db8738fc21e8 57 wifi.disconnect();
Kojto 0:db8738fc21e8 58 }
Kojto 0:db8738fc21e8 59