avr: Add support to Atmega mega1284p_xplained board

This commit is contained in:
Alan Carvalho de Assis 2023-03-18 13:36:51 -03:00 committed by Petro Karashchenko
parent c839fc45af
commit b91042e5a0
16 changed files with 890 additions and 0 deletions

Binary file not shown.

After

Width:  |  Height:  |  Size: 107 KiB

View File

@ -0,0 +1,55 @@
=========================
Atmega MEGA1284P-XPLAINED
=========================
The `MEGA1284P-XPLAINED <https://www.microchip.com/en-us/development-tool/ATMEGA1284P-XPLD>`_
is a development board for the Atmega1284P from Microchip/Atmel.
.. figure:: board.jpg
:align: center
Microchip/Atmega MEGA1284P-XPLAINED
Features
========
- Atmega1284P MCU, 128K FLASH, 16K SRAM
- 11.0592 MHz crystal
- 32768 Hz crystal
- Embedded AVR911 compatible programmer
- Reset button
- 4 user buttons (3 switch and 1 touch button)
- 4 LEDs indicator (connected to PWM pins)
- Light sensor
- NTC sensor
- Not populated external SPI Flash with labels: AT45DB and AT25DF
- Power indicator LED
Pin Mapping
===========
===== ========== ==========
Pin Signal Notes
===== ========== ==========
P0.24 Blue LED Active LOW
P0.23 Red LED Active LOW
P0.22 Green LED Active LOW
P0.20 UART TX
P0.19 UART RX
===== ========== ==========
Configurations
==============
nsh
---
Basic NuttShell configuration (console enabled in USART0, pins PD0 (RXD0) and PD1 (TXD0), at 115200 bps).
Flash & Debug
=============
You can flash the board using avrdure. First press and hold SW0 button, then press and release RESET button, after 1 second release the SW0 button. Now run the command::
$ avrdude -p atmega1284p -c avr910 -P /dev/ttyACM0 -b57600 -F -u -U flash:w:nuttx.hex:i

View File

@ -0,0 +1,65 @@
===========
Atmega1284P
===========
The Atmega1284P is a chip from Microchip ("inherited" from Atmel) with the
following features:
- 16MHz 8bit AVR RISC Processor
- 128Kbyte Flash
- 16Kbyte RAM
- 4Kbyte EEPROM
- 2 High Speed Serial Ports
- 2 8-bit Timer/Counters
- 2 16-bit Timer/Counter
- 1 Master/Slave SPI
- 1 I2C controller (aka Two-Wire interface)
- 8Ch 10bit Analog Input port
- up to 32 GPIOs
- Watchdog timer
- Real Time Clock
- JTAG/OCD Interface
Clock Configuration
===================
System Timer
============
Peripheral Support
==================
The following list indicates peripherals supported in NuttX:
========== ======= =====
Peripheral Support Notes
========== ======= =====
GPIO Yes
PWM No
ADC No
RTC No
WTD No
I2C No
SPI No
TIMER Yes
UART Yes
========== ======= =====
UART
----
UART is implemented using interrupts. The chip doesn't support DMA.
TIMER
-----
The TIMER peripheral is exposed as standard timer.
Supported Boards
================
.. toctree::
:glob:
:maxdepth: 1
boards/*/*

View File

@ -0,0 +1,11 @@
====
AVR8
====
The following AVR8 chips are supported:
.. toctree::
:maxdepth: 1
:glob:
*/*

View File

