i2c-microsd-expansion-circuitpython 1.0.13__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,114 @@
1
+ # SPDX-FileCopyrightText: 2026 I2C microSD Expansion contributors
2
+ # SPDX-License-Identifier: MIT
3
+
4
+ """protocol — wire constants for I²C microSD Expansion rev 2.
5
+
6
+ Byte-for-byte mirror of ``protocol.h`` in the Arduino library.
7
+ """
8
+
9
+ # ---- Legacy command family (0x01-0x0B, 0x0E) ----
10
+ MICROSDEXP_CMD_FILENAME = 0x01 # write: filename bytes; STOP stores path
11
+ MICROSDEXP_CMD_WRITE_FILE = 0x02 # write: payload + STOP -> create/overwrite, write, close
12
+ MICROSDEXP_CMD_READ_FILE = 0x03 # STOP -> open for read, stream via TX buffers
13
+ MICROSDEXP_CMD_APPEND_FILE = 0x04 # write: payload + STOP -> append, write, close
14
+ MICROSDEXP_CMD_FILE_SIZE = 0x05 # STOP -> size (4 B LE) in STATUS.result
15
+ MICROSDEXP_CMD_FILE_EXISTS = 0x06 # STOP -> 1=exists, 0=not found in STATUS.result
16
+ MICROSDEXP_CMD_IS_DIRECTORY = 0x07 # STOP -> 1=directory, 0=not in STATUS.result
17
+ MICROSDEXP_CMD_LIST_DIR = 0x08 # STOP -> TX-stream entries: 'F'/'D' + NUL basename + 4 B size LE, 0xFF term
18
+ MICROSDEXP_CMD_MAKE_DIR = 0x09 # STOP -> create directory at Filename
19
+ MICROSDEXP_CMD_REMOVE_DIR = 0x0A # STOP -> remove empty directory
20
+ MICROSDEXP_CMD_REMOVE_FILE = 0x0B # STOP -> delete file at Filename
21
+ MICROSDEXP_CMD_CLOCK = 0x0E # write/read: 6 B [year-2000, month, day, hour, minute, second];
22
+ # STOP applies the write; a read returns the SAME 6 bytes
23
+ # (software RTC used for FAT file timestamps; it keeps advancing once set)
24
+ MICROSDEXP_CMD_CLOCK_SET = MICROSDEXP_CMD_CLOCK # legacy name, same wire command
25
+ MICROSDEXP_CMD_VERSION = 0x0F # read: NUL-terminated 3-line firmware banner
26
+
27
+ # ---- Pin / extension commands ----
28
+ MICROSDEXP_CMD_PA5_SET_MODE = 0x10
29
+ MICROSDEXP_CMD_PA5_CONTROL = 0x11
30
+ MICROSDEXP_CMD_PB2_SET_MODE = 0x12
31
+ MICROSDEXP_CMD_PB2_CONTROL = 0x13
32
+ MICROSDEXP_CMD_PB3_SET_MODE = 0x14
33
+ MICROSDEXP_CMD_PB3_CONTROL = 0x15
34
+ MICROSDEXP_CMD_I2C_SET_ADDR = 0x16
35
+ MICROSDEXP_CMD_TEMP_READ = 0x17 # read: temperature
36
+ MICROSDEXP_CMD_ADC_READ_PA5 = 0x18 # read: 12-bit ADC (PA5)
37
+ MICROSDEXP_CMD_ADC_READ_PB3 = 0x19
38
+ MICROSDEXP_CMD_SAVEEEPROM = 0x1A # STOP -> persist pin modes + I2C addr to EEPROM (explicit only)
39
+ MICROSDEXP_CMD_MODULE_CLOCK = 0x1B # read: 4 B LE measured CPU clock (Hz)
40
+ MICROSDEXP_CMD_PIN_STATE_READ = 0x1C
41
+ MICROSDEXP_CMD_PIN_MODE_READ = 0x1E # read: 6 B mode per pin, 0xFF = pin absent
42
+ MICROSDEXP_CMD_VOLUME_NAME = 0x1F # read: 16 B NUL-terminated volume label
43
+ # Extra user pins
44
+ MICROSDEXP_CMD_PA0_SET_MODE = 0x32
45
+ MICROSDEXP_CMD_PA0_CONTROL = 0x33
46
+ MICROSDEXP_CMD_ADC_READ_PA4 = 0x34
47
+ MICROSDEXP_CMD_PA1_SET_MODE = 0x35
48
+ MICROSDEXP_CMD_PA1_CONTROL = 0x36
49
+ MICROSDEXP_CMD_PA4_SET_MODE = 0x37
50
+ MICROSDEXP_CMD_PA4_CONTROL = 0x38
51
+
52
+ # Pin modes accepted by SET_MODE / reported by PIN_MODE_READ (0x1E).
53
+ MICROSDEXP_PIN_MODE_DIGITAL_OUTPUT = 0
54
+ MICROSDEXP_PIN_MODE_PWM_OUTPUT = 1
55
+
56
+ # ---- Async protocol (rev 2) ----
57
+ MICROSDEXP_CMD_STATUS = 0x20 # read: 12-byte status frame
58
+ MICROSDEXP_CMD_OPEN_WRITE = 0x21 # write: filename bytes; STOP enqueues OPEN (RDWR, truncate)
59
+ MICROSDEXP_CMD_WRITE = 0x22 # write: payload block -> RX buffers
60
+ MICROSDEXP_CMD_READ = 0x23 # write: request block; read: drain TX buffer
61
+ MICROSDEXP_CMD_CLOSE_FLUSH = 0x24 # write: STOP enqueues CLOSE (flush + close)
62
+ MICROSDEXP_CMD_OPEN_READ = 0x25 # write: filename bytes; STOP enqueues OPEN (read-only)
63
+ MICROSDEXP_CMD_FORMAT = 0x28 # write: 1 B mode (0=auto, 1=force FAT); STOP enqueues format
64
+ MICROSDEXP_CMD_CARD_INFO = 0x29 # read: 24-byte card/volume snapshot (LE always)
65
+ MICROSDEXP_CMD_BITBANG_SET_MODE = 0x2B
66
+ MICROSDEXP_CMD_BITBANG_BUFFER = 0x2C
67
+ MICROSDEXP_CMD_BITBANG_EXECUTE = 0x2D
68
+ MICROSDEXP_CMD_BITBANG_CLEAR = 0x2E
69
+ MICROSDEXP_CMD_REBOOT = 0x2F # write: reboot module
70
+ MICROSDEXP_CMD_CARD_PRESENT = 0x39 # read: 1 byte, 1 = card inserted
71
+ MICROSDEXP_CMD_CAPABILITIES = 0x45 # read: 32-byte capability frame
72
+
73
+ # ---- Module expansion pin IDs (bit-bang and pin control) ----
74
+ MICROSDEXP_PIN_PA0 = 0
75
+ MICROSDEXP_PIN_PA1 = 1
76
+ MICROSDEXP_PIN_PA4 = 4
77
+ MICROSDEXP_PIN_PA5 = 5
78
+ MICROSDEXP_PIN_PB2 = 2
79
+ MICROSDEXP_PIN_PB3 = 3
80
+ MICROSDEXP_PIN_PF7 = 7 # reserved
81
+
82
+ # ---- Bit-bang engine profiles ----
83
+ MICROSDEXP_BITBANG_PROFILE_NEOPIXEL = 0x01
84
+ MICROSDEXP_BITBANG_PROFILE_SCRIPT = 0x02
85
+
86
+ # Frame/script workspace on the module (bytes). Bytes addressed past it are
87
+ # dropped, so a NeoPixel frame is at most 255 B (85 pixels).
88
+ BITBANG_WORKSPACE_SIZE = 256
89
+
90
+ # ---- STATUS.state ----
91
+ MICROSDEXP_ST_IDLE = 0
92
+ MICROSDEXP_ST_ACCEPTED = 1
93
+ MICROSDEXP_ST_BUSY_RX = 2
94
+ MICROSDEXP_ST_BUSY_SD = 3
95
+ MICROSDEXP_ST_TX_READY = 4
96
+ MICROSDEXP_ST_COMPLETE = 5
97
+ MICROSDEXP_ST_ERROR = 6
98
+ MICROSDEXP_ST_OVERFLOW = 7
99
+
100
+ # ---- STATUS.error ----
101
+ MICROSDEXP_ERR_NONE = 0
102
+ MICROSDEXP_ERR_NO_FILE = 1
103
+ MICROSDEXP_ERR_OPEN = 2
104
+ MICROSDEXP_ERR_CARD = 3
105
+ MICROSDEXP_ERR_QUEUE = 4
106
+ MICROSDEXP_ERR_INVALID = 5
107
+ MICROSDEXP_ERR_OVERFLOW = 6
108
+
109
+ # listDir stream terminator
110
+ LIST_END = 0xFF
111
+
112
+
113
+
114
+