os-core/kernel/drivers/timer/timer.c

54 lines
1.0 KiB
C

/******************************************************************************
*
* 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 <drivers/soc/bcm2837/bcm2837.h>
#include <leos/log.h>
#include "timer.h"
const unsigned int m_interval = 200000;
unsigned int m_current = 0;
#ifndef CONFIG_ARM_TIMER
#define CONFIG_ARM_TIMER 1
#endif
void
Timer_init(void)
{
#if CONFIG_ARM_TIMER == 1
#else
m_current = aarch64_get32r(TIMER_CLO);
m_current += m_interval;
aarch64_set32r(TIMER_C1, m_current);
#endif
}
void
Timer_incFromISR(void)
{
#if CONFIG_ARM_TIMER == 1
#else
m_current += m_interval;
aarch64_set32r(TIMER_C1, m_current);
aarch64_set32r(TIMER_CS, TIMER_CS_M1);
#endif
Log_putS("Timer: ");
Log_putI(m_current, 10);
Log_putS("\r\n");
}