test_suite_flowcontroll.cpp 6.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163
  1. #include <unity.h>
  2. // SD-Card ////////////////////
  3. #include "nvs_flash.h"
  4. #include "esp_vfs_fat.h"
  5. #include "sdmmc_cmd.h"
  6. #include "driver/sdmmc_host.h"
  7. #include "driver/sdmmc_defs.h"
  8. //static const char *TAG = "MAIN TEST";
  9. #define __SD_USE_ONE_LINE_MODE__
  10. #include "server_GPIO.h"
  11. //*****************************************************************************
  12. // Include files with functions to test
  13. //*****************************************************************************
  14. #include "components/jomjol-flowcontroll/test_flow_postrocess_helper.cpp"
  15. #include "components/jomjol-flowcontroll/test_flowpostprocessing.cpp"
  16. #include "components/jomjol-flowcontroll/test_flow_pp_negative.cpp"
  17. #include "components/jomjol-flowcontroll/test_PointerEvalAnalogToDigitNew.cpp"
  18. #include "components/jomjol-flowcontroll/test_getReadoutRawString.cpp"
  19. #include "components/jomjol-flowcontroll/test_cnnflowcontroll.cpp"
  20. bool Init_NVS_SDCard()
  21. {
  22. esp_err_t ret = nvs_flash_init();
  23. if (ret == ESP_ERR_NVS_NO_FREE_PAGES) {
  24. ESP_ERROR_CHECK(nvs_flash_erase());
  25. ret = nvs_flash_init();
  26. }
  27. ////////////////////////////////////////////////
  28. ESP_LOGI(TAG, "Using SDMMC peripheral");
  29. sdmmc_host_t host = SDMMC_HOST_DEFAULT();
  30. // This initializes the slot without card detect (CD) and write protect (WP) signals.
  31. // Modify slot_config.gpio_cd and slot_config.gpio_wp if your board has these signals.
  32. sdmmc_slot_config_t slot_config = SDMMC_SLOT_CONFIG_DEFAULT();
  33. // To use 1-line SD mode, uncomment the following line:
  34. #ifdef __SD_USE_ONE_LINE_MODE__
  35. slot_config.width = 1;
  36. #endif
  37. // GPIOs 15, 2, 4, 12, 13 should have external 10k pull-ups.
  38. // Internal pull-ups are not sufficient. However, enabling internal pull-ups
  39. // does make a difference some boards, so we do that here.
  40. gpio_set_pull_mode(GPIO_NUM_15, GPIO_PULLUP_ONLY); // CMD, needed in 4- and 1- line modes
  41. gpio_set_pull_mode(GPIO_NUM_2, GPIO_PULLUP_ONLY); // D0, needed in 4- and 1-line modes
  42. #ifndef __SD_USE_ONE_LINE_MODE__
  43. gpio_set_pull_mode(GPIO_NUM_4, GPIO_PULLUP_ONLY); // D1, needed in 4-line mode only
  44. gpio_set_pull_mode(GPIO_NUM_12, GPIO_PULLUP_ONLY); // D2, needed in 4-line mode only
  45. #endif
  46. gpio_set_pull_mode(GPIO_NUM_13, GPIO_PULLUP_ONLY); // D3, needed in 4- and 1-line modes
  47. // Options for mounting the filesystem.
  48. // If format_if_mount_failed is set to true, SD card will be partitioned and
  49. // formatted in case when mounting fails.
  50. esp_vfs_fat_sdmmc_mount_config_t mount_config = {
  51. .format_if_mount_failed = false,
  52. .max_files = 7, // anstatt 5 (2022-09-21)
  53. .allocation_unit_size = 16 * 1024
  54. };
  55. // Use settings defined above to initialize SD card and mount FAT filesystem.
  56. // Note: esp_vfs_fat_sdmmc_mount is an all-in-one convenience function.
  57. // Please check its source code and implement error recovery when developing
  58. // production applications.
  59. sdmmc_card_t* card;
  60. ret = esp_vfs_fat_sdmmc_mount("/sdcard", &host, &slot_config, &mount_config, &card);
  61. if (ret != ESP_OK) {
  62. if (ret == ESP_FAIL) {
  63. ESP_LOGE(TAG, "Failed to mount filesystem. "
  64. "If you want the card to be formatted, set format_if_mount_failed = true.");
  65. } else {
  66. ESP_LOGE(TAG, "Failed to initialize the card (%s). "
  67. "Make sure SD card lines have pull-up resistors in place.", esp_err_to_name(ret));
  68. }
  69. return false;
  70. }
  71. sdmmc_card_print_info(stdout, card);
  72. SaveSDCardInfo(card);
  73. return true;
  74. }
  75. void initGPIO()
  76. {
  77. gpio_config_t io_conf;
  78. //set as output mode
  79. io_conf.mode = gpio_mode_t::GPIO_MODE_INPUT;
  80. //bit mask of the pins that you want to set,e.g.GPIO18/19
  81. io_conf.pull_down_en = gpio_pulldown_t::GPIO_PULLDOWN_ENABLE;
  82. //set pull-up mode
  83. io_conf.pull_up_en = gpio_pullup_t::GPIO_PULLUP_DISABLE;
  84. //configure GPIO with the given settings
  85. gpio_config(&io_conf);
  86. }
  87. /**
  88. * @brief startup the test. Like a test-suite
  89. * all test methods must be called here
  90. */
  91. void task_UnityTesting(void *pvParameter)
  92. {
  93. vTaskDelay( 5000 / portTICK_PERIOD_MS ); // 5s delay to ensure established serial connection
  94. UNITY_BEGIN();
  95. RUN_TEST(test_getReadoutRawString);
  96. printf("---------------------------------------------------------------------------\n");
  97. RUN_TEST(test_ZeigerEval);
  98. printf("---------------------------------------------------------------------------\n");
  99. RUN_TEST(test_ZeigerEvalHybrid);
  100. printf("---------------------------------------------------------------------------\n");
  101. RUN_TEST(testNegative_Issues);
  102. printf("---------------------------------------------------------------------------\n");
  103. RUN_TEST(testNegative);
  104. printf("---------------------------------------------------------------------------\n");
  105. RUN_TEST(test_analogToDigit_Standard);
  106. printf("---------------------------------------------------------------------------\n");
  107. RUN_TEST(test_analogToDigit_Transition);
  108. printf("---------------------------------------------------------------------------\n");
  109. RUN_TEST(test_doFlowPP);
  110. printf("---------------------------------------------------------------------------\n");
  111. RUN_TEST(test_doFlowPP1);
  112. printf("---------------------------------------------------------------------------\n");
  113. RUN_TEST(test_doFlowPP2);
  114. printf("---------------------------------------------------------------------------\n");
  115. RUN_TEST(test_doFlowPP3);
  116. printf("---------------------------------------------------------------------------\n");
  117. RUN_TEST(test_doFlowPP4);
  118. printf("---------------------------------------------------------------------------\n");
  119. RUN_TEST(test_doFlowPP_rainman110);
  120. printf("---------------------------------------------------------------------------\n");
  121. RUN_TEST(test_doFlowPP_rainman110_transition);
  122. UNITY_END();
  123. while(1);
  124. }
  125. /**
  126. * @brief main task
  127. */
  128. extern "C" void app_main()
  129. {
  130. initGPIO();
  131. Init_NVS_SDCard();
  132. esp_log_level_set("*", ESP_LOG_DEBUG); // set all components to DEBUG level
  133. // Create dedicated testing task (heap size can be configured - large enough to handle a lot of testing cases)
  134. // ********************************************
  135. xTaskCreate(&task_UnityTesting, "task_UnityTesting", 12 * 1024, NULL, tskIDLE_PRIORITY+2, NULL);
  136. }