@ -913,6 +913,13 @@ config ARCH_BOARD_MCU123_LPC214X
lpc214x development board. This OS is also built with the arm-nuttx-elf
toolchain*. The port supports serial, timer0, spi, and usb.
config ARCH_BOARD_MEGA1284P_XPLAINED
bool "Atmel MEGA-1284P-XPLAINED"
depends on ARCH_CHIP_ATMEGA1284P
select ARCH_HAVE_LEDS
---help---
This is the configuration to support Atmel MEGA-1284P-XPLAINED board.
config ARCH_BOARD_METRO_M4
bool "Adafruit M4 Metro"
depends on ARCH_CHIP_SAMD51J19
@ -2850,6 +2857,7 @@ config ARCH_BOARD
default "mbed" if ARCH_BOARD_MBED
default "mcb1700" if ARCH_BOARD_MCB1700
default "mcu123-lpc214x" if ARCH_BOARD_MCU123_LPC214X
default "mega1284p-xplained" if ARCH_BOARD_MEGA1284P_XPLAINED
default "metro-m4" if ARCH_BOARD_METRO_M4
default "micropendous3" if ARCH_BOARD_MICROPENDOUS3
default "mirtoo" if ARCH_BOARD_MIRTOO
@ -3682,6 +3690,9 @@ endif
if ARCH_BOARD_AVR32DEV1
source "boards/avr/at32uc3/avr32dev1/Kconfig"
endif
if ARCH_BOARD_MEGA1284P_XPLAINED
source "boards/avr/atmega/mega1284p-xplained/Kconfig"
endif
if ARCH_BOARD_MICROPENDOUS3
source "boards/avr/at90usb/micropendous3/Kconfig"
endif

View File

@ -0,0 +1,4 @@
#
# For a description of the syntax of this configuration file,
# see the file kconfig-language.txt in the NuttX tools repository.
#

View File

@ -0,0 +1,8 @@
README
^^^^^^
NuttX Documentation now is online!
You can find the documentation to this board at:
https://nuttx.apache.org/docs/latest/platforms/avr/atmega/boards/mega1284p-xplained/index.html

View File

@ -0,0 +1,35 @@
#
# This file is autogenerated: PLEASE DO NOT EDIT IT.
#
# You can use "make menuconfig" to make any modifications to the installed .config file.
# You can then do "make savedefconfig" to generate a new defconfig file that includes your
# modifications.
#
CONFIG_ARCH="avr"
CONFIG_ARCH_AVR=y
CONFIG_ARCH_BOARD="mega1284p-xplained"
CONFIG_ARCH_BOARD_MEGA1284P_XPLAINED=y
CONFIG_ARCH_CHIP="atmega"
CONFIG_ARCH_CHIP_ATMEGA1284P=y
CONFIG_ARCH_CHIP_ATMEGA=y
CONFIG_ARCH_STACKDUMP=y
CONFIG_AVR_LINUXGCC_TOOLCHAIN=y
CONFIG_AVR_USART0=y
CONFIG_BOARD_LOOPSPERMSEC=888
CONFIG_CONSOLE_SYSLOG=y
CONFIG_DEFAULT_SMALL=y
CONFIG_DISABLE_MOUNTPOINT=y
CONFIG_EXAMPLES_HELLO=y
CONFIG_IDLETHREAD_STACKSIZE=512
CONFIG_INIT_ENTRYPOINT="hello_main"
CONFIG_INIT_STACKSIZE=512
CONFIG_INTELHEX_BINARY=y
CONFIG_NFILE_DESCRIPTORS_PER_BLOCK=4
CONFIG_NUNGET_CHARS=0
CONFIG_PTHREAD_STACK_DEFAULT=512
CONFIG_RAM_SIZE=16384
CONFIG_RAM_START=0x800100
CONFIG_START_DAY=31
CONFIG_START_YEAR=2015
CONFIG_TASK_NAME_SIZE=0
CONFIG_USART0_SERIAL_CONSOLE=y

View File

@ -0,0 +1,39 @@
#
# This file is autogenerated: PLEASE DO NOT EDIT IT.
#
# You can use "make menuconfig" to make any modifications to the installed .config file.
# You can then do "make savedefconfig" to generate a new defconfig file that includes your
# modifications.
#
# CONFIG_DISABLE_ENVIRON is not set
# CONFIG_NSH_DISABLEBG is not set
# CONFIG_NSH_DISABLE_IFCONFIG is not set
# CONFIG_NSH_DISABLE_PS is not set
CONFIG_ARCH="avr"
CONFIG_ARCH_AVR=y
CONFIG_ARCH_BOARD="mega1284p-xplained"
CONFIG_ARCH_BOARD_MEGA1284P_XPLAINED=y
CONFIG_ARCH_CHIP="atmega"
CONFIG_ARCH_CHIP_ATMEGA1284P=y
CONFIG_ARCH_CHIP_ATMEGA=y
CONFIG_ARCH_STACKDUMP=y
CONFIG_AVR_LINUXGCC_TOOLCHAIN=y
CONFIG_AVR_USART0=y
CONFIG_BOARD_LOOPSPERMSEC=888
CONFIG_DEFAULT_SMALL=y
CONFIG_DISABLE_MOUNTPOINT=y
CONFIG_IDLETHREAD_STACKSIZE=512
CONFIG_INIT_ENTRYPOINT="nsh_main"
CONFIG_INIT_STACKSIZE=512
CONFIG_INTELHEX_BINARY=y
CONFIG_NFILE_DESCRIPTORS_PER_BLOCK=6
CONFIG_NUNGET_CHARS=0
CONFIG_PTHREAD_STACK_DEFAULT=512
CONFIG_RAM_SIZE=16384
CONFIG_RAM_START=0x800100
CONFIG_RR_INTERVAL=200
CONFIG_START_DAY=31
CONFIG_START_YEAR=2015
CONFIG_SYSTEM_NSH=y
CONFIG_TASK_NAME_SIZE=0
CONFIG_USART0_SERIAL_CONSOLE=y

