コード例 #1
0
ファイル: pybsd.c プロジェクト: AriZuu/micropython
/// Initalizes the sd card hardware driver
STATIC void pyb_sd_hw_init (pybsd_obj_t *self) {
    if (self->pin_clk) {
        // Configure the clock pin as output only
        MAP_PinDirModeSet(((pin_obj_t *)(self->pin_clk))->pin_num, PIN_DIR_MODE_OUT);
    }
    // Enable SD peripheral clock
    MAP_PRCMPeripheralClkEnable(PRCM_SDHOST, PRCM_RUN_MODE_CLK | PRCM_SLP_MODE_CLK);
    // Reset MMCHS
    MAP_PRCMPeripheralReset(PRCM_SDHOST);
    // Initialize MMCHS
    MAP_SDHostInit(SDHOST_BASE);
    // Configure the card clock
    MAP_SDHostSetExpClk(SDHOST_BASE, MAP_PRCMPeripheralClockGet(PRCM_SDHOST), PYBSD_FREQUENCY_HZ);
    // Set card rd/wr block len
    MAP_SDHostBlockSizeSet(SDHOST_BASE, SD_SECTOR_SIZE);
    self->enabled = true;
}
コード例 #2
0
ファイル: main.c プロジェクト: dlugaz/All
//****************************************************************************
//
//! Main function
//!
//! \param none
//!
//!
//! \return None.
//
//****************************************************************************
void main()
{

    FIL fp;
    FATFS fs;
    FRESULT res;
    DIR dir;
    UINT Size;

    //
    // Initialize Board configurations
    //
    BoardInit();

    //
    // Muxing for Enabling UART_TX and UART_RX.
    //
    PinMuxConfig();

    //
    // Set the SD card clock as output pin
    //
    MAP_PinDirModeSet(PIN_07,PIN_DIR_MODE_OUT);

    //
    // Enable Pull up on data
    //
    MAP_PinConfigSet(PIN_06,PIN_STRENGTH_4MA, PIN_TYPE_STD_PU);

    //
    // Enable Pull up on CMD
    //
    MAP_PinConfigSet(PIN_08,PIN_STRENGTH_4MA, PIN_TYPE_STD_PU);

    //
    // Initialising the Terminal.
    //
    InitTerm();

    //
    // Clearing the Terminal.
    //
    ClearTerm();

    //
    // Display the Banner
    //
    Message("\n\n\n\r");
    Message("\t\t   ********************************************\n\r");
    Message("\t\t        CC3200 SDHost Fatfs Demo Application  \n\r");
    Message("\t\t   ********************************************\n\r");
    Message("\n\n\n\r");

    //
    // Enable MMCHS
    //
    MAP_PRCMPeripheralClkEnable(PRCM_SDHOST,PRCM_RUN_MODE_CLK);

    //
    // Reset MMCHS
    //
    MAP_PRCMPeripheralReset(PRCM_SDHOST);

    //
    // Configure MMCHS
    //
    MAP_SDHostInit(SDHOST_BASE);

    //
    // Configure card clock
    //
    MAP_SDHostSetExpClk(SDHOST_BASE,
                            MAP_PRCMPeripheralClockGet(PRCM_SDHOST),15000000);

    f_mount(&fs,"0",1);
    res = f_opendir(&dir,"/");
    if( res == FR_OK)
    {
        Message("Opening root directory.................... [ok]\n\n\r");
        Message("/\n\r");
        ListDirectory(&dir);
    }
    else
    {
        Message("Opening root directory.................... [Failed]\n\n\r");
    }

    Message("\n\rReading user file...\n\r");
    res = f_open(&fp,USERFILE,FA_READ);
    if(res == FR_OK)
    {
        f_read(&fp,pBuffer,100,&Size);
        Report("Read : %d Bytes\n\n\r",Size);
        Report("%s",pBuffer);
        f_close(&fp);
    }
    else
    {
        Report("Failed to open %s\n\r",USERFILE);
    }

    Message("\n\n\rWriting system file...\n\r");
    res = f_open(&fp,SYSFILE,FA_CREATE_ALWAYS|FA_WRITE);
    if(res == FR_OK)
    {
        f_write(&fp,SYSTEXT,sizeof(SYSTEXT),&Size);
        Report("Wrote : %d Bytes",Size);
        res = f_close(&fp);
    }
    else
    {
        Message("Failed to create a new file\n\r");
    }

    while(1)
    {

    }
}