Skip to content

Commit

Permalink
Breaking change: CONFIG_CRC_TAB_16LH -> CONFIG_CRC_TAB_32 rename
Browse files Browse the repository at this point in the history
  • Loading branch information
pstolarz committed Sep 2, 2024
1 parent b7b1f25 commit 4a92b1a
Show file tree
Hide file tree
Showing 7 changed files with 33 additions and 33 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/espidf-builds.yml
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ jobs:
ln -s ${repo_dir}/examples/esp-idf/${{ matrix.example }}/CMakeLists.txt CMakeLists.txt
echo "CONFIG_PWR_CTRL_ENABLED=y" >sdkconfig.defaults
echo "CONFIG_OVERDRIVE_ENABLED=y" >>sdkconfig.defaults
echo "CONFIG_CRC8_ALGO_TAB_16LH=y" >>sdkconfig.defaults
echo "CONFIG_CRC8_ALGO_TAB_32=y" >>sdkconfig.defaults
echo "CONFIG_CRC16_ENABLED=y" >>sdkconfig.defaults
echo "CONFIG_CRC16_ALGO_BASIC=y" >>sdkconfig.defaults
echo "CONFIG_BUS_BLINK_PROTECTION=y" >>sdkconfig.defaults
Expand Down
12 changes: 6 additions & 6 deletions Kconfig
Original file line number Diff line number Diff line change
Expand Up @@ -27,12 +27,12 @@ config OVERDRIVE_ENABLED

choice CRC8_ALGO
prompt "CRC-8/MAXIM calculation algorithm"
default CRC8_ALGO_TAB_16LH
default CRC8_ALGO_TAB_32

config CRC8_ALGO_BASIC
bool "Basic; no memory tables"
config CRC8_ALGO_TAB_16LH
bool "2x16 elements table"
config CRC8_ALGO_TAB_32
bool "32 elements table"
config CRC8_ALGO_TAB_16
bool "16 elements table"
endchoice
Expand All @@ -44,12 +44,12 @@ config CRC16_ENABLED
if CRC16_ENABLED
choice CRC16_ALGO
prompt "CRC-16/ALGO calculation algorithm"
default CRC16_ALGO_TAB_16LH
default CRC16_ALGO_TAB_32

config CRC16_ALGO_BASIC
bool "Basic; no memory tables"
config CRC16_ALGO_TAB_16LH
bool "2x16 elements table"
config CRC16_ALGO_TAB_32
bool "32 elements table"
config CRC16_ALGO_TAB_16
bool "16 elements table"
endchoice
Expand Down
4 changes: 2 additions & 2 deletions extras/test/test_config.h
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@
#define CONFIG_SEARCH_ENABLED
#define CONFIG_OVERDRIVE_ENABLED
#define CONFIG_CRC16_ENABLED
#define CONFIG_CRC8_ALGO CRC8_TAB_16LH
#define CONFIG_CRC16_ALGO CRC16_TAB_16LH
#define CONFIG_CRC8_ALGO CRC8_TAB_32
#define CONFIG_CRC16_ALGO CRC16_TAB_32
#define CONFIG_ITERATION_RETRIES 1
#define CONFIG_BITBANG_TIMING TIMING_NULL

Expand Down
4 changes: 2 additions & 2 deletions keywords.txt
Original file line number Diff line number Diff line change
Expand Up @@ -169,10 +169,10 @@ CONFIG_RP2040_PIO_DRIVER LITERAL1
CONFIG_RP2040_PIOSM_NUM_USED LITERAL1

CRC8_BASIC LITERAL1
CRC8_TAB_16LH LITERAL1
CRC8_TAB_32 LITERAL1
CRC8_TAB_16 LITERAL1
CRC16_BASIC LITERAL1
CRC16_TAB_16LH LITERAL1
CRC16_TAB_32 LITERAL1
CRC16_TAB_16 LITERAL1