View File

@ -0,0 +1,84 @@
/****************************************************************************
* boards/avr/atmega/mega1284p-xplained/include/board.h
*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership. The
* ASF licenses this file to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance with the
* License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
* License for the specific language governing permissions and limitations
* under the License.
*
****************************************************************************/
#ifndef __BOARDS_AVR_ATMEGA_MEGA1284P_XPLAINED_INCLUDE_BOARD_H
#define __BOARDS_AVR_ATMEGA_MEGA1284P_XPLAINED_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 11059200 /* 11.0592MHz crystal */
#define BOARD_CPU_CLOCK BOARD_XTAL_FREQ /* F_CPU = 16MHz */
/* LED definitions **********************************************************/
/* The Mega1284p-Xplained has 4 LEDs connected to PB0-PB3 */
#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 /* __BOARDS_AVR_ATMEGA_MEGA1284P_XPLAINED_INCLUDE_BOARD_H */

View File

@ -0,0 +1,31 @@
############################################################################
# boards/avr/atmega/mega1284p-xplained/scripts/Make.defs
#
# Licensed to the Apache Software Foundation (ASF) under one or more
# contributor license agreements. See the NOTICE file distributed with
# this work for additional information regarding copyright ownership. The
# ASF licenses this file to you under the Apache License, Version 2.0 (the
# "License"); you may not use this file except in compliance with the
# License. You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
# License for the specific language governing permissions and limitations
# under the License.
#
############################################################################
include $(TOPDIR)/.config
include $(TOPDIR)/tools/Config.mk
include $(TOPDIR)/arch/avr/src/avr/Toolchain.defs
ARCHSCRIPT += $(BOARD_DIR)$(DELIM)scripts$(DELIM)ld.script
CFLAGS := $(ARCHCFLAGS) $(ARCHOPTIMIZATION) $(ARCHCPUFLAGS) $(ARCHINCLUDES) $(ARCHDEFINES) $(EXTRAFLAGS) -pipe
CXXFLAGS := $(ARCHCXXFLAGS) $(ARCHOPTIMIZATION) $(ARCHCPUFLAGS) $(ARCHXXINCLUDES) $(ARCHDEFINES) $(EXTRAFLAGS) -pipe
CXXPICFLAGS = $(ARCHPICFLAGS) $(CXXFLAGS)
CPPFLAGS := $(ARCHINCLUDES) $(ARCHDEFINES) $(EXTRAFLAGS)
AFLAGS := $(CFLAGS) -D__ASSEMBLY__

View File

