From d59bbd1020524aa68df8bab6223760d0f9227006 Mon Sep 17 00:00:00 2001 From: Raphael Coeffic Date: Fri, 15 Oct 2021 15:10:31 +0200 Subject: [PATCH] Fix compiling taranis-like targets --- .../storage/yaml/yaml_datastructs_funcs.cpp | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/radio/src/storage/yaml/yaml_datastructs_funcs.cpp b/radio/src/storage/yaml/yaml_datastructs_funcs.cpp index 1d1ffec75..38f0c8cec 100644 --- a/radio/src/storage/yaml/yaml_datastructs_funcs.cpp +++ b/radio/src/storage/yaml/yaml_datastructs_funcs.cpp @@ -360,8 +360,17 @@ static void sl_name_read(const YamlNode* node, uint8_t* data, uint32_t bitoffs, uint16_t idx, const char* val, uint8_t val_len) { // data / bitoffs already incremented +#if defined(PCBTARANIS) + // Please note: + // slidersConfig is defined as a bit-field member, + // so let's take the next field and subtract 1 + // + data -= (idx + 4 /* bitsize previous field (auxSerialMode) */ + 1) / 8; + data -= offsetof(RadioData, potsConfig) - 1; +#else data -= (idx + 1) / 8; data -= offsetof(RadioData, slidersConfig); +#endif RadioData* rd = reinterpret_cast(data); idx += NUM_STICKS + STORAGE_NUM_POTS; @@ -372,8 +381,17 @@ static bool sl_name_write(const YamlNode* node, uint8_t* data, uint32_t bitoffs, uint16_t idx, yaml_writer_func wf, void* opaque) { // data / bitoffs already incremented +#if defined(PCBTARANIS) + // Please note: + // slidersConfig is defined as a bit-field member, + // so let's take the next field and subtract 1 + // + data -= (idx + 4 /* bitsize previous field (auxSerialMode) */ + 1) / 8; + data -= offsetof(RadioData, potsConfig) - 1; +#else data -= (idx + 1) / 8; data -= offsetof(RadioData, slidersConfig); +#endif RadioData* rd = reinterpret_cast(data); idx += NUM_STICKS + STORAGE_NUM_POTS;