2015-10-13 08:17 PM
I am working on project which is generated by Cube and uses HAL drivers. I require to read states of a number of pins on a port. Currently I am doing like this:
//read PC0 to PC7 to check for state (on or off) report.BUTTONS_0_7.BIT_0 = HAL_GPIO_ReadPin(GPIOC, GPIO_PIN_0); report.BUTTONS_0_7.BIT_1 = HAL_GPIO_ReadPin(GPIOC, GPIO_PIN_1); report.BUTTONS_0_7.BIT_2 = HAL_GPIO_ReadPin(GPIOC, GPIO_PIN_2); report.BUTTONS_0_7.BIT_3 = HAL_GPIO_ReadPin(GPIOC, GPIO_PIN_3); report.BUTTONS_0_7.BIT_4 = HAL_GPIO_ReadPin(GPIOC, GPIO_PIN_4); report.BUTTONS_0_7.BIT_5 = HAL_GPIO_ReadPin(GPIOC, GPIO_PIN_5); report.BUTTONS_0_7.BIT_6 = HAL_GPIO_ReadPin(GPIOC, GPIO_PIN_6); report.BUTTONS_0_7.BIT_7 = HAL_GPIO_ReadPin(GPIOC, GPIO_PIN_7);I did not find any code in HAL that allows reading a number of pins of a port simultaneously. Is there a way to read a given amount of pins from a port, or half of them or all of them?If the HAL does not have this function, what alternative exist that would be compatible with HAL?Thanks #gpio #stm32 #hal2015-10-14 12:05 AM
Something along the lines of
uint16_t pins = GPIOC->IDR; if (pins & GPIO_PIN_7) puts(''Pin 7 High'');2023-08-30 08:04 AM
If I have a port that has more pins (e.g. STM32L552ZET6Q port E has pins 0 to 15), would something like this cover all of them, or would I have to run it for both bytes contained within the port?
2023-08-30 09:18 AM
uint16_t pins = GPIOE->IDR; // would read a bit vector of all 16 pins in the bank, Read the RM