2015-01-03 07:18 AM
I have the nucleo board and an add-on board with a 2x12 oled character display. Writing to the display is not straight forward because D7..D0 lines are connected to pins on different ports (PA,PB,PC).
Is there a way to structure this hardware so I can write clean C code? For instance RS is PB3, WR is PC1, Enable is PA10, D7 is PA8, D6 is PB10, D5 is PB4, D4 is PB5, D3 is PA9, D2 is PC7, D1 is PA3, D0 is PA2. Thanks #port-pins2015-01-03 09:39 AM
Is there a way to structure this hardware so I can write clean C code?
Manage the data pin output in a single function so the complication is abstracted from all the other code?Either use a table driven method, bit mapping, or use a shift/masking technique for contiguous bits.GPIO_WriteBit(GPIOA, GPIO_Pin_2, (x & 1));GPIO_WriteBit(GPIOA, GPIO_Pin_3, (x & 2));...