SAM4S: Add macros to manage peripheral clocks

This commit is contained in:
Gregory Nutt 2013-06-11 15:42:30 -06:00
parent 7d642f7c1d
commit ebcd80a92c

View File

@ -12,7 +12,7 @@
<h1><big><font color="#3c34ec">
<i>NuttX RTOS Porting Guide</i>
</font></big></h1>
<p>Last Updated: March 20, 2013</p>
<p>Last Updated: June 11, 2013</p>
</td>
</tr>
</table>
@ -46,7 +46,8 @@
<a href="#boardlogic">2.4.2.1 Board Specific Logic</a><br>
<a href="#boardconfigsubdirs">2.4.2.2 Board Specific Configuration Sub-Directories</a>
</ul>
<a href="#supportedboards">2.4.3 Supported Boards</a>
<a href="#supportedboards">2.4.3 Supported Boards</a><br>
<a href="#newboardconfig">2.4.4 Adding a New Board Configuration</a>
</ul>
<a href="#DirStructDrivers">2.5 nuttx/drivers/</a><br>
<a href="#DirStructFs">2.6 nuttx/fs/</a><br>
@ -1021,6 +1022,84 @@
is available to build these toolchains under Linux or Cygwin.
</blockquote></small></p>
<h3><a name="newboardconfig">2.4.4 Adding a New Board Configuration</a></h3>
<p>
Okay, so you have created a new board configuration directory.
Now, how do you hook this board into the configuration system so that you can select with <code>make menuconfig</code>?
</p>
<p>
You will need modify the file <code>configs/Kconfig</code>.
Let's look at the STM32F4-Discovery configuration in the <code>Kconfig</code> file and see how we would add a new board directory to the configuration.
For this configuration let's say that you new board resides in the directory <code>configs/myboard</code>;
It uses an MCU selected with <code>CONFIG_ARCH_CHIP_MYMCU</code>; and you want the board to be selected with <code>CONFIG_ARCH_BOARD_MYBOARD</code>.
Then here is how you can clone the STM32F4-Discovery configuration in <code>configs/Kconfig</code> to support your new board configuration.
</p>
<p>
In <code>configs/Kconfig</code> for the stm32f4-discovery, you will see a configuration definition like this:
<p>
<ul><pre>
config ARCH_BOARD_STM32F4_DISCOVERY
bool "STMicro STM32F4-Discovery board"
depends on ARCH_CHIP_STM32F407VG
select ARCH_HAVE_LEDS
select ARCH_HAVE_BUTTONS
select ARCH_HAVE_IRQBUTTONS
---help---
STMicro STM32F4-Discovery board based on the STMicro STM32F407VGT6 MCU.
</pre></ul>
<p>
The above selects the STM32F4-Discovery board.
The <code>select</code> lines say that the board has both LEDs and buttons and that the board can generate interrupts from the button presses.
You can just copy the above configuration definition to a new location (notice that they the configurations are in alphabetical order).
Then you should edit the configuration to support your board.
The final configuration definition might look something like:
</p>
<ul><pre>
config ARCH_BOARD_MYBOARD
bool "My very own board configuration"
depends on ARCH_CHIP_MYMCU
select ARCH_HAVE_LEDS
select ARCH_HAVE_BUTTONS
select ARCH_HAVE_IRQBUTTONS
---help---
This options selects the board configuration for my very own board
based on the MYMCU processor.
</pre></ul>
<p>
Later in the <code>configs/Kconfig</code> file, you will see a long, long string configuration with lots of defaults like this:
</p>
<ul><pre>
config ARCH_BOARD
string
default "amber" if ARCH_BOARD_AMBER
default "avr32dev1" if ARCH_BOARD_AVR32DEV1
default "c5471evm" if ARCH_BOARD_C5471EVM
...
default "stm32f4discovery" if ARCH_BOARD_STM32F4_DISCOVERY
...
</pre></ul>
<p>
This logic will assign string value to a configuration variable called <code>CONFIG_ARCH_BOARD</code> that will name the directory where the board-specific files reside.
In our case, these files reside in <code>configs/myboard</code> and we add the following to the long list of defaults (again in alphabetical order):
</p>
<ul><pre>
default "myboar" if ARCH_BOARD_MYBOARD
</pre></ul>
<p>
Now the build system knows where to find your board configuration!
</p>
<p>
And finally, add something like this near the bottom of <code>configs/myboard</code>:
</p>
<ul><pre>
if ARCH_BOARD_MYBOARD
source "configs/myboard/Kconfig"
endif
</pre></ul>
<p>
This includes additional, board-specific configuration variabled defintion in <code>configs/myboard/Kconfig</code>.
</p>
<h2>2.5 <a name="DirStructDrivers">nuttx/drivers</a></h2>
<p>
@ -1078,7 +1157,7 @@ drivers/
| |-- Kconfig
| |-- Make.defs
| `-- <i>(Common USB host driver source files)</i>
|-- wirelss/
|-- wireless/
| |-- Kconfig
| |-- Make.defs
| `-- <i>(Common wireless driver source files)</i>