2024-06-02 07:14:45 +00:00
|
|
|
/*
|
|
|
|
* Subject: Interrupt Controller (IRQ), irq@MuraxSoc (RV32I)
|
|
|
|
* Lang_s: asm, c, c++
|
|
|
|
* Env: Bare Metal verilated MuraxSoc
|
|
|
|
* Tested: gdb@jtag
|
|
|
|
* mpabi@2024/PI
|
|
|
|
*/
|
|
|
|
|
2024-06-01 21:14:04 +00:00
|
|
|
#include <stdint.h>
|
|
|
|
|
|
|
|
#include "murax.h"
|
|
|
|
|
|
|
|
void print(const char*str){
|
|
|
|
while(*str){
|
|
|
|
// uart_write(UART,*str);
|
|
|
|
str++;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
void println(const char*str){
|
|
|
|
print(str);
|
|
|
|
// uart_write(UART,'\n');
|
|
|
|
}
|
|
|
|
|
|
|
|
volatile int mati = 0;
|
|
|
|
|
|
|
|
|
|
|
|
// Modern C++ aproach
|
|
|
|
// ---
|
|
|
|
class TimeR {
|
|
|
|
|
|
|
|
public:
|
|
|
|
static inline uint32_t readValue() {
|
|
|
|
return ptr->VALUE;
|
|
|
|
}
|
|
|
|
|
|
|
|
private:
|
|
|
|
static const Timer_Reg* ptr ;
|
|
|
|
};
|
|
|
|
|
|
|
|
const Timer_Reg* TimeR::ptr = reinterpret_cast<const Timer_Reg*>(0xF0020040);
|
|
|
|
// ---
|
|
|
|
|
|
|
|
int main() {
|
|
|
|
|
2024-06-02 07:14:45 +00:00
|
|
|
// println("hello world arty a7 v1");
|
2024-06-01 21:14:04 +00:00
|
|
|
|
|
|
|
|
|
|
|
interruptCtrl_init(TIMER_INTERRUPT);
|
|
|
|
prescaler_init(TIMER_PRESCALER);
|
|
|
|
timer_init(TIMER_A);
|
|
|
|
|
|
|
|
TIMER_PRESCALER->LIMIT = 0x10;
|
|
|
|
|
|
|
|
TIMER_A->LIMIT = 0x10000-1;
|
|
|
|
TIMER_A->CLEARS_TICKS = 0x10002;
|
|
|
|
|
|
|
|
TIMER_INTERRUPT->PENDINGS = 0xF;
|
|
|
|
TIMER_INTERRUPT->MASKS = 0x1;
|
|
|
|
|
|
|
|
while(1){
|
|
|
|
|
|
|
|
++mati;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
extern "C" void irqCallback(){
|
|
|
|
|
|
|
|
static volatile int count = 0;
|
|
|
|
++count;
|
|
|
|
TIMER_INTERRUPT->PENDINGS = 1;
|
|
|
|
|
|
|
|
}
|