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

Committer:
mbed_crane_elec
Date:
2019-01-16
Revision:
0:bd47776a2506

File content as of revision 0:bd47776a2506:

#include "mbed.h"
#include "USBMSD_SD.h"
  
//-------------------------------------------------------------------------------
//Port Settings
DigitalOut led1(LED1,1);
DigitalOut led2(P1_13,1);
//DigitalOut USB_CONNECT(P0_6,0);
DigitalIn sw(P1_20);
DigitalIn isp(P0_1);
DigitalOut sd_en(P1_16, 1);//SD card power on/off control port. and ON default.
//DigitalIn sd_dat3(P0_17); // 0x10
//DigitalIn sd_dat2(P1_22); // 0x08
//DigitalIn sd_dat1(P1_14); // 0x04
//DigitalIn sd_dat0(P0_22); // 0x02
//DigitalIn sd_cmd(P0_21);  // 0x01
 
//-------------------------------------------------------------------------------
//
//USBMSD_SD sd(P0_21, P0_22, P1_15, P0_17);

 
//-------------------------------------------------------------------------------
//
int main()
{
    led1 = 1;//OFF
    led2 = 1;//OFF
    wait(0.1);
    
    //Mass storage mode
    if(sw == 0)
    {
        USBMSD_SD *sd = new USBMSD_SD(P0_21, P0_22, P1_15, P0_17);
        //loop
        while(1)
        {
            led2 = 0;
            wait(0.5);
            led2 = 1;
            wait(0.5);
        }
    }

    //Main program
    while(1)
    {
        led1 = 0;
        wait(0.2);
        led1 = 1;
        wait(0.2);
        
        if(sw == 0)
        {
            //
        }
        
        if(isp == 0)
        {
            //
        }
    }
}