Skip to content

Commit a81fdc4

Browse files
committed
[EFM32] Backport changes from mbed OS 3.
1 parent da2a4cc commit a81fdc4

File tree

7 files changed

+44
-16
lines changed

7 files changed

+44
-16
lines changed

hal/targets/hal/TARGET_Silicon_Labs/TARGET_EFM32/TARGET_EFM32GG_STK3700/PeripheralPins.c

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -86,9 +86,15 @@ const PinMap PinMap_I2C_SDA[] = {
8686

8787
/************PWM***************/
8888
const PinMap PinMap_PWM[] = {
89-
{PA12, PWM_CH0, 0},
90-
{PA13, PWM_CH1, 0},
91-
{PA14, PWM_CH2, 0},
89+
{PA8, PWM_CH0, 0},
90+
{PA9, PWM_CH1, 0},
91+
{PA10, PWM_CH2, 0},
92+
{PA12, PWM_CH0, 1},
93+
{PA13, PWM_CH1, 1},
94+
{PA14, PWM_CH2, 1},
95+
{PC8, PWM_CH0, 2},
96+
{PC9, PWM_CH1, 2},
97+
{PC10, PWM_CH2, 2},
9298
{NC , NC , 0}
9399
};
94100

hal/targets/hal/TARGET_Silicon_Labs/TARGET_EFM32/TARGET_EFM32HG_STK3400/PeripheralPins.c

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,9 @@ const PinMap PinMap_PWM[] = {
6262
{PA0, PWM_CH0, 0},
6363
{PA1, PWM_CH1, 0},
6464
{PA2, PWM_CH2, 0},
65+
{PF0, PWM_CH0, 5},
66+
{PF1, PWM_CH1, 5},
67+
{PF2, PWM_CH2, 5},
6568
{NC , NC , NC}
6669
};
6770

hal/targets/hal/TARGET_Silicon_Labs/TARGET_EFM32/TARGET_EFM32LG_STK3600/PeripheralPins.c

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -86,9 +86,15 @@ const PinMap PinMap_I2C_SDA[] = {
8686

8787
/************PWM***************/
8888
const PinMap PinMap_PWM[] = {
89-
{PA12, PWM_CH0, 0},
90-
{PA13, PWM_CH1, 0},
91-
{PA14, PWM_CH2, 0},
89+
{PA8, PWM_CH0, 0},
90+
{PA9, PWM_CH1, 0},
91+
{PA10, PWM_CH2, 0},
92+
{PA12, PWM_CH0, 1},
93+
{PA13, PWM_CH1, 1},
94+
{PA14, PWM_CH2, 1},
95+
{PC8, PWM_CH0, 2},
96+
{PC9, PWM_CH1, 2},
97+
{PC10, PWM_CH2, 2},
9298
{NC , NC , 0}
9399
};
94100

hal/targets/hal/TARGET_Silicon_Labs/TARGET_EFM32/TARGET_EFM32WG_STK3800/PeripheralPins.c

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -86,9 +86,15 @@ const PinMap PinMap_I2C_SDA[] = {
8686

8787
/************PWM***************/
8888
const PinMap PinMap_PWM[] = {
89-
{PA12, PWM_CH0, 0},
90-
{PA13, PWM_CH1, 0},
91-
{PA14, PWM_CH2, 0},
89+
{PA8, PWM_CH0, 0},
90+
{PA9, PWM_CH1, 0},
91+
{PA10, PWM_CH2, 0},
92+
{PA12, PWM_CH0, 1},
93+
{PA13, PWM_CH1, 1},
94+
{PA14, PWM_CH2, 1},
95+
{PC8, PWM_CH0, 2},
96+
{PC9, PWM_CH1, 2},
97+
{PC10, PWM_CH2, 2},
9298
{NC , NC , 0}
9399
};
94100

hal/targets/hal/TARGET_Silicon_Labs/TARGET_EFM32/gpio_irq_api.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -96,8 +96,10 @@ int gpio_irq_init(gpio_irq_t *obj, PinName pin, gpio_irq_handler handler, uint32
9696
// Init pins
9797
gpio_irq_preinit(obj, pin);
9898
// Initialize GPIO interrupt dispatcher
99+
NVIC_SetVector(GPIO_ODD_IRQn, (uint32_t)GPIO_ODD_IRQHandler);
99100
NVIC_ClearPendingIRQ(GPIO_ODD_IRQn);
100101
NVIC_EnableIRQ(GPIO_ODD_IRQn);
102+
NVIC_SetVector(GPIO_EVEN_IRQn, (uint32_t)GPIO_EVEN_IRQHandler);
101103
NVIC_ClearPendingIRQ(GPIO_EVEN_IRQn);
102104
NVIC_EnableIRQ(GPIO_EVEN_IRQn);
103105

hal/targets/hal/TARGET_Silicon_Labs/TARGET_EFM32/pwmout_api.c

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@
3737
#include "em_gpio.h"
3838
#include "em_timer.h"
3939

40-
static int pwm_prescaler_div;
40+
static uint32_t pwm_prescaler_div;
4141

4242
float pwmout_calculate_duty(uint32_t width_cycles, uint32_t period_cycles);
4343
void pwmout_write_channel(uint32_t channel, float value);
@@ -132,7 +132,7 @@ bool pwmout_all_inactive(void) {
132132
return true;
133133
}
134134
#else
135-
if(PWM_TIMER->ROUTE == PWM_ROUTE) {
135+
if(PWM_TIMER->ROUTE & (TIMER_ROUTE_CC0PEN | TIMER_ROUTE_CC1PEN | TIMER_ROUTE_CC2PEN)) {
136136
return true;
137137
}
138138
#endif
@@ -211,7 +211,11 @@ void pwmout_init(pwmout_t *obj, PinName pin)
211211
#else
212212
// On P1, the route location is statically defined for the entire timer.
213213
PWM_TIMER->ROUTE &= ~_TIMER_ROUTE_LOCATION_MASK;
214-
PWM_TIMER->ROUTE |= PWM_ROUTE;
214+
if(pwmout_all_inactive()) {
215+
PWM_TIMER->ROUTE |= pinmap_find_function(pin,PinMap_PWM) << _TIMER_ROUTE_LOCATION_SHIFT;
216+
} else {
217+
MBED_ASSERT((pinmap_find_function(pin,PinMap_PWM) << _TIMER_ROUTE_LOCATION_SHIFT) == (PWM_TIMER->ROUTE & _TIMER_ROUTE_LOCATION_MASK));
218+
}
215219
#endif
216220

217221
// Set default 20ms frequency and 0ms pulse width
@@ -281,7 +285,7 @@ void pwmout_period(pwmout_t *obj, float seconds)
281285
// This gives us max resolution for a given period
282286

283287
//The value of the top register if prescaler is set to 0
284-
int cycles = REFERENCE_FREQUENCY * seconds;
288+
uint32_t cycles = (uint32_t)REFERENCE_FREQUENCY * seconds;
285289
pwm_prescaler_div = 0;
286290

287291
//The top register is only 16 bits, so we keep dividing till we are below 0xFFFF

hal/targets/hal/TARGET_Silicon_Labs/TARGET_EFM32/rtc_api.c

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,8 @@ void RTC_IRQHandler(void)
7171

7272
uint32_t rtc_get_32bit(void)
7373
{
74-
return (RTC_CounterGet() + (time_extend << RTC_NUM_BITS));
74+
uint32_t pending = (RTC_IntGet() & RTC_IF_OF) ? 1 : 0;
75+
return (RTC_CounterGet() + ((time_extend + pending) << RTC_NUM_BITS));
7576
}
7677

7778
uint64_t rtc_get_full(void)
@@ -104,8 +105,8 @@ void rtc_init_real(uint32_t flags)
104105

105106
/* Enable Interrupt from RTC */
106107
RTC_IntEnable(RTC_IEN_OF);
107-
NVIC_EnableIRQ(RTC_IRQn);
108108
NVIC_SetVector(RTC_IRQn, (uint32_t)RTC_IRQHandler);
109+
NVIC_EnableIRQ(RTC_IRQn);
109110

110111
/* Initialize */
111112
RTC_Init(&init);
@@ -198,8 +199,8 @@ void rtc_init_real(uint32_t flags)
198199

199200
/* Enable Interrupt from RTC */
200201
RTCC_IntEnable(RTCC_IEN_OF);
201-
NVIC_EnableIRQ(RTCC_IRQn);
202202
NVIC_SetVector(RTCC_IRQn, (uint32_t)RTCC_IRQHandler);
203+
NVIC_EnableIRQ(RTCC_IRQn);
203204

204205
/* Initialize */
205206
RTCC_Init(&init);

0 commit comments

Comments
 (0)