42 lines
780 B
C
42 lines
780 B
C
/*
|
|
* (c) danielinux 2019
|
|
*
|
|
* GPLv.2
|
|
*
|
|
* See LICENSE for details
|
|
*/
|
|
#include "system.h"
|
|
#include "systick.h"
|
|
#include <stdint.h>
|
|
/*** SYSTICK ***/
|
|
|
|
#define SYSTICK_BASE (0xE000E010)
|
|
#define SYSTICK_CSR (*(volatile uint32_t *)(SYSTICK_BASE + 0x00))
|
|
#define SYSTICK_RVR (*(volatile uint32_t *)(SYSTICK_BASE + 0x04))
|
|
#define SYSTICK_CVR (*(volatile uint32_t *)(SYSTICK_BASE + 0x08))
|
|
#define SYSTICK_CALIB (*(volatile uint32_t *)(SYSTICK_BASE + 0x0C))
|
|
|
|
volatile unsigned int jiffies = 0;
|
|
|
|
|
|
void systick_enable(void)
|
|
{
|
|
SYSTICK_RVR = ((cpu_freq / 1000) - 1);
|
|
SYSTICK_CVR = 0;
|
|
SYSTICK_CSR |= 0x07;
|
|
}
|
|
|
|
void systick_disable(void)
|
|
{
|
|
SYSTICK_CSR &= ~1;
|
|
}
|
|
|
|
void isr_systick(void)
|
|
{
|
|
++jiffies;
|
|
}
|
|
|
|
uint32_t HAL_GetTick(void)
|
|
{
|
|
return jiffies;
|
|
}
|