mirror of https://github.com/ARMmbed/mbed-os.git
CM3DS: update tickers implementation
The HAL implementation (us_ticker.c and lp_ticker.c) now calls function in cmsdk_ticker.c file. This file contains the necessary logic to be able to only use one hardware timer (CMSDK timer) per mbed ticker. This commit also updates the timer driver and removes legacy definition. Change-Id: If40413822832117f9b78f38d2cdda7847284b035 Signed-off-by: Galanakis, Minos <minos.galanakis@arm.com> Signed-off-by: Hugues de Valon <hugues.devalon@arm.com>pull/6170/head
parent
ccff46d9a3
commit
ffc7b91128
|
@ -0,0 +1,166 @@
|
|||
/*
|
||||
* Copyright (c) 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.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
/**
|
||||
* \file cmsdk_ticker.c
|
||||
* Two abstracted functionalities for CMSDK APB Timers
|
||||
* 1. Measure elapsed time
|
||||
* 2. Timer interval interrupt
|
||||
*
|
||||
* Passed \ref tick_drv_data_t should be initialized by the caller
|
||||
* for using these services accordingly.
|
||||
* See details \ref tick_cfg_t and \ref tick_data_t.
|
||||
*/
|
||||
|
||||
#include "cmsdk_ticker.h"
|
||||
|
||||
void cmsdk_ticker_init(const struct tick_drv_data_t* timer_data)
|
||||
{
|
||||
if (!timer_data->data->is_initialized) {
|
||||
timer_cmsdk_init(timer_data->cfg->timer_driver);
|
||||
timer_cmsdk_set_reload_value(timer_data->cfg->timer_driver,
|
||||
TIMER_CMSDK_MAX_RELOAD);
|
||||
timer_cmsdk_enable_interrupt(timer_data->cfg->timer_driver);
|
||||
NVIC_EnableIRQ(timer_data->cfg->irq_n);
|
||||
|
||||
timer_data->data->max_interval_time =
|
||||
timer_data->cfg->convert_tick_to_time(TIMER_CMSDK_MAX_RELOAD);
|
||||
timer_data->data->reload_time = timer_data->data->max_interval_time;
|
||||
timer_data->data->is_initialized = true;
|
||||
timer_cmsdk_enable(timer_data->cfg->timer_driver);
|
||||
}
|
||||
}
|
||||
|
||||
uint32_t cmsdk_ticker_read(const struct tick_drv_data_t* timer_data)
|
||||
{
|
||||
uint32_t current_elapsed = 0;
|
||||
|
||||
if (!timer_data->data->is_initialized) {
|
||||
cmsdk_ticker_init(timer_data);
|
||||
}
|
||||
current_elapsed = timer_cmsdk_get_elapsed_value(timer_data->cfg->timer_driver);
|
||||
/*
|
||||
* If for the same reload cycle (ie. cumulated_time is the same) the
|
||||
* current elapsed time is lower than the previous one, it means that the
|
||||
* timer has wrapped around without the system logging it. To ensure that
|
||||
* we are always returning an increasing time in those condition, we return
|
||||
* the time perviously read.
|
||||
*/
|
||||
if ((timer_data->data->previous_cumulated_time ==
|
||||
timer_data->data->cumulated_time) &&
|
||||
(current_elapsed < timer_data->data->previous_elapsed)) {
|
||||
current_elapsed = timer_data->data->previous_elapsed;
|
||||
}
|
||||
|
||||
timer_data->data->previous_elapsed = current_elapsed;
|
||||
timer_data->data->previous_cumulated_time =
|
||||
timer_data->data->cumulated_time;
|
||||
|
||||
return (timer_data->data->cumulated_time +
|
||||
timer_data->cfg->convert_tick_to_time(current_elapsed));
|
||||
}
|
||||
|
||||
void cmsdk_ticker_set_interrupt(const struct tick_drv_data_t* timer_data,
|
||||
uint32_t timestamp)
|
||||
{
|
||||
uint32_t interval = 0;
|
||||
uint32_t interval_reload_tick = 0;
|
||||
|
||||
/* Stop before read to avoid race condition with IRQ. */
|
||||
timer_cmsdk_disable(timer_data->cfg->timer_driver);
|
||||
uint32_t current_time = cmsdk_ticker_read(timer_data);
|
||||
|
||||
timer_data->data->interval_callback_enabled = true;
|
||||
|
||||
/*
|
||||
* We always assume that the event is in the future, even if this
|
||||
* substraction underflows it is still corect.
|
||||
*/
|
||||
interval = (timestamp - current_time);
|
||||
|
||||
if (interval >= timer_data->data->max_interval_time) {
|
||||
/* Event will be in the future but the time is too big: set max */
|
||||
interval_reload_tick = TIMER_CMSDK_MAX_RELOAD;
|
||||
timer_data->data->reload_time = timer_data->data->max_interval_time;
|
||||
} else {
|
||||
/* Event will be in the future in a time that can be set */
|
||||
interval_reload_tick =
|
||||
timer_data->cfg->convert_time_to_tick(interval);
|
||||
timer_data->data->reload_time = interval;
|
||||
}
|
||||
|
||||
/* Store the current elapsed time, before reset the timer */
|
||||
timer_data->data->cumulated_time = current_time;
|
||||
/* Reset the timer with new reload value */
|
||||
timer_cmsdk_set_reload_value(timer_data->cfg->timer_driver,
|
||||
interval_reload_tick);
|
||||
timer_cmsdk_reset(timer_data->cfg->timer_driver);
|
||||
|
||||
timer_cmsdk_enable(timer_data->cfg->timer_driver);
|
||||
}
|
||||
|
||||
void cmsdk_ticker_disable_interrupt(const struct tick_drv_data_t* timer_data)
|
||||
{
|
||||
if (!timer_data->data->is_initialized) {
|
||||
cmsdk_ticker_init(timer_data);
|
||||
}
|
||||
|
||||
timer_data->data->interval_callback_enabled = false;
|
||||
|
||||
/* Stop before read to avoid race condition with IRQ. */
|
||||
timer_cmsdk_disable(timer_data->cfg->timer_driver);
|
||||
/* If interval interrupt is disabled, restore the default max interval,
|
||||
* but save the current elapsed time before changing the timer. */
|
||||
timer_data->data->cumulated_time = cmsdk_ticker_read(timer_data);
|
||||
/* Reset the timer with default reload value */
|
||||
timer_cmsdk_set_reload_value(timer_data->cfg->timer_driver,
|
||||
TIMER_CMSDK_MAX_RELOAD);
|
||||
timer_data->data->reload_time = timer_data->data->max_interval_time;
|
||||
|
||||
timer_cmsdk_reset(timer_data->cfg->timer_driver);
|
||||
timer_cmsdk_enable(timer_data->cfg->timer_driver);
|
||||
}
|
||||
|
||||
void cmsdk_ticker_clear_interrupt(const struct tick_drv_data_t* timer_data)
|
||||
{
|
||||
timer_cmsdk_clear_interrupt(timer_data->cfg->timer_driver);
|
||||
}
|
||||
|
||||
void cmsdk_ticker_fire_interrupt(const struct tick_drv_data_t* timer_data)
|
||||
{
|
||||
NVIC_SetPendingIRQ(timer_data->cfg->irq_n);
|
||||
}
|
||||
|
||||
void cmsdk_ticker_irq_handler(const struct tick_drv_data_t* timer_data)
|
||||
{
|
||||
uint32_t reload_val = 0;
|
||||
/* If timer's internal interrupt status is not active, then not overflow,
|
||||
* but explicit interrupt request was fired by cmsdk_ticker_fire_interrupt.
|
||||
*/
|
||||
if (timer_cmsdk_is_interrupt_active(timer_data->cfg->timer_driver)) {
|
||||
/* 1. Calculate cumulated time by overflow */
|
||||
timer_cmsdk_clear_interrupt(timer_data->cfg->timer_driver);
|
||||
reload_val = timer_cmsdk_get_reload_value(timer_data->cfg->timer_driver);
|
||||
timer_data->data->cumulated_time +=
|
||||
timer_data->cfg->convert_tick_to_time(reload_val);
|
||||
}
|
||||
|
||||
/* 2. Call mbed interval interrupt handler if it's required */
|
||||
if (timer_data->data->interval_callback_enabled) {
|
||||
cmsdk_ticker_disable_interrupt(timer_data);
|
||||
timer_data->cfg->interval_callback();
|
||||
}
|
||||
}
|
|
@ -0,0 +1,150 @@
|
|||
/*
|
||||
* Copyright (c) 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.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*
|
||||
*/
|
||||
|
||||
/**
|
||||
* \file cmsdk_ticker.h
|
||||
* CMSDK Ticker implements the functionalities of mbed tickers:
|
||||
* 1. Elapsed time measurement
|
||||
* 2. Interval interrupt request
|
||||
*
|
||||
* This ticker service is based on CMSDK APB Timers, abstracting
|
||||
* the HAL logic, the timer driver and interrupt number.
|
||||
* These parameters should be passed to the functions by
|
||||
* an initialized \ref tick_drv_data_t pointer.
|
||||
*/
|
||||
|
||||
#ifndef CMSDK_TICKER_H
|
||||
#define CMSDK_TICKER_H
|
||||
|
||||
#include <stdbool.h>
|
||||
|
||||
#include "CMSDK_CM3DS.h"
|
||||
#include "timer_cmsdk_drv.h"
|
||||
|
||||
#define SEC_TO_USEC_MULTIPLIER 1000000U
|
||||
|
||||
/**
|
||||
* brief Encapsulating struct for config data \ref tick_cfg_t and
|
||||
* the current status \ref tick_data_t.
|
||||
*/
|
||||
struct tick_drv_data_t {
|
||||
const struct tick_cfg_t* const cfg;
|
||||
struct tick_data_t* const data;
|
||||
};
|
||||
|
||||
/**
|
||||
* brief Configuration data of the CMSDK ticker
|
||||
*/
|
||||
struct tick_cfg_t {
|
||||
/** Pointer to the used CMSDK Timer's device structure */
|
||||
struct timer_cmsdk_dev_t* const timer_driver;
|
||||
/** IRQ number of the used CMSDK Timer */
|
||||
const IRQn_Type irq_n;
|
||||
/** Interval callback of mbed*/
|
||||
void (*const interval_callback)();
|
||||
/** Function pointers to call for conversions of clock ticks and defined
|
||||
* time unit.
|
||||
* These conversions define the unit of the measured time.
|
||||
*/
|
||||
uint32_t (*const convert_tick_to_time)(uint32_t tick);
|
||||
uint32_t (*const convert_time_to_tick)(uint32_t time);
|
||||
};
|
||||
|
||||
/**
|
||||
* brief Current state data of the CMSDK ticker
|
||||
*/
|
||||
struct tick_data_t {
|
||||
/** True if initialized the ticker, false otherwise */
|
||||
bool is_initialized;
|
||||
/** Measured elapsed time in the defined unit by
|
||||
* \ref convert_tick_to_time and \ref convert_time_to_tick */
|
||||
uint32_t cumulated_time;
|
||||
/** Max interval time possible to set, in the defined unit by
|
||||
* \ref convert_tick_to_time and \ref convert_time_to_tick */
|
||||
uint32_t max_interval_time;
|
||||
/** Current reload time in the defined unit by
|
||||
* \ref convert_tick_to_time and \ref convert_time_to_tick */
|
||||
uint32_t reload_time;
|
||||
/** Interval IRQ callback is requested */
|
||||
bool interval_callback_enabled;
|
||||
/** Previous cumulated time calculated for this ticker. Used in the
|
||||
* cmsdk_ticker_read function to detect that the timer has wrapped. */
|
||||
uint32_t previous_cumulated_time;
|
||||
/** Previous elapsed value for this ticker. Used in the
|
||||
* cmsdk_ticker_read function to detect that the timer has wrapped. */
|
||||
uint32_t previous_elapsed;
|
||||
};
|
||||
|
||||
/**
|
||||
* \brief Init the CMSDK Ticker
|
||||
*
|
||||
* \param[in] timer_data Pointer to the used CMSDK Timer's device structure
|
||||
*/
|
||||
void cmsdk_ticker_init(const struct tick_drv_data_t* timer_data);
|
||||
|
||||
/**
|
||||
* \brief Read elapsed time by CMSDK Ticker
|
||||
*
|
||||
* \param[in] timer_data Pointer to the used CMSDK Timer's device structure
|
||||
*
|
||||
* \return Elapsed time in the unit defined by \ref convert_tick_to_time
|
||||
*/
|
||||
|
||||
uint32_t cmsdk_ticker_read(const struct tick_drv_data_t* timer_data);
|
||||
|
||||
/**
|
||||
* \brief Request interval interrupt by time stamp \ref timestamp_t
|
||||
*
|
||||
* \param[in] timer_data Pointer to the used CMSDK Timer's device structure
|
||||
* \param[in] timestamp Absolute time \ref timestamp_t value when the interval
|
||||
* is requested. Unit of the timestamp is defined by
|
||||
* \ref convert_tick_to_time and \ref convert_time_to_tick
|
||||
*/
|
||||
void cmsdk_ticker_set_interrupt(const struct tick_drv_data_t* timer_data,
|
||||
uint32_t timestamp);
|
||||
|
||||
/**
|
||||
* \brief Disable interval interrupt
|
||||
*
|
||||
* \param[in] timer_data Pointer to the used CMSDK Timer's device structure
|
||||
*/
|
||||
void cmsdk_ticker_disable_interrupt(const struct tick_drv_data_t* timer_data);
|
||||
|
||||
/**
|
||||
* \brief Clear interval interrupt
|
||||
*
|
||||
* \param[in] timer_data Pointer to the used CMSDK Timer's device structure
|
||||
*/
|
||||
void cmsdk_ticker_clear_interrupt(const struct tick_drv_data_t* timer_data);
|
||||
|
||||
/**
|
||||
* \brief Set pending interrupt that should be fired right away.
|
||||
*
|
||||
* \param[in] timer_data Pointer to the used CMSDK Timer's device structure
|
||||
*/
|
||||
void cmsdk_ticker_fire_interrupt(const struct tick_drv_data_t* timer_data);
|
||||
|
||||
/**
|
||||
* \brief Interrupt handler of the given CMSDK Timer
|
||||
*
|
||||
* \warning This function may be called from multiple interrupt handlers,
|
||||
* so extra care must be taken for re-entrancy!
|
||||
*
|
||||
* \param[in] timer_data Pointer to the used CMSDK Timer's device structure
|
||||
*/
|
||||
void cmsdk_ticker_irq_handler(const struct tick_drv_data_t* timer_data);
|
||||
#endif
|
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
* Copyright (c) 2009-2017 ARM Limited. All rights reserved.
|
||||
* Copyright (c) 2009-2018 ARM Limited. All rights reserved.
|
||||
*
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
*
|
||||
|
@ -202,191 +202,6 @@ typedef struct
|
|||
#define CMSDK_UART_BAUDDIV_Pos 0 /* CMSDK_UART BAUDDIV: BAUDDIV Position */
|
||||
#define CMSDK_UART_BAUDDIV_Msk (0xFFFFFul << CMSDK_UART_BAUDDIV_Pos) /* CMSDK_UART BAUDDIV: BAUDDIV Mask */
|
||||
|
||||
|
||||
/*----------------------------- Timer (TIMER) -------------------------------*/
|
||||
typedef struct
|
||||
{
|
||||
__IO uint32_t CTRL; /* Offset: 0x000 (R/W) Control Register */
|
||||
__IO uint32_t VALUE; /* Offset: 0x004 (R/W) Current Value Register */
|
||||
__IO uint32_t RELOAD; /* Offset: 0x008 (R/W) Reload Value Register */
|
||||
union {
|
||||
__I uint32_t INTSTATUS; /* Offset: 0x00C (R/ ) Interrupt Status Register */
|
||||
__O uint32_t INTCLEAR; /* Offset: 0x00C ( /W) Interrupt Clear Register */
|
||||
};
|
||||
|
||||
} CMSDK_TIMER_TypeDef;
|
||||
|
||||
/* CMSDK_TIMER CTRL Register Definitions */
|
||||
|
||||
#define CMSDK_TIMER_CTRL_IRQEN_Pos 3 /* CMSDK_TIMER CTRL: IRQEN Position */
|
||||
#define CMSDK_TIMER_CTRL_IRQEN_Msk (0x01ul << CMSDK_TIMER_CTRL_IRQEN_Pos) /* CMSDK_TIMER CTRL: IRQEN Mask */
|
||||
|
||||
#define CMSDK_TIMER_CTRL_SELEXTCLK_Pos 2 /* CMSDK_TIMER CTRL: SELEXTCLK Position */
|
||||
#define CMSDK_TIMER_CTRL_SELEXTCLK_Msk (0x01ul << CMSDK_TIMER_CTRL_SELEXTCLK_Pos) /* CMSDK_TIMER CTRL: SELEXTCLK Mask */
|
||||
|
||||
#define CMSDK_TIMER_CTRL_SELEXTEN_Pos 1 /* CMSDK_TIMER CTRL: SELEXTEN Position */
|
||||
#define CMSDK_TIMER_CTRL_SELEXTEN_Msk (0x01ul << CMSDK_TIMER_CTRL_SELEXTEN_Pos) /* CMSDK_TIMER CTRL: SELEXTEN Mask */
|
||||
|
||||
#define CMSDK_TIMER_CTRL_EN_Pos 0 /* CMSDK_TIMER CTRL: EN Position */
|
||||
#define CMSDK_TIMER_CTRL_EN_Msk (0x01ul << CMSDK_TIMER_CTRL_EN_Pos) /* CMSDK_TIMER CTRL: EN Mask */
|
||||
|
||||
#define CMSDK_TIMER_VAL_CURRENT_Pos 0 /* CMSDK_TIMER VALUE: CURRENT Position */
|
||||
#define CMSDK_TIMER_VAL_CURRENT_Msk (0xFFFFFFFFul << CMSDK_TIMER_VAL_CURRENT_Pos) /* CMSDK_TIMER VALUE: CURRENT Mask */
|
||||
|
||||
#define CMSDK_TIMER_RELOAD_VAL_Pos 0 /* CMSDK_TIMER RELOAD: RELOAD Position */
|
||||
#define CMSDK_TIMER_RELOAD_VAL_Msk (0xFFFFFFFFul << CMSDK_TIMER_RELOAD_VAL_Pos) /* CMSDK_TIMER RELOAD: RELOAD Mask */
|
||||
|
||||
#define CMSDK_TIMER_INTSTATUS_Pos 0 /* CMSDK_TIMER INTSTATUS: INTSTATUSPosition */
|
||||
#define CMSDK_TIMER_INTSTATUS_Msk (0x01ul << CMSDK_TIMER_INTSTATUS_Pos) /* CMSDK_TIMER INTSTATUS: INTSTATUSMask */
|
||||
|
||||
#define CMSDK_TIMER_INTCLEAR_Pos 0 /* CMSDK_TIMER INTCLEAR: INTCLEAR Position */
|
||||
#define CMSDK_TIMER_INTCLEAR_Msk (0x01ul << CMSDK_TIMER_INTCLEAR_Pos) /* CMSDK_TIMER INTCLEAR: INTCLEAR Mask */
|
||||
|
||||
|
||||
/*------------- Timer (TIM) --------------------------------------------------*/
|
||||
typedef struct
|
||||
{
|
||||
__IO uint32_t Timer1Load; /* Offset: 0x000 (R/W) Timer 1 Load */
|
||||
__I uint32_t Timer1Value; /* Offset: 0x004 (R/ ) Timer 1 Counter Current Value */
|
||||
__IO uint32_t Timer1Control; /* Offset: 0x008 (R/W) Timer 1 Control */
|
||||
__O uint32_t Timer1IntClr; /* Offset: 0x00C ( /W) Timer 1 Interrupt Clear */
|
||||
__I uint32_t Timer1RIS; /* Offset: 0x010 (R/ ) Timer 1 Raw Interrupt Status */
|
||||
__I uint32_t Timer1MIS; /* Offset: 0x014 (R/ ) Timer 1 Masked Interrupt Status */
|
||||
__IO uint32_t Timer1BGLoad; /* Offset: 0x018 (R/W) Background Load Register */
|
||||
uint32_t RESERVED0;
|
||||
__IO uint32_t Timer2Load; /* Offset: 0x020 (R/W) Timer 2 Load */
|
||||
__I uint32_t Timer2Value; /* Offset: 0x024 (R/ ) Timer 2 Counter Current Value */
|
||||
__IO uint32_t Timer2Control; /* Offset: 0x028 (R/W) Timer 2 Control */
|
||||
__O uint32_t Timer2IntClr; /* Offset: 0x02C ( /W) Timer 2 Interrupt Clear */
|
||||
__I uint32_t Timer2RIS; /* Offset: 0x030 (R/ ) Timer 2 Raw Interrupt Status */
|
||||
__I uint32_t Timer2MIS; /* Offset: 0x034 (R/ ) Timer 2 Masked Interrupt Status */
|
||||
__IO uint32_t Timer2BGLoad; /* Offset: 0x038 (R/W) Background Load Register */
|
||||
uint32_t RESERVED1[945];
|
||||
__IO uint32_t ITCR; /* Offset: 0xF00 (R/W) Integration Test Control Register */
|
||||
__O uint32_t ITOP; /* Offset: 0xF04 ( /W) Integration Test Output Set Register */
|
||||
} CMSDK_DUALTIMER_BOTH_TypeDef;
|
||||
|
||||
#define CMSDK_DUALTIMER1_LOAD_Pos 0 /* CMSDK_DUALTIMER1 LOAD: LOAD Position */
|
||||
#define CMSDK_DUALTIMER1_LOAD_Msk (0xFFFFFFFFul << CMSDK_DUALTIMER1_LOAD_Pos) /* CMSDK_DUALTIMER1 LOAD: LOAD Mask */
|
||||
|
||||
#define CMSDK_DUALTIMER1_VALUE_Pos 0 /* CMSDK_DUALTIMER1 VALUE: VALUE Position */
|
||||
#define CMSDK_DUALTIMER1_VALUE_Msk (0xFFFFFFFFul << CMSDK_DUALTIMER1_VALUE_Pos) /* CMSDK_DUALTIMER1 VALUE: VALUE Mask */
|
||||
|
||||
#define CMSDK_DUALTIMER1_CTRL_EN_Pos 7 /* CMSDK_DUALTIMER1 CTRL_EN: CTRL Enable Position */
|
||||
#define CMSDK_DUALTIMER1_CTRL_EN_Msk (0x1ul << CMSDK_DUALTIMER1_CTRL_EN_Pos) /* CMSDK_DUALTIMER1 CTRL_EN: CTRL Enable Mask */
|
||||
|
||||
#define CMSDK_DUALTIMER1_CTRL_MODE_Pos 6 /* CMSDK_DUALTIMER1 CTRL_MODE: CTRL MODE Position */
|
||||
#define CMSDK_DUALTIMER1_CTRL_MODE_Msk (0x1ul << CMSDK_DUALTIMER1_CTRL_MODE_Pos) /* CMSDK_DUALTIMER1 CTRL_MODE: CTRL MODE Mask */
|
||||
|
||||
#define CMSDK_DUALTIMER1_CTRL_INTEN_Pos 5 /* CMSDK_DUALTIMER1 CTRL_INTEN: CTRL Int Enable Position */
|
||||
#define CMSDK_DUALTIMER1_CTRL_INTEN_Msk (0x1ul << CMSDK_DUALTIMER1_CTRL_INTEN_Pos) /* CMSDK_DUALTIMER1 CTRL_INTEN: CTRL Int Enable Mask */
|
||||
|
||||
#define CMSDK_DUALTIMER1_CTRL_PRESCALE_Pos 2 /* CMSDK_DUALTIMER1 CTRL_PRESCALE: CTRL PRESCALE Position */
|
||||
#define CMSDK_DUALTIMER1_CTRL_PRESCALE_Msk (0x3ul << CMSDK_DUALTIMER1_CTRL_PRESCALE_Pos) /* CMSDK_DUALTIMER1 CTRL_PRESCALE: CTRL PRESCALE Mask */
|
||||
|
||||
#define CMSDK_DUALTIMER1_CTRL_SIZE_Pos 1 /* CMSDK_DUALTIMER1 CTRL_SIZE: CTRL SIZE Position */
|
||||
#define CMSDK_DUALTIMER1_CTRL_SIZE_Msk (0x1ul << CMSDK_DUALTIMER1_CTRL_SIZE_Pos) /* CMSDK_DUALTIMER1 CTRL_SIZE: CTRL SIZE Mask */
|
||||
|
||||
#define CMSDK_DUALTIMER1_CTRL_ONESHOOT_Pos 0 /* CMSDK_DUALTIMER1 CTRL_ONESHOOT: CTRL ONESHOOT Position */
|
||||
#define CMSDK_DUALTIMER1_CTRL_ONESHOOT_Msk (0x1ul << CMSDK_DUALTIMER1_CTRL_ONESHOOT_Pos) /* CMSDK_DUALTIMER1 CTRL_ONESHOOT: CTRL ONESHOOT Mask */
|
||||
|
||||
#define CMSDK_DUALTIMER1_INTCLR_Pos 0 /* CMSDK_DUALTIMER1 INTCLR: INT Clear Position */
|
||||
#define CMSDK_DUALTIMER1_INTCLR_Msk (0x1ul << CMSDK_DUALTIMER1_INTCLR_Pos) /* CMSDK_DUALTIMER1 INTCLR: INT Clear Mask */
|
||||
|
||||
#define CMSDK_DUALTIMER1_RAWINTSTAT_Pos 0 /* CMSDK_DUALTIMER1 RAWINTSTAT: Raw Int Status Position */
|
||||
#define CMSDK_DUALTIMER1_RAWINTSTAT_Msk (0x1ul << CMSDK_DUALTIMER1_RAWINTSTAT_Pos) /* CMSDK_DUALTIMER1 RAWINTSTAT: Raw Int Status Mask */
|
||||
|
||||
#define CMSDK_DUALTIMER1_MASKINTSTAT_Pos 0 /* CMSDK_DUALTIMER1 MASKINTSTAT: Mask Int Status Position */
|
||||
#define CMSDK_DUALTIMER1_MASKINTSTAT_Msk (0x1ul << CMSDK_DUALTIMER1_MASKINTSTAT_Pos) /* CMSDK_DUALTIMER1 MASKINTSTAT: Mask Int Status Mask */
|
||||
|
||||
#define CMSDK_DUALTIMER1_BGLOAD_Pos 0 /* CMSDK_DUALTIMER1 BGLOAD: Background Load Position */
|
||||
#define CMSDK_DUALTIMER1_BGLOAD_Msk (0xFFFFFFFFul << CMSDK_DUALTIMER1_BGLOAD_Pos) /* CMSDK_DUALTIMER1 BGLOAD: Background Load Mask */
|
||||
|
||||
#define CMSDK_DUALTIMER2_LOAD_Pos 0 /* CMSDK_DUALTIMER2 LOAD: LOAD Position */
|
||||
#define CMSDK_DUALTIMER2_LOAD_Msk (0xFFFFFFFFul << CMSDK_DUALTIMER2_LOAD_Pos) /* CMSDK_DUALTIMER2 LOAD: LOAD Mask */
|
||||
|
||||
#define CMSDK_DUALTIMER2_VALUE_Pos 0 /* CMSDK_DUALTIMER2 VALUE: VALUE Position */
|
||||
#define CMSDK_DUALTIMER2_VALUE_Msk (0xFFFFFFFFul << CMSDK_DUALTIMER2_VALUE_Pos) /* CMSDK_DUALTIMER2 VALUE: VALUE Mask */
|
||||
|
||||
#define CMSDK_DUALTIMER2_CTRL_EN_Pos 7 /* CMSDK_DUALTIMER2 CTRL_EN: CTRL Enable Position */
|
||||
#define CMSDK_DUALTIMER2_CTRL_EN_Msk (0x1ul << CMSDK_DUALTIMER2_CTRL_EN_Pos) /* CMSDK_DUALTIMER2 CTRL_EN: CTRL Enable Mask */
|
||||
|
||||
#define CMSDK_DUALTIMER2_CTRL_MODE_Pos 6 /* CMSDK_DUALTIMER2 CTRL_MODE: CTRL MODE Position */
|
||||
#define CMSDK_DUALTIMER2_CTRL_MODE_Msk (0x1ul << CMSDK_DUALTIMER2_CTRL_MODE_Pos) /* CMSDK_DUALTIMER2 CTRL_MODE: CTRL MODE Mask */
|
||||
|
||||
#define CMSDK_DUALTIMER2_CTRL_INTEN_Pos 5 /* CMSDK_DUALTIMER2 CTRL_INTEN: CTRL Int Enable Position */
|
||||
#define CMSDK_DUALTIMER2_CTRL_INTEN_Msk (0x1ul << CMSDK_DUALTIMER2_CTRL_INTEN_Pos) /* CMSDK_DUALTIMER2 CTRL_INTEN: CTRL Int Enable Mask */
|
||||
|
||||
#define CMSDK_DUALTIMER2_CTRL_PRESCALE_Pos 2 /* CMSDK_DUALTIMER2 CTRL_PRESCALE: CTRL PRESCALE Position */
|
||||
#define CMSDK_DUALTIMER2_CTRL_PRESCALE_Msk (0x3ul << CMSDK_DUALTIMER2_CTRL_PRESCALE_Pos) /* CMSDK_DUALTIMER2 CTRL_PRESCALE: CTRL PRESCALE Mask */
|
||||
|
||||
#define CMSDK_DUALTIMER2_CTRL_SIZE_Pos 1 /* CMSDK_DUALTIMER2 CTRL_SIZE: CTRL SIZE Position */
|
||||
#define CMSDK_DUALTIMER2_CTRL_SIZE_Msk (0x1ul << CMSDK_DUALTIMER2_CTRL_SIZE_Pos) /* CMSDK_DUALTIMER2 CTRL_SIZE: CTRL SIZE Mask */
|
||||
|
||||
#define CMSDK_DUALTIMER2_CTRL_ONESHOOT_Pos 0 /* CMSDK_DUALTIMER2 CTRL_ONESHOOT: CTRL ONESHOOT Position */
|
||||
#define CMSDK_DUALTIMER2_CTRL_ONESHOOT_Msk (0x1ul << CMSDK_DUALTIMER2_CTRL_ONESHOOT_Pos) /* CMSDK_DUALTIMER2 CTRL_ONESHOOT: CTRL ONESHOOT Mask */
|
||||
|
||||
#define CMSDK_DUALTIMER2_INTCLR_Pos 0 /* CMSDK_DUALTIMER2 INTCLR: INT Clear Position */
|
||||
#define CMSDK_DUALTIMER2_INTCLR_Msk (0x1ul << CMSDK_DUALTIMER2_INTCLR_Pos) /* CMSDK_DUALTIMER2 INTCLR: INT Clear Mask */
|
||||
|
||||
#define CMSDK_DUALTIMER2_RAWINTSTAT_Pos 0 /* CMSDK_DUALTIMER2 RAWINTSTAT: Raw Int Status Position */
|
||||
#define CMSDK_DUALTIMER2_RAWINTSTAT_Msk (0x1ul << CMSDK_DUALTIMER2_RAWINTSTAT_Pos) /* CMSDK_DUALTIMER2 RAWINTSTAT: Raw Int Status Mask */
|
||||
|
||||
#define CMSDK_DUALTIMER2_MASKINTSTAT_Pos 0 /* CMSDK_DUALTIMER2 MASKINTSTAT: Mask Int Status Position */
|
||||
#define CMSDK_DUALTIMER2_MASKINTSTAT_Msk (0x1ul << CMSDK_DUALTIMER2_MASKINTSTAT_Pos) /* CMSDK_DUALTIMER2 MASKINTSTAT: Mask Int Status Mask */
|
||||
|
||||
#define CMSDK_DUALTIMER2_BGLOAD_Pos 0 /* CMSDK_DUALTIMER2 BGLOAD: Background Load Position */
|
||||
#define CMSDK_DUALTIMER2_BGLOAD_Msk (0xFFFFFFFFul << CMSDK_DUALTIMER2_BGLOAD_Pos) /* CMSDK_DUALTIMER2 BGLOAD: Background Load Mask */
|
||||
|
||||
|
||||
typedef struct
|
||||
{
|
||||
__IO uint32_t TimerLoad; /* Offset: 0x000 (R/W) Timer Load */
|
||||
__I uint32_t TimerValue; /* Offset: 0x000 (R/W) Timer Counter Current Value */
|
||||
__IO uint32_t TimerControl; /* Offset: 0x000 (R/W) Timer Control */
|
||||
__O uint32_t TimerIntClr; /* Offset: 0x000 (R/W) Timer Interrupt Clear */
|
||||
__I uint32_t TimerRIS; /* Offset: 0x000 (R/W) Timer Raw Interrupt Status */
|
||||
__I uint32_t TimerMIS; /* Offset: 0x000 (R/W) Timer Masked Interrupt Status */
|
||||
__IO uint32_t TimerBGLoad; /* Offset: 0x000 (R/W) Background Load Register */
|
||||
} CMSDK_DUALTIMER_SINGLE_TypeDef;
|
||||
|
||||
#define CMSDK_DUALTIMER_LOAD_Pos 0 /* CMSDK_DUALTIMER LOAD: LOAD Position */
|
||||
#define CMSDK_DUALTIMER_LOAD_Msk (0xFFFFFFFFul << CMSDK_DUALTIMER_LOAD_Pos) /* CMSDK_DUALTIMER LOAD: LOAD Mask */
|
||||
|
||||
#define CMSDK_DUALTIMER_VALUE_Pos 0 /* CMSDK_DUALTIMER VALUE: VALUE Position */
|
||||
#define CMSDK_DUALTIMER_VALUE_Msk (0xFFFFFFFFul << CMSDK_DUALTIMER_VALUE_Pos) /* CMSDK_DUALTIMER VALUE: VALUE Mask */
|
||||
|
||||
#define CMSDK_DUALTIMER_CTRL_EN_Pos 7 /* CMSDK_DUALTIMER CTRL_EN: CTRL Enable Position */
|
||||
#define CMSDK_DUALTIMER_CTRL_EN_Msk (0x1ul << CMSDK_DUALTIMER_CTRL_EN_Pos) /* CMSDK_DUALTIMER CTRL_EN: CTRL Enable Mask */
|
||||
|
||||
#define CMSDK_DUALTIMER_CTRL_MODE_Pos 6 /* CMSDK_DUALTIMER CTRL_MODE: CTRL MODE Position */
|
||||
#define CMSDK_DUALTIMER_CTRL_MODE_Msk (0x1ul << CMSDK_DUALTIMER_CTRL_MODE_Pos) /* CMSDK_DUALTIMER CTRL_MODE: CTRL MODE Mask */
|
||||
|
||||
#define CMSDK_DUALTIMER_CTRL_INTEN_Pos 5 /* CMSDK_DUALTIMER CTRL_INTEN: CTRL Int Enable Position */
|
||||
#define CMSDK_DUALTIMER_CTRL_INTEN_Msk (0x1ul << CMSDK_DUALTIMER_CTRL_INTEN_Pos) /* CMSDK_DUALTIMER CTRL_INTEN: CTRL Int Enable Mask */
|
||||
|
||||
#define CMSDK_DUALTIMER_CTRL_PRESCALE_Pos 2 /* CMSDK_DUALTIMER CTRL_PRESCALE: CTRL PRESCALE Position */
|
||||
#define CMSDK_DUALTIMER_CTRL_PRESCALE_Msk (0x3ul << CMSDK_DUALTIMER_CTRL_PRESCALE_Pos) /* CMSDK_DUALTIMER CTRL_PRESCALE: CTRL PRESCALE Mask */
|
||||
|
||||
#define CMSDK_DUALTIMER_CTRL_SIZE_Pos 1 /* CMSDK_DUALTIMER CTRL_SIZE: CTRL SIZE Position */
|
||||
#define CMSDK_DUALTIMER_CTRL_SIZE_Msk (0x1ul << CMSDK_DUALTIMER_CTRL_SIZE_Pos) /* CMSDK_DUALTIMER CTRL_SIZE: CTRL SIZE Mask */
|
||||
|
||||
#define CMSDK_DUALTIMER_CTRL_ONESHOOT_Pos 0 /* CMSDK_DUALTIMER CTRL_ONESHOOT: CTRL ONESHOOT Position */
|
||||
#define CMSDK_DUALTIMER_CTRL_ONESHOOT_Msk (0x1ul << CMSDK_DUALTIMER_CTRL_ONESHOOT_Pos) /* CMSDK_DUALTIMER CTRL_ONESHOOT: CTRL ONESHOOT Mask */
|
||||
|
||||
#define CMSDK_DUALTIMER_INTCLR_Pos 0 /* CMSDK_DUALTIMER INTCLR: INT Clear Position */
|
||||
#define CMSDK_DUALTIMER_INTCLR_Msk (0x1ul << CMSDK_DUALTIMER_INTCLR_Pos) /* CMSDK_DUALTIMER INTCLR: INT Clear Mask */
|
||||
|
||||
#define CMSDK_DUALTIMER_RAWINTSTAT_Pos 0 /* CMSDK_DUALTIMER RAWINTSTAT: Raw Int Status Position */
|
||||
#define CMSDK_DUALTIMER_RAWINTSTAT_Msk (0x1ul << CMSDK_DUALTIMER_RAWINTSTAT_Pos) /* CMSDK_DUALTIMER RAWINTSTAT: Raw Int Status Mask */
|
||||
|
||||
#define CMSDK_DUALTIMER_MASKINTSTAT_Pos 0 /* CMSDK_DUALTIMER MASKINTSTAT: Mask Int Status Position */
|
||||
#define CMSDK_DUALTIMER_MASKINTSTAT_Msk (0x1ul << CMSDK_DUALTIMER_MASKINTSTAT_Pos) /* CMSDK_DUALTIMER MASKINTSTAT: Mask Int Status Mask */
|
||||
|
||||
#define CMSDK_DUALTIMER_BGLOAD_Pos 0 /* CMSDK_DUALTIMER BGLOAD: Background Load Position */
|
||||
#define CMSDK_DUALTIMER_BGLOAD_Msk (0xFFFFFFFFul << CMSDK_DUALTIMER_BGLOAD_Pos) /* CMSDK_DUALTIMER BGLOAD: Background Load Mask */
|
||||
|
||||
|
||||
/*-------------------- General Purpose Input Output (GPIO) -------------------*/
|
||||
typedef struct
|
||||
{
|
||||
|
@ -760,11 +575,6 @@ typedef struct
|
|||
#define CMSDK_UART2 ((CMSDK_UART_TypeDef *) CMSDK_UART2_BASE )
|
||||
#define CMSDK_UART3 ((CMSDK_UART_TypeDef *) CMSDK_UART3_BASE )
|
||||
#define CMSDK_UART4 ((CMSDK_UART_TypeDef *) CMSDK_UART4_BASE )
|
||||
#define CMSDK_TIMER0 ((CMSDK_TIMER_TypeDef *) CMSDK_TIMER0_BASE )
|
||||
#define CMSDK_TIMER1 ((CMSDK_TIMER_TypeDef *) CMSDK_TIMER1_BASE )
|
||||
#define CMSDK_DUALTIMER ((CMSDK_DUALTIMER_BOTH_TypeDef *) CMSDK_DUALTIMER_BASE )
|
||||
#define CMSDK_DUALTIMER1 ((CMSDK_DUALTIMER_SINGLE_TypeDef *) CMSDK_DUALTIMER_1_BASE )
|
||||
#define CMSDK_DUALTIMER2 ((CMSDK_DUALTIMER_SINGLE_TypeDef *) CMSDK_DUALTIMER_2_BASE )
|
||||
#define CMSDK_RTC ((CMSDK_RTC_TypeDef *) CMSDK_RTC_BASE )
|
||||
#define CMSDK_WATCHDOG ((CMSDK_WATCHDOG_TypeDef *) CMSDK_WATCHDOG_BASE )
|
||||
#define CMSDK_GPIO0 ((CMSDK_GPIO_TypeDef *) CMSDK_GPIO0_BASE )
|
||||
|
|
|
@ -1,265 +0,0 @@
|
|||
/* mbed Microcontroller Library
|
||||
* Copyright (c) 2016 ARM Limited
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
#include "cmsis.h"
|
||||
#include "apb_timer.h"
|
||||
|
||||
/* Timer Private Data */
|
||||
typedef struct {
|
||||
/* Timer Definition */
|
||||
CMSDK_TIMER_TypeDef *timerN;
|
||||
/* Timer IRQn */
|
||||
uint32_t timerIRQn;
|
||||
/* Timer Reload Value */
|
||||
uint32_t timerReload;
|
||||
/* Timer state */
|
||||
uint32_t state;
|
||||
} apb_timer_t;
|
||||
|
||||
/* Timer state definitions */
|
||||
#define TIMER_INITIALIZED (1)
|
||||
#define TIMER_ENABLED (1 << 1)
|
||||
|
||||
/*
|
||||
* This Timer is written for MBED OS and keeps count
|
||||
* of the ticks. All the elaboration logic is demanded
|
||||
* to the upper layers.
|
||||
*/
|
||||
#define TIMER_MAX_VALUE 0xFFFFFFFF
|
||||
#define TIMER_TICKS_US (SystemCoreClock/1000000)
|
||||
|
||||
/* Timers Array */
|
||||
static apb_timer_t Timers[NUM_TIMERS];
|
||||
|
||||
void Timer_Index_Init(uint32_t timer, uint32_t reload,
|
||||
CMSDK_TIMER_TypeDef *TimerN, uint32_t IRQn)
|
||||
{
|
||||
Timers[timer].timerN = TimerN;
|
||||
Timers[timer].timerIRQn = IRQn;
|
||||
Timers[timer].timerReload = reload;
|
||||
Timers[timer].state = TIMER_INITIALIZED;
|
||||
}
|
||||
|
||||
/*
|
||||
* Timer_Initialize(): Initializes an hardware timer
|
||||
* timer: timer to be Initialized
|
||||
* time_us: timer reload value in us - 0 to reload to timer max value
|
||||
* time_us = tick_value / TIMER_TICKS_US
|
||||
*/
|
||||
#define TIMER_INIT(index, reload) Timer_Index_Init(index, reload, CMSDK_TIMER##index, TIMER##index##_IRQn)
|
||||
void Timer_Initialize(uint32_t timer, uint32_t time_us)
|
||||
{
|
||||
uint32_t reload = 0;
|
||||
|
||||
if (timer < NUM_TIMERS) {
|
||||
if (time_us == 0) {
|
||||
reload = TIMER_MAX_VALUE;
|
||||
} else {
|
||||
reload = (time_us) * TIMER_TICKS_US;
|
||||
}
|
||||
switch (timer) {
|
||||
case 0:
|
||||
TIMER_INIT(0, reload);
|
||||
break;
|
||||
case 1:
|
||||
TIMER_INIT(1, reload);
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* Timer_Enable(): Enables a hardware timer
|
||||
* timer: timer to be enabled
|
||||
*/
|
||||
void Timer_Enable(uint32_t timer)
|
||||
{
|
||||
/* The timer has to be contained in a valid range */
|
||||
if (timer < NUM_TIMERS) {
|
||||
/* Timer has to be already initialized */
|
||||
if (Timers[timer].state == TIMER_INITIALIZED) {
|
||||
/* Disable Timer */
|
||||
(Timers[timer].timerN)->CTRL = 0x0;
|
||||
/* Reload Value */
|
||||
(Timers[timer].timerN)->RELOAD = Timers[timer].timerReload;
|
||||
/* Enable Interrupt */
|
||||
(Timers[timer].timerN)->CTRL = CMSDK_TIMER_CTRL_IRQEN_Msk;
|
||||
/* Enable Counter */
|
||||
(Timers[timer].timerN)->CTRL |= CMSDK_TIMER_CTRL_EN_Msk;
|
||||
/* Change timer state */
|
||||
Timers[timer].state |= TIMER_ENABLED;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* Timer_Disable(): Disables a hardware timer
|
||||
* timer: timer to be disabled
|
||||
*/
|
||||
void Timer_Disable(uint32_t timer)
|
||||
{
|
||||
/* The timer has to be contained in a valid range */
|
||||
if (timer < NUM_TIMERS) {
|
||||
/* Timer has to be already initialized and enabled */
|
||||
if (Timers[timer].state == (TIMER_INITIALIZED | TIMER_ENABLED)) {
|
||||
/* Disable Timer */
|
||||
(Timers[timer].timerN)->CTRL = 0x0;
|
||||
/* Change timer state */
|
||||
Timers[timer].state = TIMER_INITIALIZED;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* Timer_isEnabled(): verifies if a timer is enabled
|
||||
* timer: timer to be verified
|
||||
* @return: 0 disabled - 1 enabled
|
||||
*/
|
||||
uint32_t Timer_isEnabled(uint32_t timer)
|
||||
{
|
||||
/* The timer has to be contained in a valid range */
|
||||
if (timer < NUM_TIMERS) {
|
||||
/* Timer has to be already initialized and enabled */
|
||||
if (Timers[timer].state == (TIMER_INITIALIZED | TIMER_ENABLED)) {
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
/*
|
||||
* Timer_Read(): provides timer VALUE
|
||||
* timer: timer to be read
|
||||
* @return: timer VALUE us
|
||||
*/
|
||||
uint32_t Timer_Read(uint32_t timer)
|
||||
{
|
||||
uint32_t return_value = 0;
|
||||
/* Verify if the Timer is enabled */
|
||||
if (Timer_isEnabled(timer) == 1) {
|
||||
return_value = (Timers[timer].timerReload
|
||||
- (Timers[timer].timerN)->VALUE) / TIMER_TICKS_US;
|
||||
}
|
||||
|
||||
return return_value;
|
||||
}
|
||||
|
||||
/*
|
||||
* Timer_SetInterrupt(): sets timer Interrupt
|
||||
* timer: timer on which interrupt is set
|
||||
* time_us: reloading time in us
|
||||
*/
|
||||
void Timer_SetInterrupt(uint32_t timer, uint32_t time_us)
|
||||
{
|
||||
uint32_t load_time_us = 0;
|
||||
/* Verify if the Timer is enabled */
|
||||
if (Timer_isEnabled(timer) == 1) {
|
||||
/* Disable Timer */
|
||||
Timer_Disable(timer);
|
||||
/* Enable Interrupt */
|
||||
(Timers[timer].timerN)->CTRL = CMSDK_TIMER_CTRL_IRQEN_Msk;
|
||||
|
||||
/* Check time us condition */
|
||||
if (time_us == TIMER_DEFAULT_RELOAD) {
|
||||
load_time_us = TIMER_MAX_VALUE;
|
||||
} else {
|
||||
load_time_us = time_us * TIMER_TICKS_US;
|
||||
}
|
||||
|
||||
/* Initialize Timer Value */
|
||||
Timers[timer].timerReload = load_time_us;
|
||||
(Timers[timer].timerN)->RELOAD = Timers[timer].timerReload;
|
||||
(Timers[timer].timerN)->VALUE = Timers[timer].timerReload;
|
||||
/* Enable Counter */
|
||||
(Timers[timer].timerN)->CTRL |= CMSDK_TIMER_CTRL_EN_Msk;
|
||||
/* Change timer state */
|
||||
Timers[timer].state |= TIMER_ENABLED;
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* Timer_DisableInterrupt(): disables timer interrupt
|
||||
* timer: timer on which interrupt is disabled
|
||||
*/
|
||||
void Timer_DisableInterrupt(uint32_t timer)
|
||||
{
|
||||
/* Verify if the Timer is enabled */
|
||||
if (Timer_isEnabled(timer) == 1) {
|
||||
/* Disable Interrupt */
|
||||
(Timers[timer].timerN)->CTRL &= CMSDK_TIMER_CTRL_EN_Msk;
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* Timer_ClearInterrupt(): clear timer interrupt
|
||||
* timer: timer on which interrupt needs to be cleared
|
||||
*/
|
||||
void Timer_ClearInterrupt(uint32_t timer)
|
||||
{
|
||||
/* Verify if the Timer is enabled */
|
||||
if (Timer_isEnabled(timer) == 1) {
|
||||
/* Clear Interrupt */
|
||||
(Timers[timer].timerN)->INTCLEAR = CMSDK_TIMER_INTCLEAR_Msk;
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* Timer_GetIRQn(): returns IRQn of a Timer
|
||||
* timer: timer on which IRQn is defined - 0 if it is not defined
|
||||
*/
|
||||
uint32_t Timer_GetIRQn(uint32_t timer)
|
||||
{
|
||||
/* Verify if the Timer is enabled */
|
||||
if (Timer_isEnabled(timer) == 1) {
|
||||
return Timers[timer].timerIRQn;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
/*
|
||||
* Timer_GetTicksUS(): returns the number of Ticks per us
|
||||
* timer: timer associated with the Ticks per us
|
||||
* @return: Ticks per us - 0 if the timer is disables
|
||||
*/
|
||||
uint32_t Timer_GetTicksUS(uint32_t timer)
|
||||
{
|
||||
/* Verify if the Timer is enabled */
|
||||
if (Timer_isEnabled(timer) == 1) {
|
||||
return TIMER_TICKS_US;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
/*
|
||||
* Timer_GetReloadValue(): returns the load value of the selected
|
||||
* timer.
|
||||
* timer: timer associated with the Ticks per us
|
||||
* @return: reload value of the selected singletimer
|
||||
*/
|
||||
uint32_t Timer_GetReloadValue(uint32_t timer)
|
||||
{
|
||||
/* Verify if the Timer is enabled */
|
||||
if (Timer_isEnabled(timer) == 1) {
|
||||
if (timer == TIMER1) {
|
||||
return Timers[timer].timerReload / TIMER_TICKS_US;
|
||||
} else {
|
||||
return Timers[timer].timerReload / TIMER_TICKS_US;
|
||||
}
|
||||
}
|
||||
return 0;
|
||||
}
|
|
@ -1,111 +0,0 @@
|
|||
/* mbed Microcontroller Library
|
||||
* Copyright (c) 2016 ARM Limited
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
/* This file is derivative of apb_timer.h from BEETLE */
|
||||
|
||||
#ifndef _APB_TIMER_DRV_H
|
||||
#define _APB_TIMER_DRV_H
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/* Supported Number of Timers */
|
||||
#define NUM_TIMERS 2
|
||||
#define TIMER0 0
|
||||
#define TIMER1 1
|
||||
|
||||
/* Default reload */
|
||||
#define TIMER_DEFAULT_RELOAD 0xFFFFFFFF
|
||||
|
||||
/*
|
||||
* Timer_Initialize(): Initializes an hardware timer
|
||||
* timer: timer to be Initialized
|
||||
* time_us: timer reload value in us - 0 to reload to timer max value
|
||||
* time_us = tick_value / TIMER_TICK_US
|
||||
*/
|
||||
void Timer_Initialize(uint32_t timer, uint32_t time_us);
|
||||
|
||||
/*
|
||||
* Timer_Enable(): Enables an hardware timer
|
||||
* timer: timer to be enabled
|
||||
*/
|
||||
void Timer_Enable(uint32_t timer);
|
||||
|
||||
/*
|
||||
* Timer_Disable(): Disables an hardware timer
|
||||
* timer: timer to be disabled
|
||||
*/
|
||||
void Timer_Disable(uint32_t timer);
|
||||
|
||||
/*
|
||||
* Timer_isEnabled(): verifies if a timer is enabled
|
||||
* timer: timer to be verified
|
||||
* @return: 0 disabled - 1 enabled
|
||||
*/
|
||||
uint32_t Timer_isEnabled(uint32_t timer);
|
||||
|
||||
/*
|
||||
* Timer_Read(): provides timer VALUE
|
||||
* timer: timer to be read
|
||||
* @return: timer VALUE
|
||||
*/
|
||||
uint32_t Timer_Read(uint32_t timer);
|
||||
|
||||
/*
|
||||
* Timer_SetInterrupt(): sets timer Interrupt
|
||||
* timer: timer on which interrupt is set
|
||||
* time_us: reloading time in us
|
||||
*/
|
||||
void Timer_SetInterrupt(uint32_t timer, uint32_t time_us);
|
||||
|
||||
/*
|
||||
* Timer_DisableInterrupt(): disables timer interrupt
|
||||
* timer: timer on which interrupt is disabled
|
||||
*/
|
||||
void Timer_DisableInterrupt(uint32_t timer);
|
||||
|
||||
/*
|
||||
* Timer_ClearInterrupt(): clear timer interrupt
|
||||
* timer: timer on which interrupt needs to be cleared
|
||||
*/
|
||||
void Timer_ClearInterrupt(uint32_t timer);
|
||||
|
||||
/*
|
||||
* Timer_GetIRQn(): returns IRQn of a Timer
|
||||
* timer: timer on which IRQn is defined - 0 if it is not defined
|
||||
*/
|
||||
uint32_t Timer_GetIRQn(uint32_t timer);
|
||||
|
||||
/*
|
||||
* Timer_GetTicksUS(): returns the number of Ticks per us
|
||||
* timer: timer associated with the Ticks per us
|
||||
* @return: Ticks per us - 0 if the timer is disables
|
||||
*/
|
||||
uint32_t Timer_GetTicksUS(uint32_t timer);
|
||||
|
||||
/*
|
||||
* Timer_GetReloadValue(): returns the load value of the selected
|
||||
* timer.
|
||||
* timer: timer associated with the Ticks per us
|
||||
* @return: reload value of the selected singletimer
|
||||
*/
|
||||
uint32_t Timer_GetReloadValue(uint32_t timer);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
#endif /* _APB_TIMER_DRV_H */
|
|
@ -1,5 +1,5 @@
|
|||
/* mbed Microcontroller Library
|
||||
* Copyright (c) 2015-2017 ARM Limited
|
||||
* Copyright (c) 2015-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.
|
||||
|
@ -25,7 +25,5 @@
|
|||
#include "SMM_MPS2.h"
|
||||
/* NVIC Driver */
|
||||
#include "cmsis_nvic.h"
|
||||
/* APB Timer */
|
||||
#include "apb_timer.h"
|
||||
|
||||
#endif /* MBED_CMSIS_H */
|
||||
|
|
|
@ -0,0 +1,33 @@
|
|||
/*
|
||||
* Copyright (c) 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.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
#ifndef __ARM_LTD_DEVICE_CFG_H__
|
||||
#define __ARM_LTD_DEVICE_CFG_H__
|
||||
|
||||
/**
|
||||
* \file device_cfg.h
|
||||
* \brief
|
||||
* This is the default device configuration file with all peripherals
|
||||
* defined and configured to be used via the non-secure base address.
|
||||
* This file is an example of how to define your own configuration file
|
||||
* with the peripherals required for your application.
|
||||
*/
|
||||
|
||||
/* CMSDK Timers */
|
||||
#define ARM_CMSDK_TIMER0
|
||||
#define ARM_CMSDK_TIMER1
|
||||
|
||||
#endif /* __ARM_LTD_DEVICE_CFG_H__ */
|
|
@ -0,0 +1,223 @@
|
|||
/*
|
||||
* Copyright (c) 2016-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.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
/**
|
||||
* \file timer_cmsdk_drv.c
|
||||
* \brief Generic driver for CMSDK APB Timers.
|
||||
* The timer is a 32-bit down-counter with the following features:
|
||||
* - optional programmable external clock source
|
||||
* - programmable interrupt source, triggered if counter reaches 0
|
||||
* - automatic reload if counter reaches 0
|
||||
*/
|
||||
|
||||
#include "timer_cmsdk_drv.h"
|
||||
|
||||
/** Setter bit manipulation macro */
|
||||
#define SET_BIT(WORD, BIT_INDEX) ((WORD) |= (1U << (BIT_INDEX)))
|
||||
/** Clearing bit manipulation macro */
|
||||
#define CLR_BIT(WORD, BIT_INDEX) ((WORD) &= ~(1U << (BIT_INDEX)))
|
||||
/** Getter bit manipulation macro */
|
||||
#define GET_BIT(WORD, BIT_INDEX) (bool)(((WORD) & (1U << (BIT_INDEX))))
|
||||
|
||||
/**
|
||||
* \brief Timer register map structure
|
||||
*
|
||||
*/
|
||||
struct timer_cmsdk_reg_map_t {
|
||||
volatile uint32_t ctrl; /* Offset: 0x000 (R/W) control register */
|
||||
volatile uint32_t value; /* Offset: 0x004 (R/W) current value register */
|
||||
volatile uint32_t reload; /* Offset: 0x008 (R/W) reload value register */
|
||||
union {
|
||||
volatile uint32_t intstatus; /* Offset: 0x00C (R/ ) interrupt
|
||||
* status register */
|
||||
volatile uint32_t intclear; /* Offset: 0x00C ( /W) interrupt
|
||||
* clear register */
|
||||
}intreg;
|
||||
};
|
||||
|
||||
/**
|
||||
* \brief CTRL register bit definitions
|
||||
*
|
||||
*/
|
||||
enum ctrl_reg_bits_t{
|
||||
CTRL_REG_ENUM_ENABLE_INDEX = 0,
|
||||
CTRL_REG_ENUM_EXTERNAL_INPUT_ENABLE_INDEX = 1,
|
||||
CTRL_REG_ENUM_EXTERNAL_INPUT_CLOCK_INDEX = 2,
|
||||
CTRL_REG_ENUM_IRQ_ENABLE_INDEX = 3
|
||||
};
|
||||
|
||||
/**
|
||||
* \brief INTSTATUS/INTCLEAR register bit definitions
|
||||
*
|
||||
*/
|
||||
enum interrupt_reg_bits_t{
|
||||
INTERRUPT_REG_ENUM_STATUS_AND_CLEAR_INDEX = 0
|
||||
};
|
||||
|
||||
void timer_cmsdk_init(const struct timer_cmsdk_dev_t* dev)
|
||||
{
|
||||
struct timer_cmsdk_reg_map_t* register_map =
|
||||
(struct timer_cmsdk_reg_map_t*)dev->cfg->base;
|
||||
|
||||
if (dev->data->is_initialized == 0) {
|
||||
register_map->ctrl = 0;
|
||||
register_map->reload = TIMER_CMSDK_DEFAULT_RELOAD;
|
||||
dev->data->is_initialized = 1;
|
||||
}
|
||||
}
|
||||
|
||||
bool timer_cmsdk_is_initialized(const struct timer_cmsdk_dev_t* dev)
|
||||
{
|
||||
return dev->data->is_initialized;
|
||||
}
|
||||
|
||||
void timer_cmsdk_enable_external_input(const struct timer_cmsdk_dev_t* dev)
|
||||
{
|
||||
struct timer_cmsdk_reg_map_t* register_map =
|
||||
(struct timer_cmsdk_reg_map_t*)dev->cfg->base;
|
||||
SET_BIT(register_map->ctrl, CTRL_REG_ENUM_EXTERNAL_INPUT_ENABLE_INDEX);
|
||||
}
|
||||
|
||||
void timer_cmsdk_disable_external_input(const struct timer_cmsdk_dev_t* dev)
|
||||
{
|
||||
struct timer_cmsdk_reg_map_t* register_map =
|
||||
(struct timer_cmsdk_reg_map_t*)dev->cfg->base;
|
||||
CLR_BIT(register_map->ctrl, CTRL_REG_ENUM_EXTERNAL_INPUT_ENABLE_INDEX);
|
||||
}
|
||||
|
||||
bool timer_cmsdk_is_external_input_enabled(const struct timer_cmsdk_dev_t* dev)
|
||||
{
|
||||
struct timer_cmsdk_reg_map_t* register_map =
|
||||
(struct timer_cmsdk_reg_map_t*)dev->cfg->base;
|
||||
return GET_BIT(register_map->ctrl,
|
||||
CTRL_REG_ENUM_EXTERNAL_INPUT_ENABLE_INDEX);
|
||||
}
|
||||
|
||||
void timer_cmsdk_set_clock_to_internal(const struct timer_cmsdk_dev_t* dev)
|
||||
{
|
||||
struct timer_cmsdk_reg_map_t* register_map =
|
||||
(struct timer_cmsdk_reg_map_t*)dev->cfg->base;
|
||||
CLR_BIT(register_map->ctrl, CTRL_REG_ENUM_EXTERNAL_INPUT_CLOCK_INDEX);
|
||||
}
|
||||
|
||||
void timer_cmsdk_set_clock_to_external(const struct timer_cmsdk_dev_t* dev)
|
||||
{
|
||||
struct timer_cmsdk_reg_map_t* register_map =
|
||||
(struct timer_cmsdk_reg_map_t*)dev->cfg->base;
|
||||
SET_BIT(register_map->ctrl, CTRL_REG_ENUM_EXTERNAL_INPUT_CLOCK_INDEX);
|
||||
}
|
||||
|
||||
bool timer_cmsdk_is_clock_external(const struct timer_cmsdk_dev_t* dev)
|
||||
{
|
||||
struct timer_cmsdk_reg_map_t* register_map =
|
||||
(struct timer_cmsdk_reg_map_t*)dev->cfg->base;
|
||||
return GET_BIT(register_map->ctrl,
|
||||
CTRL_REG_ENUM_EXTERNAL_INPUT_CLOCK_INDEX);
|
||||
}
|
||||
|
||||
void timer_cmsdk_enable(const struct timer_cmsdk_dev_t* dev)
|
||||
{
|
||||
struct timer_cmsdk_reg_map_t* register_map =
|
||||
(struct timer_cmsdk_reg_map_t*)dev->cfg->base;
|
||||
SET_BIT(register_map->ctrl, CTRL_REG_ENUM_ENABLE_INDEX);
|
||||
}
|
||||
|
||||
void timer_cmsdk_disable(const struct timer_cmsdk_dev_t* dev)
|
||||
{
|
||||
struct timer_cmsdk_reg_map_t* register_map =
|
||||
(struct timer_cmsdk_reg_map_t*)dev->cfg->base;
|
||||
CLR_BIT(register_map->ctrl, CTRL_REG_ENUM_ENABLE_INDEX);
|
||||
}
|
||||
|
||||
bool timer_cmsdk_is_enabled(const struct timer_cmsdk_dev_t* dev)
|
||||
{
|
||||
struct timer_cmsdk_reg_map_t* register_map =
|
||||
(struct timer_cmsdk_reg_map_t*)dev->cfg->base;
|
||||
return GET_BIT(register_map->ctrl, CTRL_REG_ENUM_ENABLE_INDEX);
|
||||
}
|
||||
|
||||
void timer_cmsdk_enable_interrupt(const struct timer_cmsdk_dev_t* dev)
|
||||
{
|
||||
struct timer_cmsdk_reg_map_t* register_map =
|
||||
(struct timer_cmsdk_reg_map_t*)dev->cfg->base;
|
||||
SET_BIT(register_map->ctrl, CTRL_REG_ENUM_IRQ_ENABLE_INDEX);
|
||||
}
|
||||
|
||||
void timer_cmsdk_disable_interrupt(const struct timer_cmsdk_dev_t* dev)
|
||||
{
|
||||
struct timer_cmsdk_reg_map_t* register_map =
|
||||
(struct timer_cmsdk_reg_map_t*)dev->cfg->base;
|
||||
CLR_BIT(register_map->ctrl, CTRL_REG_ENUM_IRQ_ENABLE_INDEX);
|
||||
}
|
||||
|
||||
bool timer_cmsdk_is_interrupt_enabled(const struct timer_cmsdk_dev_t* dev)
|
||||
{
|
||||
struct timer_cmsdk_reg_map_t* register_map =
|
||||
(struct timer_cmsdk_reg_map_t*)dev->cfg->base;
|
||||
return GET_BIT(register_map->ctrl, CTRL_REG_ENUM_IRQ_ENABLE_INDEX);
|
||||
}
|
||||
|
||||
bool timer_cmsdk_is_interrupt_active(const struct timer_cmsdk_dev_t* dev)
|
||||
{
|
||||
struct timer_cmsdk_reg_map_t* register_map =
|
||||
(struct timer_cmsdk_reg_map_t*)dev->cfg->base;
|
||||
return GET_BIT(register_map->intreg.intstatus,
|
||||
INTERRUPT_REG_ENUM_STATUS_AND_CLEAR_INDEX);
|
||||
}
|
||||
|
||||
void timer_cmsdk_clear_interrupt(const struct timer_cmsdk_dev_t* dev)
|
||||
{
|
||||
struct timer_cmsdk_reg_map_t* register_map =
|
||||
(struct timer_cmsdk_reg_map_t*)dev->cfg->base;
|
||||
SET_BIT(register_map->intreg.intclear,
|
||||
INTERRUPT_REG_ENUM_STATUS_AND_CLEAR_INDEX);
|
||||
}
|
||||
|
||||
uint32_t timer_cmsdk_get_current_value(const struct timer_cmsdk_dev_t* dev)
|
||||
{
|
||||
struct timer_cmsdk_reg_map_t* register_map =
|
||||
(struct timer_cmsdk_reg_map_t*)dev->cfg->base;
|
||||
return register_map->value;
|
||||
}
|
||||
|
||||
void timer_cmsdk_set_reload_value(const struct timer_cmsdk_dev_t* dev,
|
||||
uint32_t reload)
|
||||
{
|
||||
struct timer_cmsdk_reg_map_t* register_map =
|
||||
(struct timer_cmsdk_reg_map_t*)dev->cfg->base;
|
||||
register_map->reload = reload;
|
||||
}
|
||||
|
||||
void timer_cmsdk_reset(const struct timer_cmsdk_dev_t* dev)
|
||||
{
|
||||
struct timer_cmsdk_reg_map_t* register_map =
|
||||
(struct timer_cmsdk_reg_map_t*)dev->cfg->base;
|
||||
register_map->value = register_map->reload;
|
||||
}
|
||||
|
||||
uint32_t timer_cmsdk_get_reload_value(const struct timer_cmsdk_dev_t* dev)
|
||||
{
|
||||
struct timer_cmsdk_reg_map_t* register_map =
|
||||
(struct timer_cmsdk_reg_map_t*)dev->cfg->base;
|
||||
return register_map->reload;
|
||||
}
|
||||
|
||||
uint32_t timer_cmsdk_get_elapsed_value(const struct timer_cmsdk_dev_t* dev)
|
||||
{
|
||||
struct timer_cmsdk_reg_map_t* register_map =
|
||||
(struct timer_cmsdk_reg_map_t*)dev->cfg->base;
|
||||
return register_map->reload - register_map->value;
|
||||
}
|
|
@ -0,0 +1,254 @@
|
|||
/*
|
||||
* Copyright (c) 2016-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.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
/**
|
||||
* \file timer_cmsdk_drv.h
|
||||
* \brief Generic driver for CMSDK APB Timers.
|
||||
* The timer is a 32-bit down-counter with the following features:
|
||||
* - optional programmable external clock source
|
||||
* - programmable interrupt source, triggered if counter reaches 0
|
||||
* - automatic reload if counter reaches 0
|
||||
*/
|
||||
|
||||
#ifndef __TIMER_CMSDK_DRV_H__
|
||||
#define __TIMER_CMSDK_DRV_H__
|
||||
|
||||
#include <stdint.h>
|
||||
#include <stdbool.h>
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/* Maximum reload value */
|
||||
#define TIMER_CMSDK_MAX_RELOAD UINT32_MAX /* max of 32-bit */
|
||||
#define TIMER_CMSDK_DEFAULT_RELOAD TIMER_CMSDK_MAX_RELOAD
|
||||
|
||||
/** CMSDK timer device configuration structure */
|
||||
struct timer_cmsdk_dev_cfg_t {
|
||||
const uintptr_t base; /*!< Timer base address */
|
||||
};
|
||||
|
||||
/** CMSDK timer device data structure */
|
||||
struct timer_cmsdk_dev_data_t {
|
||||
bool is_initialized; /*!< Indicates if the timer is initialized */
|
||||
};
|
||||
|
||||
/* CMSDK timer device structure */
|
||||
struct timer_cmsdk_dev_t {
|
||||
const struct timer_cmsdk_dev_cfg_t* const cfg; /*!< Timer configuration */
|
||||
struct timer_cmsdk_dev_data_t* const data; /*!< Timer data */
|
||||
};
|
||||
|
||||
/**
|
||||
* \brief Initializes timer to a known default state, which is:
|
||||
* - timer disabled
|
||||
* - timer interrupt disabled
|
||||
* - clock source set to internal
|
||||
* - external input disabled
|
||||
* - reload value maxed out
|
||||
* Init should be called prior to any other process and
|
||||
* it's the caller's responsibility to follow proper call order.
|
||||
*
|
||||
* \param[in] dev Timer configuration \ref timer_cmsdk_dev_t
|
||||
*/
|
||||
void timer_cmsdk_init(const struct timer_cmsdk_dev_t* dev);
|
||||
|
||||
/**
|
||||
* \brief Checks if a timer is initialized.
|
||||
*
|
||||
* \param[in] dev Timer configuration \ref timer_cmsdk_dev_t
|
||||
*
|
||||
* \return true if initialized, false otherwise
|
||||
*/
|
||||
bool timer_cmsdk_is_initialized(const struct timer_cmsdk_dev_t* dev);
|
||||
|
||||
/**
|
||||
* \brief Enables external input, which could be used as clock source
|
||||
* by calling \ref timer_cmsdk_set_clock_to_external.
|
||||
*
|
||||
* \param[in] dev Timer configuration \ref timer_cmsdk_dev_t
|
||||
*/
|
||||
void timer_cmsdk_enable_external_input(const struct timer_cmsdk_dev_t* dev);
|
||||
|
||||
/**
|
||||
* \brief Disables external input.
|
||||
* Make sure if the timer is explicitly wanted to be stopped or set
|
||||
* the clock source to internal by \ref timer_cmsdk_set_clock_to_internal.
|
||||
*
|
||||
* \param[in] dev Timer configuration \ref timer_cmsdk_dev_t
|
||||
*/
|
||||
void timer_cmsdk_disable_external_input(const struct timer_cmsdk_dev_t* dev);
|
||||
|
||||
/**
|
||||
* \brief Checks if external input is enabled.
|
||||
*
|
||||
* \param[in] dev Timer configuration \ref timer_cmsdk_dev_t
|
||||
*
|
||||
* \return true if enabled, false otherwise
|
||||
*/
|
||||
bool timer_cmsdk_is_external_input_enabled(const struct timer_cmsdk_dev_t* dev);
|
||||
|
||||
/**
|
||||
* \brief Sets the clock source to internal.
|
||||
*
|
||||
* \param[in] dev Timer configuration \ref timer_cmsdk_dev_t
|
||||
*/
|
||||
void timer_cmsdk_set_clock_to_internal(const struct timer_cmsdk_dev_t* dev);
|
||||
|
||||
/**
|
||||
* \brief Sets the clock source to external.
|
||||
* Make sure external input is enabled correspondingly
|
||||
* by \ref timer_cmsdk_enable_external_input.
|
||||
*
|
||||
* \param[in] dev Timer configuration \ref timer_cmsdk_dev_t
|
||||
*/
|
||||
void timer_cmsdk_set_clock_to_external(const struct timer_cmsdk_dev_t* dev);
|
||||
|
||||
/**
|
||||
* \brief Checks if clock source is external input.
|
||||
*
|
||||
* \param[in] dev Timer configuration \ref timer_cmsdk_dev_t
|
||||
*
|
||||
* \return true if external, false if internal
|
||||
*/
|
||||
bool timer_cmsdk_is_clock_external(const struct timer_cmsdk_dev_t* dev);
|
||||
|
||||
/**
|
||||
* \brief Enables timer operation.
|
||||
*
|
||||
* \param[in] dev Timer configuration \ref timer_cmsdk_dev_t
|
||||
*/
|
||||
void timer_cmsdk_enable(const struct timer_cmsdk_dev_t* dev);
|
||||
|
||||
/**
|
||||
* \brief Disables the given hardware timer.
|
||||
*
|
||||
* \param[in] dev Timer configuration \ref timer_cmsdk_dev_t
|
||||
*/
|
||||
void timer_cmsdk_disable(const struct timer_cmsdk_dev_t* dev);
|
||||
|
||||
/**
|
||||
* \brief Checks if a timer is enabled.
|
||||
*
|
||||
* \param[in] dev Timer configuration \ref timer_cmsdk_dev_t
|
||||
*
|
||||
* \return true if enabled, false otherwise
|
||||
*/
|
||||
bool timer_cmsdk_is_enabled(const struct timer_cmsdk_dev_t* dev);
|
||||
|
||||
/**
|
||||
* \brief Enables timer interrupt.
|
||||
*
|
||||
* \param[in] dev Timer configuration \ref timer_cmsdk_dev_t
|
||||
*/
|
||||
void timer_cmsdk_enable_interrupt(const struct timer_cmsdk_dev_t* dev);
|
||||
|
||||
/**
|
||||
* \brief Disables timer interrupt.
|
||||
*
|
||||
* \param[in] dev Timer configuration \ref timer_cmsdk_dev_t
|
||||
*/
|
||||
void timer_cmsdk_disable_interrupt(const struct timer_cmsdk_dev_t* dev);
|
||||
|
||||
/**
|
||||
* \brief Checks if a timer interrupt is enabled.
|
||||
*
|
||||
* \param[in] dev Timer configuration \ref timer_cmsdk_dev_t
|
||||
*
|
||||
* \return true if enabled, false otherwise
|
||||
*/
|
||||
bool timer_cmsdk_is_interrupt_enabled(const struct timer_cmsdk_dev_t* dev);
|
||||
|
||||
/**
|
||||
* \brief Gets timer interrupt status
|
||||
*
|
||||
* \param[in] dev Timer configuration \ref timer_cmsdk_dev_t
|
||||
*
|
||||
* * \return true if active, false otherwise
|
||||
*/
|
||||
bool timer_cmsdk_is_interrupt_active(const struct timer_cmsdk_dev_t* dev);
|
||||
|
||||
/**
|
||||
* \brief Clears timer interrupt
|
||||
* The interrupt request is held until it is cleared.
|
||||
*
|
||||
* \param[in] dev Timer configuration \ref timer_cmsdk_dev_t
|
||||
*/
|
||||
void timer_cmsdk_clear_interrupt(const struct timer_cmsdk_dev_t* dev);
|
||||
|
||||
/**
|
||||
* \brief Reads timer current value.
|
||||
*
|
||||
* \param[in] dev Timer configuration \ref timer_cmsdk_dev_t
|
||||
*
|
||||
* \return Timer value
|
||||
*/
|
||||
uint32_t timer_cmsdk_get_current_value(const struct timer_cmsdk_dev_t* dev);
|
||||
|
||||
/**
|
||||
* \brief Sets the reload value of the selected timer.
|
||||
*
|
||||
* New reload value takes effect when:
|
||||
* - timer is restarted
|
||||
* - on timer underflow
|
||||
* - when timer_cmsdk_reset is called
|
||||
*
|
||||
* \note In r1p0 technical reference manual it's incorrectly stated
|
||||
* writing the reload value automatically sets the current value also.
|
||||
* r1p1 technical reference manual includes the fix.
|
||||
*
|
||||
* \param[in] dev Timer configuration \ref timer_cmsdk_dev_t
|
||||
* \param[in] reload Timer reload value to set.
|
||||
* This is the start value of the 32-bit down counter,
|
||||
* which automatically reloaded if 0 is reached.
|
||||
*/
|
||||
void timer_cmsdk_set_reload_value(const struct timer_cmsdk_dev_t* dev,
|
||||
uint32_t reload);
|
||||
|
||||
/**
|
||||
* \brief Resets the timer counter to the reload value instantly
|
||||
* (i.e. without waiting for underflow).
|
||||
*
|
||||
* \param[in] dev Timer configuration \ref timer_cmsdk_dev_t
|
||||
*/
|
||||
void timer_cmsdk_reset(const struct timer_cmsdk_dev_t* dev);
|
||||
|
||||
/**
|
||||
* \brief Gets the reload value of the selected timer.
|
||||
* This is the start value of the 32-bit down counter,
|
||||
* which is automatically reloaded if 0 is reached by the counter.
|
||||
*
|
||||
* \param[in] dev Timer configuration \ref timer_cmsdk_dev_t
|
||||
*
|
||||
* \return Reload value of the selected timer.
|
||||
*/
|
||||
uint32_t timer_cmsdk_get_reload_value(const struct timer_cmsdk_dev_t* dev);
|
||||
|
||||
/**
|
||||
* \brief Reads the number of ticks elapsed in the current cycle.
|
||||
*
|
||||
* \param[in] dev Timer configuration \ref timer_cmsdk_dev_t
|
||||
*
|
||||
* \return Get elapsed number of ticks since last reload was set.
|
||||
* Elapsed = (Reload value - Current value)
|
||||
*/
|
||||
uint32_t timer_cmsdk_get_elapsed_value(const struct timer_cmsdk_dev_t* dev);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
#endif /* __TIMER_CMSDK_DRV_H__ */
|
|
@ -0,0 +1,37 @@
|
|||
/*
|
||||
* Copyright (c) 2017-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.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
#include "platform_devices.h"
|
||||
#include "SMM_MPS2.h"
|
||||
|
||||
/* ARM CMSDK Timer driver structures */
|
||||
#ifdef ARM_CMSDK_TIMER0
|
||||
static const struct timer_cmsdk_dev_cfg_t CMSDK_TIMER0_DEV_CFG = {
|
||||
.base = CMSDK_TIMER0_BASE};
|
||||
static struct timer_cmsdk_dev_data_t CMSDK_TIMER0_DEV_DATA = {
|
||||
.is_initialized = 0};
|
||||
struct timer_cmsdk_dev_t CMSDK_TIMER0_DEV = {&(CMSDK_TIMER0_DEV_CFG),
|
||||
&(CMSDK_TIMER0_DEV_DATA)};
|
||||
#endif
|
||||
|
||||
#ifdef ARM_CMSDK_TIMER1
|
||||
static const struct timer_cmsdk_dev_cfg_t CMSDK_TIMER1_DEV_CFG = {
|
||||
.base = CMSDK_TIMER1_BASE};
|
||||
static struct timer_cmsdk_dev_data_t CMSDK_TIMER1_DEV_DATA = {
|
||||
.is_initialized = 0};
|
||||
struct timer_cmsdk_dev_t CMSDK_TIMER1_DEV = {&(CMSDK_TIMER1_DEV_CFG),
|
||||
&(CMSDK_TIMER1_DEV_DATA)};
|
||||
#endif
|
|
@ -0,0 +1,36 @@
|
|||
/*
|
||||
* Copyright (c) 2017-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.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
#ifndef __ARM_LTD_PLATFORM_DEVICES_H__
|
||||
#define __ARM_LTD_PLATFORM_DEVICES_H__
|
||||
|
||||
#include "device_cfg.h"
|
||||
|
||||
/* ======= Includes generic driver headers ======= */
|
||||
#include "timer_cmsdk_drv.h"
|
||||
|
||||
/* ======= Defines peripheral configuration structures ======= */
|
||||
|
||||
/* ARM CMSDK Timer driver structures */
|
||||
#ifdef ARM_CMSDK_TIMER0
|
||||
extern struct timer_cmsdk_dev_t CMSDK_TIMER0_DEV;
|
||||
#endif
|
||||
|
||||
#ifdef ARM_CMSDK_TIMER1
|
||||
extern struct timer_cmsdk_dev_t CMSDK_TIMER1_DEV;
|
||||
#endif
|
||||
|
||||
#endif /* __ARM_LTD_PLATFORM_DEVICES_H__ */
|
|
@ -0,0 +1,113 @@
|
|||
/* mbed Microcontroller Library
|
||||
* Copyright (c) 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.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
/**
|
||||
* Low-power elapsed time measure and interval timer in micro-secundum,
|
||||
* servicing \ref lp_ticker_api.h, using CMSDK Timer1 \ref CMSDK_TIMER1_DEV.
|
||||
*/
|
||||
|
||||
#include <limits.h>
|
||||
|
||||
#include "cmsdk_ticker.h"
|
||||
#include "lp_ticker_api.h"
|
||||
#include "platform_devices.h"
|
||||
|
||||
/**
|
||||
* \brief Calculate clocks to us
|
||||
*
|
||||
* \param[in] tick Number of clock ticks
|
||||
*
|
||||
* \return Number of usec, relative to the timer frequency,
|
||||
* that a given ammount of ticks equates to.
|
||||
*/
|
||||
static uint32_t convert_tick_to_us(uint32_t tick)
|
||||
{
|
||||
return (tick / (SystemCoreClock / SEC_TO_USEC_MULTIPLIER));
|
||||
}
|
||||
|
||||
/**
|
||||
* \brief Calculate us to clock ticks
|
||||
*
|
||||
* \param[in] us Time to convert to clock ticks
|
||||
*
|
||||
* \return Number of clock ticks relative to the timer frequency,
|
||||
* that a given period of usec equates to.
|
||||
*/
|
||||
static uint32_t convert_us_to_tick(uint32_t us)
|
||||
{
|
||||
return (us * (SystemCoreClock / SEC_TO_USEC_MULTIPLIER));
|
||||
}
|
||||
|
||||
static const struct tick_cfg_t cfg =
|
||||
{
|
||||
.timer_driver = &CMSDK_TIMER1_DEV,
|
||||
.irq_n = TIMER1_IRQn,
|
||||
.interval_callback = &lp_ticker_irq_handler,
|
||||
.convert_tick_to_time = &convert_tick_to_us,
|
||||
.convert_time_to_tick = &convert_us_to_tick
|
||||
};
|
||||
|
||||
static struct tick_data_t data =
|
||||
{
|
||||
.is_initialized = false,
|
||||
.cumulated_time = 0,
|
||||
.max_interval_time = 0,
|
||||
.reload_time = 0,
|
||||
.interval_callback_enabled = false,
|
||||
.previous_cumulated_time = 0,
|
||||
.previous_elapsed = 0
|
||||
};
|
||||
|
||||
static struct tick_drv_data_t timer_data =
|
||||
{
|
||||
.cfg = &cfg,
|
||||
.data = &data
|
||||
};
|
||||
|
||||
void lp_ticker_init(void)
|
||||
{
|
||||
cmsdk_ticker_init(&timer_data);
|
||||
}
|
||||
|
||||
uint32_t lp_ticker_read()
|
||||
{
|
||||
return cmsdk_ticker_read(&timer_data);
|
||||
}
|
||||
|
||||
void lp_ticker_set_interrupt(timestamp_t timestamp)
|
||||
{
|
||||
cmsdk_ticker_set_interrupt(&timer_data, timestamp);
|
||||
}
|
||||
|
||||
void lp_ticker_disable_interrupt(void)
|
||||
{
|
||||
cmsdk_ticker_disable_interrupt(&timer_data);
|
||||
}
|
||||
|
||||
void lp_ticker_clear_interrupt(void)
|
||||
{
|
||||
cmsdk_ticker_clear_interrupt(&timer_data);
|
||||
}
|
||||
|
||||
void lp_ticker_fire_interrupt(void)
|
||||
{
|
||||
cmsdk_ticker_fire_interrupt(&timer_data);
|
||||
}
|
||||
|
||||
void TIMER1_IRQHandler(void)
|
||||
{
|
||||
cmsdk_ticker_irq_handler(&timer_data);
|
||||
}
|
|
@ -1,5 +1,5 @@
|
|||
/* mbed Microcontroller Library
|
||||
* Copyright (c) 2015 ARM Limited
|
||||
* Copyright (c) 2017-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.
|
||||
|
@ -14,125 +14,98 @@
|
|||
* limitations under the License.
|
||||
*/
|
||||
|
||||
/* This file is derivative of us_ticker.c from BEETLE */
|
||||
/**
|
||||
* Elapsed time measure and interval timer in micro-secundum,
|
||||
* servicing \ref us_ticker_api.h, using CMSDK Timer0 \ref CMSDK_TIMER0_DEV.
|
||||
*/
|
||||
|
||||
#include <stddef.h>
|
||||
#include "cmsis.h"
|
||||
#include "cmsdk_ticker.h"
|
||||
#include "us_ticker_api.h"
|
||||
#include "PeripheralNames.h"
|
||||
#include "platform_devices.h"
|
||||
|
||||
#define TIMER_MAX_VALUE 0
|
||||
|
||||
/* Private data */
|
||||
struct us_ticker_drv_data_t {
|
||||
uint32_t inited; /* us ticker initialized */
|
||||
uint32_t overflow_delta; /* us ticker overflow */
|
||||
uint32_t overflow_limit; /* us ticker overflow limit */
|
||||
};
|
||||
|
||||
static struct us_ticker_drv_data_t us_ticker_drv_data = {
|
||||
.inited = 0,
|
||||
.overflow_delta = 0,
|
||||
.overflow_limit = 0
|
||||
};
|
||||
|
||||
|
||||
void __us_ticker_irq_handler(void)
|
||||
/**
|
||||
* \brief Convert clocks to us
|
||||
*
|
||||
* \param[in] tick Number of clocks
|
||||
*
|
||||
* \return Number of usec, relative to the timer frequency,
|
||||
* that a given ammount of ticks equates to.
|
||||
*/
|
||||
static uint32_t convert_tick_to_us(uint32_t tick)
|
||||
{
|
||||
Timer_ClearInterrupt(TIMER1);
|
||||
/*
|
||||
* For each overflow event adds the timer max represented value to
|
||||
* the delta. This allows the us_ticker to keep track of the elapsed
|
||||
* time:
|
||||
* elapsed_time = (num_overflow * overflow_limit) + current_time
|
||||
*/
|
||||
us_ticker_drv_data.overflow_delta += us_ticker_drv_data.overflow_limit;
|
||||
return (tick / (SystemCoreClock / SEC_TO_USEC_MULTIPLIER));
|
||||
}
|
||||
|
||||
/**
|
||||
* \brief Convert us to clock ticks
|
||||
*
|
||||
* \param[in] us Time to convert to clock ticks
|
||||
*
|
||||
* \return Number of clock ticks relative to the timer frequency,
|
||||
* that a given period of usec equates to.
|
||||
*/
|
||||
static uint32_t convert_us_to_tick(uint32_t us)
|
||||
{
|
||||
return (us * (SystemCoreClock / SEC_TO_USEC_MULTIPLIER));
|
||||
}
|
||||
|
||||
static const struct tick_cfg_t cfg =
|
||||
{
|
||||
.timer_driver = &CMSDK_TIMER0_DEV,
|
||||
.irq_n = TIMER0_IRQn,
|
||||
.interval_callback = &us_ticker_irq_handler,
|
||||
.convert_tick_to_time = &convert_tick_to_us,
|
||||
.convert_time_to_tick = &convert_us_to_tick
|
||||
};
|
||||
|
||||
static struct tick_data_t data =
|
||||
{
|
||||
.is_initialized = false,
|
||||
.cumulated_time = 0,
|
||||
.max_interval_time = 0,
|
||||
.reload_time = 0,
|
||||
.interval_callback_enabled = false,
|
||||
.previous_cumulated_time = 0,
|
||||
.previous_elapsed = 0
|
||||
};
|
||||
|
||||
static struct tick_drv_data_t timer_data =
|
||||
{
|
||||
.cfg = &cfg,
|
||||
.data = &data
|
||||
};
|
||||
|
||||
void us_ticker_init(void)
|
||||
{
|
||||
uint32_t us_ticker_irqn0 = 0;
|
||||
uint32_t us_ticker_irqn1 = 0;
|
||||
|
||||
if (us_ticker_drv_data.inited) {
|
||||
return;
|
||||
}
|
||||
|
||||
us_ticker_drv_data.inited = 1;
|
||||
|
||||
/* Initialize Timer 0 */
|
||||
Timer_Initialize(TIMER0, TIMER_MAX_VALUE);
|
||||
/* Enable Timer 0 */
|
||||
Timer_Enable(TIMER0);
|
||||
|
||||
/* Initialize Timer 1 */
|
||||
Timer_Initialize(TIMER1, TIMER_MAX_VALUE);
|
||||
/* Enable Timer 1 */
|
||||
Timer_Enable(TIMER1);
|
||||
|
||||
/* Timer 0 get IRQn */
|
||||
us_ticker_irqn0 = Timer_GetIRQn(TIMER0);
|
||||
NVIC_SetVector((IRQn_Type)us_ticker_irqn0, (uint32_t)us_ticker_irq_handler);
|
||||
NVIC_EnableIRQ((IRQn_Type)us_ticker_irqn0);
|
||||
|
||||
/* Timer 1 get IRQn */
|
||||
us_ticker_irqn1 = Timer_GetIRQn(TIMER1);
|
||||
NVIC_SetVector((IRQn_Type)us_ticker_irqn1, (uint32_t)__us_ticker_irq_handler);
|
||||
NVIC_EnableIRQ((IRQn_Type)us_ticker_irqn1);
|
||||
|
||||
/* Timer set interrupt on TIMER1 */
|
||||
Timer_SetInterrupt(TIMER1, TIMER_DEFAULT_RELOAD);
|
||||
|
||||
/*
|
||||
* Set us_ticker Overflow limit. The us_ticker overflow limit is required
|
||||
* to calculated the return value of the us_ticker read function in us
|
||||
* on 32bit.
|
||||
* A 32bit us value cannot be represented directly in the Timer Load
|
||||
* register if it is greater than (0xFFFFFFFF ticks)/TIMER_DIVIDER_US.
|
||||
*/
|
||||
us_ticker_drv_data.overflow_limit = Timer_GetReloadValue(TIMER1);
|
||||
cmsdk_ticker_init(&timer_data);
|
||||
}
|
||||
|
||||
uint32_t us_ticker_read()
|
||||
{
|
||||
uint32_t return_value = 0;
|
||||
|
||||
if (!us_ticker_drv_data.inited) {
|
||||
us_ticker_init();
|
||||
}
|
||||
|
||||
return_value = us_ticker_drv_data.overflow_delta + Timer_Read(TIMER1);
|
||||
|
||||
return return_value;
|
||||
return cmsdk_ticker_read(&timer_data);
|
||||
}
|
||||
|
||||
void us_ticker_set_interrupt(timestamp_t timestamp)
|
||||
{
|
||||
uint32_t delta = 0;
|
||||
|
||||
if (!us_ticker_drv_data.inited) {
|
||||
us_ticker_init();
|
||||
}
|
||||
|
||||
delta = timestamp - us_ticker_read();
|
||||
|
||||
/* If the event was not in the past enable interrupt */
|
||||
Timer_SetInterrupt(TIMER0, delta);
|
||||
|
||||
}
|
||||
|
||||
void us_ticker_fire_interrupt(void)
|
||||
{
|
||||
uint32_t us_ticker_irqn1 = Timer_GetIRQn(TIMER1);
|
||||
NVIC_SetPendingIRQ((IRQn_Type)us_ticker_irqn1);
|
||||
cmsdk_ticker_set_interrupt(&timer_data, timestamp);
|
||||
}
|
||||
|
||||
void us_ticker_disable_interrupt(void)
|
||||
{
|
||||
Timer_DisableInterrupt(TIMER0);
|
||||
cmsdk_ticker_disable_interrupt(&timer_data);
|
||||
}
|
||||
|
||||
void us_ticker_clear_interrupt(void)
|
||||
{
|
||||
Timer_ClearInterrupt(TIMER0);
|
||||
cmsdk_ticker_clear_interrupt(&timer_data);
|
||||
}
|
||||
|
||||
void us_ticker_fire_interrupt(void)
|
||||
{
|
||||
cmsdk_ticker_fire_interrupt(&timer_data);
|
||||
}
|
||||
|
||||
void TIMER0_IRQHandler(void)
|
||||
{
|
||||
cmsdk_ticker_irq_handler(&timer_data);
|
||||
}
|
||||
|
|
|
@ -2652,7 +2652,7 @@
|
|||
"supported_toolchains": ["ARM", "GCC_ARM", "IAR"],
|
||||
"extra_labels": ["ARM_SSG", "CM3DS_MPS2"],
|
||||
"macros": ["CMSDK_CM3DS"],
|
||||
"device_has": ["ANALOGIN", "ETHERNET", "I2C", "INTERRUPTIN", "PORTIN", "PORTINOUT", "PORTOUT", "SERIAL", "SPI", "RTC"],
|
||||
"device_has": ["ANALOGIN", "ETHERNET", "I2C", "INTERRUPTIN", "PORTIN", "PORTINOUT", "PORTOUT", "SERIAL", "SPI", "RTC", "LOWPOWERTIMER"],
|
||||
"release_versions": ["2", "5"],
|
||||
"copy_method": "mps2",
|
||||
"reset_method": "reboot.txt"
|
||||
|
|
Loading…
Reference in New Issue