mirror of https://github.com/ARMmbed/mbed-os.git
KL05, KL25, KL26, KL46: Enable usticker
Signed-off-by: Mahesh Mahadevan <mahesh.mahadevan@nxp.com>pull/7009/head
parent
870600400d
commit
132dc87f3e
|
@ -1,5 +1,5 @@
|
|||
/* mbed Microcontroller Library
|
||||
* Copyright (c) 2006-2013 ARM Limited
|
||||
* Copyright (c) 2006-2018 ARM Limited
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
|
@ -18,14 +18,28 @@
|
|||
#include "PeripheralNames.h"
|
||||
#include "clk_freqs.h"
|
||||
|
||||
const ticker_info_t* us_ticker_get_info()
|
||||
{
|
||||
static const ticker_info_t info = {
|
||||
1000000, // 1 MHz
|
||||
32 // 32 bit counter
|
||||
};
|
||||
return &info;
|
||||
}
|
||||
|
||||
static bool us_ticker_inited = false;
|
||||
|
||||
static void pit_init(void);
|
||||
static void lptmr_init(void);
|
||||
|
||||
static int us_ticker_inited = 0;
|
||||
|
||||
void us_ticker_init(void) {
|
||||
if (us_ticker_inited) return;
|
||||
us_ticker_inited = 1;
|
||||
if (us_ticker_inited) {
|
||||
/* calling init again should cancel current interrupt */
|
||||
us_ticker_disable_interrupt();
|
||||
return;
|
||||
}
|
||||
us_ticker_inited = true;
|
||||
|
||||
pit_init();
|
||||
lptmr_init();
|
||||
|
@ -49,9 +63,6 @@ static void pit_init(void) {
|
|||
}
|
||||
|
||||
uint32_t us_ticker_read() {
|
||||
if (!us_ticker_inited)
|
||||
us_ticker_init();
|
||||
|
||||
// The PIT is a countdown timer
|
||||
return ~(PIT->CHANNEL[1].CVAL);
|
||||
}
|
||||
|
@ -177,6 +188,9 @@ static void lptmr_isr(void) {
|
|||
us_ticker_int_remainder = 0;
|
||||
|
||||
} else {
|
||||
/* Stop the timer */
|
||||
LPTMR0->CSR &= ~LPTMR_CSR_TEN_MASK;
|
||||
|
||||
// This function is going to disable the interrupts if there are
|
||||
// no other events in the queue
|
||||
us_ticker_irq_handler();
|
||||
|
|
Loading…
Reference in New Issue