[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PATCH qemu v3 07/20] Fixing the basic functionality of STM32 timers
From: |
~lbryndza |
Subject: |
[PATCH qemu v3 07/20] Fixing the basic functionality of STM32 timers |
Date: |
Sat, 02 Dec 2023 13:15:06 +0100 |
From: Lucjan Bryndza <lbryndza.oss@icloud.com>
The current implementation of timers does not work properly
even in basic functionality. A counter configured to report
an interrupt every 10ms reports the first interrupts after a
few seconds. There are also no properly implemented count up an
count down modes. This commit fixes bugs with interrupt
reporting and implements the basic modes of the counter's
time-base block.
Add timer ticks functions
Signed-off-by: Lucjan Bryndza <lbryndza.oss@icloud.com>
---
hw/timer/stm32f2xx_timer.c | 28 ++++++++++++++++++++++++++++
1 file changed, 28 insertions(+)
diff --git a/hw/timer/stm32f2xx_timer.c b/hw/timer/stm32f2xx_timer.c
index bd3d1bcf24..cee25252f7 100644
--- a/hw/timer/stm32f2xx_timer.c
+++ b/hw/timer/stm32f2xx_timer.c
@@ -97,6 +97,34 @@ static void stm32f2xx_timer_update_uif(STM32F2XXTimerState
*s, uint8_t value)
qemu_set_irq(s->irq, value);
}
+static void stm32f2xx_timer_tick(void *opaque)
+{
+ STM32F2XXTimerState *s = (STM32F2XXTimerState *)opaque;
+ DB_PRINT("Alarm raised\n");
+ stm32f2xx_timer_update_uif(s, 1);
+
+ if (s->count_mode == TIMER_UP_COUNT) {
+ stm32f2xx_timer_set_count(s, 0);
+ } else {
+ stm32f2xx_timer_set_count(s, s->tim_arr);
+ }
+
+ if (s->tim_cr1 & TIM_CR1_CMS) {
+ if (s->count_mode == TIMER_UP_COUNT) {
+ s->count_mode = TIMER_DOWN_COUNT;
+ } else {
+ s->count_mode = TIMER_UP_COUNT;
+ }
+ }
+
+ if (s->tim_cr1 & TIM_CR1_OPM) {
+ s->tim_cr1 &= ~TIM_CR1_CEN;
+ } else {
+ stm32f2xx_timer_update(s);
+ }
+}
+
+
static void stm32f2xx_timer_reset(DeviceState *dev)
{
STM32F2XXTimerState *s = STM32F2XXTIMER(dev);
--
2.38.5
- [PATCH qemu v3 00/20] Fix malfunctioning of T2-T5 timers on the STM32 platform, ~lbryndza, 2023/12/02
- [PATCH qemu v3 02/20] Fixing the basic functionality of STM32 timers, ~lbryndza, 2023/12/02
- [PATCH qemu v3 04/20] Fixing the basic functionality of STM32 timers, ~lbryndza, 2023/12/02
- [PATCH qemu v3 12/20] Fixing the basic functionality of STM32 timers, ~lbryndza, 2023/12/02
- [PATCH qemu v3 05/20] Fixing the basic functionality of STM32 timers, ~lbryndza, 2023/12/02
- [PATCH qemu v3 03/20] Fixing the basic functionality of STM32 timers, ~lbryndza, 2023/12/02
- [PATCH qemu v3 01/20] Fixing the basic functionality of STM32 timers, ~lbryndza, 2023/12/02
- [PATCH qemu v3 06/20] Fixing the basic functionality of STM32 timers, ~lbryndza, 2023/12/02
- [PATCH qemu v3 07/20] Fixing the basic functionality of STM32 timers,
~lbryndza <=
- [PATCH qemu v3 10/20] Fixing the basic functionality of STM32 timers, ~lbryndza, 2023/12/02
- [PATCH qemu v3 08/20] Fixing the basic functionality of STM32 timers, ~lbryndza, 2023/12/02
- [PATCH qemu v3 11/20] Fixing the basic functionality of STM32 timers, ~lbryndza, 2023/12/02
- [PATCH qemu v3 17/20] Fixing the basic functionality of STM32 timers, ~lbryndza, 2023/12/02
- [PATCH qemu v3 14/20] Fixing the basic functionality of STM32 timers, ~lbryndza, 2023/12/02
- [PATCH qemu v3 13/20] Fixing the basic functionality of STM32 timers, ~lbryndza, 2023/12/02
- [PATCH qemu v3 09/20] Fixing the basic functionality of STM32 timers, ~lbryndza, 2023/12/02
- [PATCH qemu v3 16/20] Fixing the basic functionality of STM32 timers, ~lbryndza, 2023/12/02
- [PATCH qemu v3 19/20] Fixing the basic functionality of STM32 timers, ~lbryndza, 2023/12/02
- [PATCH qemu v3 18/20] Fixing the basic functionality of STM32 timers, ~lbryndza, 2023/12/02