MCPcopy Create free account
hub / github.com/RT-Thread/rt-thread / crc7

Function crc7

components/drivers/spi/dev_spi_msd.c:106–135  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

104}
105
106static uint8_t crc7(const uint8_t *buf, int len)
107{
108 unsigned char i, j, crc, ch, ch2, ch3;
109
110 crc = 0;
111
112 for (i = 0; i < len; i ++)
113 {
114 ch = buf[i];
115
116 for (j = 0; j < 8; j ++, ch <<= 1)
117 {
118 ch2 = (crc & 0x40) ? 1 : 0;
119 ch3 = (ch & 0x80) ? 1 : 0;
120
121 if (ch2 ^ ch3)
122 {
123 crc ^= 0x04;
124 crc <<= 1;
125 crc |= 0x01;
126 }
127 else
128 {
129 crc <<= 1;
130 }
131 }
132 }
133
134 return crc;
135}
136
137static rt_err_t _send_cmd(
138 struct rt_spi_device *device,

Callers 1

_send_cmdFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected