|
| 1 | +/* mbed Microcontroller Library |
| 2 | + * Copyright (c) 2020 ARM Limited |
| 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 | + |
| 18 | +#include "utest/utest.h" |
| 19 | +#include "unity/unity.h" |
| 20 | +#include "greentea-client/test_env.h" |
| 21 | +#include "mbed.h" |
| 22 | + |
| 23 | +#ifndef LED1 |
| 24 | +// Set test as not supported, could be changed as error later |
| 25 | +#error [NOT_SUPPORTED] check docs/design-documents/hal/0004-pin-names-general-guidelines.md |
| 26 | +#else |
| 27 | + |
| 28 | +using namespace utest::v1; |
| 29 | + |
| 30 | +template <int LedId, PinName LedPin> |
| 31 | +void LED_test() |
| 32 | +{ |
| 33 | + printf("LED %u Pin 0x%x\n", LedId, LedPin); |
| 34 | + DigitalOut TEST(LedPin); |
| 35 | + TEST = 1; |
| 36 | + ThisThread::sleep_for(1s); |
| 37 | + TEST = 0; |
| 38 | +} |
| 39 | + |
| 40 | + |
| 41 | +template <int ButtonId, PinName ButtonPin> |
| 42 | +void BUTTON_test() |
| 43 | +{ |
| 44 | + printf("BUTTON %u Pin 0x%x\n", ButtonId, ButtonPin); |
| 45 | + DigitalIn TEST(ButtonPin); |
| 46 | +} |
| 47 | + |
| 48 | + |
| 49 | +Case cases[] = { |
| 50 | +#ifdef LED1 |
| 51 | + Case("LED1", LED_test<1, LED1>), |
| 52 | +#endif |
| 53 | +#ifdef LED2 |
| 54 | + Case("LED2", LED_test<2, LED2>), |
| 55 | +#endif |
| 56 | +#ifdef LED3 |
| 57 | + Case("LED3", LED_test<3, LED3>), |
| 58 | +#endif |
| 59 | +#ifdef LED4 |
| 60 | + Case("LED4", LED_test<4, LED4>), |
| 61 | +#endif |
| 62 | +#ifdef LED5 |
| 63 | + Case("LED5", LED_test<5, LED5>), |
| 64 | +#endif |
| 65 | +#ifdef LED6 |
| 66 | + Case("LED6", LED_test<6, LED6>), |
| 67 | +#endif |
| 68 | +#ifdef LED7 |
| 69 | + Case("LED7", LED_test<7, LED7>), |
| 70 | +#endif |
| 71 | +#ifdef LED8 |
| 72 | + Case("LED8", LED_test<8, LED8>), |
| 73 | +#endif |
| 74 | + |
| 75 | +#ifdef BUTTON1 |
| 76 | + Case("BUTTON1", BUTTON_test<1, BUTTON1>), |
| 77 | +#endif |
| 78 | +#ifdef BUTTON2 |
| 79 | + Case("BUTTON2", BUTTON_test<2, BUTTON2>), |
| 80 | +#endif |
| 81 | +}; |
| 82 | + |
| 83 | +utest::v1::status_t greentea_test_setup(const size_t number_of_cases) |
| 84 | +{ |
| 85 | + GREENTEA_SETUP(20, "default_auto"); |
| 86 | + return greentea_test_setup_handler(number_of_cases); |
| 87 | +} |
| 88 | + |
| 89 | +Specification specification(greentea_test_setup, cases, greentea_test_teardown_handler); |
| 90 | + |
| 91 | +int main() |
| 92 | +{ |
| 93 | + Harness::run(specification); |
| 94 | +} |
| 95 | + |
| 96 | +#endif |
0 commit comments