Is there any rak rui version where PB12 is not used by RAK3172

Nice to meet you, to give some context I lately realized RAK3271 pin PB12 is used internally by rak_rui firmware (at least in version 4.2.0), thus it is impossible to switch its state from arduino programming interface using the following code:

int state = 0;
void setup() {
    pinMode(PB12, OUTPUT);
    digitalWrite(PB12, 0);
}

void loop() {
    state = !state;
    digitalWrite(PB12, state);
    delay(1000);
}

Based on the answers given in the following links:

I have 3 questions

  1. Is there any rak_rui version where PB12 is available for the application writter?
  2. Can PB12 be used as INPUT on rak_rui 4.2.0?
  3. In rak rui repo could you point me out which module makes use of that pin?

Hi @jvech ,

  1. There’s is no RUI3 version that allows you to use PB12 for application specific use.
  2. I haven’t tested personally but you can do some test. Aside on initialization, there could be runtime repercussion that i am not aware of if you use PB12 even as input.
  3. If you are using 4.2.0 and main branch, it is in board.c.fuota. On early versions of RUI3 without FUOTA provision, it is board.c file

Thank you so much for your help,
For anyone with a similar issue I changed the following snippet of code, on the file specified by @carlrowan:

uint8_t BoardGetHardwareFreq(void)
{
    //uint8_t hardwareFreq = 0;
    //GPIO_InitTypeDef GPIO_InitStruct = {0};

    ///* GPIO Ports Clock Enable */
    //__HAL_RCC_GPIOB_CLK_ENABLE();
    ///*Configure GPIO pin : PB12 */
    //GPIO_InitStruct.Pin = GPIO_PIN_12;
    //GPIO_InitStruct.Mode = GPIO_MODE_INPUT;
    //GPIO_InitStruct.Pull = GPIO_NOPULL;
    //HAL_GPIO_Init(GPIOB, &GPIO_InitStruct);
    //hardwareFreq  = HAL_GPIO_ReadPin(GPIOB, GPIO_PIN_12);

    //HAL_GPIO_DeInit(GPIOB,GPIO_PIN_12);
    return 1 // or 0 if the RAK3172 is set for at 4M Hz freq band
}

As @carlrowan says there could be runtime side effects I’m not aware of. For those using arduino cli programming interface rak_rui repo is located at ~/.arduino15/packages/rak_rui

Even when changing the code, there is still an internal 10K pullup (high frequency version) or 10K pulldown (low frequency version) inside the module.
You have to consider this when using PB12!

image

1 Like