mirror of https://github.com/ARMmbed/mbed-os.git
Don't use define checks on DEVICE_FOO macros (mbed code)
The DEVICE_FOO macros are always defined (either 0 or 1). This patch replaces any instances of a define check on a DEVICE_FOO macro with value test instead. Signed-off-by: Alastair D'Silva <alastair@d-silva.org>pull/8957/head
parent
24dbfb6b09
commit
2617c5d55b
|
@ -95,7 +95,7 @@ void sleep_usticker_test()
|
|||
TEST_ASSERT_TRUE(sleep_manager_can_deep_sleep());
|
||||
}
|
||||
|
||||
#ifdef DEVICE_LPTICKER
|
||||
#if DEVICE_LPTICKER
|
||||
|
||||
/* Test that wake-up time from sleep should be less than 10 ms and
|
||||
* low power ticker interrupt can wake-up target from sleep. */
|
||||
|
|
|
@ -105,7 +105,7 @@ void us_ticker_isr(const ticker_data_t *const ticker_data)
|
|||
us_ticker_clear_interrupt();
|
||||
}
|
||||
|
||||
#ifdef DEVICE_LPTICKER
|
||||
#if DEVICE_LPTICKER
|
||||
void lp_ticker_isr(const ticker_data_t *const ticker_data)
|
||||
{
|
||||
lp_ticker_clear_interrupt();
|
||||
|
|
|
@ -21,7 +21,7 @@
|
|||
|
||||
#include "mbed.h"
|
||||
|
||||
#if !defined(MBED_CPU_STATS_ENABLED) || !defined(DEVICE_LPTICKER) || !defined(DEVICE_SLEEP)
|
||||
#if !defined(MBED_CPU_STATS_ENABLED) || !DEVICE_LPTICKER || !DEVICE_SLEEP
|
||||
#error [NOT_SUPPORTED] test not supported
|
||||
#endif
|
||||
|
||||
|
|
|
@ -14,7 +14,7 @@
|
|||
* limitations under the License.
|
||||
*/
|
||||
|
||||
#ifdef DEVICE_FLASH
|
||||
#if DEVICE_FLASH
|
||||
|
||||
#include "FlashIAPBlockDevice.h"
|
||||
#include "mbed_critical.h"
|
||||
|
|
|
@ -17,7 +17,7 @@
|
|||
#ifndef MBED_FLASHIAP_BLOCK_DEVICE_H
|
||||
#define MBED_FLASHIAP_BLOCK_DEVICE_H
|
||||
|
||||
#ifdef DEVICE_FLASH
|
||||
#if DEVICE_FLASH
|
||||
|
||||
#include "FlashIAP.h"
|
||||
#include "BlockDevice.h"
|
||||
|
|
|
@ -136,7 +136,7 @@
|
|||
*/
|
||||
|
||||
/* If the target has no SPI support then SDCard is not supported */
|
||||
#ifdef DEVICE_SPI
|
||||
#if DEVICE_SPI
|
||||
|
||||
#include "SDBlockDevice.h"
|
||||
#include "platform/mbed_debug.h"
|
||||
|
|
|
@ -18,7 +18,7 @@
|
|||
#define MBED_SD_BLOCK_DEVICE_H
|
||||
|
||||
/* If the target has no SPI support then SDCard is not supported */
|
||||
#ifdef DEVICE_SPI
|
||||
#if DEVICE_SPI
|
||||
|
||||
#include "BlockDevice.h"
|
||||
#include "drivers/SPI.h"
|
||||
|
|
|
@ -68,7 +68,7 @@ using namespace utest::v1;
|
|||
* <<< lines removed >>>
|
||||
*/
|
||||
|
||||
#if defined(DEVICE_SPI) && ( defined(MBED_CONF_APP_FSFAT_SDCARD_INSTALLED) || (MBED_CONF_SD_FSFAT_SDCARD_INSTALLED))
|
||||
#if DEVICE_SPI && ( defined(MBED_CONF_APP_FSFAT_SDCARD_INSTALLED) || (MBED_CONF_SD_FSFAT_SDCARD_INSTALLED))
|
||||
static char fsfat_fopen_utest_msg_g[FSFAT_UTEST_MSG_BUF_SIZE];
|
||||
#define FSFAT_FOPEN_TEST_MOUNT_PT_NAME "sd"
|
||||
#define FSFAT_FOPEN_TEST_MOUNT_PT_PATH "/" FSFAT_FOPEN_TEST_MOUNT_PT_NAME
|
||||
|
|
|
@ -29,7 +29,7 @@
|
|||
#include "platform/ScopedRomWriteLock.h"
|
||||
|
||||
|
||||
#ifdef DEVICE_FLASH
|
||||
#if DEVICE_FLASH
|
||||
|
||||
namespace mbed {
|
||||
|
||||
|
|
|
@ -101,7 +101,7 @@ class MbedCRC {
|
|||
|
||||
public:
|
||||
enum CrcMode {
|
||||
#ifdef DEVICE_CRC
|
||||
#if DEVICE_CRC
|
||||
HARDWARE = 0,
|
||||
#endif
|
||||
TABLE = 1,
|
||||
|
@ -198,7 +198,7 @@ public:
|
|||
int32_t status = 0;
|
||||
|
||||
switch (_mode) {
|
||||
#ifdef DEVICE_CRC
|
||||
#if DEVICE_CRC
|
||||
case HARDWARE:
|
||||
hal_crc_compute_partial((uint8_t *)buffer, size);
|
||||
*crc = 0;
|
||||
|
@ -232,7 +232,7 @@ public:
|
|||
{
|
||||
MBED_ASSERT(crc != NULL);
|
||||
|
||||
#ifdef DEVICE_CRC
|
||||
#if DEVICE_CRC
|
||||
if (_mode == HARDWARE) {
|
||||
lock();
|
||||
crc_mbed_config_t config;
|
||||
|
@ -264,7 +264,7 @@ public:
|
|||
{
|
||||
MBED_ASSERT(crc != NULL);
|
||||
|
||||
#ifdef DEVICE_CRC
|
||||
#if DEVICE_CRC
|
||||
if (_mode == HARDWARE) {
|
||||
*crc = hal_crc_get_result();
|
||||
unlock();
|
||||
|
@ -316,7 +316,7 @@ private:
|
|||
*/
|
||||
void lock()
|
||||
{
|
||||
#ifdef DEVICE_CRC
|
||||
#if DEVICE_CRC
|
||||
if (_mode == HARDWARE) {
|
||||
mbed_crc_mutex->lock();
|
||||
}
|
||||
|
@ -327,7 +327,7 @@ private:
|
|||
*/
|
||||
virtual void unlock()
|
||||
{
|
||||
#ifdef DEVICE_CRC
|
||||
#if DEVICE_CRC
|
||||
if (_mode == HARDWARE) {
|
||||
mbed_crc_mutex->unlock();
|
||||
}
|
||||
|
@ -503,7 +503,7 @@ private:
|
|||
{
|
||||
MBED_STATIC_ASSERT(width <= 32, "Max 32-bit CRC supported");
|
||||
|
||||
#ifdef DEVICE_CRC
|
||||
#if DEVICE_CRC
|
||||
if (POLY_32BIT_REV_ANSI == polynomial) {
|
||||
_crc_table = (uint32_t *)Table_CRC_32bit_Rev_ANSI;
|
||||
_mode = TABLE;
|
||||
|
|
|
@ -19,7 +19,7 @@
|
|||
|
||||
#include "platform/platform.h"
|
||||
|
||||
#if defined (DEVICE_QSPI) || defined(DOXYGEN_ONLY)
|
||||
#if DEVICE_QSPI || defined(DOXYGEN_ONLY)
|
||||
|
||||
#include "hal/qspi_api.h"
|
||||
#include "platform/PlatformMutex.h"
|
||||
|
|
|
@ -18,7 +18,7 @@
|
|||
*
|
||||
*/
|
||||
|
||||
#if defined(DEVICE_TRNG)
|
||||
#if DEVICE_TRNG
|
||||
|
||||
#include <string.h>
|
||||
#include "trng_api.h"
|
||||
|
|
|
@ -51,7 +51,7 @@ void generate_derived_key_consistency_32_byte_key_long_consistency_test(char *ke
|
|||
*/
|
||||
int inject_dummy_rot_key()
|
||||
{
|
||||
#if !defined(DEVICE_TRNG)
|
||||
#if !DEVICE_TRNG
|
||||
uint32_t key[DEVICE_KEY_16BYTE / sizeof(uint32_t)];
|
||||
|
||||
memcpy(key, "1234567812345678", DEVICE_KEY_16BYTE);
|
||||
|
|
|
@ -259,7 +259,7 @@ int DeviceKey::generate_key_by_random(uint32_t *output, size_t size)
|
|||
return DEVICEKEY_INVALID_PARAM;
|
||||
}
|
||||
|
||||
#if defined(DEVICE_TRNG)
|
||||
#if DEVICE_TRNG
|
||||
mbedtls_entropy_context *entropy = new mbedtls_entropy_context;
|
||||
mbedtls_entropy_init(entropy);
|
||||
memset(output, 0, size);
|
||||
|
|
|
@ -24,7 +24,7 @@
|
|||
|
||||
// Whole class is not supported if entropy is not enabled
|
||||
// Flash device is required as Device Key is currently depending on it
|
||||
#if !defined(DEVICE_FLASH) || !defined(COMPONENT_FLASHIAP)
|
||||
#if !DEVICE_FLASH || !defined(COMPONENT_FLASHIAP)
|
||||
#undef DEVICEKEY_ENABLED
|
||||
#define DEVICEKEY_ENABLED 0
|
||||
#endif
|
||||
|
|
|
@ -17,7 +17,7 @@
|
|||
* This file is part of mbed TLS (https://tls.mbed.org)
|
||||
*/
|
||||
|
||||
#if defined(DEVICE_TRNG)
|
||||
#if DEVICE_TRNG
|
||||
#define MBEDTLS_ENTROPY_HARDWARE_ALT
|
||||
#endif
|
||||
|
||||
|
|
|
@ -14,7 +14,7 @@
|
|||
* limitations under the License.
|
||||
*/
|
||||
|
||||
#if defined(DEVICE_TRNG)
|
||||
#if DEVICE_TRNG
|
||||
|
||||
#include "hal/trng_api.h"
|
||||
|
||||
|
|
|
@ -18,7 +18,7 @@
|
|||
#define MBED_NVSTORE_H
|
||||
|
||||
// These addresses need to be configured according to board (in mbed_lib.json)
|
||||
#ifndef DEVICE_FLASH
|
||||
#if !DEVICE_FLASH
|
||||
#undef NVSTORE_ENABLED
|
||||
#define NVSTORE_ENABLED 0
|
||||
#endif
|
||||
|
|
|
@ -64,7 +64,7 @@ TEST(C_String_Format, Sprintf_Negative_Integers)
|
|||
STRCMP_EQUAL(buffer, "-32768 -3214 -999 -100 -1 0 -1 -4231 -999 -4123 -32760 -99999");
|
||||
}
|
||||
|
||||
#ifdef DEVICE_SEMIHOST
|
||||
#if DEVICE_SEMIHOST
|
||||
#include "mbed_semihost_api.h"
|
||||
|
||||
TEST_GROUP(Device_Semihost)
|
||||
|
|
|
@ -52,7 +52,7 @@ typedef struct crc_mbed_config {
|
|||
bool reflect_out;
|
||||
} crc_mbed_config_t;
|
||||
|
||||
#ifdef DEVICE_CRC
|
||||
#if DEVICE_CRC
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
|
|
|
@ -20,7 +20,7 @@
|
|||
#ifndef MBED_ITM_API_H
|
||||
#define MBED_ITM_API_H
|
||||
|
||||
#if defined(DEVICE_ITM)
|
||||
#if DEVICE_ITM
|
||||
|
||||
#include <stdint.h>
|
||||
#include <stddef.h>
|
||||
|
|
|
@ -15,7 +15,7 @@
|
|||
* limitations under the License.
|
||||
*/
|
||||
|
||||
#if defined(DEVICE_ITM)
|
||||
#if DEVICE_ITM
|
||||
|
||||
#include "hal/itm_api.h"
|
||||
#include "cmsis.h"
|
||||
|
@ -131,4 +131,4 @@ void mbed_itm_send_block(uint32_t port, const void *data, size_t len)
|
|||
}
|
||||
}
|
||||
}
|
||||
#endif // defined(DEVICE_ITM)
|
||||
#endif // DEVICE_ITM
|
||||
|
|
|
@ -36,13 +36,13 @@ static uint16_t deep_sleep_lock = 0U;
|
|||
static us_timestamp_t sleep_time = 0;
|
||||
static us_timestamp_t deep_sleep_time = 0;
|
||||
|
||||
#if defined(MBED_CPU_STATS_ENABLED) && defined(DEVICE_LPTICKER)
|
||||
#if defined(MBED_CPU_STATS_ENABLED) && DEVICE_LPTICKER
|
||||
static ticker_data_t *sleep_ticker = NULL;
|
||||
#endif
|
||||
|
||||
static inline us_timestamp_t read_us(void)
|
||||
{
|
||||
#if defined(MBED_CPU_STATS_ENABLED) && defined(DEVICE_LPTICKER)
|
||||
#if defined(MBED_CPU_STATS_ENABLED) && DEVICE_LPTICKER
|
||||
if (NULL == sleep_ticker) {
|
||||
sleep_ticker = (ticker_data_t *)get_lp_ticker_data();
|
||||
}
|
||||
|
|
|
@ -13,7 +13,7 @@
|
|||
#warning Statistics are currently not supported without the rtos.
|
||||
#endif
|
||||
|
||||
#if defined(MBED_CPU_STATS_ENABLED) && (!defined(DEVICE_LPTICKER) || !defined(DEVICE_SLEEP))
|
||||
#if defined(MBED_CPU_STATS_ENABLED) && (!DEVICE_LPTICKER || !DEVICE_SLEEP)
|
||||
#warning CPU statistics are not supported without low power timer support.
|
||||
#endif
|
||||
|
||||
|
@ -21,7 +21,7 @@ void mbed_stats_cpu_get(mbed_stats_cpu_t *stats)
|
|||
{
|
||||
MBED_ASSERT(stats != NULL);
|
||||
memset(stats, 0, sizeof(mbed_stats_cpu_t));
|
||||
#if defined(MBED_CPU_STATS_ENABLED) && defined(DEVICE_LPTICKER) && defined(DEVICE_SLEEP)
|
||||
#if defined(MBED_CPU_STATS_ENABLED) && DEVICE_LPTICKER && DEVICE_SLEEP
|
||||
stats->uptime = mbed_uptime();
|
||||
stats->idle_time = mbed_time_idle();
|
||||
stats->sleep_time = mbed_time_sleep();
|
||||
|
|
|
@ -22,7 +22,7 @@
|
|||
#ifndef MBED_SYS_TIMER_H
|
||||
#define MBED_SYS_TIMER_H
|
||||
|
||||
#if defined(DEVICE_LPTICKER) || defined(DOXYGEN_ONLY)
|
||||
#if DEVICE_LPTICKER || defined(DOXYGEN_ONLY)
|
||||
|
||||
#include "platform/NonCopyable.h"
|
||||
#include "drivers/TimerEvent.h"
|
||||
|
|
|
@ -35,7 +35,7 @@ extern "C" {
|
|||
|
||||
using namespace mbed;
|
||||
|
||||
#if (defined(MBED_TICKLESS) && defined(DEVICE_LPTICKER))
|
||||
#if (defined(MBED_TICKLESS) && DEVICE_LPTICKER)
|
||||
|
||||
#include "rtos/TARGET_CORTEX/SysTimer.h"
|
||||
|
||||
|
@ -138,7 +138,7 @@ extern "C" {
|
|||
core_util_critical_section_exit();
|
||||
}
|
||||
|
||||
#endif // (defined(MBED_TICKLESS) && defined(DEVICE_LPTICKER))
|
||||
#endif // (defined(MBED_TICKLESS) && DEVICE_LPTICKER)
|
||||
|
||||
static void (*idle_hook_fptr)(void) = &default_idle_hook;
|
||||
|
||||
|
|
Loading…
Reference in New Issue