76 lines
1.2 KiB
C++
76 lines
1.2 KiB
C++
|
//#include "stddefs.h"
|
||
|
#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');
|
||
|
}
|
||
|
|
||
|
void delay(uint32_t loops){
|
||
|
for(int i=0;i<loops;i++){
|
||
|
int tmp = GPIO_A->OUTPUT;
|
||
|
}
|
||
|
}
|
||
|
|
||
|
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() {
|
||
|
|
||
|
GPIO_A->OUTPUT_ENABLE = 0x0000000F;
|
||
|
GPIO_A->OUTPUT = 0x00000001;
|
||
|
println("hello world arty a7 v1");
|
||
|
|
||
|
const int nleds = 4;
|
||
|
const int nloops = 10;
|
||
|
|
||
|
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;
|
||
|
|
||
|
}
|