PAL Mode Documentation?
Posted: Sat Jan 04, 2014 3:42 pm
Sorry to post this rant as in general I love ChiBIOS despite being relatively new to it, but I'm really struggling with the PAL driver and specifically the seemingly inconsistent and confusing ways of setting things up.
I'm using an STM32F4 and can easily set it up to use alternate function 9 with and open-drain driver by writing the various registers according to the data sheet.
However that's not remotely portable, so in the spirit of ChiBIOS I'm trying to use the PAL driver, whilst of course appreciating that not all of this is portable to other platforms, specifically the ALTERNATE function, but at least if I use ChiBIOS then it will complain if I change processors to one that doesn't support the specifics I'm trying to do.
Having spent literally hours trawling this forum, reading the source code for the LLD etc. and trying seemingly every combination of the settings, it appears the one that works is to pass "PAL_MODE_ALTERNATE(9) | PAL_STM32_OSPEED_HIGHEST | PAL_STM32_OTYPE_OPENDRAIN" to the palSetMode API.
So it's working, but I can't figure out the thought / logic behind this set of naming conventions, nor can I find any sort of documentation that would have gotten me to this point without someone else having asked it in the forum elsewhere and me having found the reply.
Anyone care to comment on how these options are supposed to work in ChiBIOS? They're dead easy in the native data sheet, but by the time they make it through the PAL layer they seem incomprehensible to me at least.
And most importantly is there any documentation apart from the lld.h file that the ChiBIOS manual refers to which is effectively just 'read the source code, stupid'!
As an example, PAL_MODE_ALTERNATE is not mentioned in the documentation as an appropriate mode, but it seems to be a non-platform specific one, whereas PAL_STM32_ are clearly non-portable ones but I can't find them documented anywhere other than the source files......
I'm using an STM32F4 and can easily set it up to use alternate function 9 with and open-drain driver by writing the various registers according to the data sheet.
However that's not remotely portable, so in the spirit of ChiBIOS I'm trying to use the PAL driver, whilst of course appreciating that not all of this is portable to other platforms, specifically the ALTERNATE function, but at least if I use ChiBIOS then it will complain if I change processors to one that doesn't support the specifics I'm trying to do.
Having spent literally hours trawling this forum, reading the source code for the LLD etc. and trying seemingly every combination of the settings, it appears the one that works is to pass "PAL_MODE_ALTERNATE(9) | PAL_STM32_OSPEED_HIGHEST | PAL_STM32_OTYPE_OPENDRAIN" to the palSetMode API.
So it's working, but I can't figure out the thought / logic behind this set of naming conventions, nor can I find any sort of documentation that would have gotten me to this point without someone else having asked it in the forum elsewhere and me having found the reply.
Anyone care to comment on how these options are supposed to work in ChiBIOS? They're dead easy in the native data sheet, but by the time they make it through the PAL layer they seem incomprehensible to me at least.
And most importantly is there any documentation apart from the lld.h file that the ChiBIOS manual refers to which is effectively just 'read the source code, stupid'!
As an example, PAL_MODE_ALTERNATE is not mentioned in the documentation as an appropriate mode, but it seems to be a non-platform specific one, whereas PAL_STM32_ are clearly non-portable ones but I can't find them documented anywhere other than the source files......