Skip to content

Commit 9491403

Browse files
committed
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.
1 parent 6440546 commit 9491403

File tree

2 files changed

+51
-0
lines changed

2 files changed

+51
-0
lines changed

hal/tests/UNITTESTS/doubles/CMakeLists.txt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,13 +17,15 @@ target_compile_definitions(mbed-stubs-hal
1717
DEVICE_PWMOUT
1818
DEVICE_WATCHDOG
1919
MBED_WDOG_ASSERT=1
20+
DEVICE_ANALOGIN
2021
)
2122

2223
target_sources(mbed-stubs-hal
2324
PRIVATE
2425
pwmout_api_stub.c
2526
us_ticker_stub.cpp
2627
watchdog_api_stub.c
28+
analogin_api_stub.c
2729
)
2830

2931
target_link_libraries(mbed-stubs-hal
Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
/*
2+
* Copyright (c) 2021 Arm Limited and affiliates.
3+
* SPDX-License-Identifier: Apache-2.0
4+
*
5+
* Licensed under the Apache License, Version 2.0 (the "License");
6+
* you may not use this file except in compliance with the License.
7+
* You may obtain a copy of the License at
8+
*
9+
* http://www.apache.org/licenses/LICENSE-2.0
10+
*
11+
* Unless required by applicable law or agreed to in writing, software
12+
* distributed under the License is distributed on an "AS IS" BASIS,
13+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14+
* See the License for the specific language governing permissions and
15+
* limitations under the License.
16+
*/
17+
#include "hal/analogin_api.h"
18+
#include <stddef.h>
19+
20+
#if DEVICE_ANALOGIN
21+
22+
void analogin_init_direct(analogin_t *obj, const PinMap *pinmap)
23+
{
24+
}
25+
26+
void analogin_init(analogin_t *obj, PinName pin)
27+
{
28+
}
29+
30+
void analogin_free(analogin_t *obj)
31+
{
32+
}
33+
34+
float analogin_read(analogin_t *obj)
35+
{
36+
return 0;
37+
}
38+
39+
uint16_t analogin_read_u16(analogin_t *obj)
40+
{
41+
return 0;
42+
}
43+
44+
const PinMap *analogin_pinmap(void)
45+
{
46+
return NULL;
47+
}
48+
49+
#endif // DEVICE_ANALOGIN

0 commit comments

Comments
 (0)