Search code examples
cstm32avrstm32cubeide

How to translate this code from AVR into STM32


I am trying to rewrite the code from AVR to STM32. How to translate this code into STM32?

#define READ_IO     PIND & (1 << PD4)
volatile unsigned char data_in = 0;
data_in = (READ_IO) >> PD4;

I use STM32CubeIDE


Solution

  • Assuming pin4 on port D.

    data_in = !!(GPIOD -> IDR & (1 << 4));