for Airio-Base. Mass Storage class program for editting FlashAir.
Dependencies: mbed USBMSD_SD USBDevice
Airio-Baseをマスストレージクラスにし、簡易的なSDカードリーダにすることでFlashAir(等SDカード)内のファイルをPCから読み書きするためのサンプルコードです。
準備
- SDカードコネクタにFlashAirを装着しておく
SWスイッチ動作
SWを押しながらPCへ接続、もしくはSWを押しながらRESET押下するとPC側からはSDカードリーダーライタとして認識します。 リーダーライタモードにならなかった場合は、Airio-BaseのLED1点滅が点滅動作します。
ISPスイッチ動作
特にありません。
main.cpp@0:bd47776a2506, 2019-01-16 (annotated)
- Committer:
- mbed_crane_elec
- Date:
- Wed Jan 16 10:59:04 2019 +0000
- Revision:
- 0:bd47776a2506
1st release.
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
mbed_crane_elec | 0:bd47776a2506 | 1 | #include "mbed.h" |
mbed_crane_elec | 0:bd47776a2506 | 2 | #include "USBMSD_SD.h" |
mbed_crane_elec | 0:bd47776a2506 | 3 | |
mbed_crane_elec | 0:bd47776a2506 | 4 | //------------------------------------------------------------------------------- |
mbed_crane_elec | 0:bd47776a2506 | 5 | //Port Settings |
mbed_crane_elec | 0:bd47776a2506 | 6 | DigitalOut led1(LED1,1); |
mbed_crane_elec | 0:bd47776a2506 | 7 | DigitalOut led2(P1_13,1); |
mbed_crane_elec | 0:bd47776a2506 | 8 | //DigitalOut USB_CONNECT(P0_6,0); |
mbed_crane_elec | 0:bd47776a2506 | 9 | DigitalIn sw(P1_20); |
mbed_crane_elec | 0:bd47776a2506 | 10 | DigitalIn isp(P0_1); |
mbed_crane_elec | 0:bd47776a2506 | 11 | DigitalOut sd_en(P1_16, 1);//SD card power on/off control port. and ON default. |
mbed_crane_elec | 0:bd47776a2506 | 12 | //DigitalIn sd_dat3(P0_17); // 0x10 |
mbed_crane_elec | 0:bd47776a2506 | 13 | //DigitalIn sd_dat2(P1_22); // 0x08 |
mbed_crane_elec | 0:bd47776a2506 | 14 | //DigitalIn sd_dat1(P1_14); // 0x04 |
mbed_crane_elec | 0:bd47776a2506 | 15 | //DigitalIn sd_dat0(P0_22); // 0x02 |
mbed_crane_elec | 0:bd47776a2506 | 16 | //DigitalIn sd_cmd(P0_21); // 0x01 |
mbed_crane_elec | 0:bd47776a2506 | 17 | |
mbed_crane_elec | 0:bd47776a2506 | 18 | //------------------------------------------------------------------------------- |
mbed_crane_elec | 0:bd47776a2506 | 19 | // |
mbed_crane_elec | 0:bd47776a2506 | 20 | //USBMSD_SD sd(P0_21, P0_22, P1_15, P0_17); |
mbed_crane_elec | 0:bd47776a2506 | 21 | |
mbed_crane_elec | 0:bd47776a2506 | 22 | |
mbed_crane_elec | 0:bd47776a2506 | 23 | //------------------------------------------------------------------------------- |
mbed_crane_elec | 0:bd47776a2506 | 24 | // |
mbed_crane_elec | 0:bd47776a2506 | 25 | int main() |
mbed_crane_elec | 0:bd47776a2506 | 26 | { |
mbed_crane_elec | 0:bd47776a2506 | 27 | led1 = 1;//OFF |
mbed_crane_elec | 0:bd47776a2506 | 28 | led2 = 1;//OFF |
mbed_crane_elec | 0:bd47776a2506 | 29 | wait(0.1); |
mbed_crane_elec | 0:bd47776a2506 | 30 | |
mbed_crane_elec | 0:bd47776a2506 | 31 | //Mass storage mode |
mbed_crane_elec | 0:bd47776a2506 | 32 | if(sw == 0) |
mbed_crane_elec | 0:bd47776a2506 | 33 | { |
mbed_crane_elec | 0:bd47776a2506 | 34 | USBMSD_SD *sd = new USBMSD_SD(P0_21, P0_22, P1_15, P0_17); |
mbed_crane_elec | 0:bd47776a2506 | 35 | //loop |
mbed_crane_elec | 0:bd47776a2506 | 36 | while(1) |
mbed_crane_elec | 0:bd47776a2506 | 37 | { |
mbed_crane_elec | 0:bd47776a2506 | 38 | led2 = 0; |
mbed_crane_elec | 0:bd47776a2506 | 39 | wait(0.5); |
mbed_crane_elec | 0:bd47776a2506 | 40 | led2 = 1; |
mbed_crane_elec | 0:bd47776a2506 | 41 | wait(0.5); |
mbed_crane_elec | 0:bd47776a2506 | 42 | } |
mbed_crane_elec | 0:bd47776a2506 | 43 | } |
mbed_crane_elec | 0:bd47776a2506 | 44 | |
mbed_crane_elec | 0:bd47776a2506 | 45 | //Main program |
mbed_crane_elec | 0:bd47776a2506 | 46 | while(1) |
mbed_crane_elec | 0:bd47776a2506 | 47 | { |
mbed_crane_elec | 0:bd47776a2506 | 48 | led1 = 0; |
mbed_crane_elec | 0:bd47776a2506 | 49 | wait(0.2); |
mbed_crane_elec | 0:bd47776a2506 | 50 | led1 = 1; |
mbed_crane_elec | 0:bd47776a2506 | 51 | wait(0.2); |
mbed_crane_elec | 0:bd47776a2506 | 52 | |
mbed_crane_elec | 0:bd47776a2506 | 53 | if(sw == 0) |
mbed_crane_elec | 0:bd47776a2506 | 54 | { |
mbed_crane_elec | 0:bd47776a2506 | 55 | // |
mbed_crane_elec | 0:bd47776a2506 | 56 | } |
mbed_crane_elec | 0:bd47776a2506 | 57 | |
mbed_crane_elec | 0:bd47776a2506 | 58 | if(isp == 0) |
mbed_crane_elec | 0:bd47776a2506 | 59 | { |
mbed_crane_elec | 0:bd47776a2506 | 60 | // |
mbed_crane_elec | 0:bd47776a2506 | 61 | } |
mbed_crane_elec | 0:bd47776a2506 | 62 | } |
mbed_crane_elec | 0:bd47776a2506 | 63 | } |