mirror of
https://gitee.com/mirrors_PX4/PX4-Autopilot.git
synced 2026-11-02 05:51:36 +08:00
Add PM support for the STM32F4Discovery -- still a work in progress
git-svn-id: https://nuttx.svn.sourceforge.net/svnroot/nuttx/trunk@4976 7fd9a85b-ad96-42d3-883c-3090e2eb8679
This commit is contained in:
@@ -3065,4 +3065,7 @@
|
|||||||
* include/termios.h and lib/termios/*: Replace cfsetispeed and cfsetospeed with
|
* include/termios.h and lib/termios/*: Replace cfsetispeed and cfsetospeed with
|
||||||
cfsetspeed (with definitions for the input/outputs in termios.h). Same for
|
cfsetspeed (with definitions for the input/outputs in termios.h). Same for
|
||||||
cfgetispeed and cfgetospeed.
|
cfgetispeed and cfgetospeed.
|
||||||
|
* configs/stm32f4discovery/src and configs/stm32f4discovery/pm: Add a power
|
||||||
|
management configuration for the STM32F4Discovery and supporting logic. This
|
||||||
|
check-in also includes some fixes for the F4 RTC alarm logic.
|
||||||
|
|
||||||
|
|||||||
@@ -626,8 +626,8 @@ int up_rtcinitialize(void)
|
|||||||
|
|
||||||
/* Then attach the ALARM interrupt handler */
|
/* Then attach the ALARM interrupt handler */
|
||||||
|
|
||||||
irq_attach(STM32_IRQ_RTC, rtc_interrupt);
|
irq_attach(STM32_IRQ_RTC_WKUP, rtc_interrupt);
|
||||||
up_enable_irq(STM32_IRQ_RTC);
|
up_enable_irq(STM32_IRQ_RTC_WKUP);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
g_rtc_enabled = true;
|
g_rtc_enabled = true;
|
||||||
@@ -813,7 +813,7 @@ int up_rtc_settime(FAR const struct timespec *tp)
|
|||||||
************************************************************************************/
|
************************************************************************************/
|
||||||
|
|
||||||
#ifdef CONFIG_RTC_ALARM
|
#ifdef CONFIG_RTC_ALARM
|
||||||
int up_rtc_setalarm(FAR const struct timespec *tp, alarmcb_t callback);
|
int up_rtc_setalarm(FAR const struct timespec *tp, alarmcb_t callback)
|
||||||
{
|
{
|
||||||
irqstate_t flags;
|
irqstate_t flags;
|
||||||
int ret = -EBUSY;
|
int ret = -EBUSY;
|
||||||
|
|||||||
@@ -1070,3 +1070,50 @@ Where <subdir> is one of the following:
|
|||||||
CONFIG_STM32_CODESOURCERYW=y : CodeSourcery under Windows
|
CONFIG_STM32_CODESOURCERYW=y : CodeSourcery under Windows
|
||||||
|
|
||||||
NOTE: As of this writing, I have not seen the LCD work!
|
NOTE: As of this writing, I have not seen the LCD work!
|
||||||
|
|
||||||
|
pm:
|
||||||
|
--
|
||||||
|
This is a configuration that is used to test STM32 power management, i.e.,
|
||||||
|
to test that the board can go into lower and lower states of power usage
|
||||||
|
as a result of inactivity. This configuration is based on the nsh2
|
||||||
|
configuration with modifications for testing power management. This
|
||||||
|
configuration should provide some guideline for power management in your
|
||||||
|
STM32 application.
|
||||||
|
|
||||||
|
CONFIG_STM32_CODESOURCERYW=y : CodeSourcery under Windows
|
||||||
|
|
||||||
|
CONFIG_PM_CUSTOMINIT and CONFIG_IDLE_CUSTOM are necessary parts of the
|
||||||
|
PM configuration:
|
||||||
|
|
||||||
|
CONFIG_PM_CUSTOMINIT=y
|
||||||
|
|
||||||
|
CONFIG_PM_CUSTOMINIT moves the PM initialization from arch/arm/src/stm32/stm32_pminitialiaze.c
|
||||||
|
to configs/stm3210-eval/src/up_pm.c. This allows us to support board-
|
||||||
|
specific PM initialization.
|
||||||
|
|
||||||
|
CONFIG_IDLE_CUSTOM=y
|
||||||
|
|
||||||
|
The bulk of the PM activities occur in the IDLE loop. The IDLE loop is
|
||||||
|
special because it is what runs when there is no other task running. Therefore
|
||||||
|
when the IDLE executes, we can be assure that nothing else is going on; this
|
||||||
|
is the ideal condition for doing reduced power management.
|
||||||
|
|
||||||
|
The configuration CONFIG_IDLE_CUSTOM allows us to "steal" the normal STM32
|
||||||
|
IDLE loop (of arch/arm/src/stm32/stm32_idle.c) and replace this with our own
|
||||||
|
custom IDLE loop (at configs/stm3210-eval/src/up_idle.c).
|
||||||
|
|
||||||
|
Here are some additional things to note in the configuration:
|
||||||
|
|
||||||
|
CONFIG_PM_BUTTONS=y
|
||||||
|
|
||||||
|
CONFIG_PM_BUTTONS enables button support for PM testing. Buttons can drive
|
||||||
|
EXTI interrupts and EXTI interrrupts can be used to wakeup for certain reduced
|
||||||
|
power modes (STOP mode). The use of the buttons here is for PM testing purposes
|
||||||
|
only; buttons would normally be part the application code and CONFIG_PM_BUTTONS
|
||||||
|
would not be defined.
|
||||||
|
|
||||||
|
CONFIG_RTC_ALARM=y
|
||||||
|
|
||||||
|
The RTC alarm is used to wake up from STOP mode and to transition to
|
||||||
|
STANDBY mode. This used of the RTC alarm could conflict with other uses of
|
||||||
|
the RTC alarm in your application.
|
||||||
|
|||||||
@@ -104,14 +104,14 @@ ifeq ($(WINTOOL),y)
|
|||||||
MKDEP = $(TOPDIR)/tools/mknulldeps.sh
|
MKDEP = $(TOPDIR)/tools/mknulldeps.sh
|
||||||
ARCHINCLUDES = -I. -isystem "${shell cygpath -w $(TOPDIR)/include}"
|
ARCHINCLUDES = -I. -isystem "${shell cygpath -w $(TOPDIR)/include}"
|
||||||
ARCHXXINCLUDES = -I. -isystem "${shell cygpath -w $(TOPDIR)/include}" -isystem "${shell cygpath -w $(TOPDIR)/include/cxx}"
|
ARCHXXINCLUDES = -I. -isystem "${shell cygpath -w $(TOPDIR)/include}" -isystem "${shell cygpath -w $(TOPDIR)/include/cxx}"
|
||||||
ARCHSCRIPT = -T "${shell cygpath -w $(TOPDIR)/configs/$(CONFIG_ARCH_BOARD)/nsh/$(LDSCRIPT)}"
|
ARCHSCRIPT = -T "${shell cygpath -w $(TOPDIR)/configs/$(CONFIG_ARCH_BOARD)/scripts/$(LDSCRIPT)}"
|
||||||
MAXOPTIMIZATION = -O2
|
MAXOPTIMIZATION = -O2
|
||||||
else
|
else
|
||||||
# Linux/Cygwin-native toolchain
|
# Linux/Cygwin-native toolchain
|
||||||
MKDEP = $(TOPDIR)/tools/mkdeps.sh
|
MKDEP = $(TOPDIR)/tools/mkdeps.sh
|
||||||
ARCHINCLUDES = -I. -isystem $(TOPDIR)/include
|
ARCHINCLUDES = -I. -isystem $(TOPDIR)/include
|
||||||
ARCHXXINCLUDES = -I. -isystem $(TOPDIR)/include -isystem $(TOPDIR)/include/cxx
|
ARCHXXINCLUDES = -I. -isystem $(TOPDIR)/include -isystem $(TOPDIR)/include/cxx
|
||||||
ARCHSCRIPT = -T$(TOPDIR)/configs/$(CONFIG_ARCH_BOARD)/nsh/$(LDSCRIPT)
|
ARCHSCRIPT = -T$(TOPDIR)/configs/$(CONFIG_ARCH_BOARD)/scripts/$(LDSCRIPT)
|
||||||
endif
|
endif
|
||||||
|
|
||||||
CC = $(CROSSDEV)gcc
|
CC = $(CROSSDEV)gcc
|
||||||
|
|||||||
@@ -104,14 +104,14 @@ ifeq ($(WINTOOL),y)
|
|||||||
MKDEP = $(TOPDIR)/tools/mknulldeps.sh
|
MKDEP = $(TOPDIR)/tools/mknulldeps.sh
|
||||||
ARCHINCLUDES = -I. -isystem "${shell cygpath -w $(TOPDIR)/include}"
|
ARCHINCLUDES = -I. -isystem "${shell cygpath -w $(TOPDIR)/include}"
|
||||||
ARCHXXINCLUDES = -I. -isystem "${shell cygpath -w $(TOPDIR)/include}" -isystem "${shell cygpath -w $(TOPDIR)/include/cxx}"
|
ARCHXXINCLUDES = -I. -isystem "${shell cygpath -w $(TOPDIR)/include}" -isystem "${shell cygpath -w $(TOPDIR)/include/cxx}"
|
||||||
ARCHSCRIPT = -T "${shell cygpath -w $(TOPDIR)/configs/$(CONFIG_ARCH_BOARD)/nxlines/$(LDSCRIPT)}"
|
ARCHSCRIPT = -T "${shell cygpath -w $(TOPDIR)/configs/$(CONFIG_ARCH_BOARD)/scripts/$(LDSCRIPT)}"
|
||||||
MAXOPTIMIZATION = -O2
|
MAXOPTIMIZATION = -O2
|
||||||
else
|
else
|
||||||
# Linux/Cygwin-native toolchain
|
# Linux/Cygwin-native toolchain
|
||||||
MKDEP = $(TOPDIR)/tools/mkdeps.sh
|
MKDEP = $(TOPDIR)/tools/mkdeps.sh
|
||||||
ARCHINCLUDES = -I. -isystem $(TOPDIR)/include
|
ARCHINCLUDES = -I. -isystem $(TOPDIR)/include
|
||||||
ARCHXXINCLUDES = -I. -isystem $(TOPDIR)/include -isystem $(TOPDIR)/include/cxx
|
ARCHXXINCLUDES = -I. -isystem $(TOPDIR)/include -isystem $(TOPDIR)/include/cxx
|
||||||
ARCHSCRIPT = -T$(TOPDIR)/configs/$(CONFIG_ARCH_BOARD)/nxlines/$(LDSCRIPT)
|
ARCHSCRIPT = -T$(TOPDIR)/configs/$(CONFIG_ARCH_BOARD)/scripts/$(LDSCRIPT)
|
||||||
endif
|
endif
|
||||||
|
|
||||||
CC = $(CROSSDEV)gcc
|
CC = $(CROSSDEV)gcc
|
||||||
|
|||||||
@@ -1,122 +0,0 @@
|
|||||||
/****************************************************************************
|
|
||||||
* configs/stm32f4discovery/nxlines/ld.script
|
|
||||||
*
|
|
||||||
* Copyright (C) 2012 Gregory Nutt. All rights reserved.
|
|
||||||
* Author: Gregory Nutt <gnutt@nuttx.org>
|
|
||||||
*
|
|
||||||
* Redistribution and use in source and binary forms, with or without
|
|
||||||
* modification, are permitted provided that the following conditions
|
|
||||||
* are met:
|
|
||||||
*
|
|
||||||
* 1. Redistributions of source code must retain the above copyright
|
|
||||||
* notice, this list of conditions and the following disclaimer.
|
|
||||||
* 2. Redistributions in binary form must reproduce the above copyright
|
|
||||||
* notice, this list of conditions and the following disclaimer in
|
|
||||||
* the documentation and/or other materials provided with the
|
|
||||||
* distribution.
|
|
||||||
* 3. Neither the name NuttX nor the names of its contributors may be
|
|
||||||
* used to endorse or promote products derived from this software
|
|
||||||
* without specific prior written permission.
|
|
||||||
*
|
|
||||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
|
||||||
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
|
||||||
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
|
|
||||||
* FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
|
|
||||||
* COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
|
|
||||||
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
|
|
||||||
* BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
|
|
||||||
* OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
|
|
||||||
* AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
|
||||||
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
|
|
||||||
* ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
|
||||||
* POSSIBILITY OF SUCH DAMAGE.
|
|
||||||
*
|
|
||||||
****************************************************************************/
|
|
||||||
|
|
||||||
/* The STM32F407VG has 1024Kb of FLASH beginning at address 0x0800:0000 and
|
|
||||||
* 192Kb of SRAM. SRAM is split up into three blocks:
|
|
||||||
*
|
|
||||||
* 1) 112Kb of SRAM beginning at address 0x2000:0000
|
|
||||||
* 2) 16Kb of SRAM beginning at address 0x2001:c000
|
|
||||||
* 3) 64Kb of CCM SRAM beginning at address 0x1000:0000
|
|
||||||
*
|
|
||||||
* When booting from FLASH, FLASH memory is aliased to address 0x0000:0000
|
|
||||||
* where the code expects to begin execution by jumping to the entry point in
|
|
||||||
* the 0x0800:0000 address
|
|
||||||
* range.
|
|
||||||
*/
|
|
||||||
|
|
||||||
MEMORY
|
|
||||||
{
|
|
||||||
flash (rx) : ORIGIN = 0x08000000, LENGTH = 1024K
|
|
||||||
sram (rwx) : ORIGIN = 0x20000000, LENGTH = 112K
|
|
||||||
}
|
|
||||||
|
|
||||||
OUTPUT_ARCH(arm)
|
|
||||||
ENTRY(_stext)
|
|
||||||
SECTIONS
|
|
||||||
{
|
|
||||||
.text : {
|
|
||||||
_stext = ABSOLUTE(.);
|
|
||||||
*(.vectors)
|
|
||||||
*(.text .text.*)
|
|
||||||
*(.fixup)
|
|
||||||
*(.gnu.warning)
|
|
||||||
*(.rodata .rodata.*)
|
|
||||||
*(.gnu.linkonce.t.*)
|
|
||||||
*(.glue_7)
|
|
||||||
*(.glue_7t)
|
|
||||||
*(.got)
|
|
||||||
*(.gcc_except_table)
|
|
||||||
*(.gnu.linkonce.r.*)
|
|
||||||
_etext = ABSOLUTE(.);
|
|
||||||
} > flash
|
|
||||||
|
|
||||||
.init_section : {
|
|
||||||
_sinit = ABSOLUTE(.);
|
|
||||||
*(.init_array .init_array.*)
|
|
||||||
_einit = ABSOLUTE(.);
|
|
||||||
} > flash
|
|
||||||
|
|
||||||
__exidx_start = ABSOLUTE(.);
|
|
||||||
.ARM.exidx : {
|
|
||||||
*(.ARM.exidx*)
|
|
||||||
} > flash
|
|
||||||
__exidx_end = ABSOLUTE(.);
|
|
||||||
|
|
||||||
_eronly = ABSOLUTE(.);
|
|
||||||
|
|
||||||
.data : {
|
|
||||||
_sdata = ABSOLUTE(.);
|
|
||||||
*(.data .data.*)
|
|
||||||
*(.gnu.linkonce.d.*)
|
|
||||||
CONSTRUCTORS
|
|
||||||
_edata = ABSOLUTE(.);
|
|
||||||
} > sram AT > flash
|
|
||||||
|
|
||||||
.ARM.extab : {
|
|
||||||
*(.ARM.extab*)
|
|
||||||
} >sram
|
|
||||||
|
|
||||||
.bss : {
|
|
||||||
_sbss = ABSOLUTE(.);
|
|
||||||
*(.bss .bss.*)
|
|
||||||
*(.gnu.linkonce.b.*)
|
|
||||||
*(COMMON)
|
|
||||||
_ebss = ABSOLUTE(.);
|
|
||||||
} > sram
|
|
||||||
|
|
||||||
/* Stabs debugging sections. */
|
|
||||||
.stab 0 : { *(.stab) }
|
|
||||||
.stabstr 0 : { *(.stabstr) }
|
|
||||||
.stab.excl 0 : { *(.stab.excl) }
|
|
||||||
.stab.exclstr 0 : { *(.stab.exclstr) }
|
|
||||||
.stab.index 0 : { *(.stab.index) }
|
|
||||||
.stab.indexstr 0 : { *(.stab.indexstr) }
|
|
||||||
.comment 0 : { *(.comment) }
|
|
||||||
.debug_abbrev 0 : { *(.debug_abbrev) }
|
|
||||||
.debug_info 0 : { *(.debug_info) }
|
|
||||||
.debug_line 0 : { *(.debug_line) }
|
|
||||||
.debug_pubnames 0 : { *(.debug_pubnames) }
|
|
||||||
.debug_aranges 0 : { *(.debug_aranges) }
|
|
||||||
}
|
|
||||||
@@ -104,14 +104,14 @@ ifeq ($(WINTOOL),y)
|
|||||||
MKDEP = $(TOPDIR)/tools/mknulldeps.sh
|
MKDEP = $(TOPDIR)/tools/mknulldeps.sh
|
||||||
ARCHINCLUDES = -I. -isystem "${shell cygpath -w $(TOPDIR)/include}"
|
ARCHINCLUDES = -I. -isystem "${shell cygpath -w $(TOPDIR)/include}"
|
||||||
ARCHXXINCLUDES = -I. -isystem "${shell cygpath -w $(TOPDIR)/include}" -isystem "${shell cygpath -w $(TOPDIR)/include/cxx}"
|
ARCHXXINCLUDES = -I. -isystem "${shell cygpath -w $(TOPDIR)/include}" -isystem "${shell cygpath -w $(TOPDIR)/include/cxx}"
|
||||||
ARCHSCRIPT = -T "${shell cygpath -w $(TOPDIR)/configs/$(CONFIG_ARCH_BOARD)/ostest/$(LDSCRIPT)}"
|
ARCHSCRIPT = -T "${shell cygpath -w $(TOPDIR)/configs/$(CONFIG_ARCH_BOARD)/scripts/$(LDSCRIPT)}"
|
||||||
MAXOPTIMIZATION = -O2
|
MAXOPTIMIZATION = -O2
|
||||||
else
|
else
|
||||||
# Linux/Cygwin-native toolchain
|
# Linux/Cygwin-native toolchain
|
||||||
MKDEP = $(TOPDIR)/tools/mkdeps.sh
|
MKDEP = $(TOPDIR)/tools/mkdeps.sh
|
||||||
ARCHINCLUDES = -I. -isystem $(TOPDIR)/include
|
ARCHINCLUDES = -I. -isystem $(TOPDIR)/include
|
||||||
ARCHXXINCLUDES = -I. -isystem $(TOPDIR)/include -isystem $(TOPDIR)/include/cxx
|
ARCHXXINCLUDES = -I. -isystem $(TOPDIR)/include -isystem $(TOPDIR)/include/cxx
|
||||||
ARCHSCRIPT = -T$(TOPDIR)/configs/$(CONFIG_ARCH_BOARD)/ostest/$(LDSCRIPT)
|
ARCHSCRIPT = -T$(TOPDIR)/configs/$(CONFIG_ARCH_BOARD)/scripts/$(LDSCRIPT)
|
||||||
endif
|
endif
|
||||||
|
|
||||||
CC = $(CROSSDEV)gcc
|
CC = $(CROSSDEV)gcc
|
||||||
|
|||||||
@@ -1,122 +0,0 @@
|
|||||||
/****************************************************************************
|
|
||||||
* configs/stm32f4discovery/ostest/ld.script
|
|
||||||
*
|
|
||||||
* Copyright (C) 2011 Gregory Nutt. All rights reserved.
|
|
||||||
* Author: Gregory Nutt <gnutt@nuttx.org>
|
|
||||||
*
|
|
||||||
* Redistribution and use in source and binary forms, with or without
|
|
||||||
* modification, are permitted provided that the following conditions
|
|
||||||
* are met:
|
|
||||||
*
|
|
||||||
* 1. Redistributions of source code must retain the above copyright
|
|
||||||
* notice, this list of conditions and the following disclaimer.
|
|
||||||
* 2. Redistributions in binary form must reproduce the above copyright
|
|
||||||
* notice, this list of conditions and the following disclaimer in
|
|
||||||
* the documentation and/or other materials provided with the
|
|
||||||
* distribution.
|
|
||||||
* 3. Neither the name NuttX nor the names of its contributors may be
|
|
||||||
* used to endorse or promote products derived from this software
|
|
||||||
* without specific prior written permission.
|
|
||||||
*
|
|
||||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
|
||||||
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
|
||||||
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
|
|
||||||
* FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
|
|
||||||
* COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
|
|
||||||
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
|
|
||||||
* BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
|
|
||||||
* OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
|
|
||||||
* AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
|
||||||
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
|
|
||||||
* ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
|
||||||
* POSSIBILITY OF SUCH DAMAGE.
|
|
||||||
*
|
|
||||||
****************************************************************************/
|
|
||||||
|
|
||||||
/* The STM32F407VG has 1024Kb of FLASH beginning at address 0x0800:0000 and
|
|
||||||
* 192Kb of SRAM. SRAM is split up into three blocks:
|
|
||||||
*
|
|
||||||
* 1) 112Kb of SRAM beginning at address 0x2000:0000
|
|
||||||
* 2) 16Kb of SRAM beginning at address 0x2001:c000
|
|
||||||
* 3) 64Kb of CCM SRAM beginning at address 0x1000:0000
|
|
||||||
*
|
|
||||||
* When booting from FLASH, FLASH memory is aliased to address 0x0000:0000
|
|
||||||
* where the code expects to begin execution by jumping to the entry point in
|
|
||||||
* the 0x0800:0000 address
|
|
||||||
* range.
|
|
||||||
*/
|
|
||||||
|
|
||||||
MEMORY
|
|
||||||
{
|
|
||||||
flash (rx) : ORIGIN = 0x08000000, LENGTH = 1024K
|
|
||||||
sram (rwx) : ORIGIN = 0x20000000, LENGTH = 112K
|
|
||||||
}
|
|
||||||
|
|
||||||
OUTPUT_ARCH(arm)
|
|
||||||
ENTRY(_stext)
|
|
||||||
SECTIONS
|
|
||||||
{
|
|
||||||
.text : {
|
|
||||||
_stext = ABSOLUTE(.);
|
|
||||||
*(.vectors)
|
|
||||||
*(.text .text.*)
|
|
||||||
*(.fixup)
|
|
||||||
*(.gnu.warning)
|
|
||||||
*(.rodata .rodata.*)
|
|
||||||
*(.gnu.linkonce.t.*)
|
|
||||||
*(.glue_7)
|
|
||||||
*(.glue_7t)
|
|
||||||
*(.got)
|
|
||||||
*(.gcc_except_table)
|
|
||||||
*(.gnu.linkonce.r.*)
|
|
||||||
_etext = ABSOLUTE(.);
|
|
||||||
} > flash
|
|
||||||
|
|
||||||
.init_section : {
|
|
||||||
_sinit = ABSOLUTE(.);
|
|
||||||
*(.init_array .init_array.*)
|
|
||||||
_einit = ABSOLUTE(.);
|
|
||||||
} > flash
|
|
||||||
|
|
||||||
__exidx_start = ABSOLUTE(.);
|
|
||||||
.ARM.exidx : {
|
|
||||||
*(.ARM.exidx*)
|
|
||||||
} > flash
|
|
||||||
__exidx_end = ABSOLUTE(.);
|
|
||||||
|
|
||||||
_eronly = ABSOLUTE(.);
|
|
||||||
|
|
||||||
.data : {
|
|
||||||
_sdata = ABSOLUTE(.);
|
|
||||||
*(.data .data.*)
|
|
||||||
*(.gnu.linkonce.d.*)
|
|
||||||
CONSTRUCTORS
|
|
||||||
_edata = ABSOLUTE(.);
|
|
||||||
} > sram AT > flash
|
|
||||||
|
|
||||||
.ARM.extab : {
|
|
||||||
*(.ARM.extab*)
|
|
||||||
} >sram
|
|
||||||
|
|
||||||
.bss : {
|
|
||||||
_sbss = ABSOLUTE(.);
|
|
||||||
*(.bss .bss.*)
|
|
||||||
*(.gnu.linkonce.b.*)
|
|
||||||
*(COMMON)
|
|
||||||
_ebss = ABSOLUTE(.);
|
|
||||||
} > sram
|
|
||||||
|
|
||||||
/* Stabs debugging sections. */
|
|
||||||
.stab 0 : { *(.stab) }
|
|
||||||
.stabstr 0 : { *(.stabstr) }
|
|
||||||
.stab.excl 0 : { *(.stab.excl) }
|
|
||||||
.stab.exclstr 0 : { *(.stab.exclstr) }
|
|
||||||
.stab.index 0 : { *(.stab.index) }
|
|
||||||
.stab.indexstr 0 : { *(.stab.indexstr) }
|
|
||||||
.comment 0 : { *(.comment) }
|
|
||||||
.debug_abbrev 0 : { *(.debug_abbrev) }
|
|
||||||
.debug_info 0 : { *(.debug_info) }
|
|
||||||
.debug_line 0 : { *(.debug_line) }
|
|
||||||
.debug_pubnames 0 : { *(.debug_pubnames) }
|
|
||||||
.debug_aranges 0 : { *(.debug_aranges) }
|
|
||||||
}
|
|
||||||
@@ -0,0 +1,197 @@
|
|||||||
|
############################################################################
|
||||||
|
# configs/stm32f4discovery/pm/Make.defs
|
||||||
|
#
|
||||||
|
# Copyright (C) 2012 Gregory Nutt. All rights reserved.
|
||||||
|
# Author: Gregory Nutt <gnutt@nuttx.org>
|
||||||
|
#
|
||||||
|
# Redistribution and use in source and binary forms, with or without
|
||||||
|
# modification, are permitted provided that the following conditions
|
||||||
|
# are met:
|
||||||
|
#
|
||||||
|
# 1. Redistributions of source code must retain the above copyright
|
||||||
|
# notice, this list of conditions and the following disclaimer.
|
||||||
|
# 2. Redistributions in binary form must reproduce the above copyright
|
||||||
|
# notice, this list of conditions and the following disclaimer in
|
||||||
|
# the documentation and/or other materials provided with the
|
||||||
|
# distribution.
|
||||||
|
# 3. Neither the name NuttX nor the names of its contributors may be
|
||||||
|
# used to endorse or promote products derived from this software
|
||||||
|
# without specific prior written permission.
|
||||||
|
#
|
||||||
|
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||||
|
# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||||
|
# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
|
||||||
|
# FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
|
||||||
|
# COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
|
||||||
|
# INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
|
||||||
|
# BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
|
||||||
|
# OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
|
||||||
|
# AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
||||||
|
# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
|
||||||
|
# ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||||
|
# POSSIBILITY OF SUCH DAMAGE.
|
||||||
|
#
|
||||||
|
############################################################################
|
||||||
|
|
||||||
|
include ${TOPDIR}/.config
|
||||||
|
|
||||||
|
# Setup for the selected toolchain
|
||||||
|
|
||||||
|
ifeq ($(CONFIG_STM32_CODESOURCERYW),y)
|
||||||
|
# CodeSourcery under Windows
|
||||||
|
CROSSDEV = arm-none-eabi-
|
||||||
|
ARCROSSDEV = arm-none-eabi-
|
||||||
|
WINTOOL = y
|
||||||
|
ARCHCPUFLAGS = -mcpu=cortex-m3 -mthumb -mfloat-abi=soft
|
||||||
|
endif
|
||||||
|
ifeq ($(CONFIG_STM32_CODESOURCERYL),y)
|
||||||
|
# CodeSourcery under Linux
|
||||||
|
CROSSDEV = arm-none-eabi-
|
||||||
|
ARCROSSDEV = arm-none-eabi-
|
||||||
|
ARCHCPUFLAGS = -mcpu=cortex-m3 -mthumb -mfloat-abi=soft
|
||||||
|
MAXOPTIMIZATION = -O2
|
||||||
|
endif
|
||||||
|
ifeq ($(CONFIG_STM32_ATOLLIC_LITE),y)
|
||||||
|
# Atollic toolchain under Windows
|
||||||
|
CROSSDEV = arm-atollic-eabi-
|
||||||
|
ARCROSSDEV =
|
||||||
|
WINTOOL = y
|
||||||
|
ifeq ($(CONFIG_ARCH_FPU),y)
|
||||||
|
ARCHCPUFLAGS = -mcpu=cortex-m4 -mthumb -march=armv7e-m -mfpu=fpv4-sp-d16 -mfloat-abi=hard
|
||||||
|
else
|
||||||
|
ARCHCPUFLAGS = -mcpu=cortex-m3 -mthumb -mfloat-abi=soft
|
||||||
|
endif
|
||||||
|
endif
|
||||||
|
ifeq ($(CONFIG_STM32_ATOLLIC_PRO),y)
|
||||||
|
# Atollic toolchain under Windows
|
||||||
|
CROSSDEV = arm-atollic-eabi-
|
||||||
|
ARCROSSDEV = arm-atollic-eabi-
|
||||||
|
WINTOOL = y
|
||||||
|
ifeq ($(CONFIG_ARCH_FPU),y)
|
||||||
|
ARCHCPUFLAGS = -mcpu=cortex-m4 -mthumb -march=armv7e-m -mfpu=fpv4-sp-d16 -mfloat-abi=hard
|
||||||
|
else
|
||||||
|
ARCHCPUFLAGS = -mcpu=cortex-m3 -mthumb -mfloat-abi=soft
|
||||||
|
endif
|
||||||
|
endif
|
||||||
|
ifeq ($(CONFIG_STM32_DEVKITARM),y)
|
||||||
|
# devkitARM under Windows
|
||||||
|
CROSSDEV = arm-eabi-
|
||||||
|
ARCROSSDEV = arm-eabi-
|
||||||
|
WINTOOL = y
|
||||||
|
ARCHCPUFLAGS = -mcpu=cortex-m3 -mthumb -mfloat-abi=soft
|
||||||
|
endif
|
||||||
|
ifeq ($(CONFIG_STM32_RAISONANCE),y)
|
||||||
|
# Raisonance RIDE7 under Windows
|
||||||
|
CROSSDEV = arm-none-eabi-
|
||||||
|
ARCROSSDEV = arm-none-eabi-
|
||||||
|
WINTOOL = y
|
||||||
|
ARCHCPUFLAGS = -mcpu=cortex-m3 -mthumb -mfloat-abi=soft
|
||||||
|
endif
|
||||||
|
ifeq ($(CONFIG_STM32_BUILDROOT),y)
|
||||||
|
# NuttX buildroot under Linux or Cygwin
|
||||||
|
CROSSDEV = arm-elf-
|
||||||
|
ARCROSSDEV = arm-elf-
|
||||||
|
ARCHCPUFLAGS = -mtune=cortex-m3 -march=armv7-m -mfloat-abi=soft
|
||||||
|
MAXOPTIMIZATION = -Os
|
||||||
|
endif
|
||||||
|
|
||||||
|
LDSCRIPT = ld.script
|
||||||
|
|
||||||
|
ifeq ($(WINTOOL),y)
|
||||||
|
# Windows-native toolchains
|
||||||
|
DIRLINK = $(TOPDIR)/tools/winlink.sh
|
||||||
|
DIRUNLINK = $(TOPDIR)/tools/unlink.sh
|
||||||
|
MKDEP = $(TOPDIR)/tools/mknulldeps.sh
|
||||||
|
ARCHINCLUDES = -I. -isystem "${shell cygpath -w $(TOPDIR)/include}"
|
||||||
|
ARCHXXINCLUDES = -I. -isystem "${shell cygpath -w $(TOPDIR)/include}" -isystem "${shell cygpath -w $(TOPDIR)/include/cxx}"
|
||||||
|
ARCHSCRIPT = -T "${shell cygpath -w $(TOPDIR)/configs/$(CONFIG_ARCH_BOARD)/scripts/$(LDSCRIPT)}"
|
||||||
|
MAXOPTIMIZATION = -O2
|
||||||
|
else
|
||||||
|
# Linux/Cygwin-native toolchain
|
||||||
|
MKDEP = $(TOPDIR)/tools/mkdeps.sh
|
||||||
|
ARCHINCLUDES = -I. -isystem $(TOPDIR)/include
|
||||||
|
ARCHXXINCLUDES = -I. -isystem $(TOPDIR)/include -isystem $(TOPDIR)/include/cxx
|
||||||
|
ARCHSCRIPT = -T$(TOPDIR)/configs/$(CONFIG_ARCH_BOARD)/scripts/$(LDSCRIPT)
|
||||||
|
endif
|
||||||
|
|
||||||
|
CC = $(CROSSDEV)gcc
|
||||||
|
CXX = $(CROSSDEV)g++
|
||||||
|
CPP = $(CROSSDEV)gcc -E
|
||||||
|
LD = $(CROSSDEV)ld
|
||||||
|
AR = $(ARCROSSDEV)ar rcs
|
||||||
|
NM = $(ARCROSSDEV)nm
|
||||||
|
OBJCOPY = $(CROSSDEV)objcopy
|
||||||
|
OBJDUMP = $(CROSSDEV)objdump
|
||||||
|
|
||||||
|
ARCHCCVERSION = ${shell $(CC) -v 2>&1 | sed -n '/^gcc version/p' | sed -e 's/^gcc version \([0-9\.]\)/\1/g' -e 's/[-\ ].*//g' -e '1q'}
|
||||||
|
ARCHCCMAJOR = ${shell echo $(ARCHCCVERSION) | cut -d'.' -f1}
|
||||||
|
|
||||||
|
ifeq ("${CONFIG_DEBUG_SYMBOLS}","y")
|
||||||
|
ARCHOPTIMIZATION = -g
|
||||||
|
else
|
||||||
|
ARCHOPTIMIZATION = $(MAXOPTIMIZATION) -fno-strict-aliasing -fno-strength-reduce -fomit-frame-pointer
|
||||||
|
endif
|
||||||
|
|
||||||
|
ARCHCFLAGS = -fno-builtin
|
||||||
|
ARCHCXXFLAGS = -fno-builtin -fno-exceptions -fno-rtti
|
||||||
|
ARCHWARNINGS = -Wall -Wstrict-prototypes -Wshadow
|
||||||
|
ARCHWARNINGSXX = -Wall -Wshadow
|
||||||
|
ARCHDEFINES =
|
||||||
|
ARCHPICFLAGS = -fpic -msingle-pic-base -mpic-register=r10
|
||||||
|
|
||||||
|
CFLAGS = $(ARCHCFLAGS) $(ARCHWARNINGS) $(ARCHOPTIMIZATION) $(ARCHCPUFLAGS) $(ARCHINCLUDES) $(ARCHDEFINES) $(EXTRADEFINES) -pipe
|
||||||
|
CPICFLAGS = $(ARCHPICFLAGS) $(CFLAGS)
|
||||||
|
CXXFLAGS = $(ARCHCXXFLAGS) $(ARCHWARNINGSXX) $(ARCHOPTIMIZATION) $(ARCHCPUFLAGS) $(ARCHXXINCLUDES) $(ARCHDEFINES) $(EXTRADEFINES) -pipe
|
||||||
|
CXXPICFLAGS = $(ARCHPICFLAGS) $(CXXFLAGS)
|
||||||
|
CPPFLAGS = $(ARCHINCLUDES) $(ARCHDEFINES) $(EXTRADEFINES)
|
||||||
|
AFLAGS = $(CFLAGS) -D__ASSEMBLY__
|
||||||
|
|
||||||
|
NXFLATLDFLAGS1 = -r -d -warn-common
|
||||||
|
NXFLATLDFLAGS2 = $(NXFLATLDFLAGS1) -T$(TOPDIR)/binfmt/libnxflat/gnu-nxflat.ld -no-check-sections
|
||||||
|
LDNXFLATFLAGS = -e main -s 2048
|
||||||
|
|
||||||
|
OBJEXT = .o
|
||||||
|
LIBEXT = .a
|
||||||
|
EXEEXT =
|
||||||
|
|
||||||
|
ifneq ($(CROSSDEV),arm-elf-)
|
||||||
|
LDFLAGS += -nostartfiles -nodefaultlibs
|
||||||
|
endif
|
||||||
|
ifeq ($(CONFIG_DEBUG_SYMBOLS),y)
|
||||||
|
LDFLAGS += -g
|
||||||
|
endif
|
||||||
|
|
||||||
|
define PREPROCESS
|
||||||
|
@echo "CPP: $1->$2"
|
||||||
|
@$(CPP) $(CPPFLAGS) $1 -o $2
|
||||||
|
endef
|
||||||
|
|
||||||
|
define COMPILE
|
||||||
|
@echo "CC: $1"
|
||||||
|
@$(CC) -c $(CFLAGS) $1 -o $2
|
||||||
|
endef
|
||||||
|
|
||||||
|
define COMPILEXX
|
||||||
|
@echo "CXX: $1"
|
||||||
|
@$(CXX) -c $(CXXFLAGS) $1 -o $2
|
||||||
|
endef
|
||||||
|
|
||||||
|
define ASSEMBLE
|
||||||
|
@echo "AS: $1"
|
||||||
|
@$(CC) -c $(AFLAGS) $1 -o $2
|
||||||
|
endef
|
||||||
|
|
||||||
|
define ARCHIVE
|
||||||
|
echo "AR: $2"; \
|
||||||
|
$(AR) $1 $2 || { echo "$(AR) $1 $2 FAILED!" ; exit 1 ; }
|
||||||
|
endef
|
||||||
|
|
||||||
|
define CLEAN
|
||||||
|
@rm -f *.o *.a
|
||||||
|
endef
|
||||||
|
|
||||||
|
HOSTCC = gcc
|
||||||
|
HOSTINCLUDES = -I.
|
||||||
|
HOSTCFLAGS = -Wall -Wstrict-prototypes -Wshadow -g -pipe
|
||||||
|
HOSTLDFLAGS =
|
||||||
|
|
||||||
@@ -0,0 +1,67 @@
|
|||||||
|
############################################################################
|
||||||
|
# configs/stm32f4discovery/pm/appconfig
|
||||||
|
#
|
||||||
|
# Copyright (C) 2012 Gregory Nutt. All rights reserved.
|
||||||
|
# Author: Gregory Nutt <gnutt@nuttx.org>
|
||||||
|
#
|
||||||
|
# Redistribution and use in source and binary forms, with or without
|
||||||
|
# modification, are permitted provided that the following conditions
|
||||||
|
# are met:
|
||||||
|
#
|
||||||
|
# 1. Redistributions of source code must retain the above copyright
|
||||||
|
# notice, this list of conditions and the following disclaimer.
|
||||||
|
# 2. Redistributions in binary form must reproduce the above copyright
|
||||||
|
# notice, this list of conditions and the following disclaimer in
|
||||||
|
# the documentation and/or other materials provided with the
|
||||||
|
# distribution.
|
||||||
|
# 3. Neither the name NuttX nor the names of its contributors may be
|
||||||
|
# used to endorse or promote products derived from this software
|
||||||
|
# without specific prior written permission.
|
||||||
|
#
|
||||||
|
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||||
|
# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||||
|
# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
|
||||||
|
# FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
|
||||||
|
# COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
|
||||||
|
# INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
|
||||||
|
# BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
|
||||||
|
# OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
|
||||||
|
# AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
||||||
|
# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
|
||||||
|
# ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||||
|
# POSSIBILITY OF SUCH DAMAGE.
|
||||||
|
#
|
||||||
|
############################################################################
|
||||||
|
|
||||||
|
# Path to example in apps/examples containing the user_start entry point
|
||||||
|
|
||||||
|
CONFIGURED_APPS += examples/nsh
|
||||||
|
|
||||||
|
# The NSH application library
|
||||||
|
|
||||||
|
CONFIGURED_APPS += system/readline
|
||||||
|
CONFIGURED_APPS += nshlib
|
||||||
|
|
||||||
|
# Applications configured as an NX built-in commands
|
||||||
|
|
||||||
|
ifeq ($(CONFIG_ADC),y)
|
||||||
|
CONFIGURED_APPS += examples/adc
|
||||||
|
endif
|
||||||
|
|
||||||
|
ifeq ($(CONFIG_PWM),y)
|
||||||
|
CONFIGURED_APPS += examples/pwm
|
||||||
|
endif
|
||||||
|
|
||||||
|
ifeq ($(CONFIG_QENCODER),y)
|
||||||
|
CONFIGURED_APPS += examples/qencoder
|
||||||
|
endif
|
||||||
|
|
||||||
|
ifeq ($(CONFIG_USBDEV),y)
|
||||||
|
ifeq ($(CONFIG_CDCACM),y)
|
||||||
|
CONFIGURED_APPS += examples/cdcacm
|
||||||
|
endif
|
||||||
|
endif
|
||||||
|
|
||||||
|
ifeq ($(CONFIG_WATCHDOG),y)
|
||||||
|
CONFIGURED_APPS += examples/watchdog
|
||||||
|
endif
|
||||||
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,75 @@
|
|||||||
|
#!/bin/bash
|
||||||
|
# configs/stm32f4discovery/pm/setenv.sh
|
||||||
|
#
|
||||||
|
# Copyright (C) 2012 Gregory Nutt. All rights reserved.
|
||||||
|
# Author: Gregory Nutt <gnutt@nuttx.org>
|
||||||
|
#
|
||||||
|
# Redistribution and use in source and binary forms, with or without
|
||||||
|
# modification, are permitted provided that the following conditions
|
||||||
|
# are met:
|
||||||
|
#
|
||||||
|
# 1. Redistributions of source code must retain the above copyright
|
||||||
|
# notice, this list of conditions and the following disclaimer.
|
||||||
|
# 2. Redistributions in binary form must reproduce the above copyright
|
||||||
|
# notice, this list of conditions and the following disclaimer in
|
||||||
|
# the documentation and/or other materials provided with the
|
||||||
|
# distribution.
|
||||||
|
# 3. Neither the name NuttX nor the names of its contributors may be
|
||||||
|
# used to endorse or promote products derived from this software
|
||||||
|
# without specific prior written permission.
|
||||||
|
#
|
||||||
|
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||||
|
# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||||
|
# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
|
||||||
|
# FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
|
||||||
|
# COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
|
||||||
|
# INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
|
||||||
|
# BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
|
||||||
|
# OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
|
||||||
|
# AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
||||||
|
# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
|
||||||
|
# ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||||
|
# POSSIBILITY OF SUCH DAMAGE.
|
||||||
|
#
|
||||||
|
|
||||||
|
if [ "$_" = "$0" ] ; then
|
||||||
|
echo "You must source this script, not run it!" 1>&2
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
WD=`pwd`
|
||||||
|
if [ ! -x "setenv.sh" ]; then
|
||||||
|
echo "This script must be executed from the top-level NuttX build directory"
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
if [ -z "${PATH_ORIG}" ]; then
|
||||||
|
export PATH_ORIG="${PATH}"
|
||||||
|
fi
|
||||||
|
|
||||||
|
# This the Cygwin path to the location where I installed the RIDE
|
||||||
|
# toolchain under windows. You will also have to edit this if you install
|
||||||
|
# the RIDE toolchain in any other location
|
||||||
|
#export TOOLCHAIN_BIN="/cygdrive/c/Program Files (x86)/Raisonance/Ride/arm-gcc/bin"
|
||||||
|
|
||||||
|
# This the Cygwin path to the location where I installed the CodeSourcery
|
||||||
|
# toolchain under windows. You will also have to edit this if you install
|
||||||
|
# the CodeSourcery toolchain in any other location
|
||||||
|
export TOOLCHAIN_BIN="/cygdrive/c/Program Files (x86)/CodeSourcery/Sourcery G++ Lite/bin"
|
||||||
|
|
||||||
|
# These are the Cygwin paths to the locations where I installed the Atollic
|
||||||
|
# toolchain under windows. You will also have to edit this if you install
|
||||||
|
# the Atollic toolchain in any other location. /usr/bin is added before
|
||||||
|
# the Atollic bin path because there is are binaries named gcc.exe and g++.exe
|
||||||
|
# at those locations as well.
|
||||||
|
#export TOOLCHAIN_BIN="/usr/bin:/cygdrive/c/Program Files (x86)/Atollic/TrueSTUDIO for ARM Pro 2.3.0/ARMTools/bin"
|
||||||
|
#export TOOLCHAIN_BIN="/usr/bin:/cygdrive/c/Program Files (x86)/Atollic/TrueSTUDIO for STMicroelectronics STM32 Lite 2.3.0/ARMTools/bin"
|
||||||
|
|
||||||
|
# This the Cygwin path to the location where I build the buildroot
|
||||||
|
# toolchain.
|
||||||
|
#export TOOLCHAIN_BIN="${WD}/../misc/buildroot/build_arm_nofpu/staging_dir/bin"
|
||||||
|
|
||||||
|
# Add the path to the toolchain to the PATH varialble
|
||||||
|
export PATH="${TOOLCHAIN_BIN}:/sbin:/usr/sbin:${PATH_ORIG}"
|
||||||
|
|
||||||
|
echo "PATH : ${PATH}"
|
||||||
+2
-2
@@ -1,7 +1,7 @@
|
|||||||
/****************************************************************************
|
/****************************************************************************
|
||||||
* configs/stm32f4discovery/nsh/ld.script
|
* configs/stm32f4discovery/scripts/ld.script
|
||||||
*
|
*
|
||||||
* Copyright (C) 2011 Gregory Nutt. All rights reserved.
|
* Copyright (C) 2011-2012 Gregory Nutt. All rights reserved.
|
||||||
* Author: Gregory Nutt <gnutt@nuttx.org>
|
* Author: Gregory Nutt <gnutt@nuttx.org>
|
||||||
*
|
*
|
||||||
* Redistribution and use in source and binary forms, with or without
|
* Redistribution and use in source and binary forms, with or without
|
||||||
@@ -72,6 +72,18 @@ ifeq ($(CONFIG_WATCHDOG),y)
|
|||||||
CSRCS += up_watchdog.c
|
CSRCS += up_watchdog.c
|
||||||
endif
|
endif
|
||||||
|
|
||||||
|
ifeq ($(CONFIG_PM_CUSTOMINIT),y)
|
||||||
|
CSRCS += up_pm.c
|
||||||
|
endif
|
||||||
|
|
||||||
|
ifeq ($(CONFIG_PM_BUTTONS),y)
|
||||||
|
CSRCS += up_pmbuttons.c
|
||||||
|
endif
|
||||||
|
|
||||||
|
ifeq ($(CONFIG_IDLE_CUSTOM),y)
|
||||||
|
CSRCS += up_idle.c
|
||||||
|
endif
|
||||||
|
|
||||||
ifeq ($(CONFIG_STM32_FSMC),y)
|
ifeq ($(CONFIG_STM32_FSMC),y)
|
||||||
CSRCS += up_extmem.c
|
CSRCS += up_extmem.c
|
||||||
|
|
||||||
|
|||||||
@@ -201,6 +201,14 @@ void stm32_enablefsmc(void);
|
|||||||
void stm32_disablefsmc(void);
|
void stm32_disablefsmc(void);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
/****************************************************************************
|
||||||
|
* Name: up_ledpminitialize
|
||||||
|
****************************************************************************/
|
||||||
|
|
||||||
|
#ifdef CONFIG_PM
|
||||||
|
void up_ledpminitialize(void);
|
||||||
|
#endif
|
||||||
|
|
||||||
#endif /* __ASSEMBLY__ */
|
#endif /* __ASSEMBLY__ */
|
||||||
#endif /* __CONFIGS_STM3240G_EVAL_SRC_STM3240G_INTERNAL_H */
|
#endif /* __CONFIGS_STM3240G_EVAL_SRC_STM3240G_INTERNAL_H */
|
||||||
|
|
||||||
|
|||||||
Executable
+277
@@ -0,0 +1,277 @@
|
|||||||
|
/****************************************************************************
|
||||||
|
* configs/stm32f4discovery/src/up_idle.c
|
||||||
|
* arch/arm/src/board/up_idle.c
|
||||||
|
*
|
||||||
|
* Copyright (C) 2012 Gregory Nutt. All rights reserved.
|
||||||
|
* Authors: Gregory Nutt <gnutt@nuttx.org>
|
||||||
|
* Diego Sanchez <dsanchez@nx-engineering.com>
|
||||||
|
*
|
||||||
|
* Redistribution and use in source and binary forms, with or without
|
||||||
|
* modification, are permitted provided that the following conditions
|
||||||
|
* are met:
|
||||||
|
*
|
||||||
|
* 1. Redistributions of source code must retain the above copyright
|
||||||
|
* notice, this list of conditions and the following disclaimer.
|
||||||
|
* 2. Redistributions in binary form must reproduce the above copyright
|
||||||
|
* notice, this list of conditions and the following disclaimer in
|
||||||
|
* the documentation and/or other materials provided with the
|
||||||
|
* distribution.
|
||||||
|
* 3. Neither the name NuttX nor the names of its contributors may be
|
||||||
|
* used to endorse or promote products derived from this software
|
||||||
|
* without specific prior written permission.
|
||||||
|
*
|
||||||
|
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||||
|
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||||
|
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
|
||||||
|
* FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
|
||||||
|
* COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
|
||||||
|
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
|
||||||
|
* BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
|
||||||
|
* OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
|
||||||
|
* AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
||||||
|
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
|
||||||
|
* ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||||
|
* POSSIBILITY OF SUCH DAMAGE.
|
||||||
|
*
|
||||||
|
*
|
||||||
|
****************************************************************************/
|
||||||
|
|
||||||
|
/****************************************************************************
|
||||||
|
* Included Files
|
||||||
|
****************************************************************************/
|
||||||
|
|
||||||
|
#include <arch/board/board.h>
|
||||||
|
#include <nuttx/config.h>
|
||||||
|
|
||||||
|
#include <nuttx/arch.h>
|
||||||
|
#include <nuttx/clock.h>
|
||||||
|
#include <nuttx/power/pm.h>
|
||||||
|
|
||||||
|
#include <debug.h>
|
||||||
|
#include <nuttx/rtc.h>
|
||||||
|
#include <arch/irq.h>
|
||||||
|
|
||||||
|
#include "up_internal.h"
|
||||||
|
#include "stm32_pm.h"
|
||||||
|
#include "stm32_rcc.h"
|
||||||
|
#include "stm32_exti.h"
|
||||||
|
|
||||||
|
#include "stm32f4discovery-internal.h"
|
||||||
|
|
||||||
|
/****************************************************************************
|
||||||
|
* Pre-processor Definitions
|
||||||
|
****************************************************************************/
|
||||||
|
/* Configuration ************************************************************/
|
||||||
|
/* Does the board support an IDLE LED to indicate that the board is in the
|
||||||
|
* IDLE state?
|
||||||
|
*/
|
||||||
|
|
||||||
|
#if defined(CONFIG_ARCH_LEDS) && defined(LED_IDLE)
|
||||||
|
# define BEGIN_IDLE() up_ledon(LED_IDLE)
|
||||||
|
# define END_IDLE() up_ledoff(LED_IDLE)
|
||||||
|
#else
|
||||||
|
# define BEGIN_IDLE()
|
||||||
|
# define END_IDLE()
|
||||||
|
#endif
|
||||||
|
|
||||||
|
/* Values for the RTC Alarm to wake up from the PM_STANDBY mode */
|
||||||
|
|
||||||
|
#ifndef CONFIG_PM_ALARM_SEC
|
||||||
|
# define CONFIG_PM_ALARM_SEC 3
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifndef CONFIG_PM_ALARM_NSEC
|
||||||
|
# define CONFIG_PM_ALARM_NSEC 0
|
||||||
|
#endif
|
||||||
|
|
||||||
|
/****************************************************************************
|
||||||
|
* Private Data
|
||||||
|
****************************************************************************/
|
||||||
|
|
||||||
|
#if defined(CONFIG_PM) && defined(CONFIG_RTC_ALARM)
|
||||||
|
static void up_alarmcb(void);
|
||||||
|
#endif
|
||||||
|
|
||||||
|
/****************************************************************************
|
||||||
|
* Private Functions
|
||||||
|
****************************************************************************/
|
||||||
|
|
||||||
|
/****************************************************************************
|
||||||
|
* Name: up_idlepm
|
||||||
|
*
|
||||||
|
* Description:
|
||||||
|
* Perform IDLE state power management.
|
||||||
|
*
|
||||||
|
****************************************************************************/
|
||||||
|
|
||||||
|
#ifdef CONFIG_PM
|
||||||
|
static void up_idlepm(void)
|
||||||
|
{
|
||||||
|
#ifdef CONFIG_RTC_ALARM
|
||||||
|
struct timespec alarmtime;
|
||||||
|
#endif
|
||||||
|
static enum pm_state_e oldstate = PM_NORMAL;
|
||||||
|
enum pm_state_e newstate;
|
||||||
|
irqstate_t flags;
|
||||||
|
int ret;
|
||||||
|
|
||||||
|
/* Decide, which power saving level can be obtained */
|
||||||
|
|
||||||
|
newstate = pm_checkstate();
|
||||||
|
|
||||||
|
/* Check for state changes */
|
||||||
|
|
||||||
|
if (newstate != oldstate)
|
||||||
|
{
|
||||||
|
lldbg("newstate= %d oldstate=%d\n", newstate, oldstate);
|
||||||
|
|
||||||
|
flags = irqsave();
|
||||||
|
|
||||||
|
/* Force the global state change */
|
||||||
|
|
||||||
|
ret = pm_changestate(newstate);
|
||||||
|
if (ret < 0)
|
||||||
|
{
|
||||||
|
/* The new state change failed, revert to the preceding state */
|
||||||
|
|
||||||
|
(void)pm_changestate(oldstate);
|
||||||
|
|
||||||
|
/* No state change... */
|
||||||
|
|
||||||
|
goto errout;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Then perform board-specific, state-dependent logic here */
|
||||||
|
|
||||||
|
switch (newstate)
|
||||||
|
{
|
||||||
|
case PM_NORMAL:
|
||||||
|
{
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
|
||||||
|
case PM_IDLE:
|
||||||
|
{
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
|
||||||
|
case PM_STANDBY:
|
||||||
|
{
|
||||||
|
#ifdef CONFIG_RTC_ALARM
|
||||||
|
/* Disable RTC Alarm interrupt */
|
||||||
|
|
||||||
|
#warning "missing logic"
|
||||||
|
|
||||||
|
/* Configure the RTC alarm to Auto Wake the system */
|
||||||
|
|
||||||
|
#warning "missing logic"
|
||||||
|
|
||||||
|
/* The tv_nsec value must not exceed 1,000,000,000. That
|
||||||
|
* would be an invalid time.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#warning "missing logic"
|
||||||
|
|
||||||
|
/* Set the alarm */
|
||||||
|
|
||||||
|
#warning "missing logic"
|
||||||
|
#endif
|
||||||
|
/* Call the STM32 stop mode */
|
||||||
|
|
||||||
|
stm32_pmstop(true);
|
||||||
|
|
||||||
|
/* We have been re-awakened by some even: A button press?
|
||||||
|
* An alarm? Cancel any pending alarm and resume the normal
|
||||||
|
* operation.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifdef CONFIG_RTC_ALARM
|
||||||
|
#warning "missing logic"
|
||||||
|
#endif
|
||||||
|
/* Resume normal operation */
|
||||||
|
|
||||||
|
pm_changestate(PM_NORMAL);
|
||||||
|
newstate = PM_NORMAL;
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
|
||||||
|
case PM_SLEEP:
|
||||||
|
{
|
||||||
|
/* We should not return from standby mode. The only way out
|
||||||
|
* of standby is via the reset path.
|
||||||
|
*/
|
||||||
|
|
||||||
|
(void)stm32_pmstandby();
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
|
||||||
|
default:
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Save the new state */
|
||||||
|
|
||||||
|
oldstate = newstate;
|
||||||
|
|
||||||
|
errout:
|
||||||
|
irqrestore(flags);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
#else
|
||||||
|
# define up_idlepm()
|
||||||
|
#endif
|
||||||
|
|
||||||
|
/************************************************************************************
|
||||||
|
* Name: up_alarmcb
|
||||||
|
*
|
||||||
|
* Description:
|
||||||
|
* RTC alarm service routine
|
||||||
|
*
|
||||||
|
************************************************************************************/
|
||||||
|
|
||||||
|
#if defined(CONFIG_PM) && defined(CONFIG_RTC_ALARM)
|
||||||
|
static void up_alarmcb(void)
|
||||||
|
{
|
||||||
|
/* This alarm occurs because there wasn't any EXTI interrupt during the
|
||||||
|
* PM_STANDBY period. So just go to sleep.
|
||||||
|
*/
|
||||||
|
|
||||||
|
pm_changestate(PM_SLEEP);
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
/****************************************************************************
|
||||||
|
* Public Functions
|
||||||
|
****************************************************************************/
|
||||||
|
|
||||||
|
/****************************************************************************
|
||||||
|
* Name: up_idle
|
||||||
|
*
|
||||||
|
* Description:
|
||||||
|
* up_idle() is the logic that will be executed when their is no other
|
||||||
|
* ready-to-run task. This is processor idle time and will continue until
|
||||||
|
* some interrupt occurs to cause a context switch from the idle task.
|
||||||
|
*
|
||||||
|
* Processing in this state may be processor-specific. e.g., this is where
|
||||||
|
* power management operations might be performed.
|
||||||
|
*
|
||||||
|
****************************************************************************/
|
||||||
|
|
||||||
|
void up_idle(void)
|
||||||
|
{
|
||||||
|
#if defined(CONFIG_SUPPRESS_INTERRUPTS) || defined(CONFIG_SUPPRESS_TIMER_INTS)
|
||||||
|
/* If the system is idle and there are no timer interrupts, then process
|
||||||
|
* "fake" timer interrupts. Hopefully, something will wake up.
|
||||||
|
*/
|
||||||
|
|
||||||
|
sched_process_timer();
|
||||||
|
#else
|
||||||
|
|
||||||
|
/* Perform IDLE mode power management */
|
||||||
|
|
||||||
|
BEGIN_IDLE();
|
||||||
|
up_idlepm();
|
||||||
|
END_IDLE();
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
|
||||||
Executable
+107
@@ -0,0 +1,107 @@
|
|||||||
|
/****************************************************************************
|
||||||
|
* configs/stm32f4discovery/src/up_pm.c
|
||||||
|
* arch/arm/src/board/up_pm.c
|
||||||
|
*
|
||||||
|
* Copyright (C) 2012 Gregory Nutt. All rights reserved.
|
||||||
|
* Authors: Gregory Nutt <gnutt@nuttx.org>
|
||||||
|
* Diego Sanchez <dsanchez@nx-engineering.com>
|
||||||
|
*
|
||||||
|
* Redistribution and use in source and binary forms, with or without
|
||||||
|
* modification, are permitted provided that the following conditions
|
||||||
|
* are met:
|
||||||
|
*
|
||||||
|
* 1. Redistributions of source code must retain the above copyright
|
||||||
|
* notice, this list of conditions and the following disclaimer.
|
||||||
|
* 2. Redistributions in binary form must reproduce the above copyright
|
||||||
|
* notice, this list of conditions and the following disclaimer in
|
||||||
|
* the documentation and/or other materials provided with the
|
||||||
|
* distribution.
|
||||||
|
* 3. Neither the name NuttX nor the names of its contributors may be
|
||||||
|
* used to endorse or promote products derived from this software
|
||||||
|
* without specific prior written permission.
|
||||||
|
*
|
||||||
|
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||||
|
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||||
|
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
|
||||||
|
* FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
|
||||||
|
* COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
|
||||||
|
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
|
||||||
|
* BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
|
||||||
|
* OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
|
||||||
|
* AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
||||||
|
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
|
||||||
|
* ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||||
|
* POSSIBILITY OF SUCH DAMAGE.
|
||||||
|
*
|
||||||
|
****************************************************************************/
|
||||||
|
|
||||||
|
/****************************************************************************
|
||||||
|
* Included Files
|
||||||
|
****************************************************************************/
|
||||||
|
|
||||||
|
#include <nuttx/config.h>
|
||||||
|
|
||||||
|
#include <nuttx/power/pm.h>
|
||||||
|
|
||||||
|
#include "up_internal.h"
|
||||||
|
#include "stm32_pm.h"
|
||||||
|
#include "stm32f4discovery-internal.h"
|
||||||
|
|
||||||
|
#ifdef CONFIG_PM
|
||||||
|
|
||||||
|
/****************************************************************************
|
||||||
|
* Pre-processor Definitions
|
||||||
|
****************************************************************************/
|
||||||
|
|
||||||
|
/****************************************************************************
|
||||||
|
* Private Data
|
||||||
|
****************************************************************************/
|
||||||
|
|
||||||
|
/****************************************************************************
|
||||||
|
* Public Data
|
||||||
|
****************************************************************************/
|
||||||
|
|
||||||
|
/****************************************************************************
|
||||||
|
* Private Functions
|
||||||
|
****************************************************************************/
|
||||||
|
|
||||||
|
/****************************************************************************
|
||||||
|
* Public Functions
|
||||||
|
****************************************************************************/
|
||||||
|
|
||||||
|
/****************************************************************************
|
||||||
|
* Name: up_pminitialize
|
||||||
|
*
|
||||||
|
* Description:
|
||||||
|
* This function is called by MCU-specific logic at power-on reset in
|
||||||
|
* order to provide one-time initialization the power management subystem.
|
||||||
|
* This function must be called *very* early in the intialization sequence
|
||||||
|
* *before* any other device drivers are initialized (since they may
|
||||||
|
* attempt to register with the power management subsystem).
|
||||||
|
*
|
||||||
|
* Input parameters:
|
||||||
|
* None.
|
||||||
|
*
|
||||||
|
* Returned value:
|
||||||
|
* None.
|
||||||
|
*
|
||||||
|
****************************************************************************/
|
||||||
|
|
||||||
|
void up_pminitialize(void)
|
||||||
|
{
|
||||||
|
/* Then initialize the NuttX power management subsystem proper */
|
||||||
|
|
||||||
|
pm_initialize();
|
||||||
|
|
||||||
|
#if defined(CONFIG_IDLE_CUSTOM) && defined(CONFIG_PM_BUTTONS)
|
||||||
|
/* Initialize the buttons to wake up the system from low power modes */
|
||||||
|
|
||||||
|
up_pmbuttons();
|
||||||
|
#endif
|
||||||
|
|
||||||
|
/* Initialize the LED PM */
|
||||||
|
|
||||||
|
up_ledpminitialize();
|
||||||
|
}
|
||||||
|
|
||||||
|
#endif /* CONFIG_PM */
|
||||||
+202
@@ -0,0 +1,202 @@
|
|||||||
|
/****************************************************************************
|
||||||
|
* configs/stm32f4discovery/src/up_pmbuttons.c
|
||||||
|
* arch/arm/src/board/up_pmbuttons.c
|
||||||
|
*
|
||||||
|
* Copyright (C) 2012 Gregory Nutt. All rights reserved.
|
||||||
|
* Authors: Gregory Nutt <gnutt@nuttx.org>
|
||||||
|
* Diego Sanchez <dsanchez@nx-engineering.com>
|
||||||
|
*
|
||||||
|
* Redistribution and use in source and binary forms, with or without
|
||||||
|
* modification, are permitted provided that the following conditions
|
||||||
|
* are met:
|
||||||
|
*
|
||||||
|
* 1. Redistributions of source code must retain the above copyright
|
||||||
|
* notice, this list of conditions and the following disclaimer.
|
||||||
|
* 2. Redistributions in binary form must reproduce the above copyright
|
||||||
|
* notice, this list of conditions and the following disclaimer in
|
||||||
|
* the documentation and/or other materials provided with the
|
||||||
|
* distribution.
|
||||||
|
* 3. Neither the name NuttX nor the names of its contributors may be
|
||||||
|
* used to endorse or promote products derived from this software
|
||||||
|
* without specific prior written permission.
|
||||||
|
*
|
||||||
|
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||||
|
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||||
|
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
|
||||||
|
* FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
|
||||||
|
* COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
|
||||||
|
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
|
||||||
|
* BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
|
||||||
|
* OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
|
||||||
|
* AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
||||||
|
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
|
||||||
|
* ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||||
|
* POSSIBILITY OF SUCH DAMAGE.
|
||||||
|
*
|
||||||
|
****************************************************************************/
|
||||||
|
|
||||||
|
/****************************************************************************
|
||||||
|
* Included Files
|
||||||
|
****************************************************************************/
|
||||||
|
|
||||||
|
#include <arch/board/board.h>
|
||||||
|
#include <nuttx/config.h>
|
||||||
|
|
||||||
|
#include <nuttx/power/pm.h>
|
||||||
|
#include <arch/irq.h>
|
||||||
|
#include <stdbool.h>
|
||||||
|
#include <debug.h>
|
||||||
|
|
||||||
|
#include "up_arch.h"
|
||||||
|
#include "nvic.h"
|
||||||
|
#include "stm32_pwr.h"
|
||||||
|
#include "stm32_pm.h"
|
||||||
|
#include "stm32f4discovery-internal.h"
|
||||||
|
|
||||||
|
#if defined(CONFIG_PM) && defined(CONFIG_IDLE_CUSTOM) && defined(CONFIG_PM_BUTTONS)
|
||||||
|
|
||||||
|
/****************************************************************************
|
||||||
|
* Pre-processor Definitions
|
||||||
|
****************************************************************************/
|
||||||
|
/* Configuration ************************************************************/
|
||||||
|
|
||||||
|
#ifndef CONFIG_ARCH_BUTTONS
|
||||||
|
# error "CONFIG_ARCH_BUTTONS is not defined in the configuration"
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifndef CONFIG_PM_BUTTONS_NAME0
|
||||||
|
# define CONFIG_PM_BUTTONS_NAME0 "BUTTON0"
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifndef CONFIG_PM_IRQBUTTON
|
||||||
|
# define CONFIG_PM_IRQBUTTON 0
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifndef CONFIG_PM_BUTTON_ACTIVITY
|
||||||
|
# define CONFIG_PM_BUTTON_ACTIVITY 10
|
||||||
|
#endif
|
||||||
|
|
||||||
|
/****************************************************************************
|
||||||
|
* Private Types
|
||||||
|
****************************************************************************/
|
||||||
|
|
||||||
|
struct button_info_s
|
||||||
|
{
|
||||||
|
FAR const char *name; /* Name for the button */
|
||||||
|
#ifdef CONFIG_ARCH_IRQBUTTONS
|
||||||
|
xcpt_t handler; /* Button interrupt handler */
|
||||||
|
#endif
|
||||||
|
};
|
||||||
|
|
||||||
|
/****************************************************************************
|
||||||
|
* Private Function Prototypes
|
||||||
|
****************************************************************************/
|
||||||
|
|
||||||
|
#ifdef CONFIG_ARCH_IRQBUTTONS
|
||||||
|
static void button_handler(int id, int irq);
|
||||||
|
|
||||||
|
#if MIN_BUTTON < 1
|
||||||
|
static int button0_handler(int irq, FAR void *context);
|
||||||
|
#endif
|
||||||
|
#if MIN_BUTTON < 2 && MAX_BUTTON > 0
|
||||||
|
static int button1_handler(int irq, FAR void *context);
|
||||||
|
#endif
|
||||||
|
#if MIN_BUTTON < 3 && MAX_BUTTON > 1
|
||||||
|
static int button2_handler(int irq, FAR void *context);
|
||||||
|
#endif
|
||||||
|
#if MIN_BUTTON < 4 && MAX_BUTTON > 2
|
||||||
|
static int button3_handler(int irq, FAR void *context);
|
||||||
|
#endif
|
||||||
|
#if MIN_BUTTON < 5 && MAX_BUTTON > 3
|
||||||
|
static int button4_handler(int irq, FAR void *context);
|
||||||
|
#endif
|
||||||
|
#if MIN_BUTTON < 6 && MAX_BUTTON > 4
|
||||||
|
static int button5_handler(int irq, FAR void *context);
|
||||||
|
#endif
|
||||||
|
#if MIN_BUTTON < 7 && MAX_BUTTON > 5
|
||||||
|
static int button6_handler(int irq, FAR void *context);
|
||||||
|
#endif
|
||||||
|
#if MAX_BUTTON > 6
|
||||||
|
static int button7_handler(int irq, FAR void *context);
|
||||||
|
#endif
|
||||||
|
#endif /* CONFIG_ARCH_IRQBUTTONS */
|
||||||
|
|
||||||
|
/****************************************************************************
|
||||||
|
* Private Data
|
||||||
|
****************************************************************************/
|
||||||
|
|
||||||
|
/* Button Names */
|
||||||
|
|
||||||
|
static const struct button_info_s g_buttoninfo =
|
||||||
|
{
|
||||||
|
CONFIG_PM_BUTTONS_NAME0,
|
||||||
|
#ifdef CONFIG_ARCH_IRQBUTTONS
|
||||||
|
button0_handler,
|
||||||
|
#endif
|
||||||
|
};
|
||||||
|
|
||||||
|
/****************************************************************************
|
||||||
|
* Private Functions
|
||||||
|
****************************************************************************/
|
||||||
|
|
||||||
|
/****************************************************************************
|
||||||
|
* Name: button_handler
|
||||||
|
*
|
||||||
|
* Description:
|
||||||
|
* Handle a button wake-up interrupt
|
||||||
|
*
|
||||||
|
****************************************************************************/
|
||||||
|
|
||||||
|
#ifdef CONFIG_ARCH_IRQBUTTONS
|
||||||
|
static void button_handler(int id, int irq)
|
||||||
|
{
|
||||||
|
/* At this point the MCU should have already awakened. The state
|
||||||
|
* change will be handled in the IDLE loop when the system is re-awakened
|
||||||
|
* The button interrupt handler should be totally ignorant of the PM
|
||||||
|
* activities and should report button activity as if nothing
|
||||||
|
* special happened.
|
||||||
|
*/
|
||||||
|
|
||||||
|
pm_activity(CONFIG_PM_BUTTON_ACTIVITY);
|
||||||
|
}
|
||||||
|
|
||||||
|
static int button0_handler(int irq, FAR void *context)
|
||||||
|
{
|
||||||
|
button_handler(0, irq);
|
||||||
|
return OK;
|
||||||
|
}
|
||||||
|
|
||||||
|
#endif /* CONFIG_ARCH_IRQBUTTONS */
|
||||||
|
|
||||||
|
/****************************************************************************
|
||||||
|
* Public Functions
|
||||||
|
****************************************************************************/
|
||||||
|
|
||||||
|
/****************************************************************************
|
||||||
|
* Name: up_pmbuttons
|
||||||
|
*
|
||||||
|
* Description:
|
||||||
|
* Configure the user button of the STM32f4discovery board as EXTI,
|
||||||
|
* so it is able to wakeup the MCU from the PM_STANDBY mode
|
||||||
|
*
|
||||||
|
****************************************************************************/
|
||||||
|
|
||||||
|
void up_pmbuttons(void)
|
||||||
|
{
|
||||||
|
/* Initialize the button GPIOs */
|
||||||
|
|
||||||
|
up_buttoninit();
|
||||||
|
|
||||||
|
#ifdef CONFIG_ARCH_IRQBUTTONS
|
||||||
|
xcpt_t oldhandler = up_irqbutton(0, g_buttoninfo.handler);
|
||||||
|
|
||||||
|
if (oldhandler != NULL)
|
||||||
|
{
|
||||||
|
lib_lowprintf("WARNING: oldhandler:%p is not NULL! "
|
||||||
|
"Button events may be lost or aliased!\n",
|
||||||
|
oldhandler);
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
|
||||||
|
#endif /* CONFIG_PM && CONFIG_IDLE_CUSTOM && CONFIG_PM_BUTTONS)*/
|
||||||
@@ -45,6 +45,7 @@
|
|||||||
#include <debug.h>
|
#include <debug.h>
|
||||||
|
|
||||||
#include <arch/board/board.h>
|
#include <arch/board/board.h>
|
||||||
|
#include <nuttx/power/pm.h>
|
||||||
|
|
||||||
#include "chip.h"
|
#include "chip.h"
|
||||||
#include "up_arch.h"
|
#include "up_arch.h"
|
||||||
@@ -82,10 +83,109 @@ static uint32_t g_ledcfg[BOARD_NLEDS] =
|
|||||||
GPIO_LED1, GPIO_LED2, GPIO_LED3, GPIO_LED4
|
GPIO_LED1, GPIO_LED2, GPIO_LED3, GPIO_LED4
|
||||||
};
|
};
|
||||||
|
|
||||||
|
/****************************************************************************
|
||||||
|
* Private Function Protototypes
|
||||||
|
****************************************************************************/
|
||||||
|
|
||||||
|
/* LED Power Management */
|
||||||
|
|
||||||
|
#ifdef CONFIG_PM
|
||||||
|
static void led_pm_notify(struct pm_callback_s *cb, enum pm_state_e pmstate);
|
||||||
|
static int led_pm_prepare(struct pm_callback_s *cb, enum pm_state_e pmstate);
|
||||||
|
#endif
|
||||||
|
|
||||||
|
|
||||||
|
/****************************************************************************
|
||||||
|
* Private Data
|
||||||
|
****************************************************************************/
|
||||||
|
|
||||||
|
#ifdef CONFIG_PM
|
||||||
|
static struct pm_callback_s g_ledscb =
|
||||||
|
{
|
||||||
|
.notify = led_pm_notify,
|
||||||
|
.prepare = led_pm_prepare,
|
||||||
|
};
|
||||||
|
#endif
|
||||||
|
|
||||||
/****************************************************************************
|
/****************************************************************************
|
||||||
* Private Functions
|
* Private Functions
|
||||||
****************************************************************************/
|
****************************************************************************/
|
||||||
|
|
||||||
|
/****************************************************************************
|
||||||
|
* Name: led_pm_notify
|
||||||
|
*
|
||||||
|
* Description:
|
||||||
|
* Notify the driver of new power state. This callback is called after
|
||||||
|
* all drivers have had the opportunity to prepare for the new power state.
|
||||||
|
*
|
||||||
|
****************************************************************************/
|
||||||
|
|
||||||
|
#ifdef CONFIG_PM
|
||||||
|
static void led_pm_notify(struct pm_callback_s *cb , enum pm_state_e pmstate)
|
||||||
|
{
|
||||||
|
switch (pmstate)
|
||||||
|
{
|
||||||
|
case(PM_NORMAL):
|
||||||
|
{
|
||||||
|
/* Restore normal LEDs operation */
|
||||||
|
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
|
||||||
|
case(PM_IDLE):
|
||||||
|
{
|
||||||
|
/* Entering IDLE mode - Turn leds off */
|
||||||
|
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
|
||||||
|
case(PM_STANDBY):
|
||||||
|
{
|
||||||
|
/* Entering STANDBY mode - Logic for PM_STANDBY goes here */
|
||||||
|
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
|
||||||
|
case(PM_SLEEP):
|
||||||
|
{
|
||||||
|
/* Entering SLEEP mode - Logic for PM_SLEEP goes here */
|
||||||
|
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
|
||||||
|
default:
|
||||||
|
{
|
||||||
|
/* Should not get here */
|
||||||
|
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
/****************************************************************************
|
||||||
|
* Name: led_pm_prepare
|
||||||
|
*
|
||||||
|
* Description:
|
||||||
|
* Request the driver to prepare for a new power state. This is a warning
|
||||||
|
* that the system is about to enter into a new power state. The driver
|
||||||
|
* should begin whatever operations that may be required to enter power
|
||||||
|
* state. The driver may abort the state change mode by returning a
|
||||||
|
* non-zero value from the callback function.
|
||||||
|
*
|
||||||
|
****************************************************************************/
|
||||||
|
|
||||||
|
#ifdef CONFIG_PM
|
||||||
|
static int led_pm_prepare(struct pm_callback_s *cb , enum pm_state_e pmstate)
|
||||||
|
{
|
||||||
|
/* No preparation to change power modes is required by the LEDs driver.
|
||||||
|
* We always accept the state change by returning OK.
|
||||||
|
*/
|
||||||
|
|
||||||
|
return OK;
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
/****************************************************************************
|
/****************************************************************************
|
||||||
* Public Functions
|
* Public Functions
|
||||||
****************************************************************************/
|
****************************************************************************/
|
||||||
@@ -128,4 +228,21 @@ void stm32_setleds(uint8_t ledset)
|
|||||||
stm32_gpiowrite(BOARD_LED4, (ledset & BOARD_LED4_BIT) == 0);
|
stm32_gpiowrite(BOARD_LED4, (ledset & BOARD_LED4_BIT) == 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/****************************************************************************
|
||||||
|
* Name: up_ledpminitialize
|
||||||
|
****************************************************************************/
|
||||||
|
|
||||||
|
#ifdef CONFIG_PM
|
||||||
|
void up_ledpminitialize(void)
|
||||||
|
{
|
||||||
|
/* Register to receive power management callbacks */
|
||||||
|
|
||||||
|
int ret = pm_register(&g_ledscb);
|
||||||
|
if (ret != OK)
|
||||||
|
{
|
||||||
|
up_ledon(LED_ASSERTION);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
#endif /* CONFIG_PM */
|
||||||
|
|
||||||
#endif /* !CONFIG_ARCH_LEDS */
|
#endif /* !CONFIG_ARCH_LEDS */
|
||||||
|
|||||||
@@ -247,8 +247,8 @@ extern "C" {
|
|||||||
/* The cfgetspeed() function is a non-POSIX function will extract the baud
|
/* The cfgetspeed() function is a non-POSIX function will extract the baud
|
||||||
* from the termios structure to which the termiosp argument points. NuttX
|
* from the termios structure to which the termiosp argument points. NuttX
|
||||||
* does not control input/output baud independently. Both must be the same.
|
* does not control input/output baud independently. Both must be the same.
|
||||||
* The POSIX standard interfaces, cfisetispeed() and cfisetospeed() are
|
* The POSIX standard interfaces, cfigetispeed() and cfigetospeed() are
|
||||||
* supported by simply defining them to be cfsetspeed().
|
* supported by simply defining them to be cfgetspeed().
|
||||||
*/
|
*/
|
||||||
|
|
||||||
EXTERN speed_t cfgetspeed(FAR const struct termios *termiosp);
|
EXTERN speed_t cfgetspeed(FAR const struct termios *termiosp);
|
||||||
|
|||||||
@@ -74,6 +74,15 @@
|
|||||||
* NOTE 1: NuttX does not control input/output baud independently. Both
|
* NOTE 1: NuttX does not control input/output baud independently. Both
|
||||||
* must be the same. The POSIX standard interfaces, cfisetispeed() and
|
* must be the same. The POSIX standard interfaces, cfisetispeed() and
|
||||||
* cfisetospeed() are defined to be cfsetspeed() in termios.h.
|
* cfisetospeed() are defined to be cfsetspeed() in termios.h.
|
||||||
|
*
|
||||||
|
* NOTE 3: A consequence of NOTE 1 is that you should never attempt to
|
||||||
|
* set the input and output baud to different values.
|
||||||
|
*
|
||||||
|
* Also, the following POSIX requirement cannot be supported: "If the input
|
||||||
|
* baud rate stored in the termios structure pointed to by termios_p is 0,
|
||||||
|
* the input baud rate given to the hardware will be the same as the output
|
||||||
|
* baud rate stored in the termios structure."
|
||||||
|
*
|
||||||
* NOTE 2. In Nuttx, the speed_t is defined to be uint32_t and the baud
|
* NOTE 2. In Nuttx, the speed_t is defined to be uint32_t and the baud
|
||||||
* encodings of termios.h are the actual baud values themselves. Therefore,
|
* encodings of termios.h are the actual baud values themselves. Therefore,
|
||||||
* any baud value can be provided as the speed argument here. However, if
|
* any baud value can be provided as the speed argument here. However, if
|
||||||
@@ -87,7 +96,7 @@
|
|||||||
* termiosp->c_ispeed = baud;
|
* termiosp->c_ispeed = baud;
|
||||||
*
|
*
|
||||||
* cfsetospeed(termiosp, BOTHER);
|
* cfsetospeed(termiosp, BOTHER);
|
||||||
* termiosp->c_ospeed = baud;
|
* termiosp->c_ospeed = baud;
|
||||||
*
|
*
|
||||||
* Input Parameters:
|
* Input Parameters:
|
||||||
* termiosp - The termiosp argument is a pointer to a termios structure.
|
* termiosp - The termiosp argument is a pointer to a termios structure.
|
||||||
|
|||||||
Reference in New Issue
Block a user