Fix revb issues (#17)

* Add support for 64M memory
* Fix startup PIN config issues with GPIO and DMA SPI
* Fixup in BAGpio.pp
* Updates some test files
pull/18/head
Blackaddr Audio 2 years ago committed by GitHub
parent bdf12b14be
commit 631f7da772
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 9
      examples/Tests/DMA_MEM0_test/DMA_MEM0_test.ino
  2. 8
      examples/Tests/DMA_MEM1_test/DMA_MEM1_test.ino
  3. 2
      examples/Tests/TGA_PRO_Basic_Test/TGA_PRO_Basic_Test.ino
  4. 4
      src/BAGpio.h
  5. 19
      src/BAHardware.h
  6. 14
      src/peripherals/BAGpio.cpp
  7. 68
      src/peripherals/BASpiMemory.cpp

@ -28,7 +28,7 @@ using namespace BALibrary;
#define SPI_ADDR_1_SHIFT 8
#define SPI_ADDR_0_MASK 0x0000FF
SPISettings memSettings(20000000, MSBFIRST, SPI_MODE0);
const int cs0pin = 15;
const int cs0pin = SPI0_CS_PIN;
BAGpio gpio; // access to User LED
BASpiMemoryDMA spiMem0(SpiDeviceId::SPI_DEVICE0);
@ -56,10 +56,15 @@ bool compareBuffers16(uint16_t *a, uint16_t *b, size_t numWords)
}
size_t SPI_MAX_ADDR;
;
void setup() {
TGA_PRO_MKII_REV1(); // Declare the version of the TGA Pro you are using.
//TGA_PRO_REVB(x);
//TGA_PRO_REVA(x);
gpio.begin();
Serial.begin(57600);
while (!Serial) { yield(); }
delay(5);

@ -28,7 +28,7 @@ using namespace BALibrary;
#define SPI_ADDR_1_SHIFT 8
#define SPI_ADDR_0_MASK 0x0000FF
SPISettings memSettings(20000000, MSBFIRST, SPI_MODE0);
const int cs0pin = 15;
const int cs0pin = SPI1_CS_PIN;
BAGpio gpio; // access to User LED
BASpiMemoryDMA spiMem1(SpiDeviceId::SPI_DEVICE1);
@ -58,6 +58,12 @@ size_t SPI_MAX_ADDR = 0;
void setup() {
TGA_PRO_MKII_REV1(); // Declare the version of the TGA Pro you are using.
//TGA_PRO_REVB(x);
//TGA_PRO_REVA(x);
gpio.begin();
Serial.begin(57600);
while (!Serial) { yield(); }
delay(5);

@ -90,6 +90,8 @@ void setup() {
//TGA_PRO_REVB(x);
//TGA_PRO_REVA(x);
gpio.begin();
Serial.begin(57600);
//while (!Serial) { yield(); }
delay(500);

@ -38,6 +38,10 @@ public:
/// Construct a GPIO object for controlling the various GPIO and user pins
BAGpio();
virtual ~BAGpio();
/// resets the configuration of the GPIO pins. Call this after to call the
/// hardware config macro. E.g. TGA_PRO_REVB();
void begin();
/// Set the direction of the specified GPIO pin.
/// @param gpioId Specify a GPIO pin such as GPIO::GPIO0

@ -61,7 +61,8 @@ enum class ExpansionBoard : unsigned {
enum class SpiMemorySize : unsigned {
NO_MEMORY = 0, ///< default, indicates no SPI memory installed
MEM_1M, ///< indicates 1Mbit memory is installed
MEM_4M ///< indicates 4Mbit memory is installed
MEM_4M, ///< indicates 4Mbit memory is installed
MEM_64M ///< indicates 64Mbit memory is installed
};
constexpr unsigned NUM_MEM_SLOTS = 2; ///< The TGA Pro has two SPI ports for memory
@ -81,6 +82,12 @@ struct SpiMemoryDefinition {
size_t DIE_BOUNDARY;
};
/// Settings for 64Mbit SPI MEM
constexpr SpiMemoryDefinition SPI_MEMORY_64M = {
.MEM_SIZE_BYTES = 8388608,
.DIE_BOUNDARY = 0
};
/// Settings for 4Mbit SPI MEM
constexpr SpiMemoryDefinition SPI_MEMORY_4M = {
.MEM_SIZE_BYTES = 524288,
@ -201,10 +208,12 @@ extern BAHardware BAHardwareConfig; ///< external definition of global configura
#define TGA_PRO_EXPAND_REV2(x) BALibrary::BAHardwareConfig.setExpansionBoard(ExpansionBoard::REV_2) ///< Macro for specifying REV 2 of the Expansion Board
#define TGA_PRO_EXPAND_REV3(x) BALibrary::BAHardwareConfig.setExpansionBoard(ExpansionBoard::REV_3) ///< Macro for specifying REV 2 of the Expansion Board
#define SPI_MEM0_1M(x) BALibrary::BAHardwareConfig.set(MEM0, SPI_MEMORY_1M) ///< Macro for specifying MEM0 is 1Mbit
#define SPI_MEM0_4M(x) BALibrary::BAHardwareConfig.set(MEM0, SPI_MEMORY_4M) ///< Macro for specifying MEM1 is 4Mbit
#define SPI_MEM1_1M(x) BALibrary::BAHardwareConfig.set(MEM1, SPI_MEMORY_1M) ///< Macro for specifying MEM0 is 1Mbit
#define SPI_MEM1_4M(x) BALibrary::BAHardwareConfig.set(MEM1, SPI_MEMORY_4M) ///< Macro for specifying MEM1 is 1Mbit
#define SPI_MEM0_1M(x) BALibrary::BAHardwareConfig.set(MEM0, SPI_MEMORY_1M) ///< Macro for specifying MEM0 is 1Mbit
#define SPI_MEM0_4M(x) BALibrary::BAHardwareConfig.set(MEM0, SPI_MEMORY_4M) ///< Macro for specifying MEM0 is 4Mbit
#define SPI_MEM0_64M(x) BALibrary::BAHardwareConfig.set(MEM0, SPI_MEMORY_64M) ///< Macro for specifying MEM0 is 64Mbit
#define SPI_MEM1_1M(x) BALibrary::BAHardwareConfig.set(MEM1, SPI_MEMORY_1M) ///< Macro for specifying MEM1 is 1Mbit
#define SPI_MEM1_4M(x) BALibrary::BAHardwareConfig.set(MEM1, SPI_MEMORY_4M) ///< Macro for specifying MEM1 is 4Mbit
#define SPI_MEM1_64M(x) BALibrary::BAHardwareConfig.set(MEM1, SPI_MEMORY_64M) ///< Macro for specifying MEM1 is 64Mbit
extern uint8_t USR_LED_ID; ///< Teensy IO number for the user LED.

@ -24,6 +24,15 @@
namespace BALibrary {
BAGpio::BAGpio()
{
}
BAGpio::~BAGpio()
{
}
void BAGpio::begin()
{
// Set all GPIOs to input
pinMode(GPIO0, INPUT);
@ -40,11 +49,6 @@ BAGpio::BAGpio()
// Set the LED to ouput
pinMode(USR_LED_ID, OUTPUT);
clearLed(); // turn off the LED
}
BAGpio::~BAGpio()
{
}
void BAGpio::setGPIODirection(GPIO gpioId, int direction)

@ -364,52 +364,15 @@ void BASpiMemory::m_rawRead16(size_t address, uint16_t *dest, size_t numWords)
BASpiMemoryDMA::BASpiMemoryDMA(SpiDeviceId memDeviceId)
: BASpiMemory(memDeviceId)
{
int cs;
switch (memDeviceId) {
case SpiDeviceId::SPI_DEVICE0 :
cs = SPI0_CS_PIN;
m_cs = new ActiveLowChipSelect(cs, m_settings);
break;
#if defined(__MK66FX1M0__)
case SpiDeviceId::SPI_DEVICE1 :
cs = SPI1_CS_PIN;
m_cs = new ActiveLowChipSelect1(cs, m_settings);
break;
#endif
default :
cs = SPI0_CS_PIN;
}
// add 4 bytes to buffer for SPI CMD and 3 bytes of address
m_txCommandBuffer = new uint8_t[CMD_ADDRESS_SIZE];
m_rxCommandBuffer = new uint8_t[CMD_ADDRESS_SIZE];
m_txTransfer = new DmaSpi::Transfer[2];
m_rxTransfer = new DmaSpi::Transfer[2];
m_memDeviceId = memDeviceId;
m_settings = {20000000, MSBFIRST, SPI_MODE0};
}
BASpiMemoryDMA::BASpiMemoryDMA(SpiDeviceId memDeviceId, uint32_t speedHz)
: BASpiMemory(memDeviceId, speedHz)
{
int cs;
switch (memDeviceId) {
case SpiDeviceId::SPI_DEVICE0 :
cs = SPI0_CS_PIN;
m_cs = new ActiveLowChipSelect(cs, m_settings);
break;
#if defined(__MK66FX1M0__)
case SpiDeviceId::SPI_DEVICE1 :
cs = SPI1_CS_PIN;
m_cs = new ActiveLowChipSelect1(cs, m_settings);
break;
#endif
default :
cs = SPI0_CS_PIN;
}
m_txCommandBuffer = new uint8_t[CMD_ADDRESS_SIZE];
m_rxCommandBuffer = new uint8_t[CMD_ADDRESS_SIZE];
m_txTransfer = new DmaSpi::Transfer[2];
m_rxTransfer = new DmaSpi::Transfer[2];
m_memDeviceId = memDeviceId;
m_settings = {20000000, MSBFIRST, SPI_MODE0};
}
BASpiMemoryDMA::~BASpiMemoryDMA()
@ -431,6 +394,29 @@ void BASpiMemoryDMA::m_setSpiCmdAddr(int command, size_t address, uint8_t *dest)
void BASpiMemoryDMA::begin(void)
{
int cs;
switch (m_memDeviceId) {
case SpiDeviceId::SPI_DEVICE0 :
cs = SPI0_CS_PIN;
m_cs = new ActiveLowChipSelect(cs, m_settings);
break;
#if defined(__MK66FX1M0__)
case SpiDeviceId::SPI_DEVICE1 :
cs = SPI1_CS_PIN;
m_cs = new ActiveLowChipSelect1(cs, m_settings);
break;
#endif
default :
cs = SPI0_CS_PIN;
}
// add 4 bytes to buffer for SPI CMD and 3 bytes of address
m_txCommandBuffer = new uint8_t[CMD_ADDRESS_SIZE];
m_rxCommandBuffer = new uint8_t[CMD_ADDRESS_SIZE];
m_txTransfer = new DmaSpi::Transfer[2];
m_rxTransfer = new DmaSpi::Transfer[2];
switch (m_memDeviceId) {
case SpiDeviceId::SPI_DEVICE0 :
m_csPin = SPI0_CS_PIN;

Loading…
Cancel
Save