From 4a92b1a59d9ef91acac86472939846169e6bb396 Mon Sep 17 00:00:00 2001 From: Piotr Stolarz Date: Mon, 2 Sep 2024 17:05:49 +0200 Subject: [PATCH] Breaking change: CONFIG_CRC_TAB_16LH -> CONFIG_CRC_TAB_32 rename --- .github/workflows/espidf-builds.yml | 2 +- Kconfig | 12 ++++++------ extras/test/test_config.h | 4 ++-- keywords.txt | 4 ++-- mbed_lib.json | 4 ++-- src/OneWireNg.cpp | 20 ++++++++++---------- src/OneWireNg_Config.h | 20 ++++++++++---------- 7 files changed, 33 insertions(+), 33 deletions(-) diff --git a/.github/workflows/espidf-builds.yml b/.github/workflows/espidf-builds.yml index d7eba61..35f7130 100644 --- a/.github/workflows/espidf-builds.yml +++ b/.github/workflows/espidf-builds.yml @@ -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 diff --git a/Kconfig b/Kconfig index 67057ee..9829f01 100644 --- a/Kconfig +++ b/Kconfig @@ -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 @@ -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 diff --git a/extras/test/test_config.h b/extras/test/test_config.h index c26b254..4648dcb 100644 --- a/extras/test/test_config.h +++ b/extras/test/test_config.h @@ -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 diff --git a/keywords.txt b/keywords.txt index 72ccf59..59c2a8b 100644 --- a/keywords.txt +++ b/keywords.txt @@ -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 diff --git a/mbed_lib.json b/mbed_lib.json index 7306f8e..2f7275d 100644 --- a/mbed_lib.json +++ b/mbed_lib.json @@ -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", @@ -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", diff --git a/src/OneWireNg.cpp b/src/OneWireNg.cpp index 56be0e1..76042f4 100644 --- a/src/OneWireNg.cpp +++ b/src/OneWireNg.cpp @@ -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 @@ -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 @@ -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)); @@ -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 @@ -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)); diff --git a/src/OneWireNg_Config.h b/src/OneWireNg_Config.h index ea7f7f0..c75c42c 100644 --- a/src/OneWireNg_Config.h +++ b/src/OneWireNg_Config.h @@ -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 @@ -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 /** @@ -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 /**