Sparkfun CC3000 WiFi Shield meets mbed. Supports the following boards: (1)FRDM-KL25Z (KL25Z) (2)ST Nucleo F401RE (STM32F401) (3)ST Nucleo F030R8 (STM32F030) (4)LPCXpresso1549 (LPC1549) (5)Seeduino-Arch-Pro (ARCH_PRO) (6)FRDM-K64F(K64F)

Dependencies:   cc3000_hostdriver_mbedsocket mbed

Fork of Sparkfun_CC3000_WiFi_hello_world_demo by Shigeki KOMATSU

Committer:
xshige
Date:
Wed Sep 03 12:59:55 2014 +0000
Revision:
8:ccc96bfaee23
Parent:
7:e450e59b0cf8
added supporting FRDM-K64F.

Who changed what in which revision?

UserRevisionLine numberNew contents of line
xshige 7:e450e59b0cf8 1 /*
xshige 7:e450e59b0cf8 2 Sparkfun CC3000 WiFi Shield meets mbed!
xshige 7:e450e59b0cf8 3
xshige 7:e450e59b0cf8 4 This program supports the following mbed boards with Sparkfun CC3000 Sheild.
xshige 7:e450e59b0cf8 5 '#define' switches board.(refer to source code)
xshige 7:e450e59b0cf8 6 (1)FRDM-KL25Z (KL25Z)
xshige 7:e450e59b0cf8 7 (2)ST Nucleo F401RE (STM32F401)
xshige 7:e450e59b0cf8 8 (3)ST Nucleo F030R8 (STM32F030)
xshige 7:e450e59b0cf8 9 (4)LPCXpresso1549 (LPC1549)
xshige 7:e450e59b0cf8 10 (5)Seeduino-Arch-Pro (ARCH_PRO)
xshige 8:ccc96bfaee23 11 (6)FRDM-K64F (K64F)
xshige 7:e450e59b0cf8 12
xshige 7:e450e59b0cf8 13 reference:
xshige 7:e450e59b0cf8 14 https://www.sparkfun.com/products/12071 for CC300 Shield
xshige 7:e450e59b0cf8 15
xshige 8:ccc96bfaee23 16 date: 2014/9/3
xshige 8:ccc96bfaee23 17 added supporting K64F by: xshige
xshige 8:ccc96bfaee23 18
xshige 8:ccc96bfaee23 19 date: 2014/8/31
xshige 8:ccc96bfaee23 20 modified by: xshige
xshige 7:e450e59b0cf8 21
xshige 7:e450e59b0cf8 22 #you get sucess when you see the following on the console.
xshige 7:e450e59b0cf8 23 cc3000 Hello World demo.
xshige 7:e450e59b0cf8 24 IP address: 192.168.0.2
xshige 7:e450e59b0cf8 25
xshige 7:e450e59b0cf8 26 cc3000 connected to the Internet. Demo completed.
xshige 7:e450e59b0cf8 27
xshige 7:e450e59b0cf8 28 */
Kojto 0:db8738fc21e8 29 /* mbed Microcontroller Library
Kojto 0:db8738fc21e8 30 * Copyright (c) 2006-2013 ARM Limited
Kojto 0:db8738fc21e8 31 *
Kojto 0:db8738fc21e8 32 * Licensed under the Apache License, Version 2.0 (the "License");
Kojto 0:db8738fc21e8 33 * you may not use this file except in compliance with the License.
Kojto 0:db8738fc21e8 34 * You may obtain a copy of the License at
Kojto 0:db8738fc21e8 35 *
Kojto 0:db8738fc21e8 36 * http://www.apache.org/licenses/LICENSE-2.0
Kojto 0:db8738fc21e8 37 *
Kojto 0:db8738fc21e8 38 * Unless required by applicable law or agreed to in writing, software
Kojto 0:db8738fc21e8 39 * distributed under the License is distributed on an "AS IS" BASIS,
Kojto 0:db8738fc21e8 40 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
Kojto 0:db8738fc21e8 41 * See the License for the specific language governing permissions and
Kojto 0:db8738fc21e8 42 * limitations under the License.
Kojto 0:db8738fc21e8 43 */
Kojto 0:db8738fc21e8 44 #include "mbed.h"
Kojto 0:db8738fc21e8 45 #include "cc3000.h"
xshige 7:e450e59b0cf8 46
xshige 7:e450e59b0cf8 47 // define board you like (KL25Z, LPC1549, STM32F401, STM32F030 ...)
xshige 7:e450e59b0cf8 48 //#define KL25Z
xshige 8:ccc96bfaee23 49 //#define STM32F401
xshige 7:e450e59b0cf8 50 //#define STM32F030
xshige 7:e450e59b0cf8 51 //#define LPC1549
xshige 7:e450e59b0cf8 52 //#define ARCH_PRO
xshige 8:ccc96bfaee23 53 #define K64F
xshige 7:e450e59b0cf8 54
xshige 7:e450e59b0cf8 55 // define SSID, PASSWORD you like
xshige 7:e450e59b0cf8 56 #define SSID "ssid"
xshige 7:e450e59b0cf8 57 #define PASSWORD "password"
Kojto 0:db8738fc21e8 58
Kojto 0:db8738fc21e8 59 using namespace mbed_cc3000;
Kojto 0:db8738fc21e8 60
xshige 7:e450e59b0cf8 61 /* cc3000 module declaration specific for user's board. */
xshige 7:e450e59b0cf8 62 #if defined(KL25Z)
xshige 7:e450e59b0cf8 63 // for KL25Z
xshige 7:e450e59b0cf8 64 cc3000 wifi(PTD4, PTC9, PTD0, SPI(PTD2, PTD3, PTD1), SSID, PASSWORD, WPA2, false);
Kojto 0:db8738fc21e8 65 Serial pc(USBTX, USBRX);
xshige 7:e450e59b0cf8 66 #endif
xshige 7:e450e59b0cf8 67 #if defined(STM32F401)
xshige 7:e450e59b0cf8 68 // for Nucleo STM32F401
xshige 7:e450e59b0cf8 69 cc3000 wifi(PA_10, PA_8, PB_6, SPI(PA_7, PA_6, PA_5), SSID, PASSWORD, WPA2, false);
xshige 7:e450e59b0cf8 70 // for Nucleo STM32F401
xshige 7:e450e59b0cf8 71 Serial pc(SERIAL_TX, SERIAL_RX);
xshige 7:e450e59b0cf8 72 #endif
xshige 7:e450e59b0cf8 73 #if defined(STM32F030)
xshige 7:e450e59b0cf8 74 // for Nucleo STM32F030
xshige 7:e450e59b0cf8 75 cc3000 wifi(PA_10, PA_8, PB_6, SPI(PA_7, PA_6, PA_5), SSID, PASSWORD, WPA2, false);
xshige 7:e450e59b0cf8 76 // for Nucleo STM32F030
xshige 7:e450e59b0cf8 77 Serial pc(SERIAL_TX, SERIAL_RX);
xshige 7:e450e59b0cf8 78 #endif
xshige 7:e450e59b0cf8 79 #if defined(LPC1549)
xshige 7:e450e59b0cf8 80 // for LPC1549
xshige 7:e450e59b0cf8 81 cc3000 wifi(P0_29, P0_0, P0_27, SPI(P0_28, P0_12, P0_16), SSID, PASSWORD, WPA2, false);
Kojto 4:2304a105c87f 82 Serial pc(USBTX, USBRX);
xshige 7:e450e59b0cf8 83 #endif
xshige 7:e450e59b0cf8 84 #if defined(ARCH_PRO)
xshige 7:e450e59b0cf8 85 // for Seeed Studio Arch Pro
xshige 7:e450e59b0cf8 86 cc3000 wifi(P0_4, P2_5, P0_6, SPI(P0_9, P0_8, P0_7), SSID, PASSWORD, WPA2, false);
xshige 7:e450e59b0cf8 87 Serial pc(USBTX, USBRX);
xshige 7:e450e59b0cf8 88 #endif
xshige 8:ccc96bfaee23 89 #if defined(K64F)
xshige 8:ccc96bfaee23 90 // for FRDM-K64F
xshige 8:ccc96bfaee23 91 cc3000 wifi(PTB9, PTC3, PTD0, SPI(PTD2, PTD3, PTD1), SSID, PASSWORD, WPA2, false);
xshige 8:ccc96bfaee23 92 Serial pc(USBTX, USBRX);
xshige 8:ccc96bfaee23 93 #endif
Kojto 0:db8738fc21e8 94
Kojto 0:db8738fc21e8 95
Kojto 0:db8738fc21e8 96 /**
Kojto 4:2304a105c87f 97 * \brief Hello World
Kojto 0:db8738fc21e8 98 * \param none
Kojto 0:db8738fc21e8 99 * \return int
Kojto 0:db8738fc21e8 100 */
Kojto 0:db8738fc21e8 101 int main() {
Kojto 0:db8738fc21e8 102 pc.baud(115200);
Kojto 0:db8738fc21e8 103
Kojto 0:db8738fc21e8 104 printf("cc3000 Hello World demo. \r\n");
Kojto 4:2304a105c87f 105 wifi.init();
Kojto 4:2304a105c87f 106 if (wifi.connect() == -1) {
Kojto 4:2304a105c87f 107 printf("Failed to connect. Please verify connection details and try again. \r\n");
Kojto 4:2304a105c87f 108 } else {
Kojto 4:2304a105c87f 109 printf("IP address: %s \r\n",wifi.getIPAddress());
Kojto 4:2304a105c87f 110 printf("\r\ncc3000 connected to the Internet. Demo completed. \r\n");
Kojto 0:db8738fc21e8 111 }
Kojto 1:c3a27e2adf93 112
Kojto 0:db8738fc21e8 113 wifi.disconnect();
Kojto 0:db8738fc21e8 114 }
Kojto 0:db8738fc21e8 115