TIMING_STRICT LITERAL1
Expand Down
4 changes: 2 additions & 2 deletions mbed_lib.json
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
"crc8_algo": {
"help": "CRC-8/MAXIM calculation algorithm",
"macro_name": "CONFIG_CRC8_ALGO",
"value": "CRC8_TAB_16LH"
"value": "CRC8_TAB_32"
},
"crc16_enabled": {
"help": "Enable CRC-16/ARC",
Expand All @@ -36,7 +36,7 @@
"crc16_algo": {
"help": "CRC-16/ALGO calculation algorithm",
"macro_name": "CONFIG_CRC16_ALGO",
"value": "CRC16_TAB_16LH"
"value": "CRC16_TAB_32"
},
"flash_crc_tab": {
"help": "Store CRC tables in flash memory",
Expand Down
20 changes: 10 additions & 10 deletions src/OneWireNg.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -14,23 +14,23 @@
#include "OneWireNg.h"

#define CRC8_BASIC 1
#define CRC8_TAB_16LH 2
#define CRC8_TAB_32 2
#define CRC8_TAB_16 3

#define CRC16_BASIC 1
#define CRC16_TAB_16LH 2
#define CRC16_TAB_32 2
#define CRC16_TAB_16 3

#if defined(CONFIG_CRC8_ALGO) && \
!(CONFIG_CRC8_ALGO == CRC8_BASIC || \
CONFIG_CRC8_ALGO == CRC8_TAB_16LH || \
CONFIG_CRC8_ALGO == CRC8_TAB_32 || \
CONFIG_CRC8_ALGO == CRC8_TAB_16)
# error "Invalid CONFIG_CRC8_ALGO"
#endif

#if defined(CONFIG_CRC16_ALGO) && \
!(CONFIG_CRC16_ALGO == CRC16_BASIC || \
CONFIG_CRC16_ALGO == CRC16_TAB_16LH || \
CONFIG_CRC16_ALGO == CRC16_TAB_32 || \
CONFIG_CRC16_ALGO == CRC16_TAB_16)
# error "Invalid CONFIG_CRC16_ALGO"
#endif
Expand Down Expand Up @@ -298,10 +298,10 @@ uint8_t OneWireNg::crc8(const void *in, size_t len, uint8_t crc_in)
{
uint8_t crc = crc_in;

#if (CONFIG_CRC8_ALGO == CRC8_TAB_16LH || CONFIG_CRC8_ALGO == CRC8_TAB_16)
#if (CONFIG_CRC8_ALGO == CRC8_TAB_32 || CONFIG_CRC8_ALGO == CRC8_TAB_16)
const uint8_t *in_bts = (const uint8_t*)in;

# if (CONFIG_CRC8_ALGO == CRC8_TAB_16LH)
# if (CONFIG_CRC8_ALGO == CRC8_TAB_32)
CRCTAB_STORAGE static uint8_t CRC8_16L[] = {
0x00, 0x5e, 0xbc, 0xe2, 0x61, 0x3f, 0xdd, 0x83,
0xc2, 0x9c, 0x7e, 0x20, 0xa3, 0xfd, 0x1f, 0x41
Expand All @@ -314,7 +314,7 @@ uint8_t OneWireNg::crc8(const void *in, size_t len, uint8_t crc_in)

while (len--) {
crc ^= *in_bts++;
# if (CONFIG_CRC8_ALGO == CRC8_TAB_16LH)
# if (CONFIG_CRC8_ALGO == CRC8_TAB_32)
uint8_t tl = tabRead_u8(CRC8_16L + (crc & 0xf));
# else
uint8_t tl = tabRead_u8(CRC8_16H + (crc & 0xf));
Expand All @@ -333,10 +333,10 @@ uint16_t OneWireNg::crc16(const void *in, size_t len, uint16_t crc_in)
{
uint16_t crc = crc_in;

# if (CONFIG_CRC16_ALGO == CRC16_TAB_16LH || CONFIG_CRC16_ALGO == CRC16_TAB_16)
# if (CONFIG_CRC16_ALGO == CRC16_TAB_32 || CONFIG_CRC16_ALGO == CRC16_TAB_16)
const uint8_t *in_bts = (const uint8_t*)in;

# if (CONFIG_CRC16_ALGO == CRC16_TAB_16LH)
# if (CONFIG_CRC16_ALGO == CRC16_TAB_32)
CRCTAB_STORAGE static uint16_t CRC16_16L[] = {
0x0000, 0xc0c1, 0xc181, 0x0140, 0xc301, 0x03c0, 0x0280, 0xc241,
0xc601, 0x06c0, 0x0780, 0xc741, 0x0500, 0xc5c1, 0xc481, 0x0440
Expand All @@ -349,7 +349,7 @@ uint16_t OneWireNg::crc16(const void *in, size_t len, uint16_t crc_in)

while (len--) {
crc ^= *in_bts++;
# if (CONFIG_CRC16_ALGO == CRC16_TAB_16LH)
# if (CONFIG_CRC16_ALGO == CRC16_TAB_32)
uint16_t tl = tabRead_u16(CRC16_16L + (crc & 0xf));
# else
uint16_t tl = tabRead_u16(CRC16_16H + (crc & 0xf));
Expand Down
20 changes: 10 additions & 10 deletions src/OneWireNg_Config.h
Original file line number Diff line number Diff line change
Expand Up @@ -40,16 +40,16 @@

# if CONFIG_CRC8_ALGO_BASIC
# define CONFIG_CRC8_ALGO CRC8_BASIC
# elif CONFIG_CRC8_ALGO_TAB_16LH
# define CONFIG_CRC8_ALGO CRC8_TAB_16LH
# elif CONFIG_CRC8_ALGO_TAB_32
# define CONFIG_CRC8_ALGO CRC8_TAB_32
# elif CONFIG_CRC8_ALGO_TAB_16
# define CONFIG_CRC8_ALGO CRC8_TAB_16
# endif

# if CONFIG_CRC16_ALGO_BASIC
# define CONFIG_CRC16_ALGO CRC16_BASIC
# elif CONFIG_CRC16_ALGO_TAB_16LH
# define CONFIG_CRC16_ALGO CRC16_TAB_16LH
# elif CONFIG_CRC16_ALGO_TAB_32
# define CONFIG_CRC16_ALGO CRC16_TAB_32
# elif CONFIG_CRC16_ALGO_TAB_16
# define CONFIG_CRC16_ALGO CRC16_TAB_16
# endif
Expand Down Expand Up @@ -143,12 +143,12 @@
* The macro may be defined as:
* - @c CRC8_BASIC: Basic method. No memory tables used. This method is about
* 8 times slower than the table based methods but no extra memory is used.
* - @c CRC8_TAB_16LH: 2x16 elements table, 1 byte each.
* - @c CRC8_TAB_32: 32 elements table, 1 byte each.
* - @c CRC8_TAB_16: 16 elements table, 1 byte each. This method is about 20%
* slower than 2x16 elements table based method.
* slower than 32 elements table based method.
*/
# ifndef CONFIG_CRC8_ALGO
# define CONFIG_CRC8_ALGO CRC8_TAB_16LH
# define CONFIG_CRC8_ALGO CRC8_TAB_32
# endif

/**
Expand All @@ -165,12 +165,12 @@
* The macro may be defined as:
* - @c CRC16_BASIC: Basic method. No memory tables used. This method is about
* 8 times slower than the table based methods but no extra memory is used.
* - @c CRC16_TAB_16LH: 2x16 elements table, 2 bytes each.
* - @c CRC16_TAB_32: 32 elements table, 2 bytes each.
* - @c CRC16_TAB_16: 16 elements table, 2 bytes each. This method is about 20%
* slower than 2x16 elements table based method.
* slower than 32 elements table based method.
*/
# ifndef CONFIG_CRC16_ALGO
# define CONFIG_CRC16_ALGO CRC16_TAB_16LH
# define CONFIG_CRC16_ALGO CRC16_TAB_32
# endif

/**
Expand Down

0 comments on commit 4a92b1a

Please sign in to comment.