68 lines
1.4 KiB
C
68 lines
1.4 KiB
C
/*
|
|
* systemPort.c
|
|
*
|
|
* Created on: Jul 24, 2017
|
|
* Author: spinalvm
|
|
*/
|
|
|
|
|
|
#import "../conf/FreeRTOSConfig.h"
|
|
|
|
#define mtime ((volatile uint64_t*)0xF00FFF40u)
|
|
#define mtime32 ((volatile uint32_t*) mtime)
|
|
#define timecmp ((volatile uint64_t*)0xF00FFF48u)
|
|
|
|
#include "../arch/vexriscv/murax.h"
|
|
|
|
/*-----------------------------------------------------------*/
|
|
|
|
/* Sets the next timer interrupt
|
|
*/
|
|
void prvSetNextTimerInterrupt(void)
|
|
{
|
|
|
|
TIMER_INTERRUPT->PENDINGS = 1;
|
|
|
|
/*
|
|
uint32_t mtimeHigh, mtimeLow;
|
|
|
|
//Get 64 bits mtime value via 32 bits access
|
|
do{
|
|
mtimeHigh = mtime32[1];
|
|
mtimeLow = mtime32[0];
|
|
}while(mtimeHigh != mtime32[1]);
|
|
|
|
*timecmp = ((((uint64_t) mtimeHigh) << 32) | mtimeLow) + (configTICK_CLOCK_HZ / configTICK_RATE_HZ);
|
|
*/
|
|
}
|
|
/*-----------------------------------------------------------*/
|
|
|
|
/* Sets and enable the timer interrupt */
|
|
void vPortSetupTimer(void)
|
|
{
|
|
prvSetNextTimerInterrupt();
|
|
|
|
/* Enable timer interupt */
|
|
// __asm volatile("csrs mie,%0"::"r"(0x80));
|
|
|
|
interruptCtrl_init(TIMER_INTERRUPT);
|
|
prescaler_init(TIMER_PRESCALER);
|
|
timer_init(TIMER_A);
|
|
|
|
TIMER_PRESCALER->LIMIT = 500;
|
|
|
|
TIMER_A->LIMIT = 1000;
|
|
TIMER_A->CLEARS_TICKS = 0x00010002;
|
|
|
|
TIMER_INTERRUPT->PENDINGS = 0xF;
|
|
|
|
__asm volatile(
|
|
"li t0, 0x880\n\t"
|
|
"csrw mie, t0\n\t"
|
|
);
|
|
|
|
|
|
}
|
|
|
|
|