test_suite_flowcontroll.cpp 3.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091
  1. #include <unity.h>
  2. #include "components/jomjol-flowcontroll/test_cnnflowcontroll.cpp"
  3. #include "components/jomjol-flowcontroll/test_flowpostprocessing.cpp"
  4. // SD-Card ////////////////////
  5. #include "nvs_flash.h"
  6. #include "esp_vfs_fat.h"
  7. #include "sdmmc_cmd.h"
  8. #include "driver/sdmmc_host.h"
  9. #include "driver/sdmmc_defs.h"
  10. static const char *TAGMAIN = "main";
  11. bool Init_NVS_SDCard()
  12. {
  13. esp_err_t ret = nvs_flash_init();
  14. if (ret == ESP_ERR_NVS_NO_FREE_PAGES) {
  15. ESP_ERROR_CHECK(nvs_flash_erase());
  16. ret = nvs_flash_init();
  17. }
  18. ////////////////////////////////////////////////
  19. ESP_LOGI(TAGMAIN, "Using SDMMC peripheral");
  20. sdmmc_host_t host = SDMMC_HOST_DEFAULT();
  21. // This initializes the slot without card detect (CD) and write protect (WP) signals.
  22. // Modify slot_config.gpio_cd and slot_config.gpio_wp if your board has these signals.
  23. sdmmc_slot_config_t slot_config = SDMMC_SLOT_CONFIG_DEFAULT();
  24. // To use 1-line SD mode, uncomment the following line:
  25. #ifdef __SD_USE_ONE_LINE_MODE__
  26. slot_config.width = 1;
  27. #endif
  28. // GPIOs 15, 2, 4, 12, 13 should have external 10k pull-ups.
  29. // Internal pull-ups are not sufficient. However, enabling internal pull-ups
  30. // does make a difference some boards, so we do that here.
  31. gpio_set_pull_mode(GPIO_NUM_15, GPIO_PULLUP_ONLY); // CMD, needed in 4- and 1- line modes
  32. gpio_set_pull_mode(GPIO_NUM_2, GPIO_PULLUP_ONLY); // D0, needed in 4- and 1-line modes
  33. #ifndef __SD_USE_ONE_LINE_MODE__
  34. gpio_set_pull_mode(GPIO_NUM_4, GPIO_PULLUP_ONLY); // D1, needed in 4-line mode only
  35. gpio_set_pull_mode(GPIO_NUM_12, GPIO_PULLUP_ONLY); // D2, needed in 4-line mode only
  36. #endif
  37. gpio_set_pull_mode(GPIO_NUM_13, GPIO_PULLUP_ONLY); // D3, needed in 4- and 1-line modes
  38. // Options for mounting the filesystem.
  39. // If format_if_mount_failed is set to true, SD card will be partitioned and
  40. // formatted in case when mounting fails.
  41. esp_vfs_fat_sdmmc_mount_config_t mount_config = {
  42. .format_if_mount_failed = false,
  43. .max_files = 5,
  44. .allocation_unit_size = 16 * 1024
  45. };
  46. // Use settings defined above to initialize SD card and mount FAT filesystem.
  47. // Note: esp_vfs_fat_sdmmc_mount is an all-in-one convenience function.
  48. // Please check its source code and implement error recovery when developing
  49. // production applications.
  50. sdmmc_card_t* card;
  51. ret = esp_vfs_fat_sdmmc_mount("/sdcard", &host, &slot_config, &mount_config, &card);
  52. if (ret != ESP_OK) {
  53. if (ret == ESP_FAIL) {
  54. ESP_LOGE(TAGMAIN, "Failed to mount filesystem. "
  55. "If you want the card to be formatted, set format_if_mount_failed = true.");
  56. } else {
  57. ESP_LOGE(TAGMAIN, "Failed to initialize the card (%s). "
  58. "Make sure SD card lines have pull-up resistors in place.", esp_err_to_name(ret));
  59. }
  60. return false;
  61. }
  62. sdmmc_card_print_info(stdout, card);
  63. return true;
  64. }
  65. /**
  66. * @brief startup the test. Like a test-suite
  67. * all test methods must be called here
  68. */
  69. extern "C" void app_main()
  70. {
  71. Init_NVS_SDCard();
  72. UNITY_BEGIN();
  73. RUN_TEST(test_ZeigerEval);
  74. RUN_TEST(test_ZeigerEvalHybrid);
  75. RUN_TEST(test_doFlow);
  76. UNITY_END();
  77. }