File tree Expand file tree Collapse file tree 1 file changed +4
-3
lines changed Expand file tree Collapse file tree 1 file changed +4
-3
lines changed Original file line number Diff line number Diff line change @@ -100,9 +100,10 @@ def init_card(self, baudrate):
100
100
if csd [0 ] & 0xC0 == 0x40 : # CSD version 2.0
101
101
self .sectors = ((csd [8 ] << 8 | csd [9 ]) + 1 ) * 1024
102
102
elif csd [0 ] & 0xC0 == 0x00 : # CSD version 1.0 (old, <=2GB)
103
- c_size = csd [6 ] & 0b11 | csd [7 ] << 2 | (csd [8 ] & 0b11000000 ) << 4
104
- c_size_mult = ((csd [9 ] & 0b11 ) << 1 ) | csd [10 ] >> 7
105
- self .sectors = (c_size + 1 ) * (2 ** (c_size_mult + 2 ))
103
+ c_size = (csd [6 ] & 0b11 ) << 10 | csd [7 ] << 2 | csd [8 ] >> 6
104
+ c_size_mult = (csd [9 ] & 0b11 ) << 1 | csd [10 ] >> 7
105
+ read_bl_len = csd [5 ] & 0b1111
106
+ self .sectors = (c_size + 1 ) * (2 ** (c_size_mult + 2 )) * (2 ** read_bl_len )
106
107
else :
107
108
raise OSError ("SD card CSD format not supported" )
108
109
# print('sectors', self.sectors)
You can’t perform that action at this time.
0 commit comments