From 6e48604f22cf35ad115a2b87b27bb7d28bc0e2e8 Mon Sep 17 00:00:00 2001 From: Eduard Iten Date: Sun, 2 Aug 2026 11:19:48 +0200 Subject: [PATCH] Added readme with comments for the firmware --- README.md | 30 ++++++++++++++++++++++++++++++ 1 file changed, 30 insertions(+) create mode 100644 README.md diff --git a/README.md b/README.md new file mode 100644 index 0000000..ec4b521 --- /dev/null +++ b/README.md @@ -0,0 +1,30 @@ +für zephr: +``` +#include +#include + +static volatile uint16_t target_val = 0; +static uint16_t akku = 0; + +// Direct ISR deklarieren – minimaler Overhead! +ISR_DIRECT_DECLARE(my_pwm_dither_isr) +{ + // 1. Hardware Interrupt-Flag löschen (direkt übers CMSIS-Register) + TIMx->SR = ~TIM_SR_UIF; + + // 2. Deine Akku-Rechnung + akku += target_val; + TIMx->CCR1 = (akku >> 6); + akku &= 0x3F; + + // 3. Kein Reschedule nötig, da wir keine Zephyr-API in der ISR aufrufen + return 0; +} + +void init_pwm_dither(void) +{ + // Interrupt in Zephyr registrieren (Priority z.B. 1 oder 2) + IRQ_DIRECT_CONNECT(TIMx_IRQn, 1, my_pwm_dither_isr, 0); + irq_enable(TIMx_IRQn); +} +```