#include #include void setUp(void) { HAL_Init(); LED_GPIO_CLK_ENABLE(); GPIO_InitTypeDef GPIO_InitStruct; GPIO_InitStruct.Pin = LED_PIN; GPIO_InitStruct.Mode = GPIO_MODE_OUTPUT_PP; GPIO_InitStruct.Pull = GPIO_PULLUP; GPIO_InitStruct.Speed = GPIO_SPEED_HIGH; HAL_GPIO_Init(LED_GPIO_PORT, &GPIO_InitStruct); } void tearDown(void) { HAL_GPIO_DeInit(LED_GPIO_PORT, LED_PIN); } void test_led_builtin_pin_number(void) { TEST_ASSERT_EQUAL(LED_PIN, GPIO_PIN_5); } void test_led_state_high(void) { HAL_GPIO_WritePin(LED_GPIO_PORT, LED_PIN, GPIO_PIN_SET); TEST_ASSERT_EQUAL(HAL_GPIO_ReadPin(LED_GPIO_PORT, LED_PIN), GPIO_PIN_SET); } void test_led_state_low(void) { HAL_GPIO_WritePin(LED_GPIO_PORT, LED_PIN, GPIO_PIN_RESET); TEST_ASSERT_EQUAL(HAL_GPIO_ReadPin(LED_GPIO_PORT, LED_PIN), GPIO_PIN_RESET); } int main() { UNITY_BEGIN(); RUN_TEST(test_led_builtin_pin_number); for (unsigned int i = 0; i < 5; i++) { RUN_TEST(test_led_state_high); HAL_Delay(500); RUN_TEST(test_led_state_low); HAL_Delay(500); } UNITY_END(); // Stop testing while (1) {} } void SysTick_Handler(void) { HAL_IncTick(); }