From 0074b34e34514f966d5b7658cade0055d69c9b6c Mon Sep 17 00:00:00 2001 From: 0xc0170 Date: Tue, 28 Apr 2015 11:18:16 +0100 Subject: [PATCH] Silabs - Fix unblock/block declaration, implement gpio_is_connected --- .../TARGET_EFM32/gpio_api.c | 1 + .../TARGET_EFM32/gpio_irq_api.c | 1 + .../TARGET_EFM32/gpio_object.h | 4 +++ .../TARGET_EFM32/i2c_api.c | 1 + .../TARGET_EFM32/rtc_api.c | 1 + .../TARGET_EFM32/serial_api.c | 5 +-- .../TARGET_Silicon_Labs/TARGET_EFM32/sleep.c | 1 + .../TARGET_EFM32/sleepmodes.h | 32 +++++++++++++++++++ .../TARGET_EFM32/spi_api.c | 1 + .../TARGET_EFM32/us_ticker.c | 1 + 10 files changed, 46 insertions(+), 2 deletions(-) create mode 100644 libraries/mbed/targets/hal/TARGET_Silicon_Labs/TARGET_EFM32/sleepmodes.h diff --git a/libraries/mbed/targets/hal/TARGET_Silicon_Labs/TARGET_EFM32/gpio_api.c b/libraries/mbed/targets/hal/TARGET_Silicon_Labs/TARGET_EFM32/gpio_api.c index c403072c46..48e5c06a99 100644 --- a/libraries/mbed/targets/hal/TARGET_Silicon_Labs/TARGET_EFM32/gpio_api.c +++ b/libraries/mbed/targets/hal/TARGET_Silicon_Labs/TARGET_EFM32/gpio_api.c @@ -17,6 +17,7 @@ #include "pinmap.h" #include "em_cmu.h" #include "mbed_assert.h" +#include "sleepmodes.h" uint8_t gpio_get_index(gpio_t *obj) { diff --git a/libraries/mbed/targets/hal/TARGET_Silicon_Labs/TARGET_EFM32/gpio_irq_api.c b/libraries/mbed/targets/hal/TARGET_Silicon_Labs/TARGET_EFM32/gpio_irq_api.c index 2d1bc7d052..cfeef10986 100644 --- a/libraries/mbed/targets/hal/TARGET_Silicon_Labs/TARGET_EFM32/gpio_irq_api.c +++ b/libraries/mbed/targets/hal/TARGET_Silicon_Labs/TARGET_EFM32/gpio_irq_api.c @@ -25,6 +25,7 @@ #include "em_int.h" #include "em_cmu.h" #include "sleep_api.h" +#include "sleepmodes.h" #define NUM_GPIO_CHANNELS (16) #define GPIO_LEAST_ACTIVE_SLEEPMODE EM3 diff --git a/libraries/mbed/targets/hal/TARGET_Silicon_Labs/TARGET_EFM32/gpio_object.h b/libraries/mbed/targets/hal/TARGET_Silicon_Labs/TARGET_EFM32/gpio_object.h index 836f9274c2..556050518b 100644 --- a/libraries/mbed/targets/hal/TARGET_Silicon_Labs/TARGET_EFM32/gpio_object.h +++ b/libraries/mbed/targets/hal/TARGET_Silicon_Labs/TARGET_EFM32/gpio_object.h @@ -48,6 +48,10 @@ static inline int gpio_read(gpio_t *obj) } } +static inline int gpio_is_connected(const gpio_t *obj) { + return obj->pin != (PinName)NC; +} + #ifdef __cplusplus } #endif diff --git a/libraries/mbed/targets/hal/TARGET_Silicon_Labs/TARGET_EFM32/i2c_api.c b/libraries/mbed/targets/hal/TARGET_Silicon_Labs/TARGET_EFM32/i2c_api.c index e9969ff32d..114027348a 100644 --- a/libraries/mbed/targets/hal/TARGET_Silicon_Labs/TARGET_EFM32/i2c_api.c +++ b/libraries/mbed/targets/hal/TARGET_Silicon_Labs/TARGET_EFM32/i2c_api.c @@ -24,6 +24,7 @@ #include "i2c_api.h" #include "PeripheralPins.h" #include "pinmap_function.h" +#include "sleepmodes.h" #include "em_i2c.h" #include "em_cmu.h" diff --git a/libraries/mbed/targets/hal/TARGET_Silicon_Labs/TARGET_EFM32/rtc_api.c b/libraries/mbed/targets/hal/TARGET_Silicon_Labs/TARGET_EFM32/rtc_api.c index 08003b8f9b..611be66d0c 100644 --- a/libraries/mbed/targets/hal/TARGET_Silicon_Labs/TARGET_EFM32/rtc_api.c +++ b/libraries/mbed/targets/hal/TARGET_Silicon_Labs/TARGET_EFM32/rtc_api.c @@ -22,6 +22,7 @@ #include "em_cmu.h" #include "em_rtc.h" #include "sleep_api.h" +#include "sleepmodes.h" static bool rtc_inited = false; static time_t time_base = 0; diff --git a/libraries/mbed/targets/hal/TARGET_Silicon_Labs/TARGET_EFM32/serial_api.c b/libraries/mbed/targets/hal/TARGET_Silicon_Labs/TARGET_EFM32/serial_api.c index 184c45c220..9f5d73166b 100644 --- a/libraries/mbed/targets/hal/TARGET_Silicon_Labs/TARGET_EFM32/serial_api.c +++ b/libraries/mbed/targets/hal/TARGET_Silicon_Labs/TARGET_EFM32/serial_api.c @@ -36,6 +36,7 @@ #include "dma_api.h" #include "sleep_api.h" #include "buffer.h" +#include "sleepmodes.h" #define SERIAL_LEAST_ACTIVE_SLEEPMODE EM1 #define SERIAL_LEAST_ACTIVE_SLEEPMODE_LEUART EM2 @@ -227,7 +228,7 @@ inline IRQn_Type serial_get_rx_irq_index(serial_t *obj) default: MBED_ASSERT(0); } - return 0; + return (IRQn_Type)0; } /** @@ -270,7 +271,7 @@ inline IRQn_Type serial_get_tx_irq_index(serial_t *obj) default: MBED_ASSERT(0); } - return 0; + return (IRQn_Type)0; } /** diff --git a/libraries/mbed/targets/hal/TARGET_Silicon_Labs/TARGET_EFM32/sleep.c b/libraries/mbed/targets/hal/TARGET_Silicon_Labs/TARGET_EFM32/sleep.c index 4d2cde67ee..015da0cf0a 100644 --- a/libraries/mbed/targets/hal/TARGET_Silicon_Labs/TARGET_EFM32/sleep.c +++ b/libraries/mbed/targets/hal/TARGET_Silicon_Labs/TARGET_EFM32/sleep.c @@ -18,6 +18,7 @@ #if DEVICE_SLEEP #include "sleep_api.h" +#include "sleepmodes.h" #include "cmsis.h" #include "em_emu.h" #include "em_int.h" diff --git a/libraries/mbed/targets/hal/TARGET_Silicon_Labs/TARGET_EFM32/sleepmodes.h b/libraries/mbed/targets/hal/TARGET_Silicon_Labs/TARGET_EFM32/sleepmodes.h new file mode 100644 index 0000000000..2dafe153af --- /dev/null +++ b/libraries/mbed/targets/hal/TARGET_Silicon_Labs/TARGET_EFM32/sleepmodes.h @@ -0,0 +1,32 @@ +/* mbed Microcontroller Library + * Copyright (c) 2015 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 MBED_SLEEPMODES_H +#define MBED_SLEEPMODES_H + +#include "em_gpio.h" + +#ifdef __cplusplus +extern "C" { +#endif + +void blockSleepMode(sleepstate_enum minimumMode); +void unblockSleepMode(sleepstate_enum minimumMode); + +#ifdef __cplusplus +} +#endif + +#endif diff --git a/libraries/mbed/targets/hal/TARGET_Silicon_Labs/TARGET_EFM32/spi_api.c b/libraries/mbed/targets/hal/TARGET_Silicon_Labs/TARGET_EFM32/spi_api.c index 471570cbd2..67a4dd5be6 100644 --- a/libraries/mbed/targets/hal/TARGET_Silicon_Labs/TARGET_EFM32/spi_api.c +++ b/libraries/mbed/targets/hal/TARGET_Silicon_Labs/TARGET_EFM32/spi_api.c @@ -30,6 +30,7 @@ #include "em_cmu.h" #include "em_dma.h" #include "sleep_api.h" +#include "sleepmodes.h" static uint16_t fill_word = SPI_FILL_WORD; #define SPI_LEAST_ACTIVE_SLEEPMODE EM1 diff --git a/libraries/mbed/targets/hal/TARGET_Silicon_Labs/TARGET_EFM32/us_ticker.c b/libraries/mbed/targets/hal/TARGET_Silicon_Labs/TARGET_EFM32/us_ticker.c index c2c84c7c7c..0667adef50 100644 --- a/libraries/mbed/targets/hal/TARGET_Silicon_Labs/TARGET_EFM32/us_ticker.c +++ b/libraries/mbed/targets/hal/TARGET_Silicon_Labs/TARGET_EFM32/us_ticker.c @@ -23,6 +23,7 @@ #include "device.h" #include "clocking.h" #include "sleep_api.h" +#include "sleepmodes.h" #define TIMER_LEAST_ACTIVE_SLEEPMODE EM1 /**