From 9491403f43344619ef82bb20d5516799d437c659 Mon Sep 17 00:00:00 2001 From: Hari Limaye Date: Tue, 10 Aug 2021 17:50:47 +0100 Subject: [PATCH] Unit tests: Add stubs for analogin_api.c functions Currently there are no stub implementations of the analogin_api.c functions. As the AnalogIn class makes use of these functions, these stub definitions are required in order to build AnalogIn.cpp and generate .gcno files to be used to generate code coverage metrics. --- hal/tests/UNITTESTS/doubles/CMakeLists.txt | 2 + .../UNITTESTS/doubles/analogin_api_stub.c | 49 +++++++++++++++++++ 2 files changed, 51 insertions(+) create mode 100644 hal/tests/UNITTESTS/doubles/analogin_api_stub.c diff --git a/hal/tests/UNITTESTS/doubles/CMakeLists.txt b/hal/tests/UNITTESTS/doubles/CMakeLists.txt index 896617bc24..dd0f3faf07 100644 --- a/hal/tests/UNITTESTS/doubles/CMakeLists.txt +++ b/hal/tests/UNITTESTS/doubles/CMakeLists.txt @@ -17,6 +17,7 @@ target_compile_definitions(mbed-stubs-hal DEVICE_PWMOUT DEVICE_WATCHDOG MBED_WDOG_ASSERT=1 + DEVICE_ANALOGIN ) target_sources(mbed-stubs-hal @@ -24,6 +25,7 @@ target_sources(mbed-stubs-hal pwmout_api_stub.c us_ticker_stub.cpp watchdog_api_stub.c + analogin_api_stub.c ) target_link_libraries(mbed-stubs-hal diff --git a/hal/tests/UNITTESTS/doubles/analogin_api_stub.c b/hal/tests/UNITTESTS/doubles/analogin_api_stub.c new file mode 100644 index 0000000000..1ae5ba1bf1 --- /dev/null +++ b/hal/tests/UNITTESTS/doubles/analogin_api_stub.c @@ -0,0 +1,49 @@ +/* + * Copyright (c) 2021 Arm Limited and affiliates. + * SPDX-License-Identifier: Apache-2.0 + * + * 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. + */ +#include "hal/analogin_api.h" +#include + +#if DEVICE_ANALOGIN + +void analogin_init_direct(analogin_t *obj, const PinMap *pinmap) +{ +} + +void analogin_init(analogin_t *obj, PinName pin) +{ +} + +void analogin_free(analogin_t *obj) +{ +} + +float analogin_read(analogin_t *obj) +{ + return 0; +} + +uint16_t analogin_read_u16(analogin_t *obj) +{ + return 0; +} + +const PinMap *analogin_pinmap(void) +{ + return NULL; +} + +#endif // DEVICE_ANALOGIN