test_suite_flowcontroll.cpp 6.4 KB

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