Преглед на файлове

Merge pull request #35 from facchinm/selectable_port

Dynamically switch SPI port in use
main
Paul Stoffregen преди 8 години
родител
ревизия
f383da63ff
променени са 2 файла, в които са добавени 9 реда и са изтрити 10 реда
  1. +1
    -0
      SerialFlash.h
  2. +8
    -10
      SerialFlashChip.cpp

+ 1
- 0
SerialFlash.h Целия файл

class SerialFlashChip class SerialFlashChip
{ {
public: public:
static bool begin(SPIClass& device, uint8_t pin = 6);
static bool begin(uint8_t pin = 6); static bool begin(uint8_t pin = 6);
static uint32_t capacity(const uint8_t *id); static uint32_t capacity(const uint8_t *id);
static uint32_t blockSize(); static uint32_t blockSize();

+ 8
- 10
SerialFlashChip.cpp Целия файл

#define CSRELEASE() DIRECT_WRITE_HIGH(cspin_basereg, cspin_bitmask) #define CSRELEASE() DIRECT_WRITE_HIGH(cspin_basereg, cspin_bitmask)
#define SPICONFIG SPISettings(50000000, MSBFIRST, SPI_MODE0) #define SPICONFIG SPISettings(50000000, MSBFIRST, SPI_MODE0)


#if defined(__arc__)
// Use SPI1 on Arduino 101 (accesses chip already on the board)
#define SPIPORT SPI1
#elif 0
// Add cases here, if you wish to use other SPI ports...
#else
// Otherwise, use the normal SPI port.
#define SPIPORT SPI
#endif

uint16_t SerialFlashChip::dirindex = 0; uint16_t SerialFlashChip::dirindex = 0;
uint8_t SerialFlashChip::flags = 0; uint8_t SerialFlashChip::flags = 0;
uint8_t SerialFlashChip::busy = 0; uint8_t SerialFlashChip::busy = 0;
static volatile IO_REG_TYPE *cspin_basereg; static volatile IO_REG_TYPE *cspin_basereg;
static IO_REG_TYPE cspin_bitmask; static IO_REG_TYPE cspin_bitmask;


static SPIClass& SPIPORT = SPI;

#define FLAG_32BIT_ADDR 0x01 // larger than 16 MByte address #define FLAG_32BIT_ADDR 0x01 // larger than 16 MByte address
#define FLAG_STATUS_CMD70 0x02 // requires special busy flag check #define FLAG_STATUS_CMD70 0x02 // requires special busy flag check
#define FLAG_DIFF_SUSPEND 0x04 // uses 2 different suspend commands #define FLAG_DIFF_SUSPEND 0x04 // uses 2 different suspend commands
//#define FLAG_DIFF_SUSPEND 0x04 // uses 2 different suspend commands //#define FLAG_DIFF_SUSPEND 0x04 // uses 2 different suspend commands
//#define FLAG_256K_BLOCKS 0x10 // has 256K erase blocks //#define FLAG_256K_BLOCKS 0x10 // has 256K erase blocks


bool SerialFlashChip::begin(SPIClass& device, uint8_t pin)
{
SPIPORT = device;
return begin(pin);
}

bool SerialFlashChip::begin(uint8_t pin) bool SerialFlashChip::begin(uint8_t pin)
{ {
uint8_t id[5]; uint8_t id[5];

Loading…
Отказ
Запис