@@ -195,7 +195,9 @@ def _init_card_v2(self, card):
195
195
time .sleep (.050 )
196
196
self ._cmd (card , 58 , 0 , 0xfd , response_buf = ocr , data_block = False )
197
197
self ._cmd (card , 55 , 0 , 0x65 )
198
- if self ._cmd (card , 41 , 0x40000000 , 0x77 ) == 0 :
198
+ # On non-longint builds, we cannot use 0x40000000 directly as the arg
199
+ # so break it into bytes, which are interpreted by self._cmd().
200
+ if self ._cmd (card , 41 , b'\x40 \x00 \x00 \x00 ' , 0x77 ) == 0 :
199
201
self ._cmd (card , 58 , 0 , 0xfd , response_buf = ocr , data_block = False )
200
202
201
203
# Check for block addressing
@@ -226,18 +228,24 @@ def _cmd(self, card, cmd, arg=0, crc=0, response_buf=None, data_block=True, wait
226
228
227
229
:param busio.SPI card: The locked SPI bus.
228
230
:param int cmd: The command number.
229
- :param int arg: The command argument.
231
+ :param int|buf(4) arg: The command argument
230
232
:param int crc: The crc to allow the card to verify the command and argument.
231
233
:param bytearray response_buf: Buffer to read a data block response into.
232
234
:param bool data_block: True if the response data is in a data block.
233
235
"""
234
236
# create and send the command
235
237
buf = self ._cmdbuf
236
238
buf [0 ] = 0x40 | cmd
237
- buf [1 ] = (arg >> 24 ) & 0xff
238
- buf [2 ] = (arg >> 16 ) & 0xff
239
- buf [3 ] = (arg >> 8 ) & 0xff
240
- buf [4 ] = arg & 0xff
239
+ if isinstance (arg , int ):
240
+ buf [1 ] = (arg >> 24 ) & 0xff
241
+ buf [2 ] = (arg >> 16 ) & 0xff
242
+ buf [3 ] = (arg >> 8 ) & 0xff
243
+ buf [4 ] = arg & 0xff
244
+ elif len (arg ) == 4 :
245
+ # arg can be a 4-byte buf
246
+ buf [1 :5 ] = arg
247
+ else :
248
+ raise ValueError ()
241
249
242
250
if (crc == 0 ):
243
251
buf [5 ] = calculate_crc (buf [:- 1 ])
0 commit comments