sd.py 787 B

12345678910111213141516171819202122232425262728293031323334353637383940414243444546
  1. '''
  2. SD card test for the CC3200 based boards.
  3. '''
  4. from machine import SD
  5. import os
  6. mch = os.uname().machine
  7. if 'LaunchPad' in mch:
  8. sd_pins = ('GP16', 'GP17', 'GP15')
  9. elif 'WiPy' in mch:
  10. sd_pins = ('GP10', 'GP11', 'GP15')
  11. else:
  12. raise Exception('Board not supported!')
  13. sd = SD(pins=sd_pins)
  14. print(sd)
  15. sd.deinit()
  16. print(sd)
  17. sd.init(sd_pins)
  18. print(sd)
  19. sd = SD(0, pins=sd_pins)
  20. sd = SD(id=0, pins=sd_pins)
  21. sd = SD(0, sd_pins)
  22. # check for memory leaks
  23. for i in range(0, 1000):
  24. sd = sd = SD(0, pins=sd_pins)
  25. # next ones should raise
  26. try:
  27. sd = SD(pins=())
  28. except Exception:
  29. print("Exception")
  30. try:
  31. sd = SD(pins=('GP10', 'GP11', 'GP8'))
  32. except Exception:
  33. print("Exception")
  34. try:
  35. sd = SD(pins=('GP10', 'GP11'))
  36. except Exception:
  37. print("Exception")