cancel
Showing results for 
Search instead for 
Did you mean: 

Read multiple digital inputs at once

SMish.4
Associate

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)))

2 REPLIES 2

uint16_t foo = GPIOC->IDR;​

Tips, Buy me a coffee, or three.. PayPal Venmo
Up vote any posts that you find helpful, it shows what's working..
Javier1
Principal

You should take a look at this app note.

It explains all the GPIO's registers and their use. (Including GPIOx_IDR)

we dont need to firmware by ourselves, lets talk