123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104 |
- #include "sdcard.h"
- extern SdFs SD;
- extern FsFile LOG_FILE;
- extern uint16_t imageSelect;
- // read SD information and print to logfile
- void readSDCardInfo()
- {
- cid_t sd_cid;
- if(SD.card()->readCID(&sd_cid))
- {
- Serial.print("Sd MID:");
- Serial.print(sd_cid.mid, 16);
- Serial.print(" OID:");
- Serial.print(sd_cid.oid[0]);
- Serial.println(sd_cid.oid[1]);
- Serial.print("Sd Name:");
- Serial.print(sd_cid.pnm[0]);
- Serial.print(sd_cid.pnm[1]);
- Serial.print(sd_cid.pnm[2]);
- Serial.print(sd_cid.pnm[3]);
- Serial.println(sd_cid.pnm[4]);
- Serial.print("Sd Date:");
- Serial.print(sd_cid.mdt_month);
- Serial.print("/20"); // CID year is 2000 + high/low
- Serial.print(sd_cid.mdt_year_high);
- Serial.println(sd_cid.mdt_year_low);
- Serial.print("Sd Serial:");
- Serial.println(sd_cid.psn);
- }
- }
- void readSDCardInfo2()
- {
- cid_t sd_cid;
- if(SD.card()->readCID(&sd_cid))
- {
- LOG_FILE.print("Sd MID:");
- LOG_FILE.print(sd_cid.mid, 16);
- LOG_FILE.print(" OID:");
- LOG_FILE.print(sd_cid.oid[0]);
- LOG_FILE.println(sd_cid.oid[1]);
- LOG_FILE.print("Sd Name:");
- LOG_FILE.print(sd_cid.pnm[0]);
- LOG_FILE.print(sd_cid.pnm[1]);
- LOG_FILE.print(sd_cid.pnm[2]);
- LOG_FILE.print(sd_cid.pnm[3]);
- LOG_FILE.println(sd_cid.pnm[4]);
- LOG_FILE.print("Sd Date:");
- LOG_FILE.print(sd_cid.mdt_month);
- LOG_FILE.print("/20"); // CID year is 2000 + high/low
- LOG_FILE.print(sd_cid.mdt_year_high);
- LOG_FILE.println(sd_cid.mdt_year_low);
- LOG_FILE.print("Sd Serial:");
- LOG_FILE.println(sd_cid.psn);
- LOG_FILE.sync();
- }
- }
- /*
- * No SC Card found, blink 5x fast
- */
- void noSDCardFound(void)
- {
- while(!SD.begin(SdSpiConfig(SS, DEDICATED_SPI))) {
- for(int i = 0; i < 5; i++) {
- LED3_ON();
- delay(500);
- LED3_OFF();
- delay(500);
- }
- delay(1000);
- }
- }
- void sdCardInsert(void){
- if (digitalRead(BOARD_SDCARD_INSERT)){
- LED1_OFF();
- }else{
- LED1_ON();
- }
- }
- void switchImage(void){
- uint16_t oldimageSelect = imageSelect;
- imageSelect = digitalRead(BOARD_SWITCH1_PIN) |
- digitalRead(BOARD_SWITCH2_PIN) << 1 |
- digitalRead(BOARD_SWITCH3_PIN) << 2 |
- digitalRead(BOARD_SWITCH4_PIN) << 3;
- if ( oldimageSelect!=imageSelect){
- Serial.print("Image: ");
- Serial.println(15-imageSelect);
- Serial.flush();
- }
- }
|