Added readme with comments for the firmware
This commit is contained in:
30
README.md
Normal file
30
README.md
Normal file
@@ -0,0 +1,30 @@
|
||||
für zephr:
|
||||
```
|
||||
#include <zephyr/kernel.h>
|
||||
#include <zephyr/arch/cpu.h>
|
||||
|
||||
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);
|
||||
}
|
||||
```
|
||||
Reference in New Issue
Block a user