diff --git a/CooperativeMultitasking.md b/CooperativeMultitasking.md index 358e13a..9b49e10 100644 --- a/CooperativeMultitasking.md +++ b/CooperativeMultitasking.md @@ -38,7 +38,7 @@ that can be implemented on a small microcontroller. ### Audience These techniques can be applied by anyone with experience in ***C***, -***Python*** or any modern computer language. +***Python***, ***Rust*** or any modern computer language. It helps to have a passing knowledge of how to connect a transducer (button, LED, buzzer, etc) to a microcontroller. @@ -70,8 +70,12 @@ Yspring MDT1x, EastSoft HR7P, Holtek Ht68.)* ![Here](blb.jpg) is a typical board hosting 12 buttons, 12 RGB LEDs, all hosted by an STM32. Every light and button can be controlled separately and simultaneously, using the technique described in this paper. + +The source of this paper can be found at +[my git repository](https://wiki.pbeirne.com/patb/cmt) + ## The Problem Let's suppose we want to flash an LED at 1 flash/2 sec, @@ -259,8 +263,8 @@ The `newEvent(evt)` routine simply adds the `evt` to the array `events[]`. Something like this might work: ```C -void newEvent(uint8r evt) { - static unsigned uint8 nextEvent; +void newEvent(uint8 evt) { + static uint8 nextEvent; events[nextEvent++] = evt; if (nextEvent == NUM_EVENTS) nextEvent = 0; @@ -279,7 +283,7 @@ Here's a more realistic version: ```C void newEvent(char evt) { - static unsigned char nextEvent; // keep track of where we are in queue + static uint8 nextEvent; // keep track of where we are in queue disable_irq(); // critical section events[nextEvent++] = evt; // insert event into queue if (nextEvent == NUM_EVENTS) // loop back to the start of queue diff --git a/c.xml b/c.xml new file mode 100644 index 0000000..a608dce --- /dev/null +++ b/c.xml @@ -0,0 +1,566 @@ + + + + + + + + + + + + + +]> + + + + + break + case + continue + default + do + else + for + goto + if + return + switch + while + + + + alignas + alignof + auto + constexpr + enum + extern + false + inline + nullptr + sizeof + static_assert + struct + true + typedef + typeof + typeof_unqual + union + _Alignas + _Alignof + _Atomic + _Noreturn + _Static_assert + _Thread_local + + + + + noreturn + deprecated + fallthrough + nodiscard + maybe_unused + unsequenced + reproducible + + + + bool + char + char16_t + char32_t + double + float + int + long + short + signed + unsigned + void + int8_t + int16_t + int32_t + int64_t + uint8 + uint16 + uint8_t + uint16_t + uint32_t + uint64_t + int_least8_t + int_least16_t + int_least32_t + int_least64_t + uint_least8_t + uint_least16_t + uint_least32_t + uint_least64_t + int_fast8_t + int_fast16_t + int_fast32_t + int_fast64_t + uint_fast8_t + uint_fast16_t + uint_fast32_t + uint_fast64_t + size_t + ssize_t + wchar_t + intptr_t + uintptr_t + intmax_t + uintmax_t + ptrdiff_t + sig_atomic_t + wint_t + _BitInt + _Bool + bool + _Decimal32 + _Decimal64 + _Decimal128 + _Complex + complex + _Imaginary + imaginary + _Generic + va_list + FILE + fpos_t + time_t + max_align_t + + + const + register + restrict + static + thread_local + volatile + + + + if + ifdef + ifndef + elif + elifdef + elifndef + else + endif + define + include + error + line + pragma + undef + warning + embed + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/makefile b/makefile index 48834ae..014ece0 100644 --- a/makefile +++ b/makefile @@ -10,6 +10,8 @@ IMG_OBJECTS=$(IMG_SOURCES:.dot=.png) CC=pandoc -s -t html -B header.md -A footer.md CC=pandoc -s -t html --toc --css pandoc.css --toc-depth=3 +# CC=pandoc -s -t html --toc --css pandoc.css --highlight-style tango --toc-depth=3 +CC=pandoc -s -t html --toc --css pandoc.css --syntax-definition=c.xml --toc-depth=3 IM=dot -Tpng %.html : %.md