1
0
mirror of https://github.com/RIOT-OS/RIOT.git synced 2024-12-29 04:50:03 +01:00

drivers/sdcard_spi: make use of crc16_ccitt_false_update()

Use crc16_ccitt instead of ucrc16.
This can be speed up by using a look-up table if desired and does
not use more memory in the default configuration.
This commit is contained in:
Benjamin Valentin 2022-10-20 00:43:27 +02:00
parent e0e0c4002b
commit f7197ba16a

View File

@ -24,7 +24,7 @@
#include "sdcard_spi_params.h"
#include "periph/spi.h"
#include "periph/gpio.h"
#include "checksum/ucrc16.h"
#include "checksum/crc16_ccitt.h"
#include "ztimer.h"
#include <stdio.h>
@ -622,7 +622,7 @@ static sd_rw_response_t _read_data_packet(sdcard_spi_t *card, uint8_t token,
if (_transfer_bytes(card, 0, crc_bytes, sizeof(crc_bytes)) == sizeof(crc_bytes)) {
uint16_t data_crc16 = (crc_bytes[0] << 8) | crc_bytes[1];
if (ucrc16_calc_be((uint8_t *)data, size, UCRC16_CCITT_POLY_BE, 0) == data_crc16) {
if (crc16_ccitt_false_update(0, data, size) == data_crc16) {
DEBUG("_read_data_packet: [OK]\n");
return SD_RW_OK;
}
@ -716,7 +716,7 @@ static sd_rw_response_t _write_data_packet(sdcard_spi_t *card, uint8_t token,
if (_transfer_bytes(card, data, 0, size) == size) {
uint16_t data_crc16 = ucrc16_calc_be((uint8_t *)data, size, UCRC16_CCITT_POLY_BE, 0);
uint16_t data_crc16 = crc16_ccitt_false_update(0, data, size);
uint8_t crc[sizeof(uint16_t)] = { data_crc16 >> 8, data_crc16 & 0xFF };
if (_transfer_bytes(card, crc, 0, sizeof(crc)) == sizeof(crc)) {