board config

This forum is dedicated to feedback, discussions about ongoing or future developments, ideas and suggestions regarding the ChibiOS projects are welcome. This forum is NOT for support.
tdwebste
Posts: 35
Joined: Mon Jan 14, 2013 2:01 pm

board config

Post by tdwebste »

Examining the stm32f3_discovery board I see pin names like GPIOA_SPI1_SCK
#define GPIOA_SPI1_SCK 5
in board.h

This pin name does not appear outside board.h
I assume these names are arbitrary.

Was this board.h file generated or hand crafted?
User avatar
Tectu
Posts: 1225
Joined: Thu May 10, 2012 9:50 am

Re: board config

Post by Tectu »

The board file for the STM32F3 Discovery board was generated using the eclipse plugin. I'm not sure if the plugin is yet available for public or if only Giovanni has access to use it.

The macros defined in the board.h file are just there so you can create a nicer and more readable application code. For example, you can then write something like:

Code: Select all

palSetPad(GPIOD, GPIOD_LED_0);

instead of:

Code: Select all

palSetPad(GPIOD, 13);


In case of SPI pins you can use them for example in the SPI configuration structure instead of the actual numbers of the pins.

This is really just for esthetics and has nothing to do with the actual functionallity of the board.


~ Tectu
User avatar
Giovanni
Site Admin
Posts: 14892
Joined: Wed May 27, 2009 8:48 am
Has thanked: 1202 times
Been thanked: 996 times

Re: board config

Post by Giovanni »

Hi,

Named pins are used on-board, see the STM32F3-Discovery schematic, unused pins have a generic name.

Giovanni
gentijo
Posts: 11
Joined: Sat Jul 21, 2012 5:00 am

Re: board config

Post by gentijo »

Giovanni,

Is there some documentation that you can point us to on the best way to do
pin configuration management. I am hand editing the board.h file to enable
/ disable pins for my code but not all the pins are defined in board.h. i.e.
For my STM32F4 discovery board, there was a board.h but the I2C pins were
not defined, so I found another STM32F4 board.h where they were defined
and copying them into my file.. I get the feeling I am reinventing the wheel
and there is some other process that I could use to do configuration management.

I gave the Eclipse Config Wizard a try, it generated a board.chcfg file and I added
in the template .ftl files. When I choose the "Generate files from Configuration data"
it builds the board.c & board.h, but it have just generic pin information. I get
the feeling that there is a specific editor for board.chcfg that will allow you
to select a pins function vs editing the raw data in the xml editor.

How do you do pin configuration management ?

-John Gentilin
User avatar
Tectu
Posts: 1225
Joined: Thu May 10, 2012 9:50 am

Re: board config

Post by Tectu »

I can tell you how I do it:
When the board I have to write board files for is similar to an existing once (eg. same MCU), I copy and then modify it afterwards. I open the schematics of the board, locate pin A0, look what's going on there, decide what's the best, safest state, write it down in the board.h file. Then I continue with pin A1 and so on.
Also note that you can give the pins an initial value in your board.c file.


~ Tectu
User avatar
Giovanni
Site Admin
Posts: 14892
Joined: Wed May 27, 2009 8:48 am
Has thanked: 1202 times
Been thanked: 996 times

Re: board config

Post by Giovanni »

Hi,

If you want to use the configuration tool I suggest to copy the board.chcfg file of a similar board into ./boards/<yourboard>/cfg then edit the file using the Eclipse XML editor (in visual mode) setting up all the pins you need. Make sure you have the XML editor installed in Eclipse, it is installed by default in ChibiStudio if you are using that.

Note that if you don't assign a pin a name a generic name will be generated, so give them names.

Like Tectu suggested, the board schematic is your best friend here. The Reference Manual can help too.

Giovanni
Anubirux
Posts: 39
Joined: Sat Apr 21, 2012 2:28 pm

Re: board config

Post by Anubirux »

Hello,

I have some problems with this board config tool also. I didn't want to start new topic and I hope its ok to write here ;)

So I tried generate board files but I only have files with *.c.ftl like. I tried to use cfg files just from demos.
What em I doing wrong ?

Greetings

Edit:
Maybe this helps, I'm using the latest ChibiStudio.
User avatar
Giovanni
Site Admin
Posts: 14892
Joined: Wed May 27, 2009 8:48 am
Has thanked: 1202 times
Been thanked: 996 times

Re: board config

Post by Giovanni »

Hi,

I just tried, got the .c and .h files. What procedure are you using?

I did the following:
1) Select the .chcfg file.
2) Press the generate button in the toolbar (it only appears if the chcfg file is selected).
3) Files appeared in the upper directory.

Giovanni
Anubirux
Posts: 39
Joined: Sat Apr 21, 2012 2:28 pm

Re: board config

Post by Anubirux »

Files appear in "C:\ChibiStudio\eclipse\configuration\org.eclipse.osgi\bundles\323\2\.cp\resources\gencfg\processors\boards\stm32f3xx\templates".
Here is also console copy:

Code: Select all

Starting session

> Processing board.c.ftl
> Processing board.h.ftl
> Processing board.mk.ftl

Finished
Anubirux
Posts: 39
Joined: Sat Apr 21, 2012 2:28 pm

Re: board config

Post by Anubirux »

Everything is fine, it generates files perfectly. I though that it didnt overwrite old board files but it does. I was definitely too tired yesterday.
Anyway thanks for help ;)
Post Reply