Intermediary commit. Nothing's working, everything is broken. Let's start over now...
This commit is contained in:
@ -1,13 +1,15 @@
|
||||
#pragma once
|
||||
|
||||
#include "player.h"
|
||||
#include "sd_card.h"
|
||||
|
||||
class Controller {
|
||||
private:
|
||||
Player* _player;
|
||||
SDCard* _sd_card;
|
||||
|
||||
public:
|
||||
Controller(Player* p) : _player(p) {}
|
||||
Controller(Player* p, SDCard* c) : _player(p), _sd_card(c) {}
|
||||
void vol_up();
|
||||
void vol_down();
|
||||
void track_next();
|
||||
|
@ -1,7 +1,27 @@
|
||||
#pragma once
|
||||
#include "sd_card.h"
|
||||
#include "config.h"
|
||||
|
||||
#define SCI_MODE 0x00
|
||||
#define SCI_STATUS 0x01
|
||||
#define SCI_CLOCKF 0x03
|
||||
|
||||
#define CMD_WRITE 0x02
|
||||
#define CMD_READ 0x03
|
||||
|
||||
#define XRESET PIN_VS1053_XRESET
|
||||
#define DREQ PIN_VS1053_DREQ
|
||||
|
||||
class Player {
|
||||
private:
|
||||
SDCard* _sd_card;
|
||||
void _reset();
|
||||
void _init();
|
||||
void _wait();
|
||||
uint16_t _read_register(uint8_t address, uint32_t spi_speed, uint16_t t);//=SPI_CLOCK_DIV4);
|
||||
void _write_register(uint8_t address, uint16_t value, uint32_t spi_speed);//=SPI_CLOCK_DIV2);
|
||||
public:
|
||||
Player(SDCard* c);
|
||||
void vol_up();
|
||||
void vol_down();
|
||||
void track_next();
|
||||
|
8
include/sd_card.h
Normal file
8
include/sd_card.h
Normal file
@ -0,0 +1,8 @@
|
||||
#pragma once
|
||||
#include <SD.h>
|
||||
#include "config.h"
|
||||
|
||||
class SDCard {
|
||||
public:
|
||||
SDCard();
|
||||
};
|
27
include/spi_master.h
Normal file
27
include/spi_master.h
Normal file
@ -0,0 +1,27 @@
|
||||
#pragma once
|
||||
|
||||
class SPIMaster {
|
||||
public:
|
||||
static void init() {
|
||||
SPI.setHwCs(false);
|
||||
pinMode(PIN_SD_CS, OUTPUT);
|
||||
pinMode(PIN_VS1053_XCS, OUTPUT);
|
||||
pinMode(PIN_VS1053_XDCS, OUTPUT);
|
||||
}
|
||||
static void enable(uint8_t pin) {
|
||||
digitalWrite(PIN_SD_CS, pin==PIN_SD_CS ? LOW : HIGH);
|
||||
digitalWrite(PIN_VS1053_XCS, pin==PIN_VS1053_XCS ? LOW : HIGH);
|
||||
digitalWrite(PIN_VS1053_XDCS, pin==PIN_VS1053_XDCS ? LOW : HIGH);
|
||||
}
|
||||
|
||||
static void printStatus() {
|
||||
Serial.printf("CS state: SD:%d, VS1053_XCS:%d, VS1053_XDCS:%d\n",
|
||||
digitalRead(PIN_SD_CS),
|
||||
digitalRead(PIN_VS1053_XCS),
|
||||
digitalRead(PIN_VS1053_XDCS));
|
||||
}
|
||||
|
||||
static void disable() {
|
||||
enable(142);
|
||||
}
|
||||
};
|
Reference in New Issue
Block a user