sdio_test.py 4.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136
  1. # Copyright 2015-2017 Espressif Systems (Shanghai) PTE LTD
  2. #
  3. # Licensed under the Apache License, Version 2.0 (the "License");
  4. # you may not use this file except in compliance with the License.
  5. # You may obtain a copy of the License at
  6. #
  7. # http:#www.apache.org/licenses/LICENSE-2.0
  8. #
  9. # Unless required by applicable law or agreed to in writing, software
  10. # distributed under the License is distributed on an "AS IS" BASIS,
  11. # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  12. # See the License for the specific language governing permissions and
  13. # limitations under the License.
  14. """ example of writing test with TinyTestFW """
  15. import os
  16. import sys
  17. try:
  18. import TinyFW
  19. except ImportError:
  20. # if we want to run test case outside `tiny-test-fw` folder,
  21. # we need to insert tiny-test-fw path into sys path
  22. test_fw_path = os.getenv("TEST_FW_PATH")
  23. if test_fw_path and test_fw_path not in sys.path:
  24. sys.path.insert(0, test_fw_path)
  25. import TinyFW
  26. import IDF
  27. @IDF.idf_example_test(env_tag="Example_SDIO", ignore=True)
  28. def test_example_sdio_communication(env, extra_data):
  29. """
  30. Configurations
  31. dut1 = host -> dut2 = slave
  32. should be in the same group of devices, otherwise may meet download issue
  33. group1: (Wroom-32 Series or PICO-D4 modules: PICO-Kit, DevKitC, WroverKit v2 or earlier)
  34. group2: (Wrover module: WroverKit v3)
  35. GPIO14->GPIO14
  36. GPIO15->GPIO15
  37. GPIO2->GPIO2
  38. GPIO4->GPIO4
  39. GND->GND
  40. VDD3.3 -> GPIO13 if dut2 uses WroverKit v3
  41. or use sdio test board, which has two wrover modules connect to a same FT3232
  42. Assume that first dut is host and second is slave
  43. """
  44. dut1 = env.get_dut("sdio_host", "examples/peripherals/sdio/host")
  45. dut2 = env.get_dut("sdio_slave", "examples/peripherals/sdio/slave")
  46. dut1.start_app()
  47. # wait until the master is ready to setup the slave
  48. dut1.expect("host ready, start initializing slave...")
  49. dut2.start_app()
  50. dut1.expect("0a 0d 10 13 16 19 1c 1f 22 25 28 2b 2e 31 34 37")
  51. dut1.expect("3a 3d 40 43 46 49 4c 4f 52 55 58 5b 00 00 00 00")
  52. dut1.expect("6a 6d 70 73 76 79 7c 7f 82 85 88 8b 8e 91 94 97")
  53. dut1.expect("9a 9d a0 a3 a6 a9 ac af b2 b5 b8 bb be c1 c4 c7")
  54. dut2.expect("================ JOB_WRITE_REG ================")
  55. dut2.expect("0a 0d 10 13 16 19 1c 1f 22 25 28 2b 2e 31 34 37")
  56. dut2.expect("3a 3d 40 43 46 49 4c 4f 52 55 58 5b 00 00 00 00")
  57. dut2.expect("6a 6d 70 73 76 79 7c 7f 82 85 88 8b 8e 91 94 97")
  58. dut2.expect("9a 9d a0 a3 a6 a9 ac af b2 b5 b8 bb be c1 c4 c7")
  59. dut1.expect("host int: 0")
  60. dut1.expect("host int: 1")
  61. dut1.expect("host int: 2")
  62. dut1.expect("host int: 3")
  63. dut1.expect("host int: 4")
  64. dut1.expect("host int: 5")
  65. dut1.expect("host int: 6")
  66. dut1.expect("host int: 7")
  67. dut1.expect("host int: 0")
  68. dut1.expect("host int: 1")
  69. dut1.expect("host int: 2")
  70. dut1.expect("host int: 3")
  71. dut1.expect("host int: 4")
  72. dut1.expect("host int: 5")
  73. dut1.expect("host int: 6")
  74. dut1.expect("host int: 7")
  75. dut2.expect("================ JOB_SEND_INT ================")
  76. dut2.expect("================ JOB_SEND_INT ================")
  77. dut1.expect("send packet length: 3")
  78. dut1.expect("send packet length: 6")
  79. dut1.expect("send packet length: 12")
  80. dut1.expect("send packet length: 128")
  81. dut1.expect("send packet length: 511")
  82. dut1.expect("send packet length: 512")
  83. dut2.expect("recv len: 3")
  84. dut2.expect("recv len: 6")
  85. dut2.expect("recv len: 12")
  86. dut2.expect("recv len: 128")
  87. # 511
  88. dut2.expect("recv len: 128")
  89. dut2.expect("recv len: 128")
  90. dut2.expect("recv len: 128")
  91. dut2.expect("recv len: 127")
  92. # 512
  93. dut2.expect("recv len: 128")
  94. dut2.expect("recv len: 128")
  95. dut2.expect("recv len: 128")
  96. dut2.expect("recv len: 128")
  97. dut1.expect("receive data, size: 3")
  98. dut1.expect("receive data, size: 6")
  99. dut1.expect("receive data, size: 12")
  100. dut1.expect("receive data, size: 128")
  101. dut1.expect("receive data, size: 128")
  102. dut1.expect("receive data, size: 128")
  103. dut1.expect("receive data, size: 128")
  104. dut1.expect("receive data, size: 127")
  105. dut1.expect("receive data, size: 128")
  106. dut1.expect("receive data, size: 128")
  107. dut1.expect("receive data, size: 128")
  108. dut1.expect("receive data, size: 128")
  109. # the last valid line of one round
  110. dut1.expect("ce d3 d8 dd e2 e7 ec f1 f6 fb 00 05 0a 0f 14 19")
  111. # the first 2 lines of the second round
  112. dut1.expect("46 4b 50")
  113. dut1.expect("5a 5f 64 69 6e 73")
  114. if __name__ == '__main__':
  115. TinyFW.set_default_config(env_config_file="EnvConfigTemplate.yml", dut=IDF.IDFDUT)
  116. test_example_sdio_communication()