RAK11720 error: 'UDRV_ADC_MODE_1_5' undeclared

Hi I’m facing an error trying to compile code for RAK11720, for the command:

arduino-cli compile -b rak_rui:apollo3:WisCoreRAK11720Board . \
					--build-path=./build \
					--build-property 'build.extra_flags=-DFW_VERSION="v1.7.0" -DHW_v2_2_RAK11720 -D_DEBUG_PRINT=1 -DDEBUG_LORAWAN_HANDLER=0 -DDEBUG_BUTTON_HANDLER=0 -DDEBUG_VTR_HANDLER=0 -DTESTMODE=0 -DINIT_STRUCTURES=0'

I get the following message:

/home/jvech/.arduino15/packages/rak_rui/hardware/apollo3/4.2.4/cores/apollo3/component/core/mcu/apollo3/uhal/uhal_adc.c: In function 'uhal_adc_set_mode':
/home/jvech/.arduino15/packages/rak_rui/hardware/apollo3/4.2.4/cores/apollo3/component/core/mcu/apollo3/uhal/uhal_adc.c:89:14: error: 'UDRV_ADC_MODE_1_5' undeclared (first use in this function); did you mean 'UDRV_ADC_MODE_1_2'?
   89 |         case UDRV_ADC_MODE_1_5:
      |              ^~~~~~~~~~~~~~~~~
      |              UDRV_ADC_MODE_1_2
/home/jvech/.arduino15/packages/rak_rui/hardware/apollo3/4.2.4/cores/apollo3/component/core/mcu/apollo3/uhal/uhal_adc.c:89:14: note: each undeclared identifier is reported only once for each function it appears in

Used platform   Version Path
rak_rui:apollo3 4.2.4   /home/jvech/.arduino15/packages/rak_rui/hardware/apollo3/4.2.4

The weird thing is I’m not using analog input yet. Is there a known issue with this module in RUI platform?

There is no known problem with RUI3 for RAK1172.
I tried to compile several application and they compile without any errors.

Can you try to uninstall the BSP and reinstall it again. Either the installation failed or some files got corrupted.

Example output of compilation with Arduino-CLI in VSC:

I tried reinstalling with no success, looking at the codebase I noticed something interesting on files uhal_adc.c (line 86) and udrv_adc.h (line 29):

uhal_adc.c has a switch case for constant UDRV_ADC_MODE_1_5:

void uhal_adc_set_mode (UDRV_ADC_MODE mode) {
    
    switch (mode) {
        case UDRV_ADC_MODE_1_5:
        {
            uhal_adc_mode = UDRV_ADC_MODE_1_5;
            ADCConfig.eReference = AM_HAL_ADC_REFSEL_INT_1P5;
            break;
        }
        case UDRV_ADC_MODE_DEFAULT:
        default:
        {
            uhal_adc_mode = UDRV_ADC_MODE_DEFAULT;
            ADCConfig.eReference = AM_HAL_ADC_REFSEL_INT_2P0;
            break;
        }
    }
}

which is not defined in udrv_adc.h if rak11720 preprocessor constant isn’t declared:

typedef enum{
    UDRV_ADC_MODE_DEFAULT = (0UL),  //default range
    #ifndef rak11720 
    UDRV_ADC_MODE_3_3     = (1UL),  // 0 - 3.3 V
    UDRV_ADC_MODE_3_0     = (2UL),  // 0 - 3 V
    UDRV_ADC_MODE_2_4     = (3UL),  // 0 - 2.4 V
    UDRV_ADC_MODE_1_8     = (4UL),  // 0 - 1.8 V
    UDRV_ADC_MODE_1_2     = (5UL),  // 0 - 1.2 V
    #else
    UDRV_ADC_MODE_1_5     = (2UL),  // 0 - 1.5 V
    #endif
} UDRV_ADC_MODE;

(Edit)

I finally figure out the error, when compiling with:

arduino-cli compile -b rak_rui:apollo3:WisCoreRAK11720Board . \
					--build-path=./build \
					--build-property 'build.extra_flags=-DFW_VERSION="v1.7.0" -DHW_v2_2_RAK11720 -D_DEBUG_PRINT=1 -DDEBUG_LORAWAN_HANDLER=0 -DDEBUG_BUTTON_HANDLER=0 -DDEBUG_VTR_HANDLER=0 -DTESTMODE=0 -DINIT_STRUCTURES=0'

I was overriding build.extra_flags already defined in boards.txt file:

WisCoreRAK11720Board.build.extra_flags=-DPART_APOLLO3 -DRAK11720+RAK5005-O_V1.0 -Drak11720 -DWISBLOCK_BASE_5005_O {build.flags.usb}

So I decided to override compile.cpp.extra_flags in platform.txt which is less problematic it only has a DEBUG preprocesor variable:

compiler.cpp.extra_flags= -DDEBUG

now I compile with:

arduino-cli compile -b rak_rui:apollo3:WisCoreRAK11720Board . \
					--build-path=./build \
					--build-property 'compiler.cpp.extra_flags=-DDEBUG -DFW_VERSION="v1.7.0" -DHW_v2_2_RAK11720 -D_DEBUG_PRINT=1 -DDEBUG_LORAWAN_HANDLER=0 -DDEBUG_BUTTON_HANDLER=0 -DDEBUG_VTR_HANDLER=0 -DTESTMODE=0 -DINIT_STRUCTURES=0'
Sketch uses 295420 bytes (32%) of program storage space. Maximum is 917504 bytes.
Global variables use 156460 bytes (39%) of dynamic memory, leaving 235732 bytes for local variables. Maximum is 392192 bytes.