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