Merge commit '1207647ee19ac48746300f2d3fa8f4679c32de95'

This commit is contained in:
Gregory Nutt
2015-01-31 13:47:10 -06:00
27 changed files with 3252 additions and 9 deletions
+41 -2
View File
@@ -51,10 +51,11 @@
* Pre-processor Definitions
****************************************************************************/
/* The ATmega128 has 35 interrupt vectors including vector 0, the reset
* vector. The remaining 34 are assigned IRQ numbers here:
/* ATmega interrupt vectors other than vector 0, the reset vector, are
* assigned here:
*/
#if defined(CONFIG_ARCH_CHIP_ATMEGA128)
#define ATMEGA_IRQ_INT0 0 /* 0x0002 External Interrupt Request 0 */
#define ATMEGA_IRQ_INT1 1 /* 0x0004 External Interrupt Request 1 */
#define ATMEGA_IRQ_INT2 2 /* 0x0006 External Interrupt Request 2 */
@@ -89,6 +90,44 @@
#define ATMEGA_IRQ_U1TX 31 /* 0x0040 USART1 Tx Complete */
#define ATMEGA_IRQ_TWI 32 /* 0x0042 TWI Two-wire Serial Interface */
#define ATMEGA_IRQ_SPMRDY 33 /* 0x0044 Store Program Memory Ready */
#elif defined(CONFIG_ARCH_CHIP_ATMEGA1284P)
#define ATMEGA_IRQ_INT0 0 /* 0x0002 External Interrupt Request 0 */
#define ATMEGA_IRQ_INT1 1 /* 0x0004 External Interrupt Request 1 */
#define ATMEGA_IRQ_INT2 2 /* 0x0006 External Interrupt Request 2 */
#define ATMEGA_IRQ_PCINT0 3 /* 0x0008 Pin Change Interrupt Request 0 */
#define ATMEGA_IRQ_PCINT1 4 /* 0x000a Pin Change Interrupt Request 1 */
#define ATMEGA_IRQ_PCINT2 5 /* 0x000c Pin Change Interrupt Request 2 */
#define ATMEGA_IRQ_PCINT3 6 /* 0x000e Pin Change Interrupt Request 3 */
#define ATMEGA_IRQ_WDT 7 /* 0x0010 Watchdog Time-Out Interrupt */
#define ATMEGA_IRQ_T2COMPA 8 /* 0x0012 TIMER2 COMPA Timer/Counter2 Compare Match */
#define ATMEGA_IRQ_T2COMPB 9 /* 0x0014 TIMER2 COMPB Timer/Counter2 Compare Match */
#define ATMEGA_IRQ_T2OVF 10 /* 0x0016 TIMER2 OVF Timer/Counter2 Overflow */
#define ATMEGA_IRQ_T1CAPT 11 /* 0x0018 TIMER1 CAPT Timer/Counter1 Capture Event */
#define ATMEGA_IRQ_T1COMPA 12 /* 0x001a TIMER1 COMPA Timer/Counter1 Compare Match A */
#define ATMEGA_IRQ_T1COMPB 13 /* 0x001c TIMER1 COMPB Timer/Counter1 Compare Match B */
#define ATMEGA_IRQ_T1OVF 14 /* 0x001e TIMER1 OVF Timer/Counter1 Overflow */
#define ATMEGA_IRQ_T0COMPA 15 /* 0x0020 TIMER0 COMP Timer/Counter0 Compare Match */
#define ATMEGA_IRQ_T0COMPB 16 /* 0x0022 TIMER0 COMP Timer/Counter0 Compare Match */
#define ATMEGA_IRQ_T0OVF 17 /* 0x0024 TIMER0 OVF Timer/Counter0 Overflow */
#define ATMEGA_IRQ_SPI 18 /* 0x0026 STC SPI Serial Transfer Complete */
#define ATMEGA_IRQ_U0RX 19 /* 0x0028 USART0 Rx Complete */
#define ATMEGA_IRQ_U0DRE 20 /* 0x002a USART0 Data Register Empty */
#define ATMEGA_IRQ_U0TX 21 /* 0x002c USART0 Tx Complete */
#define ATMEGA_IRQ_ANACOMP 22 /* 0x002e ANALOG COMP Analog Comparator */
#define ATMEGA_IRQ_ADC 23 /* 0x0030 ADC Conversion Complete */
#define ATMEGA_IRQ_EE 24 /* 0x0032 EEPROM Ready */
#define ATMEGA_IRQ_TWI 25 /* 0x0034 TWI Two-wire Serial Interface */
#define ATMEGA_IRQ_SPMRDY 26 /* 0x0036 Store Program Memory Ready */
#define ATMEGA_IRQ_U1RX 27 /* 0x0038 USART1 Rx Complete */
#define ATMEGA_IRQ_U1DRE 28 /* 0x003a USART1 Data Register Empty */
#define ATMEGA_IRQ_U1TX 29 /* 0x003c USART1 Tx Complete */
#define ATMEGA_IRQ_T3CAPT 30 /* 0x003e TIMER3 CAPT Timer/Counter3 Capture Event */
#define ATMEGA_IRQ_T3COMPA 31 /* 0x0040 TIMER3 COMPA Timer/Counter3 Compare Match A */
#define ATMEGA_IRQ_T3COMPB 32 /* 0x0042 TIMER3 COMPB Timer/Counter3 Compare Match B */
#define ATMEGA_IRQ_T3OVF 33 /* 0x0044 TIMER3 OVF Timer/Counter3 Overflow */
#else
#error "Unrecognized chip"
#endif
#define NR_IRQS 34
+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"
+1 -1
View File
@@ -48,7 +48,7 @@
/* USARTs ***************************************************************************/
#undef HAVE_USART_DEVICE
#if defined(CONFIG_AVR_USART0) || defined(CONFIG_AVR_USART0)
#if defined(CONFIG_AVR_USART0) || defined(CONFIG_AVR_USART1)
# define HAVE_USART_DEVICE 1
#endif
+39
View File
@@ -61,6 +61,7 @@
.section .handlers, "ax", @progbits
#if defined(CONFIG_ARCH_CHIP_ATMEGA128)
HANDLER atmega_int0, ATMEGA_IRQ_INT0, excpt_common /* External interrupt request 0 */
HANDLER atmega_int1, ATMEGA_IRQ_INT1, excpt_common /* External interrupt request 1 */
HANDLER atmega_int2, ATMEGA_IRQ_INT2, excpt_common /* External interrupt request 2 */
@@ -95,6 +96,44 @@
HANDLER atmega_u1tx, ATMEGA_IRQ_U1TX, excpt_common /* USART1 TX complete */
HANDLER atmega_twi, ATMEGA_IRQ_TWI, excpt_common /* TWI two-wire serial interface */
HANDLER atmega_spmrdy, ATMEGA_IRQ_SPMRDY, excpt_common /* Store program memory ready */
#elif defined(CONFIG_ARCH_CHIP_ATMEGA1284P)
HANDLER atmega_int0, ATMEGA_IRQ_INT0, excpt_common /* External interrupt request 0 */
HANDLER atmega_int1, ATMEGA_IRQ_INT1, excpt_common /* External interrupt request 1 */
HANDLER atmega_int2, ATMEGA_IRQ_INT2, excpt_common /* External interrupt request 2 */
HANDLER atmega_pcint0, ATMEGA_IRQ_PCINT0, excpt_common /* Pin change interrupt request 0 */
HANDLER atmega_pcint1, ATMEGA_IRQ_PCINT1, excpt_common /* Pin change interrupt request 1 */
HANDLER atmega_pcint2, ATMEGA_IRQ_PCINT2, excpt_common /* Pin change interrupt request 2 */
HANDLER atmega_pcint3, ATMEGA_IRQ_PCINT3, excpt_common /* Pin change interrupt request 3 */
HANDLER atmega_wdt, ATMEGA_IRQ_WDT, excpt_common /* Watchdog time-out interrupt */
HANDLER atmega_t2compa, ATMEGA_IRQ_T2COMPA, excpt_common /* TIMER2 COMPA timer/counter2 compare match */
HANDLER atmega_t2compb, ATMEGA_IRQ_T2COMPB, excpt_common /* TIMER2 COMPB timer/counter2 compare match */
HANDLER atmega_t2ovf, ATMEGA_IRQ_T2OVF, excpt_common /* TIMER2 OVF timer/counter2 overflow */
HANDLER atmega_t1capt, ATMEGA_IRQ_T1CAPT, excpt_common /* TIMER1 CAPT timer/counter1 capture event */
HANDLER atmega_t1compa, ATMEGA_IRQ_T1COMPA, excpt_common /* TIMER1 COMPA timer/counter1 compare match a */
HANDLER atmega_t1compb, ATMEGA_IRQ_T1COMPB, excpt_common /* TIMER1 COMPB timer/counter1 compare match b */
HANDLER atmega_t1ovf, ATMEGA_IRQ_T1OVF, excpt_common /* TIMER1 OVF timer/counter1 overflow */
HANDLER atmega_t0compa, ATMEGA_IRQ_T0COMPA, excpt_common /* TIMER0 COMPA timer/counter0 compare match */
HANDLER atmega_t0compb, ATMEGA_IRQ_T0COMPB, excpt_common /* TIMER0 COMPB timer/counter0 compare match */
HANDLER atmega_t0ovf, ATMEGA_IRQ_T0OVF, excpt_common /* TIMER0 OVF timer/counter0 overflow */
HANDLER atmega_spi, ATMEGA_IRQ_SPI, excpt_common /* STC SPI serial transfer complete */
HANDLER atmega_u0rx, ATMEGA_IRQ_U0RX, excpt_common /* USART0 RX complete */
HANDLER atmega_u0dre, ATMEGA_IRQ_U0DRE, excpt_common /* USART0 data register empty */
HANDLER atmega_u0tx, ATMEGA_IRQ_U0TX, excpt_common /* USART0 TX complete */
HANDLER atmega_anacomp, ATMEGA_IRQ_ANACOMP, excpt_common /* ANALOG COMP analog comparator */
HANDLER atmega_adc, ATMEGA_IRQ_ADC, excpt_common /* ADC conversion complete */
HANDLER atmega_ee, ATMEGA_IRQ_EE, excpt_common /* EEPROM ready */
HANDLER atmega_twi , ATMEGA_IRQ_TWI, excpt_common /* TWI two-wire serial interface */
HANDLER atmega_spmrdy, ATMEGA_IRQ_SPMRDY, excpt_common /* Store program memory ready */
HANDLER atmega_u1rx, ATMEGA_IRQ_U1RX, excpt_common /* USART1 RX complete */
HANDLER atmega_u1dre, ATMEGA_IRQ_U1DRE, excpt_common /* USART1 data register empty */
HANDLER atmega_u1tx, ATMEGA_IRQ_U1TX, excpt_common /* USART1 TX complete */
HANDLER atmega_t3capt, ATMEGA_IRQ_T3CAPT, excpt_common /* TIMER3 CAPT timer/counter3 capture event */
HANDLER atmega_t3compa, ATMEGA_IRQ_T3COMPA, excpt_common /* TIMER3 COMPA timer/counter3 compare match a */
HANDLER atmega_t3compb, ATMEGA_IRQ_T3COMPB, excpt_common /* TIMER3 COMPB timer/counter3 compare match b */
HANDLER atmega_t3ovf, ATMEGA_IRQ_T3OVF, excpt_common /* TIMER3 OVF timer/counter3 overflow */
#else
#error "Unrecognized chip"
#endif
/********************************************************************************************
* Name: excpt_common
+78
View File
@@ -77,6 +77,7 @@
.global os_start /* NuttX entry point */
.global vectortab
#if defined(CONFIG_ARCH_CHIP_ATMEGA128)
.global atmega_int0 /* External interrupt request 0 */
.global atmega_int1 /* External interrupt request 1 */
.global atmega_int2 /* External interrupt request 2 */
@@ -111,6 +112,44 @@
.global atmega_u1tx /* USART1 TX complete */
.global atmega_twi /* TWI two-wire serial interface */
.global atmega_spmrdy /* Store program memory ready */
#elif defined(CONFIG_ARCH_CHIP_ATMEGA1284P)
.global atmega_int0 /* External interrupt request 0 */
.global atmega_int1 /* External interrupt request 1 */
.global atmega_int2 /* External interrupt request 2 */
.global atmega_pcint0 /* Pin change interrupt request 0 */
.global atmega_pcint1 /* Pin change interrupt request 1 */
.global atmega_pcint2 /* Pin change interrupt request 2 */
.global atmega_pcint3 /* Pin change interrupt request 3 */
.global atmega_wdt /* Watchdog time-out interrupt */
.global atmega_t2compa /* TIMER2 COMPA timer/counter2 compare match */
.global atmega_t2compb /* TIMER2 COMPB timer/counter2 compare match */
.global atmega_t2ovf /* TIMER2 OVF timer/counter2 overflow */
.global atmega_t1capt /* TIMER1 CAPT timer/counter1 capture event */
.global atmega_t1compa /* TIMER1 COMPA timer/counter1 compare match a */
.global atmega_t1compb /* TIMER1 COMPB timer/counter1 compare match b */
.global atmega_t1ovf /* TIMER1 OVF timer/counter1 overflow */
.global atmega_t0compa /* TIMER0 COMPA timer/counter0 compare match */
.global atmega_t0compb /* TIMER0 COMPB timer/counter0 compare match */
.global atmega_t0ovf /* TIMER0 OVF timer/counter0 overflow */
.global atmega_spi /* STC SPI serial transfer complete */
.global atmega_u0rx /* USART0 RX complete */
.global atmega_u0dre /* USART0 data register empty */
.global atmega_u0tx /* USART0 TX complete */
.global atmega_anacomp /* ANALOG COMP analog comparator */
.global atmega_adc /* ADC conversion complete */
.global atmega_ee /* EEPROM ready */
.global atmega_twi /* TWI two-wire serial interface */
.global atmega_spmrdy /* Store program memory ready */
.global atmega_u1rx /* USART1 RX complete */
.global atmega_u1dre /* USART1 data register empty */
.global atmega_u1tx /* USART1 TX complete */
.global atmega_t3capt /* TIMER3 CAPT timer/counter3 capture event */
.global atmega_t3compa /* TIMER3 COMPA timer/counter3 compare match a */
.global atmega_t3compb /* TIMER3 COMPB timer/counter3 compare match b */
.global atmega_t3ovf /* TIMER3 OVF timer/counter3 overflow */
#else
#error "Unrecognized chip"
#endif
/****************************************************************************
* Macros
@@ -132,6 +171,7 @@
.func vectortab
vectortab:
jmp __start /* 0: Vector 0 is the reset vector */
#if defined(CONFIG_ARCH_CHIP_ATMEGA128)
vector atmega_int0 /* 1: External interrupt request 0 */
vector atmega_int1 /* 2: External interrupt request 1 */
vector atmega_int2 /* 3: External interrupt request 2 */
@@ -166,6 +206,44 @@ vectortab:
vector atmega_u1tx /* 32: USART1 TX complete */
vector atmega_twi /* 33: TWI two-wire serial interface */
vector atmega_spmrdy /* 34: Store program memory ready */
#elif defined(CONFIG_ARCH_CHIP_ATMEGA1284P)
vector atmega_int0 /* External interrupt request 0 */
vector atmega_int1 /* External interrupt request 1 */
vector atmega_int2 /* External interrupt request 2 */
vector atmega_pcint0 /* Pin change interrupt request 0 */
vector atmega_pcint1 /* Pin change interrupt request 1 */
vector atmega_pcint2 /* Pin change interrupt request 2 */
vector atmega_pcint3 /* Pin change interrupt request 3 */
vector atmega_wdt /* Watchdog time-out interrupt */
vector atmega_t2compa /* TIMER2 COMPA timer/counter2 compare match */
vector atmega_t2compb /* TIMER2 COMPB timer/counter2 compare match */
vector atmega_t2ovf /* TIMER2 OVF timer/counter2 overflow */
vector atmega_t1capt /* TIMER1 CAPT timer/counter1 capture event */
vector atmega_t1compa /* TIMER1 COMPA timer/counter1 compare match a */
vector atmega_t1compb /* TIMER1 COMPB timer/counter1 compare match b */
vector atmega_t1ovf /* TIMER1 OVF timer/counter1 overflow */
vector atmega_t0compa /* TIMER0 COMPA timer/counter0 compare match */
vector atmega_t0compb /* TIMER0 COMPB timer/counter0 compare match */
vector atmega_t0ovf /* TIMER0 OVF timer/counter0 overflow */
vector atmega_spi /* STC SPI serial transfer complete */
vector atmega_u0rx /* USART0 RX complete */
vector atmega_u0dre /* USART0 data register empty */
vector atmega_u0tx /* USART0 TX complete */
vector atmega_anacomp /* ANALOG COMP analog comparator */
vector atmega_adc /* ADC conversion complete */
vector atmega_ee /* EEPROM ready */
vector atmega_twi /* TWI two-wire serial interface */
vector atmega_spmrdy /* Store program memory ready */
vector atmega_u1rx /* USART1 RX complete */
vector atmega_u1dre /* USART1 data register empty */
vector atmega_u1tx /* USART1 TX complete */
vector atmega_t3capt /* TIMER3 CAPT timer/counter3 capture event */
vector atmega_t3compa /* TIMER3 COMPA timer/counter3 compare match a */
vector atmega_t3compb /* TIMER3 COMPB timer/counter3 compare match b */
vector atmega_t3ovf /* TIMER3 OVF timer/counter3 overflow */
#else
#error "Unrecognized chip"
#endif
.endfunc
/****************************************************************************
+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 */
+2 -5
View File
@@ -897,7 +897,7 @@ void up_earlyserialinit(void)
{
/* Disable all USARTS */
#ifdef CONFIG_AVR_USART1
#ifdef CONFIG_AVR_USART0
usart0_disableusartint(NULL);
#endif
#ifdef CONFIG_AVR_USART1
@@ -949,9 +949,6 @@ void up_serialinit(void)
*
****************************************************************************/
#ifdef HAVE_SERIAL_CONSOLE
#endif
int up_putc(int ch)
{
#ifdef HAVE_SERIAL_CONSOLE
@@ -960,7 +957,7 @@ int up_putc(int ch)
#if defined(CONFIG_USART0_SERIAL_CONSOLE)
usart0_disableusartint(&imr);
#else
usart1_cdisableusartint(&imr);
usart1_disableusartint(&imr);
#endif
/* Check for LF */
+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.
#
+276
View File
@@ -0,0 +1,276 @@
README
^^^^^^
This port conributed by jeditekunum.
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 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
^^^^^^^^^^^^^^^
-------------------- -----------------------------
ATMega1284P Pinout MoteinoMEGA board connection
-------------------- -----------------------------
(left)
1 AREF AR
2 PA7 A7
3 PA6 A6
4 PA5 A5
5 PA4 A4
6 PA3 A3
7 PA2 A2
8 PA1 A1
9 PA0 A0
10 PB0 0
11 PB1 1
12 PB2 (INT2) 2/i2 (used by optional radio)
13 PB3 (PWM0) 3
14 PB4 (PWM1/SS) 4/SS (used by optional radio)
15 PB5 (MOSI) 5/MO (used by optional radio/flash)
16 PB6 (MISO/PWM2) 6/MI (used by optional radio/flash)
17 PB7 (SCK/PWM3) 7/SCK (used by optional radio/flash)
18 VOUT 3v3
19 VIN VIN
20 GND GND
(bottom)
21 DTR/RTS DTR
22 TX0 v
23 RX0 ^
24 VIN
25
26 GND GND
(right)
27 GND GND
28 VIN VIN
29 VOUT 3v3
30 RESET RST
31 PD0 (RX0) 8/Serial 0 ^
32 PD1 (TX0) 9/Serial 0 v
33 PD2 (RX1/INT0) 10/Serial 0 ^/i0
34 PD3 (TX1/INT1) 11/Serial 1 v/i1
35 PD4 (PWM4) 12
36 PD5 (PWM5) 13
37 PD6 (PWM6) 14
38 PD7 (PWM7) 15/LED
39 PC0 (SCL) 16/SCL
40 PC1 (SDA) 17/SDA
41 PC2 (TCK) 18
42 PC3 (TMS) 19
43 PC4 (TDO) 20
44 PC5 (TDI) 21
45 PC6 22
46 PC7 23 (used by optional flash)
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.
This port was tested using the OS X / CROSSPACK tool chain, GCC version 4.8.1.
Please see other NuttX documentation for toolchain details.
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_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.
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.
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
+215
View File
@@ -0,0 +1,215 @@
/**************************************************************************************
* 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)
*(.progmem.gcc*)
*(.progmem*)
*(.init)
*(.handlers)
*(.text)
*(.text.*)
_etext = . ;
} > flash
_eronly = ABSOLUTE(.);
.data :
{
_sdata = ABSOLUTE(.);
*(.data .data.*)
*(.rodata)
*(.rodata*)
*(.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
+215
View File
@@ -0,0 +1,215 @@
/**************************************************************************************
* 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)
*(.progmem.gcc*)
*(.progmem*)
*(.init)
*(.handlers)
*(.text)
*(.text.*)
_etext = . ;
} > flash
_eronly = ABSOLUTE(.);
.data :
{
_sdata = ABSOLUTE(.);
*(.data .data.*)
*(.rodata)
*(.rodata*)
*(.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 */