Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/FastLED/FastLED.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSam Guyer <sam.guyer@gmail.com>2020-11-02 20:35:55 +0300
committerSam Guyer <sam.guyer@gmail.com>2020-11-02 20:35:55 +0300
commit26e222e8eda4c91c829dcd22016b8d91b51e48ab (patch)
treee7f6c783e57a43132d5a0f3a2ecfb8f927a063ec /src/platforms/arm/mxrt1062/fastspi_arm_mxrt1062.h
parent2fa8bb41c34eb3fb44786c85bbc6ebd7e031a777 (diff)
parent2fbac71e7b5f98e59f5dd7a472b714c9c882728a (diff)
Merged changes from main FastLED repo (upstream)
Diffstat (limited to 'src/platforms/arm/mxrt1062/fastspi_arm_mxrt1062.h')
-rw-r--r--src/platforms/arm/mxrt1062/fastspi_arm_mxrt1062.h90
1 files changed, 45 insertions, 45 deletions
diff --git a/src/platforms/arm/mxrt1062/fastspi_arm_mxrt1062.h b/src/platforms/arm/mxrt1062/fastspi_arm_mxrt1062.h
index fa6b81ff..068c7be1 100644
--- a/src/platforms/arm/mxrt1062/fastspi_arm_mxrt1062.h
+++ b/src/platforms/arm/mxrt1062/fastspi_arm_mxrt1062.h
@@ -9,18 +9,18 @@ FASTLED_NAMESPACE_BEGIN
template <uint8_t _DATA_PIN, uint8_t _CLOCK_PIN, uint32_t _SPI_CLOCK_RATE, SPIClass & _SPIObject, int _SPI_INDEX>
class Teesy4HardwareSPIOutput {
Selectable *m_pSelect;
- uint32_t m_bitCount;
- uint32_t m_bitData;
- inline IMXRT_LPSPI_t & port() __attribute__((always_inline)) {
- switch(_SPI_INDEX) {
- case 0:
- return IMXRT_LPSPI4_S;
- case 1:
- return IMXRT_LPSPI3_S;
- case 2:
- return IMXRT_LPSPI1_S;
- }
- }
+ uint32_t m_bitCount;
+ uint32_t m_bitData;
+ inline IMXRT_LPSPI_t & port() __attribute__((always_inline)) {
+ switch(_SPI_INDEX) {
+ case 0:
+ return IMXRT_LPSPI4_S;
+ case 1:
+ return IMXRT_LPSPI3_S;
+ case 2:
+ return IMXRT_LPSPI1_S;
+ }
+ }
public:
Teesy4HardwareSPIOutput() { m_pSelect = NULL; m_bitCount = 0;}
@@ -34,42 +34,42 @@ public:
// latch the CS select
void inline select() __attribute__((always_inline)) {
- // begin the SPI transaction
- _SPIObject.beginTransaction(SPISettings(_SPI_CLOCK_RATE, MSBFIRST, SPI_MODE0));
- if(m_pSelect != NULL) { m_pSelect->select(); }
- }
+ // begin the SPI transaction
+ _SPIObject.beginTransaction(SPISettings(_SPI_CLOCK_RATE, MSBFIRST, SPI_MODE0));
+ if(m_pSelect != NULL) { m_pSelect->select(); }
+ }
// release the CS select
void inline release() __attribute__((always_inline)) {
- if(m_pSelect != NULL) { m_pSelect->release(); }
- _SPIObject.endTransaction();
- }
+ if(m_pSelect != NULL) { m_pSelect->release(); }
+ _SPIObject.endTransaction();
+ }
// wait until all queued up data has been written
static void waitFully() { /* TODO */ }
// write a byte out via SPI (returns immediately on writing register) -
void inline writeByte(uint8_t b) __attribute__((always_inline)) {
- if(m_bitCount == 0) {
- _SPIObject.transfer(b);
- } else {
- // There's been a bit of data written, add that to the output as well
- uint32_t outData = (m_bitData << 8) | b;
- uint32_t tcr = port().TCR;
- port().TCR = (tcr & 0xfffff000) | LPSPI_TCR_FRAMESZ((8+m_bitCount) - 1); // turn on 9 bit mode
- port().TDR = outData; // output 9 bit data.
- while ((port().RSR & LPSPI_RSR_RXEMPTY)) ; // wait while the RSR fifo is empty...
+ if(m_bitCount == 0) {
+ _SPIObject.transfer(b);
+ } else {
+ // There's been a bit of data written, add that to the output as well
+ uint32_t outData = (m_bitData << 8) | b;
+ uint32_t tcr = port().TCR;
+ port().TCR = (tcr & 0xfffff000) | LPSPI_TCR_FRAMESZ((8+m_bitCount) - 1); // turn on 9 bit mode
+ port().TDR = outData; // output 9 bit data.
+ while ((port().RSR & LPSPI_RSR_RXEMPTY)) ; // wait while the RSR fifo is empty...
port().TCR = (tcr & 0xfffff000) | LPSPI_TCR_FRAMESZ((8) - 1); // turn back on 8 bit mode
- port().RDR;
- m_bitCount = 0;
- }
- }
+ port().RDR;
+ m_bitCount = 0;
+ }
+ }
// write a word out via SPI (returns immediately on writing register)
void inline writeWord(uint16_t w) __attribute__((always_inline)) {
- writeByte(((w>>8) & 0xFF));
- _SPIObject.transfer(w & 0xFF);
- }
+ writeByte(((w>>8) & 0xFF));
+ _SPIObject.transfer(w & 0xFF);
+ }
// A raw set of writing byte values, assumes setup/init/waiting done elsewhere
static void writeBytesValueRaw(uint8_t value, int len) {
@@ -99,16 +99,16 @@ public:
// write a single bit out, which bit from the passed in byte is determined by template parameter
template <uint8_t BIT> inline void writeBit(uint8_t b) {
- m_bitData = (m_bitData<<1) | ((b&(1<<BIT)) != 0);
- // If this is the 8th bit we've collected, just write it out raw
- register uint32_t bc = m_bitCount;
- bc = (bc + 1) & 0x07;
- if (!bc) {
- m_bitCount = 0;
- _SPIObject.transfer(m_bitData);
- }
- m_bitCount = bc;
- }
+ m_bitData = (m_bitData<<1) | ((b&(1<<BIT)) != 0);
+ // If this is the 8th bit we've collected, just write it out raw
+ register uint32_t bc = m_bitCount;
+ bc = (bc + 1) & 0x07;
+ if (!bc) {
+ m_bitCount = 0;
+ _SPIObject.transfer(m_bitData);
+ }
+ m_bitCount = bc;
+ }
// write a block of uint8_ts out in groups of three. len is the total number of uint8_ts to write out. The template
// parameters indicate how many uint8_ts to skip at the beginning and/or end of each grouping