Skip to content

Commit 0a521f4

Browse files
committed
drivers/sdcard/sdcard.py: Fixes per PR discussion.
Removed viper-mode crc7 function, since it didn't really help much. Signed-off-by: Marcus Mendenhall <[email protected]>
1 parent dda1c98 commit 0a521f4

File tree

1 file changed

+5
-27
lines changed

1 file changed

+5
-27
lines changed

micropython/drivers/storage/sdcard/sdcard.py

Lines changed: 5 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -43,33 +43,11 @@
4343
b"\xe4\xd2\xc0\x1c\x0e8*TFpb\x8c\x9e\xa8\xba\xc4\xd6\xe0\xf2"
4444
)
4545

46-
# ruff: noqa: F821 - @asm_thumb and @viper decorator adds names to function scope
47-
try:
48-
from uctypes import addressof
49-
50-
@micropython.viper
51-
def crc7(buf) -> int:
52-
n = int(len(buf))
53-
table = ptr8(addressof(crc7_be_syndrome_table))
54-
bp = ptr8(addressof(buf))
55-
idx = 0
56-
crc = 0
57-
while idx < n:
58-
crc = table[crc ^ bp[idx]]
59-
idx = idx + 1
60-
return crc
61-
62-
# test to make sure this works!
63-
# print(f"{crc7('abcde'):02x}")
64-
assert crc7(b"abcde") == 0x34
65-
except:
66-
# non-viper version if viper can'r be built
67-
def crc7(buf) -> int:
68-
crc = 0
69-
for b in buf:
70-
crc = crc7_be_syndrome_table[crc ^ b]
71-
return crc
72-
46+
def crc7(buf) -> int:
47+
crc = 0
48+
for b in buf:
49+
crc = crc7_be_syndrome_table[crc ^ b]
50+
return crc
7351

7452
def gb(bigval, b0, bn):
7553
# get numbered bits from a buf_to_int from, for example, the CSD

0 commit comments

Comments
 (0)