diff --git a/.gitignore b/.gitignore index ab98bb0..2c52023 100644 --- a/.gitignore +++ b/.gitignore @@ -8,6 +8,8 @@ *.hex *.map *.elf +*.o +*.so */midi/melody.c */midi/miditone.c */midi/ton/gen diff --git a/V203F6P6/README.md b/V203F6P6/README.md new file mode 100644 index 0000000..6a02cd2 --- /dev/null +++ b/V203F6P6/README.md @@ -0,0 +1,4 @@ +# V203R6 +Koupil jsem na ALI pár levných procesorů CH32V203F6P6, +tak jsem se rozhodl je vyzkoušet. Má to méně paměti (32K flash, 10K ram), +ořezané periferie, ale na pokusy by to mohlo stačit. diff --git a/V203R6/blink/Makefile b/V203F6P6/blink/Makefile similarity index 100% rename from V203R6/blink/Makefile rename to V203F6P6/blink/Makefile diff --git a/V203R6/blink/ch32v203 b/V203F6P6/blink/ch32v203 similarity index 100% rename from V203R6/blink/ch32v203 rename to V203F6P6/blink/ch32v203 diff --git a/V203R6/blink/main.cpp b/V203F6P6/blink/main.cpp similarity index 100% rename from V203R6/blink/main.cpp rename to V203F6P6/blink/main.cpp diff --git a/V203R6/ch32v203/CH32V20xxx.h b/V203F6P6/ch32v203/CH32V20xxx.h similarity index 100% rename from V203R6/ch32v203/CH32V20xxx.h rename to V203F6P6/ch32v203/CH32V20xxx.h diff --git a/V203R6/ch32v203/clang.mk b/V203F6P6/ch32v203/clang.mk similarity index 100% rename from V203R6/ch32v203/clang.mk rename to V203F6P6/ch32v203/clang.mk diff --git a/V203R6/ch32v203/gcc.mk b/V203F6P6/ch32v203/gcc.mk similarity index 100% rename from V203R6/ch32v203/gcc.mk rename to V203F6P6/ch32v203/gcc.mk diff --git a/V203R6/ch32v203/generated_CH32V203F6P6.ld b/V203F6P6/ch32v203/generated_CH32V203F6P6.ld similarity index 100% rename from V203R6/ch32v203/generated_CH32V203F6P6.ld rename to V203F6P6/ch32v203/generated_CH32V203F6P6.ld diff --git a/V203R6/ch32v203/gpio.h b/V203F6P6/ch32v203/gpio.h similarity index 100% rename from V203R6/ch32v203/gpio.h rename to V203F6P6/ch32v203/gpio.h diff --git a/V203R6/ch32v203/startup.cpp b/V203F6P6/ch32v203/startup.cpp similarity index 100% rename from V203R6/ch32v203/startup.cpp rename to V203F6P6/ch32v203/startup.cpp diff --git a/V203R6/ch32v203/system.cpp b/V203F6P6/ch32v203/system.cpp similarity index 100% rename from V203R6/ch32v203/system.cpp rename to V203F6P6/ch32v203/system.cpp diff --git a/V203R6/ch32v203/system.h b/V203F6P6/ch32v203/system.h similarity index 100% rename from V203R6/ch32v203/system.h rename to V203F6P6/ch32v203/system.h diff --git a/V203R6/common/baselayer.h b/V203F6P6/common/baselayer.h similarity index 100% rename from V203R6/common/baselayer.h rename to V203F6P6/common/baselayer.h diff --git a/V203R6/common/fifo.h b/V203F6P6/common/fifo.h similarity index 100% rename from V203R6/common/fifo.h rename to V203F6P6/common/fifo.h diff --git a/V203R6/common/oneway.h b/V203F6P6/common/oneway.h similarity index 64% rename from V203R6/common/oneway.h rename to V203F6P6/common/oneway.h index e4e503d..fe80684 100644 --- a/V203R6/common/oneway.h +++ b/V203F6P6/common/oneway.h @@ -4,7 +4,7 @@ /* C++ interface (jako callback v C) */ template class OneWay { public: - virtual unsigned Send (T * const ptr, const unsigned len, const bool low = false) = 0; + virtual unsigned Send (T * const ptr, const unsigned len) = 0; }; #endif // ONEWAY_H diff --git a/V203R6/common/print.cpp b/V203F6P6/common/print.cpp similarity index 100% rename from V203R6/common/print.cpp rename to V203F6P6/common/print.cpp diff --git a/V203R6/common/print.h b/V203F6P6/common/print.h similarity index 100% rename from V203R6/common/print.h rename to V203F6P6/common/print.h diff --git a/V203R6/common/usart.h b/V203F6P6/common/usart.h similarity index 100% rename from V203R6/common/usart.h rename to V203F6P6/common/usart.h diff --git a/V203R6/ws2812b/Makefile b/V203F6P6/ws2812b/Makefile similarity index 100% rename from V203R6/ws2812b/Makefile rename to V203F6P6/ws2812b/Makefile diff --git a/V203R6/ws2812b/ch32v203 b/V203F6P6/ws2812b/ch32v203 similarity index 100% rename from V203R6/ws2812b/ch32v203 rename to V203F6P6/ws2812b/ch32v203 diff --git a/V203R6/ws2812b/common b/V203F6P6/ws2812b/common similarity index 100% rename from V203R6/ws2812b/common rename to V203F6P6/ws2812b/common diff --git a/V203R6/ws2812b/hack.c b/V203F6P6/ws2812b/hack.c similarity index 100% rename from V203R6/ws2812b/hack.c rename to V203F6P6/ws2812b/hack.c diff --git a/V203R6/ws2812b/linux/Makefile b/V203F6P6/ws2812b/linux/Makefile similarity index 100% rename from V203R6/ws2812b/linux/Makefile rename to V203F6P6/ws2812b/linux/Makefile diff --git a/V203R6/ws2812b/linux/graph.py b/V203F6P6/ws2812b/linux/graph.py similarity index 100% rename from V203R6/ws2812b/linux/graph.py rename to V203F6P6/ws2812b/linux/graph.py diff --git a/V203R6/ws2812b/linux/main.cpp b/V203F6P6/ws2812b/linux/main.cpp similarity index 100% rename from V203R6/ws2812b/linux/main.cpp rename to V203F6P6/ws2812b/linux/main.cpp diff --git a/V203R6/ws2812b/main.cpp b/V203F6P6/ws2812b/main.cpp similarity index 79% rename from V203R6/ws2812b/main.cpp rename to V203F6P6/ws2812b/main.cpp index edf7e15..85a4b17 100644 --- a/V203R6/ws2812b/main.cpp +++ b/V203F6P6/ws2812b/main.cpp @@ -3,14 +3,14 @@ #include "system.h" #include "gpio.h" extern "C" { - extern const unsigned table []; + extern const unsigned table []; // generováno linux/graph.py }; -static FIFO ring; +static FIFO ring; static ws2812b driver(ring); static SpiClass spi (driver); static GpioClass led (GPIOB, 8); -static constexpr unsigned timeout = 5'000u; +static constexpr unsigned timeout = 10'000u; int main () { led << true; diff --git a/V203R6/ws2812b/spiclass.cpp b/V203F6P6/ws2812b/spiclass.cpp similarity index 89% rename from V203R6/ws2812b/spiclass.cpp rename to V203F6P6/ws2812b/spiclass.cpp index 2f0d8dc..291e26e 100644 --- a/V203R6/ws2812b/spiclass.cpp +++ b/V203F6P6/ws2812b/spiclass.cpp @@ -41,20 +41,19 @@ static void InitPins () noexcept { void SpiClass::drq() { if (!driver) return; DMA1_Type::INTFR_DEF state (DMA1.INTFR); - if (state.B.HTIF3) { +/*if (state.B.HTIF3) { DMA1.INTFCR.B.CHTIF3 = SET; // clear half - driver->Send (ptrl, HALF_LEN, true); - } + } */ if (state.B.TCIF3) { DMA1.INTFCR.B.CTCIF3 = SET; // clear complete - //driver->Send (ptrh, HALF_LEN, false); // reset + driver->Send (ptrh, LEDS_LEN); } } -SpiClass::SpiClass(OneWay & base) noexcept : driver (& base), ptrl (buffer), ptrh (buffer + HALF_LEN) { +SpiClass::SpiClass(OneWay & base) noexcept : driver (& base), ptrl (buffer), ptrh (buffer + PADDING) { pSpiInstance = this; for (unsigned n=0u; n(ptrl); + Color * ptr = reinterpret_cast(ptrh); const OneColor oz(0x00); for (unsigned n=0; n 9 x 8 x 0.444 = 32 us DMA celkem (10 + 4) x 32 = 0.448 ms * */ r.B.BR = FPCLK_64; return r.R; diff --git a/V203R6/ws2812b/spiclass.h b/V203F6P6/ws2812b/spiclass.h similarity index 66% rename from V203R6/ws2812b/spiclass.h rename to V203F6P6/ws2812b/spiclass.h index dee1152..52bdcd0 100644 --- a/V203R6/ws2812b/spiclass.h +++ b/V203F6P6/ws2812b/spiclass.h @@ -4,8 +4,9 @@ #include "ws2812b.h" /** */ -static constexpr unsigned HALF_LEN = NUMLEDS * sizeof (Color); -static constexpr unsigned FULL_LEN = 2 * HALF_LEN; +static constexpr unsigned PADDING = 10 * sizeof (Color); +static constexpr unsigned LEDS_LEN = NUMLEDS * sizeof (Color); +static constexpr unsigned FULL_LEN = PADDING + LEDS_LEN; class SpiClass { OneWay * driver; diff --git a/V203R6/ws2812b/table.c b/V203F6P6/ws2812b/table.c similarity index 100% rename from V203R6/ws2812b/table.c rename to V203F6P6/ws2812b/table.c diff --git a/V203R6/ws2812b/ws2812b.cpp b/V203F6P6/ws2812b/ws2812b.cpp similarity index 98% rename from V203R6/ws2812b/ws2812b.cpp rename to V203F6P6/ws2812b/ws2812b.cpp index b94d3a3..840e33c 100644 --- a/V203R6/ws2812b/ws2812b.cpp +++ b/V203F6P6/ws2812b/ws2812b.cpp @@ -37,7 +37,7 @@ unsigned OneColor::to_string(char * ptr, const int m) { ws2812b::ws2812b (FIFO & r) noexcept : OneWay (), ring(r) { } -unsigned int ws2812b::Send (uint8_t * const ptr, const unsigned int len, const bool low) { +unsigned int ws2812b::Send (uint8_t * const ptr, const unsigned int len) { uint32_t cmd; while (ring.Read(cmd)) { const Entry ne (cmd); diff --git a/V203R6/ws2812b/ws2812b.h b/V203F6P6/ws2812b/ws2812b.h similarity index 67% rename from V203R6/ws2812b/ws2812b.h rename to V203F6P6/ws2812b/ws2812b.h index 0783bec..d416838 100644 --- a/V203R6/ws2812b/ws2812b.h +++ b/V203F6P6/ws2812b/ws2812b.h @@ -27,25 +27,25 @@ union Entry { uint32_t number; explicit Entry (const uint32_t e) noexcept { number = e; } }; -/***************************************************************************/ -static constexpr unsigned NUMLEDS = 8u; -/***************************************************************************/ +/*************************************************************************************/ +static constexpr unsigned NUMLEDS = 4u; +static constexpr unsigned FIFOLEN = 8u; // min. depth je 8, jinak mocnina 2 >= NUMLEDS +/*************************************************************************************/ /** @class ws2812b * @brief Driver pro WS2812B * On ten driver je trochu divný. Běží nad SPI s použitím pinu MOSI, 1 bit barvy * jsou 3 bity SPI. Funguje to tak, že SPI běží přes DMA v cirkulárním módu, tedy - * pořád, v 1. polovině si vybere z fronty ring data a uloží je do buferu ve správném - * tvaru, 2. polovina dělá "reset", tedy časování rámce (vysílá nuly). + * pořád, v 1. části dělá "reset", tedy časování rámce (vysílá nuly). + * V 2. části si vybere z fronty ring data a uloží je do buferu ve správném + * tvaru. Využívá se toho, že přerušení přijde až na konci a naplnění daty + * netrvá dlouho, takže se přepisuje jen část, která se nevysílá. * Fronta byla použita (celkem zbytečně) protože zatím netuším jaká data posílat. - * To, že celá 2. polovina je zabrána pro reset je také volovina, ale ničemu to nevadí - * a je to jednoduché. Šlo by dát reset na začátek a v přerušení na konci do buferu - * nasypat data - nebude to trvat tak dlouho aby DMA už začalo posílat data pro LED. * */ class ws2812b : public OneWay { - FIFO & ring; + FIFO & ring; public: - explicit ws2812b (FIFO & r) noexcept; - unsigned int Send (uint8_t * const ptr, const unsigned int len, const bool low = false) override; + explicit ws2812b (FIFO & r) noexcept; + unsigned int Send (uint8_t * const ptr, const unsigned int len) override; protected: }; diff --git a/V203R6/ws2812b/linux/graph.so b/V203R6/ws2812b/linux/graph.so deleted file mode 100755 index daf9572..0000000 Binary files a/V203R6/ws2812b/linux/graph.so and /dev/null differ diff --git a/V203R6/ws2812b/linux/main.o b/V203R6/ws2812b/linux/main.o deleted file mode 100644 index 5fe6d4b..0000000 Binary files a/V203R6/ws2812b/linux/main.o and /dev/null differ