Added Sparkfun WiFi Shield

Dependencies:   cc3000_hostdriver_mbedsocket mbed

Fork of cc3000_hello_world_demo by Martin Kojtal

Committer:
michaeljkoster
Date:
Tue Oct 14 22:48:10 2014 +0000
Revision:
9:053a5e3e4c06
Parent:
8:f784df013169
Add Adafruit WiFi Shield

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);
michaeljkoster 7:a4e91e42f008 32 #elif (MY_BOARD == SPARKFUN_WIFI_SHIELD)
michaeljkoster 9:053a5e3e4c06 33 cc3000 wifi(D2, D7, D10, SPI(D11, D12, D13), "demo", "ARMDEMO1", WPA2, false); //SparkFun Board on Arduino pin definitions
michaeljkoster 9:053a5e3e4c06 34 Serial pc(USBTX, USBRX);
michaeljkoster 9:053a5e3e4c06 35 #elif (MY_BOARD == ADAFRUIT_WIFI_SHIELD)
michaeljkoster 9:053a5e3e4c06 36 cc3000 wifi(D3, D5, D10, SPI(D11, D12, D13), "demo", "ARMDEMO1", WPA2, false); //SparkFun Board on Arduino pin definitions
michaeljkoster 7:a4e91e42f008 37 Serial pc(USBTX, USBRX);
Kojto 0:db8738fc21e8 38 #endif
Kojto 0:db8738fc21e8 39
Kojto 0:db8738fc21e8 40 /**
Kojto 4:2304a105c87f 41 * \brief Hello World
Kojto 0:db8738fc21e8 42 * \param none
Kojto 0:db8738fc21e8 43 * \return int
Kojto 0:db8738fc21e8 44 */
Kojto 0:db8738fc21e8 45 int main() {
Kojto 0:db8738fc21e8 46 init(); /* board dependent init */
michaeljkoster 7:a4e91e42f008 47 pc.baud(9600);
Kojto 0:db8738fc21e8 48
Kojto 0:db8738fc21e8 49 printf("cc3000 Hello World demo. \r\n");
Kojto 4:2304a105c87f 50 wifi.init();
Kojto 4:2304a105c87f 51 if (wifi.connect() == -1) {
Kojto 4:2304a105c87f 52 printf("Failed to connect. Please verify connection details and try again. \r\n");
Kojto 4:2304a105c87f 53 } else {
Kojto 4:2304a105c87f 54 printf("IP address: %s \r\n",wifi.getIPAddress());
Kojto 4:2304a105c87f 55 printf("\r\ncc3000 connected to the Internet. Demo completed. \r\n");
Kojto 0:db8738fc21e8 56 }
Kojto 1:c3a27e2adf93 57
Kojto 0:db8738fc21e8 58 wifi.disconnect();
Kojto 0:db8738fc21e8 59 }
Kojto 0:db8738fc21e8 60