#pragma once #include #include #include "config.h" class SPIMaster { public: static void init() { PIN_SD_CS_SETUP(); PIN_VS1053_XCS_SETUP(); PIN_VS1053_XDCS_SETUP(); PIN_RC522_CS_SETUP(); disable(); } static void select_sd(bool enabled=true) { PIN_SD_CS(enabled ? LOW : HIGH); delayMicroseconds(MCP_SPI_SETTING_DELAY); } static void select_vs1053_xcs(bool enabled=true) { PIN_VS1053_XCS(enabled ? LOW : HIGH); delayMicroseconds(MCP_SPI_SETTING_DELAY); } static void select_vs1053_xdcs(bool enabled=true) { PIN_VS1053_XDCS(enabled ? LOW : HIGH); delayMicroseconds(MCP_SPI_SETTING_DELAY); } static void select_rc522(bool enabled=true) { PIN_RC522_CS(enabled ? LOW : HIGH); delayMicroseconds(MCP_SPI_SETTING_DELAY); } static void disable() { PIN_SD_CS(HIGH); PIN_VS1053_XCS(HIGH); PIN_VS1053_XDCS(HIGH); PIN_RC522_CS(HIGH); } };