test_suite_flowcontroll.cpp 4.3 KB

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