@ -0,0 +1,198 @@
/****************************************************************************
* boards/avr/atmega/mega1284p-xplained/scripts/ld.script
*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership. The
* ASF licenses this file to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance with the
* License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
* License for the specific language governing permissions and limitations
* under the License.
*
****************************************************************************/
/* 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
}
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) }
}

View File

@ -0,0 +1,29 @@
############################################################################
# boards/avr/atmega/mega1284p-xplained/src/Makefile
#
# Licensed to the Apache Software Foundation (ASF) under one or more
# contributor license agreements. See the NOTICE file distributed with
# this work for additional information regarding copyright ownership. The
# ASF licenses this file to you under the Apache License, Version 2.0 (the
# "License"); you may not use this file except in compliance with the
# License. You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
# License for the specific language governing permissions and limitations
# under the License.
#
############################################################################
include $(TOPDIR)/Make.defs
CSRCS = avr_boot.c
ifeq ($(CONFIG_ARCH_LEDS),y)
CSRCS += avr_leds.c
endif
include $(TOPDIR)/boards/Board.mk

View File

@ -0,0 +1,77 @@
/****************************************************************************
* boards/avr/atmega/mega1284p-xplained/src/avr_boot.c
*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership. The
* ASF licenses this file to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance with the
* License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
* License for the specific language governing permissions and limitations
* under the License.
*
****************************************************************************/
/****************************************************************************
* Included Files
****************************************************************************/
#include <nuttx/config.h>
#include <debug.h>
#include <arch/board/board.h>
#include "avr_internal.h"
#include "atmega.h"
#include "mega1284p_xplained.h"
/****************************************************************************
* Pre-processor Definitions
****************************************************************************/
/****************************************************************************
* Private Functions
****************************************************************************/
/****************************************************************************
* Public Functions
****************************************************************************/
/****************************************************************************
* Name: atmega_boardinitialize
*
* Description:
* All ATMega architectures must provide the following entry point.
* This entry point is called early in the initialization -- after all
* memory has been configured and mapped but before any devices have been
* initialized.
*
****************************************************************************/
void atmega_boardinitialize(void)
{
/* Configure SSP chip selects if 1) at least one SSP is enabled, and 2)
* the weak function atmega_spidev_initialize() has been brought into the
* link.
*/
#if defined(CONFIG_AVR_SPI1) || defined(CONFIG_AVR_SPI2)
if (atmega_spidev_initialize)
{
atmega_spidev_initialize();
}
#endif
/* Configure on-board LEDs if LED support has been selected. */
#ifdef CONFIG_ARCH_LEDS
atmega_led_initialize();
#endif
}

View File

@ -0,0 +1,155 @@
/****************************************************************************
* boards/avr/atmega/mega1284p-xplained/src/avr_leds.c
*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership. The
* ASF licenses this file to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance with the
* License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
* License for the specific language governing permissions and limitations
* under the License.
*
****************************************************************************/
/****************************************************************************
* Included Files
****************************************************************************/
#include <nuttx/config.h>
#include <stdbool.h>
#include <debug.h>
#include <avr/io.h>
#include <nuttx/board.h>
#include "avr_internal.h"
#include "atmega.h"
#include "mega1284p_xplained.h"
#ifdef CONFIG_ARCH_LEDS
/****************************************************************************
* Private Data
****************************************************************************/
static bool g_ncoff;
/****************************************************************************
* Public Functions
****************************************************************************/
/****************************************************************************
* Name: atmega_led_initialize
****************************************************************************/
void atmega_led_initialize(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_autoled_on
****************************************************************************/
void board_autoled_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_autoled_off
****************************************************************************/
void board_autoled_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 */

View File

@ -0,0 +1,88 @@
/****************************************************************************
* boards/avr/atmega/mega1284p-xplained/src/mega1284p_xplained.h
*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership. The
* ASF licenses this file to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance with the
* License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
* License for the specific language governing permissions and limitations
* under the License.
*
****************************************************************************/
#ifndef __BOARDS_AVR_ATMEGA_MEGA1284P_XPLAINED_SRC_MEGA1284P_XPLAINED_H
#define __BOARDS_AVR_ATMEGA_MEGA1284P_XPLAINED_SRC_MEGA1284P_XPLAINED_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_spidev_initialize
*
* Description:
* Called to configure SPI chip select GPIO pins for the Amber Web Server.
*
****************************************************************************/
#if defined(CONFIG_AVR_SPI1) || defined(CONFIG_AVR_SPI2)
void weak_function atmega_spidev_initialize(void);
#endif
/****************************************************************************
* Name: atmega_led_initialize
*
* Description:
* Configure on-board LEDs if LED support has been selected.
*
****************************************************************************/
#ifdef CONFIG_ARCH_LEDS
void atmega_led_initialize(void);
#endif
#undef EXTERN
#ifdef __cplusplus
}
#endif
#endif /* __ASSEMBLY__ */
#endif /* __BOARDS_AVR_ATMEGA_MEGA1284P_XPLAINED_SRC_MEGA1284P_XPLAINED_H */