Europalab Devices produces a LoRaWAN transmitting client node, specialised for higher research of actuator and sensor assisted IoT networks. https://dev.europalab.com/nlnet/20200000/
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

56 lines
1.1KB

  1. #include <main.h>
  2. #include <unity.h>
  3. void setUp(void) {
  4. HAL_Init();
  5. LED_GPIO_CLK_ENABLE();
  6. GPIO_InitTypeDef GPIO_InitStruct;
  7. GPIO_InitStruct.Pin = LED_PIN;
  8. GPIO_InitStruct.Mode = GPIO_MODE_OUTPUT_PP;
  9. GPIO_InitStruct.Pull = GPIO_PULLUP;
  10. GPIO_InitStruct.Speed = GPIO_SPEED_HIGH;
  11. HAL_GPIO_Init(LED_GPIO_PORT, &GPIO_InitStruct);
  12. }
  13. void tearDown(void) {
  14. HAL_GPIO_DeInit(LED_GPIO_PORT, LED_PIN);
  15. }
  16. void test_led_builtin_pin_number(void) {
  17. TEST_ASSERT_EQUAL(LED_PIN, GPIO_PIN_5);
  18. }
  19. void test_led_state_high(void) {
  20. HAL_GPIO_WritePin(LED_GPIO_PORT, LED_PIN, GPIO_PIN_SET);
  21. TEST_ASSERT_EQUAL(HAL_GPIO_ReadPin(LED_GPIO_PORT, LED_PIN), GPIO_PIN_SET);
  22. }
  23. void test_led_state_low(void) {
  24. HAL_GPIO_WritePin(LED_GPIO_PORT, LED_PIN, GPIO_PIN_RESET);
  25. TEST_ASSERT_EQUAL(HAL_GPIO_ReadPin(LED_GPIO_PORT, LED_PIN), GPIO_PIN_RESET);
  26. }
  27. int main() {
  28. UNITY_BEGIN();
  29. RUN_TEST(test_led_builtin_pin_number);
  30. for (unsigned int i = 0; i < 5; i++)
  31. {
  32. RUN_TEST(test_led_state_high);
  33. HAL_Delay(500);
  34. RUN_TEST(test_led_state_low);
  35. HAL_Delay(500);
  36. }
  37. UNITY_END(); // Stop testing
  38. while (1) {}
  39. }
  40. void SysTick_Handler(void) {
  41. HAL_IncTick();
  42. }