Skip to content

Commit

Permalink
Move fill uart fifo (#241)
Browse files Browse the repository at this point in the history
* Moved

* Make Esp8266 v2.4.2 compatible

2.5.0beta works fine, but current normal build does not.
  • Loading branch information
Makuna authored Dec 25, 2018
1 parent 8933c30 commit 037d9be
Show file tree
Hide file tree
Showing 4 changed files with 35 additions and 34 deletions.
2 changes: 1 addition & 1 deletion library.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
"type": "git",
"url": "https://github.com/Makuna/NeoPixelBus"
},
"version": "2.4.0",
"version": "2.4.1",
"frameworks": "arduino",
"platforms": "*"
}
Expand Down
2 changes: 1 addition & 1 deletion library.properties
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
name=NeoPixelBus by Makuna
version=2.4.0
version=2.4.1
author=Michael C. Miller ([email protected])
maintainer=Michael C. Miller ([email protected])
sentence=A library that makes controlling NeoPixels (WS2811, WS2812, WS2813 & SK6812) and DotStars (APA102) easy.
Expand Down
33 changes: 30 additions & 3 deletions src/internal/NeoEsp8266UartMethod.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -29,10 +29,37 @@ License along with NeoPixel. If not, see
#include <utility>
extern "C"
{
// #include <eagle_soc.h>
#include <ets_sys.h>
// #include <uart.h>
// #include <uart_register.h>
}

const volatile uint8_t* ICACHE_RAM_ATTR NeoEsp8266UartContext::FillUartFifo(uint8_t uartNum,
const volatile uint8_t* pixels,
const volatile uint8_t* end)
{
// Remember: UARTs send less significant bit (LSB) first so
// pushing ABCDEF byte will generate a 0FEDCBA1 signal,
// including a LOW(0) start & a HIGH(1) stop bits.
// Also, we have configured UART to invert logic levels, so:
const uint8_t _uartData[4] = {
0b110111, // On wire: 1 000 100 0 [Neopixel reads 00]
0b000111, // On wire: 1 000 111 0 [Neopixel reads 01]
0b110100, // On wire: 1 110 100 0 [Neopixel reads 10]
0b000100, // On wire: 1 110 111 0 [NeoPixel reads 11]
};
uint8_t avail = (UART_TX_FIFO_SIZE - GetTxFifoLength(uartNum)) / 4;
if (end - pixels > avail)
{
end = pixels + avail;
}
while (pixels < end)
{
uint8_t subpix = *pixels++;
Enqueue(uartNum, _uartData[(subpix >> 6) & 0x3]);
Enqueue(uartNum, _uartData[(subpix >> 4) & 0x3]);
Enqueue(uartNum, _uartData[(subpix >> 2) & 0x3]);
Enqueue(uartNum, _uartData[subpix & 0x3]);
}
return pixels;
}

volatile NeoEsp8266UartInterruptContext* NeoEsp8266UartInterruptContext::s_uartInteruptContext[] = { nullptr, nullptr };
Expand Down
32 changes: 3 additions & 29 deletions src/internal/NeoEsp8266UartMethod.h
Original file line number Diff line number Diff line change
Expand Up @@ -47,35 +47,9 @@ class NeoEsp8266UartContext
USF(uartNum) = value;
}

static const volatile uint8_t* ICACHE_RAM_ATTR FillUartFifo(uint8_t uartNum,
const volatile uint8_t* pixels,
const volatile uint8_t* end)
{
// Remember: UARTs send less significant bit (LSB) first so
// pushing ABCDEF byte will generate a 0FEDCBA1 signal,
// including a LOW(0) start & a HIGH(1) stop bits.
// Also, we have configured UART to invert logic levels, so:
const uint8_t _uartData[4] = {
0b110111, // On wire: 1 000 100 0 [Neopixel reads 00]
0b000111, // On wire: 1 000 111 0 [Neopixel reads 01]
0b110100, // On wire: 1 110 100 0 [Neopixel reads 10]
0b000100, // On wire: 1 110 111 0 [NeoPixel reads 11]
};
uint8_t avail = (UART_TX_FIFO_SIZE - GetTxFifoLength(uartNum)) / 4;
if (end - pixels > avail)
{
end = pixels + avail;
}
while (pixels < end)
{
uint8_t subpix = *pixels++;
Enqueue(uartNum, _uartData[(subpix >> 6) & 0x3]);
Enqueue(uartNum, _uartData[(subpix >> 4) & 0x3]);
Enqueue(uartNum, _uartData[(subpix >> 2) & 0x3]);
Enqueue(uartNum, _uartData[subpix & 0x3]);
}
return pixels;
}
static const volatile uint8_t* ICACHE_RAM_ATTR FillUartFifo(uint8_t uartNum,
const volatile uint8_t* pixels,
const volatile uint8_t* end);
};

// this template method class is used to track the data being sent on the uart
Expand Down

0 comments on commit 037d9be

Please sign in to comment.