mirror of
https://github.com/hsoft/collapseos.git
synced 2024-12-25 17:18:06 +11:00
124da6adec
Although the SPI Relay driver is RC2014-specific, the SD Card driver is generic enough to be a subsystem. That's the second subsystem we add and this warrants, I think, the formalization of a new concept: protocols.
16 lines
422 B
Plaintext
16 lines
422 B
Plaintext
( c n -- c )
|
|
( Computes n into crc c with polynomial 0x09
|
|
Note that the result is "left aligned", that is, that 8th
|
|
bit to the "right" is insignificant (will be stop bit). )
|
|
: _crc7
|
|
XOR ( c )
|
|
8 0 DO
|
|
2 * ( <<1 )
|
|
DUP 255 > IF
|
|
( MSB was set, apply polynomial )
|
|
0xff AND
|
|
0x12 XOR ( 0x09 << 1, we apply CRC on high bits )
|
|
THEN
|
|
LOOP
|
|
;
|