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

54 lines
1.0 KiB
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>
2020-01-17 10:13:01 +01:00
#include <drivers/soc/bcm2837/bcm2837.h>
#include <leos/log.h>
2019-12-01 22:57:02 +01:00
#include "timer.h"
const unsigned int m_interval = 200000;
unsigned int m_current = 0;
2020-01-17 10:13:01 +01:00
#ifndef CONFIG_ARM_TIMER
#define CONFIG_ARM_TIMER 1
#endif
2019-12-01 22:57:02 +01:00
void
2020-01-17 10:13:01 +01:00
Timer_init(void)
2019-12-01 22:57:02 +01:00
{
2020-01-17 10:13:01 +01:00
#if CONFIG_ARM_TIMER == 1
#else
2019-12-01 22:57:02 +01:00
m_current = aarch64_get32r(TIMER_CLO);
m_current += m_interval;
aarch64_set32r(TIMER_C1, m_current);
2020-01-17 10:13:01 +01:00
#endif
2019-12-01 22:57:02 +01:00
}
void
2020-01-17 10:13:01 +01:00
Timer_incFromISR(void)
2019-12-01 22:57:02 +01:00
{
2020-01-17 10:13:01 +01:00
#if CONFIG_ARM_TIMER == 1
#else
2019-12-01 22:57:02 +01:00
m_current += m_interval;
aarch64_set32r(TIMER_C1, m_current);
aarch64_set32r(TIMER_CS, TIMER_CS_M1);
2020-01-17 10:13:01 +01:00
#endif
Log_putS("Timer: ");
Log_putI(m_current, 10);
Log_putS("\r\n");
2019-12-01 22:57:02 +01:00
}
2020-01-17 10:13:01 +01:00