|
1 | 1 | """Test for nrf24l01 module. Portable between MicroPython targets.""" |
2 | 2 |
|
3 | | -import usys |
4 | | -import ustruct as struct |
| 3 | +import sys |
| 4 | +import struct |
5 | 5 | import utime |
6 | 6 | from machine import Pin, SPI, SoftSPI |
7 | 7 | from nrf24l01 import NRF24L01 |
|
14 | 14 | # initiator may be a slow device. Value tested with Pyboard, ESP32 and ESP8266. |
15 | 15 | _RESPONDER_SEND_DELAY = const(10) |
16 | 16 |
|
17 | | -if usys.platform == "pyboard": |
| 17 | +if sys.platform == "pyboard": |
18 | 18 | spi = SPI(2) # miso : Y7, mosi : Y8, sck : Y6 |
19 | 19 | cfg = {"spi": spi, "csn": "Y5", "ce": "Y4"} |
20 | | -elif usys.platform == "esp8266": # Hardware SPI |
| 20 | +elif sys.platform == "esp8266": # Hardware SPI |
21 | 21 | spi = SPI(1) # miso : 12, mosi : 13, sck : 14 |
22 | 22 | cfg = {"spi": spi, "csn": 4, "ce": 5} |
23 | | -elif usys.platform == "esp32": # Software SPI |
| 23 | +elif sys.platform == "esp32": # Software SPI |
24 | 24 | spi = SoftSPI(sck=Pin(25), mosi=Pin(33), miso=Pin(32)) |
25 | 25 | cfg = {"spi": spi, "csn": 26, "ce": 27} |
26 | | -elif usys.platform == "rp2": # Hardware SPI with explicit pin definitions |
| 26 | +elif sys.platform == "rp2": # Hardware SPI with explicit pin definitions |
27 | 27 | spi = SPI(0, sck=Pin(2), mosi=Pin(3), miso=Pin(4)) |
28 | 28 | cfg = {"spi": spi, "csn": 5, "ce": 6} |
29 | 29 | else: |
30 | | - raise ValueError("Unsupported platform {}".format(usys.platform)) |
| 30 | + raise ValueError("Unsupported platform {}".format(sys.platform)) |
31 | 31 |
|
32 | 32 | # Addresses are in little-endian format. They correspond to big-endian |
33 | 33 | # 0xf0f0f0f0e1, 0xf0f0f0f0d2 |
|
0 commit comments