I definitely wouldn't use NETDUINO_PLUS_2. You're much better off to use feature related constants.gradoj wrote:The sdcard power on and off are working now and probably were the whole time. I was using the usb connector as ground and it's not grounded![]()
https://github.com/gradoj/micropython
I have created a branch but I haven't got the compile options proper yet. I can wrap the power pin as you suggested but what should I do with the SPI/SDIO difference? I was thinking of creating MICROPY_HW_HAS_SDCARD_SPI and MICROPY_HW_HAS_SDCARD_SDIO but the MICROPY_HW_HAS_SDCARD is used in lots of places where the code is required for both spi and sdio. Would it make sense to just use the NETDUINO_PLUS_2? The cleanest would be to have a sdcard_sdio.c and sdcard_spi.c which both include the same sdcard.h and handle it through the makefile somehow. The code is going to get difficult to read with so many compile switches. Suggestions?
So I would use MICROPY_HW_HAS_SDCARD as a master switch. It should control common stuff for an sdcard that's not related to the protocol to talk to the card and use MICROPY_HW_HAS_SDCARD_SDIO and MICROPY_HW_HAS_SDCARD_SPI (as you suggested) to control the protocol specific portions.
The NETDUINO_PLUS_2/mpconfigboard.h file should define MICROPY_HW_HAS_ SDCARD and also define MICROPY_HW_HAS_SDCARD_SPI plus whatever other things are needed (like the card detect pin, the power pin, which SPI bus, etc).
If you want to create separate files, then you would need to have the options go into a makefile, like the way its done for unix/mpconfigport.mk Then the Makefile can determine which files to pull in, and can also add the -D options to the compile so that the options get into the C world.