All checks were successful
Build RPi Pico firmware image / Build-Firmware (push) Successful in 5m29s
Check code formatting / Check-C-Format (push) Successful in 9s
Check code formatting / Check-Python-Flake8 (push) Successful in 9s
Check code formatting / Check-Bash-Shellcheck (push) Successful in 4s
Run unit tests on host / Run-Unit-Tests (push) Successful in 8s
The python and C modules that are supposed to be built into the firmware image (i.e. those that are in manifest.py or in USER_C_MODULES) have been moved to the software/modules directory. The software/src directory should now only contain python scripts and other files that should be installed to the Picos flash filesystem. The idea is that these should be those scripts that implement the application behaviour, as these are the ones that a user who does not want to build the whole firmware themself wants to modify.
31 lines
846 B
C
31 lines
846 B
C
#pragma once
|
|
|
|
#include <stddef.h>
|
|
#include <stdint.h>
|
|
|
|
inline static uint8_t sd_crc7(size_t len, const uint8_t data[const static len])
|
|
{
|
|
const uint8_t poly = 0b1001;
|
|
uint8_t crc = 0;
|
|
for (size_t pos = 0; pos < len; ++pos) {
|
|
crc ^= data[pos];
|
|
for (int bit = 0; bit < 8; ++bit) {
|
|
crc = (crc << 1) ^ ((crc & 0x80) ? (poly << 1) : 0);
|
|
}
|
|
}
|
|
return crc >> 1;
|
|
}
|
|
|
|
/* inline static uint16_t sd_crc16(size_t len, const uint8_t data[const static len]) */
|
|
/* { */
|
|
/* const uint16_t poly = 0b1000000100001; */
|
|
/* uint16_t crc = 0; */
|
|
/* for (size_t pos = 0; pos < len; ++pos) { */
|
|
/* crc ^= data[pos] << 8; */
|
|
/* for (int bit = 0; bit < 8; ++bit) { */
|
|
/* crc = (crc << 1) ^ ((crc & 0x8000) ? poly : 0); */
|
|
/* } */
|
|
/* } */
|
|
/* return crc; */
|
|
/* } */
|