cancel
Showing results for 
Search instead for 
Did you mean: 

CHANGE PINS TO IMPUT THEN BACK TO OUTPUT

m-a-c-f
Associate II

 

Hi,

 

I'm trying to read an LCD 8 bits information, so I need to quickly change PA0 ~ PA7 to input, then read the IDR register, and return them to output after reading the 8 bit bus, but I need help.

 

Thank you all.

 

1 REPLY 1
MasterT
Lead

Define macros, than call when necessary.

#define setWriteDir() { setReadDir(); \
                        GPIOA->MODER |=  0x150000; GPIOB->MODER |=  0x100540; GPIOC->MODER |=  0x4000; }
#define setReadDir()  { GPIOA->MODER &= ~0x3F0000; GPIOB->MODER &= ~0x300FC0; GPIOC->MODER &= ~0xC000; }