From d66d8ae99871e478499fbe5544a976efaf6d960e Mon Sep 17 00:00:00 2001 From: Bas Stottelaar Date: Wed, 8 Jan 2020 00:45:10 +0100 Subject: [PATCH] tests/cpu_efm32_drivers: add test application --- tests/cpu_efm32_drivers/Makefile | 17 +++++++++++ tests/cpu_efm32_drivers/README.md | 11 +++++++ tests/cpu_efm32_drivers/main.c | 51 +++++++++++++++++++++++++++++++ 3 files changed, 79 insertions(+) create mode 100644 tests/cpu_efm32_drivers/Makefile create mode 100644 tests/cpu_efm32_drivers/README.md create mode 100644 tests/cpu_efm32_drivers/main.c diff --git a/tests/cpu_efm32_drivers/Makefile b/tests/cpu_efm32_drivers/Makefile new file mode 100644 index 0000000000..192e00f572 --- /dev/null +++ b/tests/cpu_efm32_drivers/Makefile @@ -0,0 +1,17 @@ +BOARD ?= sltb001a +include ../Makefile.tests_common + +BOARD_WHITELIST := ikea-tradfri \ + slstk3401a \ + slstk3402a \ + sltb001a \ + slwstk6000b-slwrb4150a \ + slwstk6000b-slwrb4162a \ + slwstk6220a \ + stk3200 \ + stk3600 \ + stk3700 + +USEMODULE += efm32_coretemp + +include $(RIOTBASE)/Makefile.include diff --git a/tests/cpu_efm32_drivers/README.md b/tests/cpu_efm32_drivers/README.md new file mode 100644 index 0000000000..269fd83a70 --- /dev/null +++ b/tests/cpu_efm32_drivers/README.md @@ -0,0 +1,11 @@ +# EFM32 CPU Drivers + +## Introduction +The EFM32 CPU has additional drivers that can be used. This test application +ensure that these drivers work. + +Current tests includes: +* EFM32 core temperature driver + +## Expected result +The test application compiles for EFM32-based boards. diff --git a/tests/cpu_efm32_drivers/main.c b/tests/cpu_efm32_drivers/main.c new file mode 100644 index 0000000000..014df953ed --- /dev/null +++ b/tests/cpu_efm32_drivers/main.c @@ -0,0 +1,51 @@ +/* + * Copyright (C) 2020 Bas Stottelaar + * + * This file is subject to the terms and conditions of the GNU Lesser + * General Public License v2.1. See the file LICENSE in the top level + * directory for more details. + */ + +/** + * @ingroup tests + * @{ + * + * @file + * @brief Test application for EFM32 specific drivers + * + * @author Bas Stottelaar + * + * @} + */ + +#include + +#include "coretemp.h" + +static void test_coretemp(void) +{ + puts("Testing internal EFM32 temperature driver."); + + /* initialize the sensor */ + int result = coretemp_init(); + + if (result == 0) { + puts("Driver initialization OK."); + } + else { + printf("Driver initialization failed: %d.", result); + return; + } + + /* read temperature */ + int16_t temperature = coretemp_read(); + + printf("Temperature: %d.%02d C\n", temperature / 100, temperature % 100); +} + +int main(void) +{ + test_coretemp(); + + return 0; +}