adds support for new mnrs peripherals

This commit is contained in:
2024-02-22 17:09:35 +01:00
parent 10b8f3173d
commit 98760929c6
12 changed files with 540 additions and 129 deletions

View File

@@ -2,51 +2,20 @@
#define _BSP_TIMER_H
#include <stdint.h>
#include "gen/Apb3Timer.h"
typedef struct __attribute((__packed__)) {
volatile uint32_t mtime; // 0x0:0
volatile uint32_t mtimeh; // 0x4:0
volatile uint32_t mtimecmp; // 0x8:0
volatile uint32_t mtimecmph; // 0xc:0
} mtimer_t;
#define timer_t apb3timer_t
#ifndef APB_BUS
typedef struct __attribute((__packed__)) {
volatile uint16_t count;
} prescaler_t;
typedef struct __attribute((__packed__)) {
volatile uint16_t clk_en; // 0x0:0, 0->always, 1->prescaler
volatile uint16_t clr_en; // 0x2:0, 0->on overflow
volatile uint32_t limit; // 0x4:0, upper limit of counter
volatile uint32_t timer_value; // 0x8:0 current timer value
} timer_a_t;
#else
typedef struct __attribute((__packed__)) {
volatile uint32_t LIMIT;
} prescaler_t;
typedef struct __attribute((__packed__)) {
volatile uint32_t CLEARS_TICKS; // 0x0/0:0->always, 1->prescaler; 16:0->on overflow
volatile uint32_t LIMIT; // 0x4/0 upper limit of counter
volatile uint32_t VALUE; // 0x8/0 current timer value
} timer_a_t;
inline void prescaler_init(prescaler_t* reg){
(void)reg;
inline void prescaler_init(timer_t* reg, uint16_t value){
set_timer_prescaler(reg, value);
}
inline void timer_init(timer_a_t *reg){
reg->CLEARS_TICKS = 0;
reg->VALUE = 0;
inline void timer_t0__init(timer_t *reg){
set_timer_t0_overflow(reg, 0xffffffff);
}
inline void mtimer_init(mtimer_t *reg){
reg->mtimecmph = UINT32_MAX;
reg->mtimecmp = UINT32_MAX;
inline void timer_t1__init(timer_t *reg){
set_timer_t1_overflow(reg, 0xffffffff);
}
#endif
#endif /* _BSP_TIMER_H */