Commit 828a145
committed
Optimize MCP2515Class::parsePacket()
1) Use the RX STATUS command instead of READ(CANINTF) to check availability of
data to read. This reduces SPI usage for a simple "is data available" check
from 3 bytes to 2.
2) Use the READ RX BUFFER command to read the RXFn* registers as well as the
received data. This requires doing only a single CS pull, and only N+6 bytes
transferred over SPI. READ RX BUFFER also takes care of resetting the RXnIF
flag.
If my math is right, the old code needed N+6 readRegister() calls for a standard
frame, and N+9 readRegister() calls for an extended frame, plus one
modifyRegister() call to reset the RXnIF flag. Each readRegister() call requires
a CS pull and transferring 3 bytes over SPI.
For N = 8,
- we now send 16 bytes over SPI vs 45 for a standard frame (>2.8x reduction!)
- we now do just 2 CS pulls vs 16 for a standard frame (8x reduction!)1 parent bcdd7ac commit 828a145
1 file changed
+41
-16
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
212 | 212 | | |
213 | 213 | | |
214 | 214 | | |
215 | | - | |
216 | | - | |
217 | | - | |
| 215 | + | |
| 216 | + | |
| 217 | + | |
| 218 | + | |
| 219 | + | |
| 220 | + | |
218 | 221 | | |
219 | | - | |
| 222 | + | |
| 223 | + | |
220 | 224 | | |
221 | | - | |
| 225 | + | |
222 | 226 | | |
223 | 227 | | |
224 | 228 | | |
225 | 229 | | |
226 | 230 | | |
| 231 | + | |
| 232 | + | |
227 | 233 | | |
228 | 234 | | |
229 | 235 | | |
230 | 236 | | |
231 | | - | |
232 | | - | |
233 | | - | |
| 237 | + | |
| 238 | + | |
| 239 | + | |
| 240 | + | |
| 241 | + | |
| 242 | + | |
| 243 | + | |
| 244 | + | |
| 245 | + | |
| 246 | + | |
| 247 | + | |
| 248 | + | |
| 249 | + | |
| 250 | + | |
| 251 | + | |
234 | 252 | | |
235 | | - | |
| 253 | + | |
| 254 | + | |
| 255 | + | |
| 256 | + | |
236 | 257 | | |
237 | 258 | | |
238 | | - | |
| 259 | + | |
239 | 260 | | |
240 | 261 | | |
241 | | - | |
| 262 | + | |
242 | 263 | | |
243 | | - | |
| 264 | + | |
| 265 | + | |
244 | 266 | | |
245 | 267 | | |
246 | 268 | | |
247 | 269 | | |
248 | 270 | | |
249 | 271 | | |
250 | 272 | | |
251 | | - | |
252 | | - | |
| 273 | + | |
| 274 | + | |
| 275 | + | |
253 | 276 | | |
254 | 277 | | |
255 | 278 | | |
256 | | - | |
257 | | - | |
| 279 | + | |
| 280 | + | |
| 281 | + | |
| 282 | + | |
258 | 283 | | |
259 | 284 | | |
260 | 285 | | |
| |||
0 commit comments