bidirectional pin config

ChibiOS public support forum for all topics not covered by a specific support forum.

Moderators: RoccoMarco, lbednarz, tfAteba

Post Reply
JoVM
Posts: 89
Joined: Thu Mar 12, 2015 12:13 pm

bidirectional pin config

Post by JoVM »

Is there an option to use bidirectional pins with the pal driver? Other I need to abandon the KS0108(oldies).
User avatar
Giovanni
Site Admin
Posts: 14895
Joined: Wed May 27, 2009 8:48 am
Has thanked: 1202 times
Been thanked: 997 times

Re: bidirectional pin config

Post 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
JoVM
Posts: 89
Joined: Thu Mar 12, 2015 12:13 pm

Re: bidirectional pin config

Post 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.
User avatar
Tectu
Posts: 1225
Joined: Thu May 10, 2012 9:50 am

Re: bidirectional pin config

Post 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
JoVM
Posts: 89
Joined: Thu Mar 12, 2015 12:13 pm

Re: bidirectional pin config

Post 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.
User avatar
Tectu
Posts: 1225
Joined: Thu May 10, 2012 9:50 am

Re: bidirectional pin config

Post 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
JoVM
Posts: 89
Joined: Thu Mar 12, 2015 12:13 pm

Re: bidirectional pin config

Post by JoVM »

Tnx for the sample code Tectu. This keep the files in order.
Post Reply