First step at porting to MoteinoMEGA. LED shows assert failure at boot. Appears to be short double blink, short off (~1sec), followed by 250ms toggle cycles. Most of it derived from amber board.

This commit is contained in:
jeditekunum
2015-01-24 14:31:35 -06:00
parent 1dd722f836
commit b050703849
22 changed files with 3099 additions and 1 deletions
+5
View File
@@ -15,6 +15,11 @@ config ARCH_CHIP_ATMEGA128
---help---
Atmel ATMega128 8-bit AVR.
config ARCH_CHIP_ATMEGA1284P
bool "ATMega1284P"
---help---
Atmel ATMega1284P 8-bit AVR.
endchoice # ATMega Configuration Options
menu "ATMega Peripheral Selections"
+23 -1
View File
@@ -218,8 +218,13 @@ void usart0_reset(void)
/* Unconfigure pins (no action needed */
#ifdef CONFIG_ARCH_CHIP_ATMEGA1284P
DDRD &= ~(1 << 1);
PORTD &= ~(1 << 0);
#else
DDRE &= ~(1 << 1);
PORTE &= ~(1 << 0);
#endif
/* Unconfigure BAUD divisor */
@@ -309,6 +314,22 @@ void usart0_configure(void)
UCSR0B = ucsr0b;
UCSR0C = ucsr0c;
#ifdef CONFIG_ARCH_CHIP_ATMEGA1284P
/* Pin Configuration: None necessary, Port D bits 0&1 are automatically
* configured:
*
* Port D, Bit 0: RXD0, USART0 Receive Pin. Receive Data (Data input pin
* for the USART0). When the USART0 receiver is enabled this pin is
* configured as an input regardless of the value of DDRD0. When the
* USART0 forces this pin to be an input, a logical one in PORTD0 will
* turn on the internal pull-up.
*
* Port D, Bit 1: TXD0, UART0 Transmit pin.
*/
DDRD |= (1 << 1); /* Force Port D pin 1 to be an output -- should not be necessary */
PORTD |= (1 << 0); /* Set pull-up on Port D pin 0 */
#else
/* Pin Configuration: None necessary, Port E bits 0&1 are automatically
* configured:
*
@@ -324,8 +345,9 @@ void usart0_configure(void)
* However, this is not explicitly stated in the text.
*/
DDRE |= (1 << 1); /* Force Port E pin 1 to be an input -- might not be necessary */
DDRE |= (1 << 1); /* Force Port E pin 1 to be an output -- might not be necessary */
PORTE |= (1 << 0); /* Set pull-up on Port E pin 0 */
#endif
/* Set the baud rate divisor */
+5
View File
@@ -128,7 +128,12 @@ void up_lowinit(void)
/* Set the system clock divider to 1 */
#ifdef CONFIG_ARCH_CHIP_ATMEGA1284P
CLKPR = 0x80;
CLKPR = 0;
#else
XDIV = 0;
#endif
/* Initialize the watchdog timer */
+4
View File
@@ -177,5 +177,9 @@ void up_timer_initialize(void)
/* Enable the interrupt on compare match A */
#ifdef CONFIG_ARCH_CHIP_ATMEGA1284P
TIMSK1 |= (1 << OCIE1A);
#else
TIMSK |= (1 << OCIE1A);
#endif
}
+2
View File
@@ -70,6 +70,8 @@ endif
ifeq ($(CONFIG_ARCH_CHIP_ATMEGA128),y)
ARCHCPUFLAGS += -mmcu=atmega128
else ifeq ($(CONFIG_ARCH_CHIP_ATMEGA1284P),y)
ARCHCPUFLAGS += -mmcu=atmega1284p
else ifeq ($(CONFIG_ARCH_CHIP_AT90USB646),y)
ARCHCPUFLAGS += -mmcu=at90usb646
else ifeq ($(CONFIG_ARCH_CHIP_AT90USB647),y)
+13
View File
@@ -318,6 +318,15 @@ config ARCH_BOARD_MICROPENDOUS3
be populated with either an AVR AT90USB646, 647, 1286, or 1287 MCU.
Support is configured for the AT90USB647.
config ARCH_BOARD_MOTEINO_MEGA
bool "LowPowerLab MoteinoMEGA"
depends on ARCH_CHIP_ATMEGA1284P
select ARCH_HAVE_LEDS
---help---
This is placeholder for the LowPowerLab MoteinoMEGA that is based
on the Atmel AVR ATMega1284P MCU. There is not much there yet and what is
there is untested due to tool-related issues.
config ARCH_BOARD_MX1ADS
bool "Motorola MX1ADS development board"
depends on ARCH_CHIP_IMX1
@@ -1065,6 +1074,7 @@ config ARCH_BOARD
default "mcu123-lpc214x" if ARCH_BOARD_MCU123_LPC214X
default "micropendous3" if ARCH_BOARD_MICROPENDOUS3
default "mirtoo" if ARCH_BOARD_MIRTOO
default "moteino-mega" if ARCH_BOARD_MOTEINO_MEGA
default "mx1ads" if ARCH_BOARD_MX1ADS
default "ne64badge" if ARCH_BOARD_NE64BADGE
default "ntosd-dm320" if ARCH_BOARD_NTOSD_DM320
@@ -1288,6 +1298,9 @@ endif
if ARCH_BOARD_MIRTOO
source "configs/mirtoo/Kconfig"
endif
if ARCH_BOARD_MOTEINO_MEGA
source "configs/moteino-mega/Kconfig"
endif
if ARCH_BOARD_MX1ADS
source "configs/mx1ads/Kconfig"
endif
+4
View File
@@ -0,0 +1,4 @@
#
# For a description of the syntax of this configuration file,
# see misc/tools/kconfig-language.txt.
#
+491
View File
@@ -0,0 +1,491 @@
README
^^^^^^
**********************************************************************
**** PRELIMINARY - Port in progress ****
**********************************************************************
This is the README file for the port of NuttX to the MoteinoMEGA from
LowPowerLab (http://www.lowpowerlab.com). The MoteinoMEGA is based
on an Atmel ATMega1284P. As of this writing, documentation for the
MoteinoMEGA board is available here:
https://lowpowerlab.com/shop/index.php?_route_=Moteino/moteinomega
Contents
^^^^^^^^
o MoteinoMEGA Features
o Pin Connections
o DualOptiboot Bootloader
o Toolchains
o Windows Native Toolchains
o NuttX buildroot Toolchain
o avr-libc
o MoteinoMEGA Configuration Options
o Configurations
MoteinoMEGA Features
^^^^^^^^^^^^^^^^^^^^
o 16MHz ATmega1284P Atmel 8bit AVR RISC Processor
o 128Kbyte Flash
o 16Kbyte RAM
o 4Kbyte EEPROM
o 2 High Speed Serial Ports
o 8Ch 10bit Analog Input port
Pin Connections (PCB Rev ?)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
-------------------- -----------------------------
ATMega1284P Pinout MoteinoMEGA board connection
-------------------- -----------------------------
**********************************************************************
**** INVALID - Port in progress ****
**********************************************************************
(left)
1 PEN Pulled-up
2 PE0 (RXD0/PDI) MAX202ECWED T1IN or J7-1, ISP-PDI (via 74HC5053), J5-26
3 PE1 (TXD0/PDO) MAX202ECWED A1OUT or J7-9, ISP-PDO (via 74HC5053), J5-25
4 PE2 (XCK0/AIN0) MAX202ECWED T2IN, J5-24
5 PE3 (OC3A/AIN1) MAX202ECWED A2OUT, J5-23
6 PE4 (OC3B/INT4) J5-22
7 PE5 (OC3C/INT5) J5-21, RTL8019AS INT 0, TP5 PE5
8 PE6 (T3/INT6) J5-20
9 PE7 (ICP3/INT7) J5-19
10 PB0 (SS) Pull up of SS SPI master
11 PB1 (SCK) J7-7, ISP_SCK (via 74HC4053) and AT45D011 SCK, J5-17
12 PB2 (MOSI) AT45D011 SI. J5-16
13 PB3 (MISO) AT45D011 SO, J5-15
14 PB4 (OC0) AT45D011 CS\, J5-14
15 PB5 (OC1A) J5-13
16 PB6 (OC1B) J5-12
(bottom)
17 PB7 (OC2/OC1C) J5-11
18 PG3/TOSC2 32.768KHz XTAL
19 PG4/TOSC1 32.768KHz XTAL
20 RESET RESET
21 VCC
22 GND GND
23 XTAL2 14.7456MHz XTAL
24 XTAL1 14.7456MHz XTAL
25 PD0 (SCL/INT0) J5-10
26 PD1 (SDA/INT1) J5-9
27 PD2 (RXD1/INT2) J5-8, MAX488CSA RO (RS-485)
28 PD3 (TXD1/INT3) J5-7, MAX488CSA DI (RS-485)
29 PD4 (ICP1) J5-6
30 PD5 (XCK1) J5-5
31 PD6 (T1) J5-4
32 PD7 (T2) J5-3
(left)
48 PA3 (AD3) J5-?, 74HC5730, 62246DLP-7, RTL8019AS
47 PA4 (AD4) J5-?, 74HC5730, 62246DLP-7, RTL8019AS
46 PA5 (AD5) J5-?, 74HC5730, 62246DLP-7, RTL8019AS
45 PA6 (AD6) J5-?, 74HC5730, 62246DLP-7, RTL8019AS
44 PA7 (AD7) J5-?, 74HC5730, 62246DLP-7, RTL8019AS
43 PG2 (ALE) J5-1, 74HC5730, 62246DLP-7, RTL8019AS
42 PC7 (A15) TP4 A15, J5-27, 74HC5730
41 PC6 (A14) J5-28, 74HC5730, 62246DLP-7, RTL8019AS
40 PC5 (A13) J5-29, 74HC5730, 62246DLP-7, RTL8019AS
39 PC4 (A12) J5-30, 74HC5730, 62246DLP-7, RTL8019AS
38 PC3 (A11) J5-31, 74HC5730, 62246DLP-7, RTL8019AS
37 PC2 (A10) J5-32, 74HC5730, 62246DLP-7, RTL8019AS
36 PC1 (A9) J5-33, 74HC5730, 62246DLP-7, RTL8019AS
35 PC0 (A8) J5-34, 74HC5730, 62246DLP-7, RTL8019AS
34 PG1 (RD) TP2 RD\, J5-52, 62246DLP-7, RTL8019AS
33 PG0 (WR) TP3 WR\, J5-51, 62246DLP-7, RTL8019AS
(top)
64 AVCC
63 GND GND
62 AREF (analog supply)
61 PF0 (ADC0) J6-5, PDV-P9 Light Sensor
60 PF1 (ADC1) J6-7, Thermister
59 PF2 (ADC2) J6-9, MXA2500GL Dual Axis Accesserometer, AOUTX
58 PF3 (ADC3) J6-11, MXA2500GL Dual Axis Accesserometer, AOUTY
57 PF4 (ADC4/TCK) J6-13, MXA2500GL Dual Axis Accesserometer, TOUT
56 PF5 (ADC5/TMS) J6-15
55 PF6 (ADC6/TDO) J6-17
54 PF7 (ADC7/TDI) J6-19
53 GND GND
52 VCC
51 PA0 (AD0) J5-?, 74HC5730, 62246DLP-7, RTL8019AS
50 PA1 (AD1) J5-?, 74HC5730, 62246DLP-7, RTL8019AS
49 PA2 (AD2) J5-?, 74HC5730, 62246DLP-7, RTL8019AS
DualOptiboot Bootloader
^^^^^^^^^^^^^^^^^^^^^^^
o FTDI (or similar) USB-To-Serial converter with compatible connector
configured for DTR (AdaFruit, SparkFun, etc)
o Obtain ard-reset-arduino Python script
(one source: https://github.com/mikaelpatel/Cosa/blob/master/build/Arduino-Makefile/bin/ard-reset-arduino)
This script triggers the DTR pin to enter bootloader mode.
o Obtain avrdude for your platform.
Bootloader operates at 115200 baud. It would be useful to create a short script
that invokes ard-reset-arduino and then avrdude to load program. This script
could then also, optionally, invoke miniterm.py or some other serial interface
program for console.
Example:
APP=nuttx
CPU=atmega1284p
BAUD=115200
PORT=/dev/tty.usbserial-A703X8PQ
avr-size --mcu=$CPU -C --format=avr $APP
ard-reset-arduino --verbose $PORT
avrdude -q -V -p $CPU -C {location-of-avrdude.conf} -D -c arduino -b $BAUD \
-P $PORT -U flash:w:${APP}.hex:i
miniterm.py --port=$PORT --baud=$BAUD -q --lf
Toolchains
^^^^^^^^^^
The toolchain may be selected using the kconfig-mconf tool (via 'make menuconfig'),
by editing the existing configuration file (defconfig), or by overriding
the toolchain on the make commandline with CONFIG_AVR_TOOLCHAIN=<toolchain>.
The valid values for <toolchain> are BUILDROOT, CROSSPACK, LINUXGCC and WINAVR.
Buildroot:
There is a DIY buildroot version for the AVR boards here:
http://sourceforge.net/projects/nuttx/files/buildroot/. See the
following section for details on building this toolchain.
It is assumed in some places that buildroot toolchain is available
at ../misc/buildroot/build_avr. Edit the setenv.sh file if
this is not the case.
After configuring NuttX, make sure that CONFIG_AVR_BUILDROOT=y is set in your
.config file.
WinAVR:
For Cygwin development environment on Windows machines, you can use
WinAVR: http://sourceforge.net/projects/winavr/files/
It is assumed in some places that WinAVR is installed at C:/WinAVR. Edit the
setenv.sh file if this is not the case.
After configuring NuttX, make sure that CONFIG_AVR_WINAVR=y is set in your
.config file.
WARNING: There is an incompatible version of cygwin.dll in the WinAVR/bin
directory! Make sure that the path to the correct cygwin.dll file precedes
the path to the WinAVR binaries!
Linux:
For Linux, there are widely available avr-gcc packages. On Ubuntu, use:
sudo apt-get install gcc-avr gdb-avr avr-libc
After configuring NuttX, make sure that CONFIG_AVR_LINUXGCC=y is set in your
.config file.
Mac OS X:
For Mac OS X, the CrossPack for AVR toolchain is available from:
http://www.obdev.at/products/crosspack/index.html
This toolchain is functionally equivalent to the Linux GCC toolchain.
Windows Native Toolchains
^^^^^^^^^^^^^^^^^^^^^^^^^
The WinAVR toolchain is a Windows native toolchain. There are several
limitations to using a Windows native toolchain in a Cygwin environment.
The three biggest are:
1. The Windows toolchain cannot follow Cygwin paths. Path conversions are
performed automatically in the Cygwin makefiles using the 'cygpath'
utility but you might easily find some new path problems. If so, check
out 'cygpath -w'
2. Windows toolchains cannot follow Cygwin symbolic links. Many symbolic
links are used in Nuttx (e.g., include/arch). The make system works
around these problems for the Windows tools by copying directories
instead of linking them. But this can also cause some confusion for
you: For example, you may edit a file in a "linked" directory and find
that your changes had no effect. That is because you are building the
copy of the file in the "fake" symbolic directory. If you use a
Windows toolchain, you should get in the habit of making like this:
make clean_context all
An alias in your .bashrc file might make that less painful.
3. Dependencies are not made when using Windows versions of the GCC. This
is because the dependencies are generated using Windows pathes which do
not work with the Cygwin make.
MKDEP = $(TOPDIR)/tools/mknulldeps.sh
An additional issue with the WinAVR toolchain, in particular, is that it
contains an incompatible version of the Cygwin DLL in its bin/ directory.
You must take care that the correct Cygwin DLL is used.
NuttX buildroot Toolchain
^^^^^^^^^^^^^^^^^^^^^^^^^
If NuttX buildroot toolchain source tarball cne can be downloaded from the
NuttX SourceForge download site (https://sourceforge.net/projects/nuttx/files/).
This GNU toolchain builds and executes in the Linux or Cygwin environment.
1. You must have already configured Nuttx in <some-dir>/nuttx.
cd tools
./configure.sh amber/<sub-dir>
NOTE: you also must copy avr-libc header files into the NuttX include
directory with command perhaps like:
cp -a /cygdrive/c/WinAVR/include/avr include/.
2. Download the latest buildroot package into <some-dir>
3. unpack the buildroot tarball. The resulting directory may
have versioning information on it like buildroot-x.y.z. If so,
rename <some-dir>/buildroot-x.y.z to <some-dir>/buildroot.
4. cd <some-dir>/buildroot
5. cp configs/avr-defconfig-4.5.2 .config
6. make oldconfig
7. make
8. Edit setenv.h, if necessary, so that the PATH variable includes
the path to the newly built binaries.
See the file configs/README.txt in the buildroot source tree. That has more
detailed PLUS some special instructions that you will need to follow if you
are building a toolchain for Cygwin under Windows.
avr-libc
^^^^^^^^
Header Files
In any case, header files from avr-libc are required: http://www.nongnu.org/avr-libc/.
A snapshot of avr-lib is included in the WinAVR installation. For Linux
development platforms, avr-libc package is readily available (and would
be installed in the apt-get command shown above). But if you are using
the NuttX buildroot configuration on Cygwin, then you will have to build
get avr-libc from binaries.
Header File Installation
The NuttX build will required that the AVR header files be available via
the NuttX include directory. This can be accomplished by either copying
the avr-libc header files into the NuttX include directory:
cp -a <avr-libc-path>/include/avr <nuttx-path>/include/.
Or simply using a symbolic link:
ln -s <avr-libc-path>/include/avr <nuttx-path>/include/.
Build Notes:
It may not necessary to have a built version of avr-lib; only header files
are required. Bu if you choose to use the optimized libraru functions of
the flowing point library, then you may have to build avr-lib from sources.
Below are instructions for building avr-lib from fresh sources:
1. Download the avr-libc package from:
http://savannah.nongnu.org/projects/avr-libc/
I am using avr-lib-1.7.1.tar.bz2
2. Upack the tarball and cd into the
tar jxf avr-lib-1.7.1.tar.bz2
cd avr-lib-1.7.1
3. Configure avr-lib. Assuming that WinAVR is installed at the following
loction:
export PATH=/cygdrive/c/WinAVR/bin:$PATH
./configure --build=`./config.guess` --host=avr
This takes a *long* time.
4. Make avr-lib.
make
This also takes a long time because it generates variants for nearly
all AVR chips.
5. Install avr-lib.
make install
MoteinoMEGA Configuration Options
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
CONFIG_ARCH - Identifies the arch/ subdirectory. This should
be set to:
CONFIG_ARCH=avr
CONFIG_ARCH_FAMILY - For use in C code:
CONFIG_ARCH_FAMILY=avr
CONFIG_ARCH_FAMILY_family - For use in C code:
CONFIG_ARCH_FAMILY_AVR=y
CONFIG_ARCH_CHIP - Identifies the arch/*/chip subdirectory
CONFIG_ARCH_CHIP=atmega
CONFIG_ARCH_CHIP_name - For use in C code to identify the exact
chip:
CONFIG_ARCH_CHIP_ATMEGA1284P=y
CONFIG_ARCH_BOARD - Identifies the configs subdirectory and
hence, the board that supports the particular chip or SoC.
CONFIG_ARCH_BOARD=moteino-mega
CONFIG_ARCH_BOARD_name - For use in C code
CONFIG_ARCH_BOARD_MOTEINO_MEGA=y
CONFIG_ARCH_LOOPSPERMSEC - Must be calibrated for correct operation
of delay loops
CONFIG_ENDIAN_BIG - define if big endian (default is little
endian)
CONFIG_RAM_SIZE - Describes the installed DRAM. One of:
CONFIG_RAM_SIZE=(16*1024) - (16Kb)
CONFIG_RAM_START - The start address of installed SRAM
CONFIG_RAM_START=0x800100
CONFIG_ARCH_LEDS - Use LEDs to show state. Unique to boards that
have LEDs
CONFIG_ARCH_INTERRUPTSTACK - This architecture supports an interrupt
stack. If defined, this symbol is the size of the interrupt
stack in bytes. If not defined, the user task stacks will be
used during interrupt handling.
CONFIG_ARCH_STACKDUMP - Do stack dumps after assertions
CONFIG_ARCH_LEDS - Use LEDs to show state. Unique to board architecture.
CONFIG_ARCH_CALIBRATION - Enables some build in instrumentation that
cause a 100 second delay during boot-up. This 100 second delay
serves no purpose other than it allows you to calibratre
CONFIG_ARCH_LOOPSPERMSEC. You simply use a stop watch to measure
the 100 second delay then adjust CONFIG_ARCH_LOOPSPERMSEC until
the delay actually is 100 seconds.
Individual subsystems can be enabled:
CONFIG_AVR_INT0=n
CONFIG_AVR_INT1=n
CONFIG_AVR_INT2=n
CONFIG_AVR_INT3=n
CONFIG_AVR_INT4=n
CONFIG_AVR_INT5=n
CONFIG_AVR_INT6=n
CONFIG_AVR_INT7=n
CONFIG_AVR_WDT=n
CONFIG_AVR_TIMER0=n
CONFIG_AVR_TIMER1=n
CONFIG_AVR_TIMER2=n
CONFIG_AVR_TIMER3=n
CONFIG_AVR_SPI=n
CONFIG_AVR_USART0=y
CONFIG_AVR_USART1=n
CONFIG_AVR_ADC=n
CONFIG_AVR_ANACOMP=n
CONFIG_AVR_TWI=n
If the watchdog is enabled, this specifies the initial timeout. Default
is maximum supported value.
CONFIG_WDTO_15MS
CONFIG_WDTO_30MS
CONFIG_WDTO_60MS
CONFIG_WDTO_120MS
CONFIG_WDTO_1250MS
CONFIG_WDTO_500MS
CONFIG_WDTO_1S
CONFIG_WDTO_2S
CONFIG_WDTO_4S
CONFIG_WDTO_8S
ATMEGA specific device driver settings
CONFIG_USARTn_SERIAL_CONSOLE - selects the USARTn for the
console and ttys0 (default is the USART0).
CONFIG_USARTn_RXBUFSIZE - Characters are buffered as received.
This specific the size of the receive buffer
CONFIG_USARTn_TXBUFSIZE - Characters are buffered before
being sent. This specific the size of the transmit buffer
CONFIG_USARTn_BAUD - The configure BAUD of the USART. Must be
CONFIG_USARTn_BITS - The number of bits. Must be either 7 or 8.
CONFIG_USARTn_PARTIY - 0=no parity, 1=odd parity, 2=even parity
CONFIG_USARTn_2STOP - Two stop bits
Configurations
^^^^^^^^^^^^^^
Common Configuration Notes
--------------------------
1. Each MoteinoMEGA configuration is maintained in a sub-directory and
can be selected as follow:
cd tools
./configure.sh moteino-mega/<subdir>
cd -
. ./setenv.sh
Where <subdir> is one of the configuration sub-directories described in
the following paragraph.
NOTE: You must also copy avr-libc header files, perhaps like:
cp -a /cygdrive/c/WinAVR/include/avr include/.
2. These configurations use the mconf-based configuration tool. To
change a configurations using that tool, you should:
a. Build and install the kconfig-mconf tool. See nuttx/README.txt
and misc/tools/
b. Execute 'make menuconfig' in nuttx/ in order to start the
reconfiguration process.
3. By default, all configurations assume the NuttX Buildroot toolchain
under Cygwin with Windows. This is easily reconfigured:
CONFIG_HOST_WINDOWS=y
CONFIG_WINDOWS_CYGWIN=y
CONFIG_AVR_BUILDROOT=y
Configuration Sub-Directories
-----------------------------
hello:
The simple apps/examples/hello "Hello, World!" example.
nsh:
Configures the NuttShell (nsh) located at examples/nsh. The
Configuration enables only the serial NSH interfaces.
+98
View File
@@ -0,0 +1,98 @@
############################################################################
# configs/moteino-mega/hello/Make.defs
#
# Copyright (C) 2015 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
include ${TOPDIR}/tools/Config.mk
include ${TOPDIR}/arch/avr/src/avr/Toolchain.defs
ifeq ($(WINTOOL),y)
# Windows-native toolchains
DIRLINK = $(TOPDIR)/tools/copydir.sh
DIRUNLINK = $(TOPDIR)/tools/unlink.sh
MKDEP = $(TOPDIR)/tools/mknulldeps.sh
ARCHINCLUDES = -I. -isystem "${shell cygpath -w $(TOPDIR)/include}"
ARCHXXINCLUDES = $(ARCHINCLUDES) "${shell cygpath -w $(TOPDIR)/include/cxx}"
ARCHSCRIPT = -T "${shell cygpath -w $(TOPDIR)/configs/$(CONFIG_ARCH_BOARD)/hello/ld.script}"
else
# Linux/Cygwin-native toolchain
MKDEP = $(TOPDIR)/tools/mkdeps.sh
ARCHINCLUDES = -I. -isystem "$(TOPDIR)/include"
ARCHXXINCLUDES = $(ARCHINCLUDES) -isystem "$(TOPDIR)/include/cxx"
ARCHSCRIPT = -T$(TOPDIR)/configs/$(CONFIG_ARCH_BOARD)/hello/ld.script
endif
CC = $(CROSSDEV)gcc
CXX = $(CROSSDEV)g++
CPP = $(CROSSDEV)gcc -E
LD = $(CROSSDEV)ld
AR = $(CROSSDEV)ar rcs
NM = $(CROSSDEV)nm
OBJCOPY = $(CROSSDEV)objcopy
OBJDUMP = $(CROSSDEV)objdump
ifeq ($(CONFIG_DEBUG_SYMBOLS),y)
ARCHOPTIMIZATION = -g
endif
ifneq ($(CONFIG_DEBUG_NOOPT),y)
ARCHOPTIMIZATION += $(MAXOPTIMIZATION) -fno-strict-aliasing -fno-strength-reduce -fomit-frame-pointer
endif
ARCHCFLAGS = -fno-builtin
ARCHCXXFLAGS = -fno-builtin -fno-exceptions
ARCHWARNINGS = -Wall -Wstrict-prototypes -Wshadow
ARCHWARNINGSXX = -Wall -Wshadow
ARCHDEFINES =
CFLAGS = $(ARCHCFLAGS) $(ARCHWARNINGS) $(ARCHOPTIMIZATION) $(ARCHCPUFLAGS) $(ARCHINCLUDES) $(ARCHDEFINES) $(EXTRADEFINES) -pipe
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-gotoff.ld -no-check-sections
LDNXFLATFLAGS = -e main -s 2048
OBJEXT = .o
LIBEXT = .a
EXEEXT =
HOSTCC = gcc
HOSTINCLUDES = -I.
HOSTCFLAGS = -Wall -Wstrict-prototypes -Wshadow -g -pipe
HOSTLDFLAGS =
File diff suppressed because it is too large Load Diff
+211
View File
@@ -0,0 +1,211 @@
/**************************************************************************************
* configs/moteino-mega/hello/ld.script
*
* Copyright (C) 2015 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.
*
**************************************************************************************/
/* Memory Regions *********************************************************************/
/* -------------- ------ ------+------- -- ------ -- ------ --- ------ ----+------- ---
* FLASH | REGISTERS I/O EXT I/O ISRAM | EEPROM
* | REGISTERS REGISTERS |
* -------------- ------ ------+------- -- ------ -- ------ --- ------ ----+------- ---
* ATMEGA1284P 0x0000 128Kb | 0x0000 32 0x0020 64 0x0060 160 0x0100 16Kb| 0x0000 4Kb
* -------------- ------ ------+------- -- ------ -- ------ --- ------ ----+------- ---
* *Memory configuration A
*/
MEMORY
{
flash (rx) : ORIGIN = 0, LENGTH = 128K
sram (rw!x) : ORIGIN = 0x800100, LENGTH = 16K
eeprom (rw!x) : ORIGIN = 0x810000, LENGTH = 4K
}
OUTPUT_FORMAT("elf32-avr","elf32-avr","elf32-avr")
OUTPUT_ARCH(avr:5)
ENTRY(__start)
SECTIONS
{
/* Read-only sections, merged into text segment: */
.hash : { *(.hash) }
.dynsym : { *(.dynsym) }
.dynstr : { *(.dynstr) }
.gnu.version : { *(.gnu.version) }
.gnu.version_d : { *(.gnu.version_d) }
.gnu.version_r : { *(.gnu.version_r) }
.rel.init : { *(.rel.init) }
.rela.init : { *(.rela.init) }
.rel.text :
{
*(.rel.text)
*(.rel.text.*)
*(.rel.gnu.linkonce.t*)
}
.rela.text :
{
*(.rela.text)
*(.rela.text.*)
*(.rela.gnu.linkonce.t*)
}
.rel.fini : { *(.rel.fini) }
.rela.fini : { *(.rela.fini) }
.rel.rodata :
{
*(.rel.rodata)
*(.rel.rodata.*)
*(.rel.gnu.linkonce.r*)
}
.rela.rodata :
{
*(.rela.rodata)
*(.rela.rodata.*)
*(.rela.gnu.linkonce.r*)
}
.rel.data :
{
*(.rel.data)
*(.rel.data.*)
*(.rel.gnu.linkonce.d*)
}
.rela.data :
{
*(.rela.data)
*(.rela.data.*)
*(.rela.gnu.linkonce.d*)
}
.rel.ctors : { *(.rel.ctors) }
.rela.ctors : { *(.rela.ctors) }
.rel.dtors : { *(.rel.dtors) }
.rela.dtors : { *(.rela.dtors) }
.rel.got : { *(.rel.got) }
.rela.got : { *(.rela.got) }
.rel.bss : { *(.rel.bss) }
.rela.bss : { *(.rela.bss) }
.rel.plt : { *(.rel.plt) }
.rela.plt : { *(.rela.plt) }
.text :
{
_stext = . ;
*(.vectors)
*(.init)
*(.handlers)
*(.text)
*(.text.*)
_etext = . ;
} > flash
_eronly = ABSOLUTE(.);
.data :
{
_sdata = ABSOLUTE(.);
*(.data .data.*)
*(.gnu.linkonce.d.*)
CONSTRUCTORS
_edata = ABSOLUTE(.);
} > sram AT > flash
.bss :
{
_sbss = ABSOLUTE(.);
*(.bss .bss.*)
*(.gnu.linkonce.b.*)
*(COMMON)
_ebss = ABSOLUTE(.);
} > sram
/* Global data not cleared after reset. */
.noinit :
{
_snoinit = ABSOLUTE(.);
*(.noinit*)
_enoinit = ABSOLUTE(.);
} > sram
.eeprom :
{
_seeprom = ABSOLUTE(.);
*(.eeprom*)
_eeeprom = ABSOLUTE(.);
} > eeprom
/* 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) }
/* DWARF debug sections.
Symbols in the DWARF debugging sections are relative to the beginning
of the section so we begin them at 0. */
/* DWARF 1 */
.debug 0 : { *(.debug) }
.line 0 : { *(.line) }
/* GNU DWARF 1 extensions */
.debug_srcinfo 0 : { *(.debug_srcinfo) }
.debug_sfnames 0 : { *(.debug_sfnames) }
/* DWARF 1.1 and DWARF 2 */
.debug_aranges 0 : { *(.debug_aranges) }
.debug_pubnames 0 : { *(.debug_pubnames) }
/* DWARF 2 */
.debug_info 0 : { *(.debug_info) *(.gnu.linkonce.wi.*) }
.debug_abbrev 0 : { *(.debug_abbrev) }
.debug_line 0 : { *(.debug_line) }
.debug_frame 0 : { *(.debug_frame) }
.debug_str 0 : { *(.debug_str) }
.debug_loc 0 : { *(.debug_loc) }
.debug_macinfo 0 : { *(.debug_macinfo) }
}
+63
View File
@@ -0,0 +1,63 @@
#!/bin/bash
# configs/moteino-mega/hello/setenv.sh
#
# Copyright (C) 2015 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 is the Cygwin path to the location where I installed the WinAVR
# toolchain under windows. This is *not* the default install
# location so you will probably have to edit this. You will also have
# to edit this if you install the Linux AVR toolchain as well
#export TOOLCHAIN_BIN="/cygdrive/c/WinAVR/bin"
# This is the Cygwin path to the location where I build the buildroot
# toolchain.
export TOOLCHAIN_BIN="${WD}/../misc/buildroot/build_avr/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}"
+97
View File
@@ -0,0 +1,97 @@
/****************************************************************************
* configs/moteino-mega/include/board.h
* include/arch/board/board.h
*
* Copyright (C) 2015 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.
*
****************************************************************************/
#ifndef __CONFIGS_MOTEINO_MEGA_INCLUDE_BOARD_H
#define __CONFIGS_MOTEINO_MEGA_INCLUDE_BOARD_H
/****************************************************************************
* Included Files
****************************************************************************/
#include <nuttx/config.h>
/****************************************************************************
* Pre-Processor Definitions
****************************************************************************/
/* Configuration ************************************************************/
/* Clocking *****************************************************************/
/* Assume default CLKDIV8 fuse setting is overridden to CLKDIV1 */
#define BOARD_XTAL_FREQ 16000000 /* 16MHz crystal */
#define BOARD_CPU_CLOCK BOARD_XTAL_FREQ /* F_CPU = 16MHz */
/* LED definitions **********************************************************/
/* The MoteinoMEGA has a single on-board LED connected to PortD, Pin 7 */
#define LED_STARTED 0 /* OFF ON (never happens) */
#define LED_HEAPALLOCATE 0 /* OFF ON (never happens) */
#define LED_IRQSENABLED 0 /* OFF ON (never happens) */
#define LED_STACKCREATED 1 /* ON ON (never happens) */
#define LED_INIRQ 2 /* OFF NC (momentary) */
#define LED_SIGNAL 2 /* OFF NC (momentary) */
#define LED_ASSERTION 2 /* OFF NC (momentary) */
#define LED_PANIC 0 /* OFF ON (1Hz flashing) */
/****************************************************************************
* Public Types
****************************************************************************/
#ifndef __ASSEMBLY__
/****************************************************************************
* Inline Functions
****************************************************************************/
/****************************************************************************
* Public Function Prototypes
****************************************************************************/
#ifdef __cplusplus
#define EXTERN extern "C"
extern "C" {
#else
#define EXTERN extern
#endif
#undef EXTERN
#ifdef __cplusplus
}
#endif
#endif /* __ASSEMBLY__ */
#endif /* __CONFIGS_MOTEINO_MEGA_INCLUDE_BOARD_H */
+98
View File
@@ -0,0 +1,98 @@
############################################################################
# configs/moteino-mega/nsh/Make.defs
#
# Copyright (C) 2015 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
include ${TOPDIR}/tools/Config.mk
include ${TOPDIR}/arch/avr/src/avr/Toolchain.defs
ifeq ($(WINTOOL),y)
# Windows-native toolchains
DIRLINK = $(TOPDIR)/tools/copydir.sh
DIRUNLINK = $(TOPDIR)/tools/unlink.sh
MKDEP = $(TOPDIR)/tools/mknulldeps.sh
ARCHINCLUDES = -I. -isystem "${shell cygpath -w $(TOPDIR)/include}"
ARCHXXINCLUDES = $(ARCHINCLUDES) "${shell cygpath -w $(TOPDIR)/include/cxx}"
ARCHSCRIPT = -T "${shell cygpath -w $(TOPDIR)/configs/$(CONFIG_ARCH_BOARD)/nsh/ld.script}"
else
# Linux/Cygwin-native toolchain
MKDEP = $(TOPDIR)/tools/mkdeps.sh
ARCHINCLUDES = -I. -isystem "$(TOPDIR)/include"
ARCHXXINCLUDES = $(ARCHINCLUDES) -isystem "$(TOPDIR)/include/cxx"
ARCHSCRIPT = -T$(TOPDIR)/configs/$(CONFIG_ARCH_BOARD)/nsh/ld.script
endif
CC = $(CROSSDEV)gcc
CXX = $(CROSSDEV)g++
CPP = $(CROSSDEV)gcc -E
LD = $(CROSSDEV)ld
AR = $(CROSSDEV)ar rcs
NM = $(CROSSDEV)nm
OBJCOPY = $(CROSSDEV)objcopy
OBJDUMP = $(CROSSDEV)objdump
ifeq ($(CONFIG_DEBUG_SYMBOLS),y)
ARCHOPTIMIZATION = -g
endif
ifneq ($(CONFIG_DEBUG_NOOPT),y)
ARCHOPTIMIZATION += $(MAXOPTIMIZATION) -fno-strict-aliasing -fno-strength-reduce -fomit-frame-pointer
endif
ARCHCFLAGS = -fno-builtin
ARCHCXXFLAGS = -fno-builtin -fno-exceptions
ARCHWARNINGS = -Wall -Wstrict-prototypes -Wshadow
ARCHWARNINGSXX = -Wall -Wshadow
ARCHDEFINES =
CFLAGS = $(ARCHCFLAGS) $(ARCHWARNINGS) $(ARCHOPTIMIZATION) $(ARCHCPUFLAGS) $(ARCHINCLUDES) $(ARCHDEFINES) $(EXTRADEFINES) -pipe
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-gotoff.ld -no-check-sections
LDNXFLATFLAGS = -e main -s 2048
OBJEXT = .o
LIBEXT = .a
EXEEXT =
HOSTCC = gcc
HOSTINCLUDES = -I.
HOSTCFLAGS = -Wall -Wstrict-prototypes -Wshadow -g -pipe
HOSTLDFLAGS =
File diff suppressed because it is too large Load Diff
+211
View File
@@ -0,0 +1,211 @@
/**************************************************************************************
* configs/moteino-mega/nsh/ld.script
*
* Copyright (C) 2015 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.
*
**************************************************************************************/
/* Memory Regions *********************************************************************/
/* -------------- ------ ------+------- -- ------ -- ------ --- ------ ----+------- ---
* FLASH | REGISTERS I/O EXT I/O ISRAM | EEPROM
* | REGISTERS REGISTERS |
* -------------- ------ ------+------- -- ------ -- ------ --- ------ ----+------- ---
* ATMEGA1284P 0x0000 128Kb | 0x0000 32 0x0020 64 0x0060 160 0x0100 16Kb| 0x0000 4Kb
* -------------- ------ ------+------- -- ------ -- ------ --- ------ ----+------- ---
* *Memory configuration A
*/
MEMORY
{
flash (rx) : ORIGIN = 0, LENGTH = 128K
sram (rw!x) : ORIGIN = 0x800100, LENGTH = 16K
eeprom (rw!x) : ORIGIN = 0x810000, LENGTH = 4K
}
OUTPUT_FORMAT("elf32-avr","elf32-avr","elf32-avr")
OUTPUT_ARCH(avr:5)
ENTRY(__start)
SECTIONS
{
/* Read-only sections, merged into text segment: */
.hash : { *(.hash) }
.dynsym : { *(.dynsym) }
.dynstr : { *(.dynstr) }
.gnu.version : { *(.gnu.version) }
.gnu.version_d : { *(.gnu.version_d) }
.gnu.version_r : { *(.gnu.version_r) }
.rel.init : { *(.rel.init) }
.rela.init : { *(.rela.init) }
.rel.text :
{
*(.rel.text)
*(.rel.text.*)
*(.rel.gnu.linkonce.t*)
}
.rela.text :
{
*(.rela.text)
*(.rela.text.*)
*(.rela.gnu.linkonce.t*)
}
.rel.fini : { *(.rel.fini) }
.rela.fini : { *(.rela.fini) }
.rel.rodata :
{
*(.rel.rodata)
*(.rel.rodata.*)
*(.rel.gnu.linkonce.r*)
}
.rela.rodata :
{
*(.rela.rodata)
*(.rela.rodata.*)
*(.rela.gnu.linkonce.r*)
}
.rel.data :
{
*(.rel.data)
*(.rel.data.*)
*(.rel.gnu.linkonce.d*)
}
.rela.data :
{
*(.rela.data)
*(.rela.data.*)
*(.rela.gnu.linkonce.d*)
}
.rel.ctors : { *(.rel.ctors) }
.rela.ctors : { *(.rela.ctors) }
.rel.dtors : { *(.rel.dtors) }
.rela.dtors : { *(.rela.dtors) }
.rel.got : { *(.rel.got) }
.rela.got : { *(.rela.got) }
.rel.bss : { *(.rel.bss) }
.rela.bss : { *(.rela.bss) }
.rel.plt : { *(.rel.plt) }
.rela.plt : { *(.rela.plt) }
.text :
{
_stext = . ;
*(.vectors)
*(.init)
*(.handlers)
*(.text)
*(.text.*)
_etext = . ;
} > flash
_eronly = ABSOLUTE(.);
.data :
{
_sdata = ABSOLUTE(.);
*(.data .data.*)
*(.gnu.linkonce.d.*)
CONSTRUCTORS
_edata = ABSOLUTE(.);
} > sram AT > flash
.bss :
{
_sbss = ABSOLUTE(.);
*(.bss .bss.*)
*(.gnu.linkonce.b.*)
*(COMMON)
_ebss = ABSOLUTE(.);
} > sram
/* Global data not cleared after reset. */
.noinit :
{
_snoinit = ABSOLUTE(.);
*(.noinit*)
_enoinit = ABSOLUTE(.);
} > sram
.eeprom :
{
_seeprom = ABSOLUTE(.);
*(.eeprom*)
_eeeprom = ABSOLUTE(.);
} > eeprom
/* 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) }
/* DWARF debug sections.
Symbols in the DWARF debugging sections are relative to the beginning
of the section so we begin them at 0. */
/* DWARF 1 */
.debug 0 : { *(.debug) }
.line 0 : { *(.line) }
/* GNU DWARF 1 extensions */
.debug_srcinfo 0 : { *(.debug_srcinfo) }
.debug_sfnames 0 : { *(.debug_sfnames) }
/* DWARF 1.1 and DWARF 2 */
.debug_aranges 0 : { *(.debug_aranges) }
.debug_pubnames 0 : { *(.debug_pubnames) }
/* DWARF 2 */
.debug_info 0 : { *(.debug_info) *(.gnu.linkonce.wi.*) }
.debug_abbrev 0 : { *(.debug_abbrev) }
.debug_line 0 : { *(.debug_line) }
.debug_frame 0 : { *(.debug_frame) }
.debug_str 0 : { *(.debug_str) }
.debug_loc 0 : { *(.debug_loc) }
.debug_macinfo 0 : { *(.debug_macinfo) }
}
+63
View File
@@ -0,0 +1,63 @@
#!/bin/bash
# configs/moteino-mega/nsh/setenv.sh
#
# Copyright (C) 2015 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 is the Cygwin path to the location where I installed the WinAVR
# toolchain under windows. This is *not* the default install
# location so you will probably have to edit this. You will also have
# to edit this if you install the Linux AVR toolchain as well
#export TOOLCHAIN_BIN="/cygdrive/c/WinAVR/bin"
# This is the Cygwin path to the location where I build the buildroot
# toolchain.
export TOOLCHAIN_BIN="${WD}/../misc/buildroot/build_avr/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
View File
@@ -0,0 +1,2 @@
/.depend
/Make.dep
+96
View File
@@ -0,0 +1,96 @@
############################################################################
# configs/moteino-mega/src/Makefile
#
# Copyright (C) 2015 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)/Make.defs
ASRCS =
CSRCS = up_boot.c
ifeq ($(CONFIG_ARCH_LEDS),y)
CSRCS += up_leds.c
endif
AOBJS = $(ASRCS:.S=$(OBJEXT))
COBJS = $(CSRCS:.c=$(OBJEXT))
SRCS = $(ASRCS) $(CSRCS)
OBJS = $(AOBJS) $(COBJS)
ARCH_SRCDIR = $(TOPDIR)/arch/$(CONFIG_ARCH)/src
ifeq ($(CONFIG_ARCH_FAMILY_AVR32),y)
ARCH_SUBDIR = avr32
endif
ifeq ($(CONFIG_ARCH_FAMILY_AVR),y)
ARCH_SUBDIR = avr
endif
ifeq ($(WINTOOL),y)
CFLAGS += -I "${shell cygpath -w $(TOPDIR)/sched}"
CFLAGS += -I "${shell cygpath -w $(ARCH_SRCDIR)/chip}"
CFLAGS += -I "${shell cygpath -w $(ARCH_SRCDIR)/common}"
CFLAGS += -I "${shell cygpath -w $(ARCH_SRCDIR)/$(ARCH_SUBDIR)}"
else
CFLAGS += -I "$(TOPDIR)/sched"
CFLAGS += -I "$(ARCH_SRCDIR)/chip"
CFLAGS += -I "$(ARCH_SRCDIR)/common"
CFLAGS += -I "$(ARCH_SRCDIR)/$(ARCH_SUBDIR)"
endif
all: libboard$(LIBEXT)
$(AOBJS): %$(OBJEXT): %.S
$(call ASSEMBLE, $<, $@)
$(COBJS) $(LINKOBJS): %$(OBJEXT): %.c
$(call COMPILE, $<, $@)
libboard$(LIBEXT): $(OBJS)
$(call ARCHIVE, $@, $(OBJS))
.depend: Makefile $(SRCS)
$(Q) $(MKDEP) $(CC) -- $(CFLAGS) -- $(SRCS) >Make.dep
$(Q) touch $@
depend: .depend
clean:
$(call DELFILE, libboard$(LIBEXT))
$(call CLEAN)
distclean: clean
$(call DELFILE, Make.dep)
$(call DELFILE, .depend)
-include Make.dep
@@ -0,0 +1,101 @@
/****************************************************************************
* configs/moteino-mega/src/moteino-mega-internal.h
*
* Copyright (C) 2015 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.
*
****************************************************************************/
#ifndef __CONFIGS_MOTEINO_MEGA_SRC_MOTEINO_MEGA_INTERNAL_H
#define __CONFIGS_MOTEINO_MEGA_SRC_MOTEINO_MEGA_INTERNAL_H
/****************************************************************************
* Included Files
****************************************************************************/
#include <nuttx/config.h>
/****************************************************************************
* Pre-Processor Definitions
****************************************************************************/
/* Configuration ************************************************************/
/****************************************************************************
* Public Types
****************************************************************************/
#ifndef __ASSEMBLY__
/****************************************************************************
* Inline Functions
****************************************************************************/
/****************************************************************************
* Public Function Prototypes
****************************************************************************/
#ifdef __cplusplus
#define EXTERN extern "C"
extern "C" {
#else
#define EXTERN extern
#endif
/************************************************************************************
* Name: atmega_spiinitialize
*
* Description:
* Called to configure SPI chip select GPIO pins for the Amber Web Server.
*
************************************************************************************/
#if defined(CONFIG_AVR_SPI1) || defined(CONFIG_AVR_SPI2)
EXTERN void weak_function atmega_spiinitialize(void);
#endif
/************************************************************************************
* Name: atmega_ledinit
*
* Description:
* Configure on-board LEDs if LED support has been selected.
*
************************************************************************************/
#ifdef CONFIG_ARCH_LEDS
EXTERN void atmega_ledinit(void);
#endif
#undef EXTERN
#ifdef __cplusplus
}
#endif
#endif /* __ASSEMBLY__ */
#endif /* __CONFIGS_MOTEINO_MEGA_SRC_MOTEINO_MEGA_INTERNAL_H */
+92
View File
@@ -0,0 +1,92 @@
/************************************************************************************
* configs/moteino-mega/src/up_boot.c
*
* Copyright (C) 2015 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.
*
************************************************************************************/
/************************************************************************************
* Included Files
************************************************************************************/
#include <nuttx/config.h>
#include <debug.h>
#include <arch/board/board.h>
#include "up_arch.h"
#include "up_internal.h"
#include "atmega_internal.h"
#include "moteino_mega_internal.h"
/************************************************************************************
* Definitions
************************************************************************************/
/************************************************************************************
* Private Functions
************************************************************************************/
/************************************************************************************
* Public Functions
************************************************************************************/
/************************************************************************************
* Name: up_boardinitialize
*
* Description:
* All ATMega architectures must provide the following entry point. This entry
* point is called early in the intitialization -- after all memory has been
* configured and mapped but before any devices have been initialized.
*
************************************************************************************/
void up_boardinitialize(void)
{
/* Configure SSP chip selects if 1) at least one SSP is enabled, and 2) the weak
* function atmega_spiinitialize() has been brought into the link.
*/
#if defined(CONFIG_AVR_SPI1) || defined(CONFIG_AVR_SPI2)
if (atmega_spiinitialize)
{
atmega_spiinitialize();
}
#endif
/* Configure on-board LEDs if LED support has been selected. */
#ifdef CONFIG_ARCH_LEDS
atmega_ledinit();
#endif
}
+189
View File
@@ -0,0 +1,189 @@
/****************************************************************************
* configs/moteino-mega/src/up_leds.c
*
* Copyright (C) 2015 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.
*
****************************************************************************/
/****************************************************************************
* Included Files
****************************************************************************/
#include <nuttx/config.h>
#include <stdbool.h>
#include <debug.h>
#include <avr/io.h>
#include "up_arch.h"
#include "up_internal.h"
#include "atmega_internal.h"
#include "moteino_mega_internal.h"
#ifdef CONFIG_ARCH_LEDS
/****************************************************************************
* Definitions
****************************************************************************/
/* CONFIG_DEBUG_LEDS enables debug output from this file (needs CONFIG_DEBUG
* with CONFIG_DEBUG_VERBOSE too)
*/
#ifdef CONFIG_DEBUG_LEDS
# define leddbg lldbg
# ifdef CONFIG_DEBUG_VERBOSE
# define ledvdbg lldbg
# else
# define ledvdbg(x...)
# endif
#else
# define leddbg(x...)
# define ledvdbg(x...)
#endif
/****************************************************************************
* Private Data
****************************************************************************/
static bool g_ncoff;
/****************************************************************************
* Private Functions
****************************************************************************/
/****************************************************************************
* Public Functions
****************************************************************************/
/****************************************************************************
* Name: atmega_ledinit
****************************************************************************/
void atmega_ledinit(void)
{
/* The MoteinoMEGA's single LED is on Port D, Pin 7. Configure this pin as an
* output and turn it OFF. The "other" side of the LED is onnected to
* ground through a resistor. Therefore, a logic value of 0 should turn
* the LED off.
*/
DDRD |= (1 << 7);
PORTD &= ~(1 << 7);
g_ncoff = true;
}
/****************************************************************************
* Name: board_led_on
****************************************************************************/
void board_led_on(int led)
{
/* ON OFF
* LED_STARTED 0 OFF ON (never happens)
* LED_HEAPALLOCATE 0 OFF ON (never happens)
* LED_IRQSENABLED 0 OFF ON (never happens)
* LED_STACKCREATED 1 ON ON (never happens)
* LED_INIRQ 2 OFF NC (momentary)
* LED_SIGNAL 2 OFF NC (momentary)
* LED_ASSERTION 2 OFF NC (momentary)
* LED_PANIC 0 OFF ON (1Hz flashing)
*/
switch (led)
{
case 0:
/* The steady state is OFF */
g_ncoff = true;
case 2:
/* Turn the LED off */
PORTD &= ~(1 << 7);
break;
case 1:
/* The steady state is ON */
PORTD |= (1 << 7);
g_ncoff = false;
break;
default:
return;
}
}
/****************************************************************************
* Name: board_led_off
****************************************************************************/
void board_led_off(int led)
{
/* ON OFF
* LED_STARTED 0 OFF ON (never happens)
* LED_HEAPALLOCATE 0 OFF ON (never happens)
* LED_IRQSENABLED 0 OFF ON (never happens)
* LED_STACKCREATED 1 ON ON (never happens)
* LED_INIRQ 2 OFF NC (momentary)
* LED_SIGNAL 2 OFF NC (momentary)
* LED_ASSERTION 2 OFF NC (momentary)
* LED_PANIC 0 OFF ON (1Hz flashing)
*/
switch (led)
{
case 2:
/* If the "no-change" state is OFF, then turn the LED off */
if (g_ncoff)
{
PORTD &= ~(1 << 7);
break;
}
/* Otherwise, fall through to turn the LED ON */
case 0:
case 1:
/* Turn the LED on */
PORTD |= (1 << 7);
break;
default:
return;
}
}
#endif /* CONFIG_ARCH_LEDS */