2022-08-31 04:55 AM
I am new to STM MCU and have started working with stm8s105k4. I have a 4 bit digital input and wants to know how can I read that 4 bit at once which is connected to PORTC.
Below logic is very lengthy and not a good way to read inputs. Kindly help.
if ((!GPIO_ReadInputPin(GPIOC, GPIO_PIN_3)) && (GPIO_ReadInputPin(GPIOC, GPIO_PIN_4)) && (GPIO_ReadInputPin(GPIOC, GPIO_PIN_5)) && (!GPIO_ReadInputPin(GPIOC, GPIO_PIN_6)))
2022-08-31 05:42 AM
uint16_t foo = GPIOC->IDR;
2022-08-31 06:07 AM
You should take a look at this app note.
It explains all the GPIO's registers and their use. (Including GPIOx_IDR)