test_apb_dport_access.c 1.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556
  1. /* Implementation of utility functions to verify
  2. unit tests aren't performing SMP-unsafe DPORT reads.
  3. */
  4. #include "unity.h"
  5. #include "sdkconfig.h"
  6. #include "freertos/FreeRTOS.h"
  7. #include "freertos/task.h"
  8. #include "soc/uart_periph.h"
  9. #include "test_apb_dport_access.h"
  10. #include "test_utils.h"
  11. #ifndef CONFIG_FREERTOS_UNICORE
  12. static void apb_access_loop_task(void *ignore);
  13. static volatile bool apb_access_corrupt;
  14. static TaskHandle_t apb_task_handle;
  15. void start_apb_access_loop(void)
  16. {
  17. apb_access_corrupt = false;
  18. xTaskCreatePinnedToCore(apb_access_loop_task, "accessAPB", 2048, NULL,
  19. UNITY_FREERTOS_PRIORITY - 1,
  20. &apb_task_handle, !UNITY_FREERTOS_CPU);
  21. }
  22. void verify_apb_access_loop(void)
  23. {
  24. vTaskDelete(apb_task_handle);
  25. apb_task_handle = NULL;
  26. TEST_ASSERT_FALSE(apb_access_corrupt);
  27. printf("Verified no APB corruption from operations\n");
  28. }
  29. static void apb_access_loop_task(void *ignore)
  30. {
  31. uint32_t initial = REG_READ(UART_DATE_REG(0));
  32. while(1) {
  33. if (REG_READ(UART_DATE_REG(0)) != initial) {
  34. apb_access_corrupt = true;
  35. }
  36. }
  37. }
  38. #else /*CONFIG_FREERTOS_UNICORE */
  39. void start_apb_access_loop(void)
  40. {
  41. }
  42. void verify_apb_access_loop(void)
  43. {
  44. }
  45. #endif