Trying to just write to the sd card on my board. Can’t get the sd card to init() without error. When I compile and run the following code, the board always lights the red LED.
#include "mbed.h"
#include "platform/mbed_thread.h"
#include "SDBlockDevice.h"
#define HIGH 1
#define LOW 0
//SDBlockDevice sd(D11, D12, D13, D10);
SDBlockDevice sd(MBED_CONF_APP_SD_CARD_MOSI, MBED_CONF_APP_SD_CARD_MISO,
MBED_CONF_APP_SD_CARD_SCK, MBED_CONF_APP_SD_CARD_CS);
DigitalOut led1(LED1);
int main()
{
int ret = sd.init();
switch(ret){
case BD_ERROR_OK:
led1 = LOW;
break;
case BD_ERROR_DEVICE_ERROR:
led1 = HIGH;
break;
}
}
and I have this mbed_app.json
{
"config": {
"update_file": {
"help": "Path to the application update binary on the SD card",
"value": "\"mbed-os-example-blinky_application.bin\""
},
"sd_card_mosi": {
"help": "MCU pin connected to the SD card's SPI MOSI pin",
"value": "D11"
},
"sd_card_miso": {
"help": "MCU pin connected to the SD card's SPI MISO pin",
"value": "D12"
},
"sd_card_sck": {
"help": "MCU pin connected to the SD card's SPI SCK pin",
"value": "D13"
},
"sd_card_cs": {
"help": "MCU pin connected to the SD card's SPI CS pin",
"value": "D10"
}
},
"target_overrides": {
"UBLOX_EVK_ODIN_W2": {
"target.components_add": ["SD"],
"target.restrict_size": "0x40000",
"sd_card_cs": "D9"
}
}
}
Seems like a very simple thing to me and I’m here after a few hours work unable to get this to work!