Page 1 of 1

bidirectional pin config

Posted: Thu Jul 09, 2015 9:22 pm
by JoVM
Is there an option to use bidirectional pins with the pal driver? Other I need to abandon the KS0108(oldies).

Re: bidirectional pin config

Posted: Fri Jul 10, 2015 1:06 pm
by Giovanni
Using palSetPadMode() or palSetPortMode() you can reconfigure pins on the fly (input/output). Another way is to use open-drain outputs with pullups.

It depends on what you need to do exactly.

Giovanni

Re: bidirectional pin config

Posted: Fri Jul 10, 2015 3:54 pm
by JoVM
Tnx Giovanni,

Apparently the KS0108 must read busy state at the data pins. So it's reconfiguring on the fly of the data pins.

Re: bidirectional pin config

Posted: Fri Jul 10, 2015 7:08 pm
by Tectu
Are you already using the µGFX library? If so this is what you would do at the beginning of the read_data() and write_data() functions in your board file.

The ChibiOS/HAL API allows you to define a bus group. This would allow you to easily change the configs of all the relevant pins.


~ Tectu

Re: bidirectional pin config

Posted: Sun Jul 12, 2015 10:23 am
by JoVM
Hi Tectu,

I'm using uGFX. The KS0108 is in mho verry expensive on pins. It works with palSetPadMode() but it's sloppy(I mean cumberson) and STM32 doesn't support DMA on its GPIO. I have a board file for the KS0108 in "boards/addons/gdisp/" but it requires specific functions like EnableController() and DisableController() were you need to give the relevant controller(CS1-CS3) as an argument.

Re: bidirectional pin config

Posted: Sun Jul 12, 2015 11:31 pm
by Tectu
Hello JoVM,

It is common with these parallel bus interfaces that you have to switch the pin directions. That is why I recommended you to use the ChibiOS/HAL pal grouping feature. You can look at this board file. The thing that made it easy here is that all 16 pins of the LCD data bus are on one port of the STM32. This board file on the other hand shows you how to define a bus composed of arbitrary pins.
You should try to keep all the driver specific stuff like EnableController() inside the driver file and only have the actual hardware interface in the board file. This will save you a lot of trouble.

If you want you can post your code on the uGFX forum and I will have a look. I am happy to help where I can!


~ Tectu

Re: bidirectional pin config

Posted: Mon Jul 13, 2015 6:00 pm
by JoVM
Tnx for the sample code Tectu. This keep the files in order.