os-core/kernel/core/timer.c

42 lines
905 B
C
Raw Normal View History

2019-12-01 22:57:02 +01:00
/******************************************************************************
*
* Copyright (c) 2017-2019 by Löwenware Ltd
* Please, refer LICENSE file for legal information
*
******************************************************************************/
/**
* @file timer.c
* @author Ilja Kartašov <ik@lowenware.com>
* @brief
*
* @see https://lowenware.com/
*/
#include <aarch64/aarch64.h>
#include <aarch64/bcm2837.h>
#include "timer.h"
#include "log.h"
const unsigned int m_interval = 200000;
unsigned int m_current = 0;
void
k_timer_init(void)
{
m_current = aarch64_get32r(TIMER_CLO);
m_current += m_interval;
aarch64_set32r(TIMER_C1, m_current);
}
void
k_timer_irq_handler(void)
{
m_current += m_interval;
aarch64_set32r(TIMER_C1, m_current);
aarch64_set32r(TIMER_CS, TIMER_CS_M1);
k_logs("Timer: ");
k_logu(m_current, 10);
k_logs("\r\n");
2019-12-01 22:57:02 +01:00
}