Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

drivers/sdcard_spi: make use of crc16_ccitt_false_update() #18778

Merged
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions drivers/sdcard_spi/sdcard_spi.c
Original file line number Diff line number Diff line change
Expand Up @@ -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>
Expand Down Expand Up @@ -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;
}
Expand Down Expand Up @@ -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)) {
Expand Down