2019-08-04 11:42:07 +00:00
|
|
|
#pragma once
|
|
|
|
|
2019-08-06 18:50:11 +00:00
|
|
|
#include <Arduino.h>
|
|
|
|
#include <SPI.h>
|
|
|
|
#include "config.h"
|
|
|
|
|
2019-08-04 11:42:07 +00:00
|
|
|
class SPIMaster {
|
|
|
|
public:
|
2019-11-11 04:32:41 +00:00
|
|
|
SPIMaster() {
|
2019-11-10 13:45:33 +00:00
|
|
|
PIN_SD_CS_SETUP();
|
|
|
|
PIN_VS1053_XCS_SETUP();
|
|
|
|
PIN_VS1053_XDCS_SETUP();
|
|
|
|
PIN_RC522_CS_SETUP();
|
|
|
|
disable();
|
2019-08-04 11:42:07 +00:00
|
|
|
}
|
2019-08-11 15:15:22 +00:00
|
|
|
|
2019-11-10 13:45:33 +00:00
|
|
|
void select_sd(bool enabled=true) {
|
|
|
|
PIN_SD_CS(enabled ? LOW : HIGH);
|
|
|
|
delayMicroseconds(MCP_SPI_SETTING_DELAY);
|
2019-08-04 11:42:07 +00:00
|
|
|
}
|
|
|
|
|
2019-11-10 13:45:33 +00:00
|
|
|
void select_vs1053_xcs(bool enabled=true) {
|
|
|
|
PIN_VS1053_XCS(enabled ? LOW : HIGH);
|
|
|
|
delayMicroseconds(MCP_SPI_SETTING_DELAY);
|
2019-08-04 11:42:07 +00:00
|
|
|
}
|
|
|
|
|
2019-11-10 13:45:33 +00:00
|
|
|
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);
|
2019-08-04 11:42:07 +00:00
|
|
|
}
|
|
|
|
};
|