From c8b75ee71f2c66b7b9515c1023496a5314bb9ba0 Mon Sep 17 00:00:00 2001 From: gab-k Date: Tue, 26 Dec 2023 18:59:58 +0100 Subject: [PATCH] Fix missing Bitmask in F0-F4 function evaluation, Handle NULL-pointer in get_direction(), CMakelists.txt disable optimizing, Upload CLion config --- .gitignore | 1 - .idea/.gitignore | 8 ++++++++ .idea/RP2040-Decoder.iml | 2 ++ .idea/misc.xml | 4 ++++ .idea/modules.xml | 8 ++++++++ .idea/vcs.xml | 13 +++++++++++++ CMakeLists.txt | 3 +++ core0.c | 14 ++++++++++---- 8 files changed, 48 insertions(+), 5 deletions(-) create mode 100644 .idea/.gitignore create mode 100644 .idea/RP2040-Decoder.iml create mode 100644 .idea/misc.xml create mode 100644 .idea/modules.xml create mode 100644 .idea/vcs.xml diff --git a/.gitignore b/.gitignore index 0cc6dfc..f116a11 100644 --- a/.gitignore +++ b/.gitignore @@ -1,4 +1,3 @@ -.idea .vscode build cmake-build-debug diff --git a/.idea/.gitignore b/.idea/.gitignore new file mode 100644 index 0000000..13566b8 --- /dev/null +++ b/.idea/.gitignore @@ -0,0 +1,8 @@ +# Default ignored files +/shelf/ +/workspace.xml +# Editor-based HTTP Client requests +/httpRequests/ +# Datasource local storage ignored files +/dataSources/ +/dataSources.local.xml diff --git a/.idea/RP2040-Decoder.iml b/.idea/RP2040-Decoder.iml new file mode 100644 index 0000000..f08604b --- /dev/null +++ b/.idea/RP2040-Decoder.iml @@ -0,0 +1,2 @@ + + \ No newline at end of file diff --git a/.idea/misc.xml b/.idea/misc.xml new file mode 100644 index 0000000..79b3c94 --- /dev/null +++ b/.idea/misc.xml @@ -0,0 +1,4 @@ + + + + \ No newline at end of file diff --git a/.idea/modules.xml b/.idea/modules.xml new file mode 100644 index 0000000..7baa790 --- /dev/null +++ b/.idea/modules.xml @@ -0,0 +1,8 @@ + + + + + + + + \ No newline at end of file diff --git a/.idea/vcs.xml b/.idea/vcs.xml new file mode 100644 index 0000000..2532000 --- /dev/null +++ b/.idea/vcs.xml @@ -0,0 +1,13 @@ + + + + + + + + + + + + + \ No newline at end of file diff --git a/CMakeLists.txt b/CMakeLists.txt index 8f08180..50d798f 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -9,6 +9,9 @@ set(CMAKE_CXX_STANDARD 17) set(PICO_DECODER_PATH ${PROJECT_SOURCE_DIR}) +# Stop the compiler from inling method calls making it easier to debug +set(PICO_DEOPTIMIZED_DEBUG 1) + # Initialize the SDK pico_sdk_init() diff --git a/core0.c b/core0.c index fb8f0d7..a46b953 100644 --- a/core0.c +++ b/core0.c @@ -242,7 +242,8 @@ void set_outputs(uint32_t functions_to_set_bitmask) { uint32_t temp_mask = 1; for (uint8_t i = 0; i < 32; i++) { if (temp_mask & functions_to_set_bitmask ){ - outputs_to_set |= get_32bit_CV(i * 8 + 260 - 4 * get_direction(0)); + bool dir = get_direction(0); + outputs_to_set |= get_32bit_CV(i * 8 + 260 - 4 * dir); } temp_mask<<=1; } @@ -384,7 +385,7 @@ void instruction_evaluation(uint8_t number_of_bytes,const uint8_t * const byte_a update_active_functions((command_byte_n << 9),2,false); break; default: // F0-F4 - update_active_functions(((command_byte_n << 1) + (command_byte_n >> 4)),0,false); + update_active_functions((((command_byte_n & 0b00001111) << 1) + ((command_byte_n & 0b00010000) >> 4)),0,false); break; } } @@ -624,8 +625,13 @@ bool get_direction(bool *direction_ptr){ static bool set_flag; static bool *dir_ptr; if(!set_flag) { - dir_ptr = direction_ptr; - set_flag = true; + if (direction_ptr == NULL){ + LOG(0, "Error! Direction pointer argument is NULL-pointer!") + } + else { + set_flag = true; + dir_ptr = direction_ptr; + } } return *dir_ptr; }