some refactoring,
minor code changes added a small class for SNESController reading
This commit is contained in:
20
io/GPIO.h
20
io/GPIO.h
@@ -177,10 +177,28 @@
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
#elif TEENSY
|
||||
|
||||
struct MyGPIO {
|
||||
|
||||
public:
|
||||
|
||||
static void setOutput(uint8_t pin) {pinMode(pin, OUTPUT);}
|
||||
|
||||
static void setInput(uint8_t pin) {pinMode(pin, INPUT);}
|
||||
|
||||
static void clear(uint8_t pin) {digitalWriteFast(pin, 0);}
|
||||
|
||||
static void set(uint8_t pin) {digitalWriteFast(pin, 1);}
|
||||
|
||||
static uint8_t get(uint8_t pin) {return digitalReadFast(pin);}
|
||||
|
||||
};
|
||||
|
||||
#else
|
||||
|
||||
#error "unsupported platform";
|
||||
#error "GPIO: unsupported platform";
|
||||
|
||||
#endif
|
||||
|
||||
|
||||
@@ -17,7 +17,7 @@
|
||||
template <int PIN_NUM_MISO, int PIN_NUM_MOSI, int PIN_NUM_CLK> class HardSPI {
|
||||
//class HardSPI {
|
||||
|
||||
static constexpr int MAX_LEN = 4000;
|
||||
static constexpr int MAX_LEN = 8192;
|
||||
|
||||
spi_device_handle_t spi;
|
||||
|
||||
@@ -57,7 +57,7 @@ private:
|
||||
|
||||
// DEVICE specific options
|
||||
memset(&devcfg, 0, sizeof(devcfg));
|
||||
devcfg.clock_speed_hz = 10 * 1000 * 1000;
|
||||
devcfg.clock_speed_hz = 20 * 1000 * 1000; // IMPORTANT!
|
||||
devcfg.mode = 0;
|
||||
devcfg.spics_io_num = -1;//PIN_NUM_CS; // currently not used
|
||||
devcfg.queue_size = 2;
|
||||
@@ -104,6 +104,7 @@ public:
|
||||
|
||||
}
|
||||
|
||||
|
||||
void read(uint8_t* dst, size_t len) {
|
||||
|
||||
// sanity check
|
||||
|
||||
11
io/I2S.h
11
io/I2S.h
@@ -28,13 +28,16 @@ public:
|
||||
cfg.mode = static_cast<i2s_mode_t>(I2S_MODE_MASTER | I2S_MODE_TX);
|
||||
#endif
|
||||
|
||||
cfg.dma_buf_count = 6;
|
||||
// cfg.dma_buf_count = 6;
|
||||
// cfg.dma_buf_len = 128;
|
||||
|
||||
cfg.dma_buf_count = 16;
|
||||
cfg.dma_buf_len = 128;
|
||||
|
||||
cfg.sample_rate = 44100;
|
||||
cfg.bits_per_sample = I2S_BITS_PER_SAMPLE_16BIT;
|
||||
cfg.channel_format = I2S_CHANNEL_FMT_RIGHT_LEFT; //2-channels
|
||||
cfg.communication_format = I2S_COMM_FORMAT_I2S_MSB;
|
||||
cfg.communication_format = I2S_COMM_FORMAT_STAND_I2S;//I2S_COMM_FORMAT_I2S_MSB;
|
||||
|
||||
|
||||
cfg.intr_alloc_flags = 0; //Default interrupt priority
|
||||
@@ -72,9 +75,9 @@ public:
|
||||
}
|
||||
|
||||
/** add the given samples for playback. returns the number of added samples, which might be less in case of timeouts */
|
||||
size_t add(const uint8_t* data, const size_t len) {
|
||||
size_t add(const uint8_t* data, const size_t len_bytes) {
|
||||
size_t written;
|
||||
i2s_write(port, data, len, &written, portMAX_DELAY);
|
||||
i2s_write(port, data, len_bytes, &written, portMAX_DELAY);
|
||||
return written;
|
||||
}
|
||||
|
||||
|
||||
@@ -88,7 +88,7 @@ public:
|
||||
writeByte((word>>0)&0xFF);
|
||||
}
|
||||
|
||||
void IRAM_ATTR writeByte(uint8_t byte) {
|
||||
inline void IRAM_ATTR writeByte(uint8_t byte) {
|
||||
writeBit(byte & BIT( 7));
|
||||
writeBit(byte & BIT( 6));
|
||||
writeBit(byte & BIT( 5));
|
||||
|
||||
Reference in New Issue
Block a user