esmp3/include/spi_master.h

44 lines
857 B
C
Raw Normal View History

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