sdcard.cpp 1.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990
  1. #include "sdcard.h"
  2. extern SdFs SD;
  3. extern FsFile LOG_FILE;
  4. extern uint16_t imageSelect;
  5. // read SD information and print to logfile
  6. void readSDCardInfo()
  7. {
  8. cid_t sd_cid;
  9. if(SD.card()->readCID(&sd_cid))
  10. {
  11. LOG("Sd MID:");
  12. LOG(sd_cid.mid); //,16
  13. LOG(" OID:");
  14. LOG(sd_cid.oid[0]);
  15. LOGN(sd_cid.oid[1]);
  16. LOG("Sd Name:");
  17. LOG(sd_cid.pnm[0]);
  18. LOG(sd_cid.pnm[1]);
  19. LOG(sd_cid.pnm[2]);
  20. LOG(sd_cid.pnm[3]);
  21. LOGN(sd_cid.pnm[4]);
  22. LOG("Sd Date:");
  23. LOG(sd_cid.mdtYear());
  24. LOG("-");
  25. LOGN(sd_cid.mdtMonth());
  26. LOG("Sd Serial:");
  27. LOGN(sd_cid.psn());
  28. }
  29. }
  30. void readSDCardInfo2()
  31. {
  32. cid_t sd_cid;
  33. if(SD.card()->readCID(&sd_cid))
  34. {
  35. LOG_FILE.print("Sd MID:");
  36. LOG_FILE.print(sd_cid.mid, 16);
  37. LOG_FILE.print(" OID:");
  38. LOG_FILE.print(sd_cid.oid[0]);
  39. LOG_FILE.println(sd_cid.oid[1]);
  40. LOG_FILE.print("Sd Name:");
  41. LOG_FILE.print(sd_cid.pnm[0]);
  42. LOG_FILE.print(sd_cid.pnm[1]);
  43. LOG_FILE.print(sd_cid.pnm[2]);
  44. LOG_FILE.print(sd_cid.pnm[3]);
  45. LOG_FILE.println(sd_cid.pnm[4]);
  46. LOG_FILE.print("Sd Date:");
  47. LOG_FILE.print(sd_cid.mdtMonth());
  48. LOG_FILE.println(sd_cid.mdtYear());
  49. LOG_FILE.print("Sd Serial:");
  50. LOG_FILE.println(sd_cid.psn());
  51. LOG_FILE.sync();
  52. }
  53. }
  54. void sdCardInsert(void){
  55. if (digitalRead(BOARD_SDCARD_INSERT)){
  56. LED2_OFF();
  57. }else{
  58. LED2_ON();
  59. }
  60. }
  61. void switchImage(void){
  62. uint8_t oldimageSelect = imageSelect;
  63. imageSelect = (~(digitalRead(BOARD_SWITCH1_PIN) |
  64. digitalRead(BOARD_SWITCH2_PIN) << 1 |
  65. digitalRead(BOARD_SWITCH3_PIN) << 2 |
  66. digitalRead(BOARD_SWITCH4_PIN) << 3)) & 0x0F;
  67. if ( oldimageSelect!=imageSelect){
  68. LOG("Image: ");
  69. LOGN(imageSelect);
  70. }
  71. }