Skip to content

Commit 1b79231

Browse files
committed
Implement LP and us tickers to CM3DS
This commit represents the first stage of the low power implementations that are required from Mbed 5.10 onwards. The LP ticker has been implemented using a CMSDK Dual Timer's both timers (HW prescaler needed to operate in the specified frequency domain), whereas the us ticker uses one CMSDK Timer. Besides the default hal implementations (lp_ticker.c and us_ticker.c), the CMSDK Dual Timer's native driver needed to be added. Change-Id: I0b16b93dfac7753bebf430a2ce77761cb9c43ee5 Signed-off-by: Bence Kaposzta <[email protected]>
1 parent aab3ade commit 1b79231

File tree

8 files changed

+1677
-163
lines changed

8 files changed

+1677
-163
lines changed

targets/TARGET_ARM_SSG/TARGET_CM3DS_MPS2/device/device_cfg.h

Lines changed: 45 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (c) 2018 ARM Limited
2+
* Copyright (c) 2018 Arm Limited
33
*
44
* Licensed under the Apache License Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -27,8 +27,50 @@
2727
*/
2828

2929
/* CMSDK Timers */
30-
#define ARM_CMSDK_TIMER0
3130
#define ARM_CMSDK_TIMER1
31+
#define ARM_CMSDK_DUALTIMER
32+
33+
/* Timer Peripherals are driven by APB System Core Clocks,
34+
* defined in system_CMSDK_CM3DS.c
35+
*/
36+
#define TIMERS_INPUT_CLOCK_FREQ_HZ 25000000U
37+
38+
/* mbed usec high-resolution ticker configuration */
39+
#define USEC_TIMER_DEV CMSDK_TIMER1_DEV
40+
41+
#define usec_interval_irq_handler TIMER1_IRQHandler
42+
#define USEC_INTERVAL_IRQ TIMER1_IRQn
43+
44+
/* The us ticker uses CMSDK Timer1, that does not have HW prescaler.
45+
* The reported shift define is necessary for the software emulated
46+
* prescaler behavior, so the ticker works as if it was ticking on a
47+
* virtually slower frequency. The value 5 sets up the ticker to work
48+
* properly in the specified frequency interval.
49+
*/
50+
#define USEC_TIMER_BIT_WIDTH 32U
51+
#define USEC_REPORTED_SHIFT 5U
52+
#define USEC_REPORTED_FREQ_HZ (TIMERS_INPUT_CLOCK_FREQ_HZ >> USEC_REPORTED_SHIFT)
53+
#define USEC_REPORTED_BITS (USEC_TIMER_BIT_WIDTH - USEC_REPORTED_SHIFT)
54+
55+
/* mbed low power ticker configuration */
56+
#define LP_TIMER_DEV CMSDK_DUALTIMER_DEV
57+
58+
#define lp_interval_irq_handler DUALTIMER_IRQHandler
59+
#define LP_INTERVAL_IRQ DUALTIMER_IRQn
60+
61+
/* The lp ticker a CMSDK Dual Timer that is capable of prescaling
62+
* its input clock frequency by 256 at most. Having 25MHz as input
63+
* frequency requires an additional slowing factor in order for the ticker
64+
* to operate in the specified frequency interval, thus the effective
65+
* prescaler value is going to be the sum of the HW and the virtual
66+
* prescaler values.
67+
*/
68+
#define LP_TIMER_BIT_WIDTH 32U
69+
#define LP_TIMER_HW_PRESCALER 8U
70+
#define LP_REPORTED_SHIFT 1U
71+
#define LP_REPORTED_FREQ_HZ (TIMERS_INPUT_CLOCK_FREQ_HZ >> \
72+
(LP_TIMER_HW_PRESCALER+LP_REPORTED_SHIFT))
73+
#define LP_REPORTED_BITS (LP_TIMER_BIT_WIDTH - LP_REPORTED_SHIFT)
3274

3375
/* ARM GPIO */
3476
#define ARM_GPIO0
@@ -51,7 +93,7 @@
5193
#define ARM_SPI4
5294

5395
/* ARM UART */
54-
#define DEFAULT_UART_BAUDRATE 9600
96+
#define DEFAULT_UART_BAUDRATE 9600U
5597
#define ARM_UART0
5698
#define ARM_UART1
5799
#define ARM_UART2

0 commit comments

Comments
 (0)