feat: implementing sd card over hspi
This commit is contained in:
parent
6320ba96e0
commit
cf0d438862
File diff suppressed because it is too large
Load Diff
@ -6,17 +6,9 @@
|
||||
#include <audio/tone_generator.hpp>
|
||||
#include <input/encoder.hpp>
|
||||
|
||||
#ifndef ENCODER_A_PIN
|
||||
#define ENCODER_A_PIN 12
|
||||
#endif
|
||||
|
||||
#ifndef ENCODER_B_PIN
|
||||
#define ENCODER_B_PIN 13
|
||||
#endif
|
||||
|
||||
#ifndef ENTER_BUTTON_PIN
|
||||
#define ENTER_BUTTON_PIN 14
|
||||
#endif
|
||||
#define ENCODER_A_PIN 16
|
||||
#define ENCODER_B_PIN 17
|
||||
#define ENCODER_BUTTON_PIN 27
|
||||
|
||||
namespace Encoder
|
||||
{
|
||||
@ -34,11 +26,11 @@ namespace Encoder
|
||||
|
||||
void init()
|
||||
{
|
||||
pinMode(ENTER_BUTTON_PIN, INPUT);
|
||||
pinMode(ENCODER_BUTTON_PIN, INPUT);
|
||||
pinMode(ENCODER_A_PIN, INPUT);
|
||||
pinMode(ENCODER_B_PIN, INPUT);
|
||||
|
||||
encoder = new Versatile_RotaryEncoder(ENCODER_A_PIN, ENCODER_B_PIN, ENTER_BUTTON_PIN);
|
||||
encoder = new Versatile_RotaryEncoder(ENCODER_A_PIN, ENCODER_B_PIN, ENCODER_BUTTON_PIN);
|
||||
encoder->setHandlePress(handlePress);
|
||||
encoder->setHandlePressRelease(handleRelease);
|
||||
encoder->setHandleRotate(handleRotate);
|
||||
|
||||
46
src/input/sd_card_reader.cpp
Normal file
46
src/input/sd_card_reader.cpp
Normal file
@ -0,0 +1,46 @@
|
||||
#include <SPI.h>
|
||||
#include <SD.h>
|
||||
#include <LittleFS.h>
|
||||
|
||||
#define SD_CS 15
|
||||
#define SD_MOSI 13
|
||||
#define SD_MISO 12
|
||||
#define SD_SCK 14
|
||||
|
||||
namespace SdCardReader
|
||||
{
|
||||
SPIClass spiSD(HSPI);
|
||||
void init()
|
||||
{
|
||||
spiSD.begin(SD_SCK, SD_MISO, SD_MOSI, SD_CS);
|
||||
if (!SD.begin(SD_CS, spiSD))
|
||||
{
|
||||
Serial.println("Card failed, or not present");
|
||||
}
|
||||
uint32_t cardSize = SD.cardSize() / (1024 * 1024);
|
||||
String str = "SDCard Size: " + String(cardSize) + "MB";
|
||||
//Serial.println(str);
|
||||
uint8_t cardType = SD.cardType();
|
||||
if (cardType == CARD_NONE)
|
||||
{
|
||||
Serial.println("No SD card attached");
|
||||
}
|
||||
Serial.print("SD Card Type: ");
|
||||
if (cardType == CARD_MMC)
|
||||
{
|
||||
Serial.println("MMC");
|
||||
}
|
||||
else if (cardType == CARD_SD)
|
||||
{
|
||||
Serial.println("SDSC");
|
||||
}
|
||||
else if (cardType == CARD_SDHC)
|
||||
{
|
||||
Serial.println("SDHC");
|
||||
}
|
||||
else
|
||||
{
|
||||
Serial.println("UNKNOWN");
|
||||
}
|
||||
}
|
||||
}
|
||||
8
src/input/sd_card_reader.hpp
Normal file
8
src/input/sd_card_reader.hpp
Normal file
@ -0,0 +1,8 @@
|
||||
#ifndef DRUMZ_SD_CARD_READER
|
||||
#define DRUMZ_SD_CARD_READER
|
||||
|
||||
namespace SdCardReader {
|
||||
void init();
|
||||
}
|
||||
|
||||
#endif //DRUMZ_SD_CARD_READER
|
||||
@ -3,10 +3,6 @@
|
||||
#define SCREEN_WIDTH 320
|
||||
#define SCREEN_HEIGHT 240
|
||||
|
||||
#define ENCODER_BUTTON_PIN 14;
|
||||
#define ENCODER_A_PIN 12;
|
||||
#define ENCODER_B_PIN 13;
|
||||
|
||||
#define ANALOG_OUTPUT_PIN 25;
|
||||
#define ANALOG_INPUT_PIN 34;
|
||||
|
||||
@ -14,6 +10,7 @@
|
||||
#include <input/encoder.hpp>
|
||||
#include <input/pad_reader.hpp>
|
||||
#include <input/user_input_manager.hpp>
|
||||
#include <input/sd_card_reader.hpp>
|
||||
#include <audio/tone_generator.hpp>
|
||||
#include <tools/file_manager.hpp>
|
||||
|
||||
@ -24,6 +21,7 @@ void setup()
|
||||
Serial.begin(115200);
|
||||
pinMode(ONBOARD_LED_PIN, OUTPUT);
|
||||
|
||||
SdCardReader::init();
|
||||
PadReader::init();
|
||||
Encoder::init();
|
||||
FileManager::init();
|
||||
|
||||
Loading…
Reference in New Issue
Block a user