Add AT90USB support and AVR vector/startup logic
git-svn-id: svn://svn.code.sf.net/p/nuttx/code/trunk@3677 42af7a65-404d-4744-a932-0658087f49c3
This commit is contained in:
parent
f31872ef24
commit
284baee1bc
149
arch/avr/include/at90usb/irq.h
Normal file
149
arch/avr/include/at90usb/irq.h
Normal file
@ -0,0 +1,149 @@
|
||||
/****************************************************************************
|
||||
* arch/avr/include/avr/at90usb/irq.h
|
||||
*
|
||||
* Copyright (C) 2011 Gregory Nutt. All rights reserved.
|
||||
* Author: Gregory Nutt <spudmonkey@racsa.co.cr>
|
||||
*
|
||||
* 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.
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
/* This file should never be included directed but, rather, only indirectly
|
||||
* through nuttx/irq.h
|
||||
*/
|
||||
|
||||
#ifndef __ARCH_AVR_INCLUDE_AT90USB_IRQ_H
|
||||
#define __ARCH_AVR_INCLUDE_AT90USB_IRQ_H
|
||||
|
||||
/****************************************************************************
|
||||
* Included Files
|
||||
****************************************************************************/
|
||||
|
||||
#include <nuttx/irq.h>
|
||||
#include <arch/avr/avr.h>
|
||||
|
||||
/****************************************************************************
|
||||
* Definitions
|
||||
****************************************************************************/
|
||||
|
||||
/* The AT90USB has 38 interrupt vectors including vector 0, the reset
|
||||
* vector. The remaining 37 are assigned IRQ numbers here:
|
||||
*/
|
||||
|
||||
#define AT90USB_IRQ_INT0 0 /* 0x0002 External Interrupt Request 0 */
|
||||
#define AT90USB_IRQ_INT1 1 /* 0x0004 External Interrupt Request 1 */
|
||||
#define AT90USB_IRQ_INT2 2 /* 0x0006 External Interrupt Request 2 */
|
||||
#define AT90USB_IRQ_INT3 3 /* 0x0008 External Interrupt Request 3 */
|
||||
#define AT90USB_IRQ_INT4 4 /* 0x000a External Interrupt Request 4 */
|
||||
#define AT90USB_IRQ_INT5 5 /* 0x000c External Interrupt Request 5 */
|
||||
#define AT90USB_IRQ_INT6 6 /* 0x000e External Interrupt Request 6 */
|
||||
#define AT90USB_IRQ_INT7 7 /* 0x0010 External Interrupt Request 7 */
|
||||
#define AT90USB_IRQ_PCINT0 8 /* 0x0012 PCINT0 Pin Change Interrupt Request 0 */
|
||||
#define AT90USB_IRQ_USBGEN 9 /* 0x0014 USB General USB General Interrupt request */
|
||||
#define AT90USB_IRQ_USBEP 10 /* 0x0016 USB Endpoint/Pipe USB ENdpoint/Pipe Interrupt request */
|
||||
#define AT90USB_IRQ_WDT 11 /* 0x0018 Watchdog Time-out Interrupt */
|
||||
#define AT90USB_IRQ_T2COMPA 12 /* 0x001a TIMER2 COMPA Timer/Counter2 Compare Match A */
|
||||
#define AT90USB_IRQ_T2COMPB 13 /* 0x001c TIMER2 COMPB Timer/Counter2 Compare Match B */
|
||||
#define AT90USB_IRQ_T2OVF 14 /* 0x001e TIMER2 OVF Timer/Counter2 Overflow */
|
||||
#define AT90USB_IRQ_T1CAPT 15 /* 0x0020 TIMER1 CAPT Timer/Counter1 Capture Event */
|
||||
#define AT90USB_IRQ_T1COMPA 16 /* 0x0022 TIMER1 COMPA Timer/Counter1 Compare Match A */
|
||||
#define AT90USB_IRQ_T1COMPB 17 /* 0x0024 TIMER1 COMPB Timer/Counter1 Compare Match B */
|
||||
#define AT90USB_IRQ_T1COMPC 18 /* 0x0026 TIMER1 COMPC Timer/Counter1 Compare Match c */
|
||||
#define AT90USB_IRQ_T1OVF 19 /* 0x0028 TIMER1 OVF Timer/Counter1 Overflow */
|
||||
#define AT90USB_IRQ_T0COMPA 20 /* 0x002a TIMER0 COMPA Timer/Counter0 Compare Match A */
|
||||
#define AT90USB_IRQ_T0COMPB 21 /* 0x002c TIMER0 COMPB Timer/Counter0 Compare Match B */
|
||||
#define AT90USB_IRQ_T0OVF 22 /* 0x002e TIMER0 OVF Timer/Counter0 Overflow */
|
||||
#define AT90USB_IRQ_SPI 23 /* 0x0030 STC SPI Serial Transfer Complete */
|
||||
#define AT90USB_IRQ_U1RX 24 /* 0x0032 USART1 Rx Complete */
|
||||
#define AT90USB_IRQ_U1DRE 25 /* 0x0034 USART1 Data Register Empty */
|
||||
#define AT90USB_IRQ_U1TX 26 /* 0x0036 USART1 Tx Complete */
|
||||
#define AT90USB_IRQ_ANACOMP 27 /* 0x0038 ANALOG COMP Analog Comparator */
|
||||
#define AT90USB_IRQ_ADC 28 /* 0x003a ADC Conversion Complete */
|
||||
#define AT90USB_IRQ_EE 29 /* 0x003c EEPROM Ready */
|
||||
#define AT90USB_IRQ_T3CAPT 30 /* 0x003e TIMER3 CAPT Timer/Counter3 Capture Event */
|
||||
#define AT90USB_IRQ_T3COMPA 31 /* 0x0034 TIMER3 COMPA Timer/Counter3 Compare Match A */
|
||||
#define AT90USB_IRQ_T3COMPB 32 /* 0x0042 TIMER3 COMPB Timer/Counter3 Compare Match B */
|
||||
#define AT90USB_IRQ_T3COMPC 33 /* 0x0044 TIMER3 COMPC Timer/Counter3 Compare Match C */
|
||||
#define AT90USB_IRQ_T3OVF 34 /* 0x0046 TIMER3 OVF Timer/Counter3 Overflow */
|
||||
#define AT90USB_IRQ_TWI 35 /* 0x0048 TWI Two-wire Serial Interface */
|
||||
#define AT90USB_IRQ_SPMRDY 36 /* 0x004a Store Program Memory Ready */
|
||||
|
||||
#define NR_IRQS 37
|
||||
|
||||
/****************************************************************************
|
||||
* Public Types
|
||||
****************************************************************************/
|
||||
|
||||
/****************************************************************************
|
||||
* Inline functions
|
||||
****************************************************************************/
|
||||
|
||||
#ifndef __ASSEMBLY__
|
||||
|
||||
/* Save the current interrupt enable state & disable all interrupts */
|
||||
|
||||
static inline irqstate_t irqsave(void)
|
||||
{
|
||||
/* Needs to return the current interrupt state, then disable interrupts */
|
||||
#warning "Not implemented"
|
||||
return 0
|
||||
}
|
||||
|
||||
/* Restore saved interrupt state */
|
||||
|
||||
static inline void irqrestore(irqstate_t flags)
|
||||
{
|
||||
/* Based on the provided interrupt flags, conditionally enable interrupts */
|
||||
#warning "Not implemented"
|
||||
}
|
||||
#endif /* __ASSEMBLY__ */
|
||||
|
||||
/****************************************************************************
|
||||
* Public Variables
|
||||
****************************************************************************/
|
||||
|
||||
/****************************************************************************
|
||||
* Public Function Prototypes
|
||||
****************************************************************************/
|
||||
|
||||
#ifndef __ASSEMBLY__
|
||||
#ifdef __cplusplus
|
||||
#define EXTERN extern "C"
|
||||
extern "C" {
|
||||
#else
|
||||
#define EXTERN extern
|
||||
#endif
|
||||
|
||||
#undef EXTERN
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#endif /* __ARCH_AVR_INCLUDE_AT90USB_IRQ_H */
|
||||
|
146
arch/avr/include/atmega/irq.h
Normal file
146
arch/avr/include/atmega/irq.h
Normal file
@ -0,0 +1,146 @@
|
||||
/****************************************************************************
|
||||
* arch/avr/include/avr/atmega/irq.h
|
||||
*
|
||||
* Copyright (C) 2011 Gregory Nutt. All rights reserved.
|
||||
* Author: Gregory Nutt <spudmonkey@racsa.co.cr>
|
||||
*
|
||||
* 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.
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
/* This file should never be included directed but, rather, only indirectly
|
||||
* through nuttx/irq.h
|
||||
*/
|
||||
|
||||
#ifndef __ARCH_AVR_INCLUDE_ATMEGA_IRQ_H
|
||||
#define __ARCH_AVR_INCLUDE_ATMEGA_IRQ_H
|
||||
|
||||
/****************************************************************************
|
||||
* Included Files
|
||||
****************************************************************************/
|
||||
|
||||
#include <nuttx/irq.h>
|
||||
#include <arch/avr/avr.h>
|
||||
|
||||
/****************************************************************************
|
||||
* Definitions
|
||||
****************************************************************************/
|
||||
|
||||
/* The ATmega128 has 35 interrupt vectors including vector 0, the reset
|
||||
* vector. The remaining 34 are assigned IRQ numbers here:
|
||||
*/
|
||||
|
||||
#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_INT3 3 /* 0x0008 External Interrupt Request 3 */
|
||||
#define ATMEGA_IRQ_INT4 4 /* 0x000a External Interrupt Request 4 */
|
||||
#define ATMEGA_IRQ_INT5 5 /* 0x000c External Interrupt Request 5 */
|
||||
#define ATMEGA_IRQ_INT6 6 /* 0x000e External Interrupt Request 6 */
|
||||
#define ATMEGA_IRQ_INT7 7 /* 0x0010 External Interrupt Request 7 */
|
||||
#define ATMEGA_IRQ_T2COMP 8 /* 0x0012 TIMER2 COMP Timer/Counter2 Compare Match */
|
||||
#define ATMEGA_IRQ_T2OVF 9 /* 0x0014 TIMER2 OVF Timer/Counter2 Overflow */
|
||||
#define ATMEGA_IRQ_T1CAPT 10 /* 0x0016 TIMER1 CAPT Timer/Counter1 Capture Event */
|
||||
#define ATMEGA_IRQ_T1COMPA 11 /* 0x0018 TIMER1 COMPA Timer/Counter1 Compare Match A */
|
||||
#define ATMEGA_IRQ_T1COMPB 12 /* 0x001a TIMER1 COMPB Timer/Counter1 Compare Match B */
|
||||
#define ATMEGA_IRQ_T1OVF 13 /* 0x001c TIMER1 OVF Timer/Counter1 Overflow */
|
||||
#define ATMEGA_IRQ_T0COMP 14 /* 0x001e TIMER0 COMP Timer/Counter0 Compare Match */
|
||||
#define ATMEGA_IRQ_T0OVF 15 /* 0x0020 TIMER0 OVF Timer/Counter0 Overflow */
|
||||
#define ATMEGA_IRQ_SPI 16 /* 0x0022 STC SPI Serial Transfer Complete */
|
||||
#define ATMEGA_IRQ_U0RX 17 /* 0x0024 USART0 Rx Complete */
|
||||
#define ATMEGA_IRQ_U0DRE 18 /* 0x0026 USART0 Data Register Empty */
|
||||
#define ATMEGA_IRQ_U0TX 19 /* 0x0028 USART0 Tx Complete */
|
||||
#define ATMEGA_IRQ_ADC 20 /* 0x002a ADC Conversion Complete */
|
||||
#define ATMEGA_IRQ_EE 21 /* 0x002c EEPROM Ready */
|
||||
#define ATMEGA_IRQ_ANACOMP 22 /* 0x002e ANALOG COMP Analog Comparator */
|
||||
#define ATMEGA_IRQ_T1COMPC 23 /* 0x0030 TIMER1 COMPC Timer/Countre1 Compare Match C */
|
||||
#define ATMEGA_IRQ_T3CAPT 24 /* 0x0032 TIMER3 CAPT Timer/Counter3 Capture Event */
|
||||
#define ATMEGA_IRQ_T3COMPA 25 /* 0x0034 TIMER3 COMPA Timer/Counter3 Compare Match A */
|
||||
#define ATMEGA_IRQ_T3COMPB 26 /* 0x0036 TIMER3 COMPB Timer/Counter3 Compare Match B */
|
||||
#define ATMEGA_IRQ_T3COMPC 27 /* 0x0038 TIMER3 COMPC Timer/Counter3 Compare Match C */
|
||||
#define ATMEGA_IRQ_T3OVF 28 /* 0x003a TIMER3 OVF Timer/Counter3 Overflow */
|
||||
#define ATMEGA_IRQ_U1RX 29 /* 0x003c USART1 Rx Complete */
|
||||
#define ATMEGA_IRQ_U1DRE 30 /* 0x003e USART1 Data Register Empty */
|
||||
#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 */
|
||||
|
||||
#define NR_IRQS 34
|
||||
|
||||
/****************************************************************************
|
||||
* Public Types
|
||||
****************************************************************************/
|
||||
|
||||
/****************************************************************************
|
||||
* Inline functions
|
||||
****************************************************************************/
|
||||
|
||||
#ifndef __ASSEMBLY__
|
||||
|
||||
/* Save the current interrupt enable state & disable all interrupts */
|
||||
|
||||
static inline irqstate_t irqsave(void)
|
||||
{
|
||||
/* Needs to return the current interrupt state, then disable interrupts */
|
||||
#warning "Not implemented"
|
||||
return 0
|
||||
}
|
||||
|
||||
/* Restore saved interrupt state */
|
||||
|
||||
static inline void irqrestore(irqstate_t flags)
|
||||
{
|
||||
/* Based on the provided interrupt flags, conditionally enable interrupts */
|
||||
#warning "Not implemented"
|
||||
}
|
||||
#endif /* __ASSEMBLY__ */
|
||||
|
||||
/****************************************************************************
|
||||
* Public Variables
|
||||
****************************************************************************/
|
||||
|
||||
/****************************************************************************
|
||||
* Public Function Prototypes
|
||||
****************************************************************************/
|
||||
|
||||
#ifndef __ASSEMBLY__
|
||||
#ifdef __cplusplus
|
||||
#define EXTERN extern "C"
|
||||
extern "C" {
|
||||
#else
|
||||
#define EXTERN extern
|
||||
#endif
|
||||
|
||||
#undef EXTERN
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#endif /* __ARCH_AVR_INCLUDE_ATMEGA_IRQ_H */
|
||||
|
64
arch/avr/src/at90usb/Make.defs
Normal file
64
arch/avr/src/at90usb/Make.defs
Normal file
@ -0,0 +1,64 @@
|
||||
############################################################################
|
||||
# arch/avr/src/at90usb/Make.defs
|
||||
#
|
||||
# Copyright (C) 2011 Gregory Nutt. All rights reserved.
|
||||
# Author: Gregory Nutt <spudmonkey@racsa.co.cr>
|
||||
#
|
||||
# Redistribution and use in source and binary forms, with or without
|
||||
# modification, are permitted provided that the following conditions
|
||||
# are met:
|
||||
#
|
||||
# 1. Redistributions of source code must retain the above copyright
|
||||
# notice, this list of conditions and the following disclaimer.
|
||||
# 2. Redistributions in binary form must reproduce the above copyright
|
||||
# notice, this list of conditions and the following disclaimer in
|
||||
# the documentation and/or other materials provided with the
|
||||
# distribution.
|
||||
# 3. Neither the name NuttX nor the names of its contributors may be
|
||||
# used to endorse or promote products derived from this software
|
||||
# without specific prior written permission.
|
||||
#
|
||||
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
|
||||
# FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
|
||||
# COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
|
||||
# INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
|
||||
# BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
|
||||
# OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
|
||||
# AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
||||
# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
|
||||
# ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
# POSSIBILITY OF SUCH DAMAGE.
|
||||
#
|
||||
############################################################################
|
||||
|
||||
# The start-up, "head", file
|
||||
|
||||
HEAD_ASRC = at90usb_head.S
|
||||
|
||||
# Common AVR files
|
||||
|
||||
CMN_ASRCS = up_exceptions.S up_fullcontextrestore.S up_switchcontext.S
|
||||
CMN_CSRCS = up_assert.c up_allocateheap.c up_blocktask.c up_copystate.c \
|
||||
up_createstack.c up_mdelay.c up_udelay.c up_exit.c up_idle.c \
|
||||
up_initialize.c up_initialstate.c up_interruptcontext.c \
|
||||
up_modifyreg8.c up_modifyreg16.c up_modifyreg32.c \
|
||||
up_releasepending.c up_releasestack.c up_reprioritizertr.c \
|
||||
up_schedulesigaction.c up_sigdeliver.c up_unblocktask.c \
|
||||
up_usestack.c up_doirq.c
|
||||
|
||||
# Required ATMEGA files
|
||||
|
||||
CHIP_ASRCS =
|
||||
CHIP_CSRCS = at90usb_clkinit.c at90usb_gpio.c at90usb_irq.c \
|
||||
at90usb_lowconsole.c at90usb_lowinit.c at90usb_serial.c \
|
||||
at90usb_timerisr.c
|
||||
|
||||
# Configuration-dependent ATMEGA files
|
||||
|
||||
ifeq ($(CONFIG_AVR_GPIOIRQ),y)
|
||||
CHIP_CSRCS += at90usb_gpioirq.c
|
||||
endif
|
||||
|
||||
|
220
arch/avr/src/at90usb/at90usb_head.S
Executable file
220
arch/avr/src/at90usb/at90usb_head.S
Executable file
@ -0,0 +1,220 @@
|
||||
/****************************************************************************
|
||||
* arch/avr32/src/at90usb/at90usb_head.S
|
||||
*
|
||||
* Copyright (C) 2011 Gregory Nutt. All rights reserved.
|
||||
* Author: Gregory Nutt <spudmonkey@racsa.co.cr>
|
||||
*
|
||||
* 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>
|
||||
#define __AVR_ATmega128__
|
||||
#include <avr/io.h>
|
||||
#include <avr/sfr_defs.h>
|
||||
|
||||
/****************************************************************************
|
||||
* Pre-processor definitions
|
||||
****************************************************************************/
|
||||
|
||||
#define STACKBASE (_ebss+CONFIG_IDLETHREAD_STACKSIZE-4)
|
||||
|
||||
/****************************************************************************
|
||||
* External Symbols
|
||||
****************************************************************************/
|
||||
|
||||
.file "up_nommuhead.S"
|
||||
.global _sbss /* Start of .bss. Defined by ld.script */
|
||||
.global _ebss /* End of .bss. Defined by ld.script */
|
||||
.global _sdata /* Start of .data section in RAM */
|
||||
.global _edata /* End of .data section in RAM */
|
||||
.global _eronly /* Start of .data section in FLASH */
|
||||
.global up_lowinit /* Perform low level initialization */
|
||||
.global os_start /* NuttX entry point */
|
||||
|
||||
.global vectortab
|
||||
.global at90usb_int0 /* External interrupt request 0 */
|
||||
.global at90usb_int1 /* External interrupt request 1 */
|
||||
.global at90usb_int2 /* External interrupt request 2 */
|
||||
.global at90usb_int3 /* External interrupt request 3 */
|
||||
.global at90usb_int4 /* External interrupt request 4 */
|
||||
.global at90usb_int5 /* External interrupt request 5 */
|
||||
.global at90usb_int6 /* External interrupt request 6 */
|
||||
.global at90usb_int7 /* External interrupt request 7 */
|
||||
.global at90usb_pcint0 /* PCINT0 Pin Change Interrupt Request 0 */
|
||||
.global at90usb_usbgen /* USB General USB General Interrupt request */
|
||||
.global at90usb_usbep /* USB Endpoint/Pipe USB ENdpoint/Pipe Interrupt request */
|
||||
.global at90usb_wdt /* Watchdog Time-out Interrupt */
|
||||
.global at90usb_t2compa /* TIMER2 COMPA Timer/Counter2 Compare Match A */
|
||||
.global at90usb_t2compb /* TIMER2 COMPB Timer/Counter2 Compare Match B */
|
||||
.global at90usb_t2ovf /* TIMER2 OVF Timer/Counter2 Overflow */
|
||||
.global at90usb_t1capt /* TIMER1 CAPT Timer/Counter1 Capture Event */
|
||||
.global at90usb_t1compa /* TIMER1 COMPA Timer/Counter1 Compare Match A */
|
||||
.global at90usb_t1compb /* TIMER1 COMPB Timer/Counter1 Compare Match B */
|
||||
.global at90usb_t1compc /* TIMER1 COMPC Timer/Counter1 Compare Match c */
|
||||
.global at90usb_t1ovf /* TIMER1 OVF Timer/Counter1 Overflow */
|
||||
.global at90usb_t0compa /* TIMER0 COMPA Timer/Counter0 Compare Match A */
|
||||
.global at90usb_t0compb /* TIMER0 COMPB Timer/Counter0 Compare Match B */
|
||||
.global at90usb_t0ovf /* TIMER0 OVF Timer/Counter0 Overflow */
|
||||
.global at90usb_spi /* STC SPI Serial Transfer Complete */
|
||||
.global at90usb_u1rx /* USART1 Rx Complete */
|
||||
.global at90usb_u1dre /* USART1 Data Register Empty */
|
||||
.global at90usb_u1tx /* USART1 Tx Complete */
|
||||
.global at90usb_anacomp /* ANALOG COMP Analog Comparator */
|
||||
.global at90usb_adc /* ADC Conversion Complete */
|
||||
.global at90usb_ee /* EEPROM Ready */
|
||||
.global at90usb_t3capt /* TIMER3 CAPT Timer/Counter3 Capture Event */
|
||||
.global at90usb_t3compa /* TIMER3 COMPA Timer/Counter3 Compare Match A */
|
||||
.global at90usb_t3compb /* TIMER3 COMPB Timer/Counter3 Compare Match B */
|
||||
.global at90usb_t3compc /* TIMER3 COMPC Timer/Counter3 Compare Match C */
|
||||
.global at90usb_t3ovf /* TIMER3 OVF Timer/Counter3 Overflow */
|
||||
.global at90usb_twi /* TWI Two-wire Serial Interface */
|
||||
.global at90usb_spmrdy /* Store Program Memory Ready */
|
||||
|
||||
/****************************************************************************
|
||||
* Macros
|
||||
****************************************************************************/
|
||||
|
||||
.macro vector name
|
||||
jmp \name
|
||||
.endm
|
||||
|
||||
/****************************************************************************
|
||||
* Vector Table
|
||||
****************************************************************************/
|
||||
|
||||
/* The AT90USB has 38 interrupt vectors including vector 0, the reset
|
||||
* vector.
|
||||
*/
|
||||
|
||||
.section .vectors, "ax", @progbits
|
||||
.func vectortab
|
||||
vectortab:
|
||||
jmp __start /* 0: Vector 0 is the reset vector */
|
||||
vector at90usb_int0 /* 1: External interrupt request 0 */
|
||||
vector at90usb_int1 /* 2: External interrupt request 1 */
|
||||
vector at90usb_int2 /* 3: External interrupt request 2 */
|
||||
vector at90usb_int3 /* 4: External interrupt request 3 */
|
||||
vector at90usb_int4 /* 5: External interrupt request 4 */
|
||||
vector at90usb_int5 /* 6: External interrupt request 5 */
|
||||
vector at90usb_int6 /* 7: External interrupt request 6 */
|
||||
vector at90usb_int7 /* 8: External interrupt request 7 */
|
||||
vector at90usb_pcint0 /* 9: PCINT0 Pin Change Interrupt Request 0 */
|
||||
vector at90usb_usbgen /* 10: USB General USB General Interrupt request */
|
||||
vector at90usb_usbep /* 11: USB Endpoint/Pipe USB ENdpoint/Pipe Interrupt request */
|
||||
vector at90usb_wdt /* 12: Watchdog Time-out Interrupt */
|
||||
vector at90usb_t2compa /* 13: TIMER2 COMPA Timer/Counter2 Compare Match A */
|
||||
vector at90usb_t2compb /* 14: TIMER2 COMPB Timer/Counter2 Compare Match B */
|
||||
vector at90usb_t2ovf /* 15: TIMER2 OVF Timer/Counter2 Overflow */
|
||||
vector at90usb_t1capt /* 16: TIMER1 CAPT Timer/Counter1 Capture Event */
|
||||
vector at90usb_t1compa /* 17: TIMER1 COMPA Timer/Counter1 Compare Match A */
|
||||
vector at90usb_t1compb /* 18: TIMER1 COMPB Timer/Counter1 Compare Match B */
|
||||
vector at90usb_t1compc /* 19: TIMER1 COMPC Timer/Counter1 Compare Match c */
|
||||
vector at90usb_t1ovf /* 20: TIMER1 OVF Timer/Counter1 Overflow */
|
||||
vector at90usb_t0compa /* 21: TIMER0 COMPA Timer/Counter0 Compare Match A */
|
||||
vector at90usb_t0compb /* 22: TIMER0 COMPB Timer/Counter0 Compare Match B */
|
||||
vector at90usb_t0ovf /* 23: TIMER0 OVF Timer/Counter0 Overflow */
|
||||
vector at90usb_spi /* 24: STC SPI Serial Transfer Complete */
|
||||
vector at90usb_u1rx /* 25: USART1 Rx Complete */
|
||||
vector at90usb_u1dre /* 26: USART1 Data Register Empty */
|
||||
vector at90usb_u1tx /* 27: USART1 Tx Complete */
|
||||
vector at90usb_anacomp /* 28: ANALOG COMP Analog Comparator */
|
||||
vector at90usb_adc /* 29: ADC Conversion Complete */
|
||||
vector at90usb_ee /* 30: EEPROM Ready */
|
||||
vector at90usb_t3capt /* 31: TIMER3 CAPT Timer/Counter3 Capture Event */
|
||||
vector at90usb_t3compa /* 32: TIMER3 COMPA Timer/Counter3 Compare Match A */
|
||||
vector at90usb_t3compb /* 33: TIMER3 COMPB Timer/Counter3 Compare Match B */
|
||||
vector at90usb_t3compc /* 34: TIMER3 COMPC Timer/Counter3 Compare Match C */
|
||||
vector at90usb_t3ovf /* 35: TIMER3 OVF Timer/Counter3 Overflow */
|
||||
vector at90usb_twi /* 36: TWI Two-wire Serial Interface */
|
||||
vector at90usb_spmrdy /* 37: Store Program Memory Ready */
|
||||
.endfunc
|
||||
|
||||
/****************************************************************************
|
||||
* Reset Entry Point
|
||||
****************************************************************************/
|
||||
|
||||
.section .init, "ax", @progbits
|
||||
.func __start
|
||||
__start:
|
||||
|
||||
/* Initialize the IDLE thread stack */
|
||||
|
||||
clr r1
|
||||
out _SFR_IO_ADDR(SREG), r1
|
||||
ldi r28, lo8(STACKBASE)
|
||||
ldi r29, hi8(STACKBASE)
|
||||
out _SFR_IO_ADDR(SPH), r29
|
||||
out _SFR_IO_ADDR(SPL), r28
|
||||
|
||||
/* Copy initial global data values from FLASH into RAM */
|
||||
|
||||
ldi r17, hi8(_edata)
|
||||
ldi r26, lo8(_sdata)
|
||||
ldi r27, hi8(_sdata)
|
||||
ldi r30, lo8(_eronly)
|
||||
ldi r31, hi8(_eronly)
|
||||
ldi r16, hh8(_eronly)
|
||||
out _SFR_IO_ADDR(RAMPZ), r16
|
||||
rjmp .Lcopystart
|
||||
|
||||
.Lcopyloop:
|
||||
elpm r0, Z+
|
||||
st X+, r0
|
||||
|
||||
.Lcopystart:
|
||||
cpi r26, lo8(__data_end)
|
||||
cpc r27, r17
|
||||
brne .Lcopyloop
|
||||
|
||||
/* Now start NuttX */
|
||||
|
||||
call os_start /* Start NuttX */
|
||||
jmp exit
|
||||
.endfunc
|
||||
|
||||
/****************************************************************************
|
||||
* Heap Base
|
||||
****************************************************************************/
|
||||
|
||||
/* This global variable is unsigned long g_heapbase and is
|
||||
* exported from here only because of its coupling to other
|
||||
* uses of _ebss in this file
|
||||
*/
|
||||
|
||||
.data
|
||||
.globl g_heapbase
|
||||
.type g_heapbase, object
|
||||
g_heapbase:
|
||||
.word _ebss+CONFIG_IDLETHREAD_STACKSIZE
|
||||
.size g_heapbase, .-g_heapbase
|
||||
.end
|
245
arch/avr/src/at90usb/at90usb_internal.h
Normal file
245
arch/avr/src/at90usb/at90usb_internal.h
Normal file
@ -0,0 +1,245 @@
|
||||
/****************************************************************************
|
||||
* arch/avr/src/at90usb/at90usb_internal.h
|
||||
*
|
||||
* Copyright (C) 2011 Gregory Nutt. All rights reserved.
|
||||
* Author: Gregory Nutt <spudmonkey@racsa.co.cr>
|
||||
*
|
||||
* 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 __ARCH_AVR_SRC_ATMEGA_ATMEGA_INTERNAL_H
|
||||
#define __ARCH_AVR_SRC_ATMEGA_ATMEGA_INTERNAL_H
|
||||
|
||||
/****************************************************************************
|
||||
* Included Files
|
||||
****************************************************************************/
|
||||
|
||||
#include <nuttx/config.h>
|
||||
#include "at90usb_config.h"
|
||||
|
||||
#ifdef CONFIG_AVR_GPIOIRQ
|
||||
# include <nuttx/irq.h>
|
||||
#endif
|
||||
|
||||
#include <stdint.h>
|
||||
#include <stdbool.h>
|
||||
|
||||
/****************************************************************************
|
||||
* Pre-processor Definitions
|
||||
****************************************************************************/
|
||||
|
||||
/* Bit-encoded input to at90usb_configgpio() ********************************/
|
||||
# warning "Missing definitions"
|
||||
|
||||
/****************************************************************************
|
||||
* Public Types
|
||||
****************************************************************************/
|
||||
|
||||
#ifndef __ASSEMBLY__
|
||||
|
||||
/****************************************************************************
|
||||
* Inline Functions
|
||||
****************************************************************************/
|
||||
|
||||
/****************************************************************************
|
||||
* Public Data
|
||||
****************************************************************************/
|
||||
|
||||
#undef EXTERN
|
||||
#if defined(__cplusplus)
|
||||
#define EXTERN extern "C"
|
||||
extern "C" {
|
||||
#else
|
||||
#define EXTERN extern
|
||||
#endif
|
||||
|
||||
/****************************************************************************
|
||||
* Public Function Prototypes
|
||||
****************************************************************************/
|
||||
|
||||
/****************************************************************************
|
||||
* Name: up_clkinit
|
||||
*
|
||||
* Description:
|
||||
* Initialiaze clock/PLL settings per the definitions in the board.h file.
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
EXTERN void up_clkinitialize(void);
|
||||
|
||||
/****************************************************************************
|
||||
* Name: usart_reset
|
||||
*
|
||||
* Description:
|
||||
* Reset a USART.
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
EXTERN void usart_reset(uintptr_t usart_base);
|
||||
|
||||
/****************************************************************************
|
||||
* Name: usart_configure
|
||||
*
|
||||
* Description:
|
||||
* Configure a USART as a RS-232 UART.
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
void usart_configure(uintptr_t usart_base, uint32_t baud, unsigned int parity,
|
||||
unsigned int nbits, bool stop2);
|
||||
|
||||
/****************************************************************************
|
||||
* Name: up_consoleinit
|
||||
*
|
||||
* Description:
|
||||
* Initialize a console for debug output. This function is called very
|
||||
* early in the intialization sequence to configure the serial console
|
||||
* uart (only).
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
EXTERN void up_consoleinit(void);
|
||||
|
||||
/****************************************************************************
|
||||
* Name: up_boardinit
|
||||
*
|
||||
* Description:
|
||||
* This function must be provided by the board-specific logic in the
|
||||
* directory configs/<board-name>/up_boot.c.
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
EXTERN void up_boardinitialize(void);
|
||||
|
||||
/****************************************************************************
|
||||
* Name: at90usb_configgpio
|
||||
*
|
||||
* Description:
|
||||
* Configure a GPIO pin based on bit-encoded description of the pin.
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
EXTERN int at90usb_configgpio(uint16_t cfgset);
|
||||
|
||||
/****************************************************************************
|
||||
* Name: at90usb_gpiowrite
|
||||
*
|
||||
* Description:
|
||||
* Write one or zero to the selected GPIO pin
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
EXTERN void at90usb_gpiowrite(uint16_t pinset, bool value);
|
||||
|
||||
/****************************************************************************
|
||||
* Name: at90usb_gpioread
|
||||
*
|
||||
* Description:
|
||||
* Read one or zero from the selected GPIO pin
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
EXTERN bool at90usb_gpioread(uint16_t pinset);
|
||||
|
||||
/****************************************************************************
|
||||
* Name: gpio_irqinitialize
|
||||
*
|
||||
* Description:
|
||||
* Initialize all vectors to the unexpected interrupt handler
|
||||
*
|
||||
* Configuration Notes:
|
||||
* Configuration CONFIG_AVR_GPIOIRQ must be selected to enable the
|
||||
* overall GPIO IRQ feature.
|
||||
*
|
||||
* Assumptions:
|
||||
* Called during the early boot sequence before global interrupts have
|
||||
* been enabled.
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
#ifdef CONFIG_AVR_GPIOIRQ
|
||||
EXTERN void weak_function gpio_irqinitialize(void);
|
||||
#endif
|
||||
|
||||
/****************************************************************************
|
||||
* Name: gpio_irqattach
|
||||
*
|
||||
* Description:
|
||||
* Attach in GPIO interrupt to the provide 'isr'
|
||||
*
|
||||
* Configuration Notes:
|
||||
* Configuration CONFIG_AVR_GPIOIRQ must be selected to enable the
|
||||
* overall GPIO IRQ feature.
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
#ifdef CONFIG_AVR_GPIOIRQ
|
||||
EXTERN int gpio_irqattach(int irq, xcpt_t newisr, xcpt_t *oldisr);
|
||||
#endif
|
||||
|
||||
/****************************************************************************
|
||||
* Name: gpio_irqenable
|
||||
*
|
||||
* Description:
|
||||
* Enable the GPIO IRQ specified by 'irq'
|
||||
*
|
||||
* Configuration Notes:
|
||||
* Configuration CONFIG_AVR_GPIOIRQ must be selected to enable the
|
||||
* overall GPIO IRQ feature.
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
#ifdef CONFIG_AVR_GPIOIRQ
|
||||
EXTERN void gpio_irqenable(int irq);
|
||||
#endif
|
||||
|
||||
/*****************************************************************************
|
||||
* Name: gpio_irqdisable
|
||||
*
|
||||
* Description:
|
||||
* Disable the GPIO IRQ specified by 'irq'
|
||||
*
|
||||
* Configuration Notes:
|
||||
* Configuration CONFIG_AVR_GPIOIRQ must be selected to enable the
|
||||
* overall GPIO IRQ feature.
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
#ifdef CONFIG_AVR_GPIOIRQ
|
||||
EXTERN void gpio_irqdisable(int irq);
|
||||
#endif
|
||||
|
||||
#undef EXTERN
|
||||
#if defined(__cplusplus)
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* __ASSEMBLY__ */
|
||||
#endif /* __ARCH_AVR_SRC_ATMEGA_ATMEGA_INTERNAL_H */
|
||||
|
68
arch/avr/src/at90usb/at90usb_memorymap.h
Normal file
68
arch/avr/src/at90usb/at90usb_memorymap.h
Normal file
@ -0,0 +1,68 @@
|
||||
/************************************************************************************
|
||||
* arch/avr/src/at90usb/at90usb_memorymap.h
|
||||
*
|
||||
* Copyright (C) 2011 Gregory Nutt. All rights reserved.
|
||||
* Author: Gregory Nutt <spudmonkey@racsa.co.cr>
|
||||
*
|
||||
* 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 __ARCH_AVR_SRC_ATMEGA_ATMEGA_MEMORYMAP_H
|
||||
#define __ARCH_AVR_SRC_ATMEGA_ATMEGA_MEMORYMAP_H
|
||||
|
||||
/************************************************************************************
|
||||
* Included Files
|
||||
************************************************************************************/
|
||||
|
||||
#include <nuttx/config.h>
|
||||
|
||||
/************************************************************************************
|
||||
* Pre-processor Definitions
|
||||
************************************************************************************/
|
||||
|
||||
/* Physical memory map */
|
||||
# warning "Missing Definitions"
|
||||
|
||||
/* Peripheral Address Map */
|
||||
# warning "Missing Definitions"
|
||||
|
||||
/************************************************************************************
|
||||
* Public Types
|
||||
************************************************************************************/
|
||||
|
||||
/************************************************************************************
|
||||
* Public Data
|
||||
************************************************************************************/
|
||||
|
||||
/************************************************************************************
|
||||
* Public Functions
|
||||
************************************************************************************/
|
||||
|
||||
#endif /* __ARCH_AVR_SRC_ATMEGA_ATMEGA_MEMORYMAP_H */
|
||||
|
75
arch/avr/src/at90usb/chip.h
Normal file
75
arch/avr/src/at90usb/chip.h
Normal file
@ -0,0 +1,75 @@
|
||||
/************************************************************************************
|
||||
* arch/avr/src/at90usb/chip.h
|
||||
*
|
||||
* Copyright (C) 2011 Gregory Nutt. All rights reserved.
|
||||
* Author: Gregory Nutt <spudmonkey@racsa.co.cr>
|
||||
*
|
||||
* 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 __ARCH_AVR_SRC_ATMEGA_CHIP_H
|
||||
#define __ARCH_AVR_SRC_ATMEGA_CHIP_H
|
||||
|
||||
/************************************************************************************
|
||||
* Included Files
|
||||
************************************************************************************/
|
||||
|
||||
#include <nuttx/config.h>
|
||||
|
||||
/************************************************************************************
|
||||
* Pre-processor Definitions
|
||||
************************************************************************************/
|
||||
|
||||
/* Define features for supported chip in the ATMEGA family */
|
||||
|
||||
#if 0
|
||||
#else
|
||||
# error "Unsupported AVR chip"
|
||||
#endif
|
||||
|
||||
/* Include only the memory map. Other chip hardware files should then include this
|
||||
* file for the proper setup
|
||||
*/
|
||||
|
||||
#include "at90usb_memorymap.h"
|
||||
|
||||
/************************************************************************************
|
||||
* Public Types
|
||||
************************************************************************************/
|
||||
|
||||
/************************************************************************************
|
||||
* Public Data
|
||||
************************************************************************************/
|
||||
|
||||
/************************************************************************************
|
||||
* Public Functions
|
||||
************************************************************************************/
|
||||
|
||||
#endif /* __ARCH_AVR_SRC_ATMEGA_CHIP_H */
|
||||
|
214
arch/avr/src/atmega/atmega_head.S
Executable file
214
arch/avr/src/atmega/atmega_head.S
Executable file
@ -0,0 +1,214 @@
|
||||
/****************************************************************************
|
||||
* arch/avr32/src/atmega/atmega_head.S
|
||||
*
|
||||
* Copyright (C) 2011 Gregory Nutt. All rights reserved.
|
||||
* Author: Gregory Nutt <spudmonkey@racsa.co.cr>
|
||||
*
|
||||
* 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>
|
||||
#define __AVR_ATmega128__
|
||||
#include <avr/io.h>
|
||||
#include <avr/sfr_defs.h>
|
||||
|
||||
/****************************************************************************
|
||||
* Pre-processor definitions
|
||||
****************************************************************************/
|
||||
|
||||
#define STACKBASE (_ebss+CONFIG_IDLETHREAD_STACKSIZE-4)
|
||||
|
||||
/****************************************************************************
|
||||
* External Symbols
|
||||
****************************************************************************/
|
||||
|
||||
.file "up_nommuhead.S"
|
||||
.global _sbss /* Start of .bss. Defined by ld.script */
|
||||
.global _ebss /* End of .bss. Defined by ld.script */
|
||||
.global _sdata /* Start of .data section in RAM */
|
||||
.global _edata /* End of .data section in RAM */
|
||||
.global _eronly /* Start of .data section in FLASH */
|
||||
.global up_lowinit /* Perform low level initialization */
|
||||
.global os_start /* NuttX entry point */
|
||||
|
||||
.global vectortab
|
||||
.global atmega_int0 /* External interrupt request 0 */
|
||||
.global atmega_int1 /* External interrupt request 1 */
|
||||
.global atmega_int2 /* External interrupt request 2 */
|
||||
.global atmega_int3 /* External interrupt request 3 */
|
||||
.global atmega_int4 /* External interrupt request 4 */
|
||||
.global atmega_int5 /* External interrupt request 5 */
|
||||
.global atmega_int6 /* External interrupt request 6 */
|
||||
.global atmega_int7 /* External interrupt request 7 */
|
||||
.global atmega_t2comp /* TIMER2 COMP 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_t0comp /* TIMER0 COMP 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_adc /* ADC conversion complete */
|
||||
.global atmega_ee /* EEPROM ready */
|
||||
.global atmega_anacomp /* ANALOG COMP analog comparator */
|
||||
.global atmega_t1compc /* TIMER1 COMPC timer/countre1 compare match c */
|
||||
.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_t3compc /* TIMER3 COMPC timer/counter3 compare match c */
|
||||
.global atmega_t3ovf /* TIMER3 OVF timer/counter3 overflow */
|
||||
.global atmega_u1rx /* USART1 RX complete */
|
||||
.global atmega_u1dre /* USART1 data register empty */
|
||||
.global atmega_u1tx /* USART1 TX complete */
|
||||
.global atmega_twi /* TWI two-wire serial interface */
|
||||
.global atmega_spmrdy /* Store program memory ready */
|
||||
|
||||
/****************************************************************************
|
||||
* Macros
|
||||
****************************************************************************/
|
||||
|
||||
.macro vector name
|
||||
jmp \name
|
||||
.endm
|
||||
|
||||
/****************************************************************************
|
||||
* Vector Table
|
||||
****************************************************************************/
|
||||
|
||||
/* The ATmega128 has 35 interrupt vectors including vector 0, the reset
|
||||
* vector.
|
||||
*/
|
||||
|
||||
.section .vectors, "ax", @progbits
|
||||
.func vectortab
|
||||
vectortab:
|
||||
jmp __start /* 0: Vector 0 is the reset vector */
|
||||
vector atmega_int0 /* 1: External interrupt request 0 */
|
||||
vector atmega_int1 /* 2: External interrupt request 1 */
|
||||
vector atmega_int2 /* 3: External interrupt request 2 */
|
||||
vector atmega_int3 /* 4: External interrupt request 3 */
|
||||
vector atmega_int4 /* 5: External interrupt request 4 */
|
||||
vector atmega_int5 /* 6 : External interrupt request 5 */
|
||||
vector atmega_int6 /* 7: External interrupt request 6 */
|
||||
vector atmega_int7 /* 8: External interrupt request 7 */
|
||||
vector atmega_t2comp /* 9: TIMER2 COMP timer/counter2 compare match */
|
||||
vector atmega_t2ovf /* 10: TIMER2 OVF timer/counter2 overflow */
|
||||
vector atmega_t1capt /* 11: TIMER1 CAPT timer/counter1 capture event */
|
||||
vector atmega_t1compa /* 12: TIMER1 COMPA timer/counter1 compare match a */
|
||||
vector atmega_t1compb /* 13: TIMER1 COMPB timer/counter1 compare match b */
|
||||
vector atmega_t1ovf /* 14: TIMER1 OVF timer/counter1 overflow */
|
||||
vector atmega_t0comp /* 15: TIMER0 COMP timer/counter0 compare match */
|
||||
vector atmega_t0ovf /* 16: TIMER0 OVF timer/counter0 overflow */
|
||||
vector atmega_spi /* 17: STC SPI serial transfer complete */
|
||||
vector atmega_u0rx /* 18: USART0 RX complete */
|
||||
vector atmega_u0dre /* 19: USART0 data register empty */
|
||||
vector atmega_u0tx /* 20: USART0 TX complete */
|
||||
vector atmega_adc /* 21: ADC conversion complete */
|
||||
vector atmega_ee /* 22: EEPROM ready */
|
||||
vector atmega_anacomp /* 23: ANALOG COMP analog comparator */
|
||||
vector atmega_t1compc /* 24: TIMER1 COMPC timer/countre1 compare match c */
|
||||
vector atmega_t3capt /* 25: TIMER3 CAPT timer/counter3 capture event */
|
||||
vector atmega_t3compa /* 26: TIMER3 COMPA timer/counter3 compare match a */
|
||||
vector atmega_t3compb /* 27: TIMER3 COMPB timer/counter3 compare match b */
|
||||
vector atmega_t3compc /* 28: TIMER3 COMPC timer/counter3 compare match c */
|
||||
vector atmega_t3ovf /* 29: TIMER3 OVF timer/counter3 overflow */
|
||||
vector atmega_u1rx /* 30: USART1 RX complete */
|
||||
vector atmega_u1dre /* 31: USART1 data register empty */
|
||||
vector atmega_u1tx /* 32: USART1 TX complete */
|
||||
vector atmega_twi /* 33: TWI two-wire serial interface */
|
||||
vector atmega_spmrdy /* 34: Store program memory ready */
|
||||
.endfunc
|
||||
|
||||
/****************************************************************************
|
||||
* Reset Entry Point
|
||||
****************************************************************************/
|
||||
|
||||
.section .init, "ax", @progbits
|
||||
.func __start
|
||||
__start:
|
||||
|
||||
/* Initialize the IDLE thread stack */
|
||||
|
||||
clr r1
|
||||
out _SFR_IO_ADDR(SREG), r1
|
||||
ldi r28, lo8(STACKBASE)
|
||||
ldi r29, hi8(STACKBASE)
|
||||
out _SFR_IO_ADDR(SPH), r29
|
||||
out _SFR_IO_ADDR(SPL), r28
|
||||
|
||||
/* Copy initial global data values from FLASH into RAM */
|
||||
|
||||
ldi r17, hi8(_edata)
|
||||
ldi r26, lo8(_sdata)
|
||||
ldi r27, hi8(_sdata)
|
||||
ldi r30, lo8(_eronly)
|
||||
ldi r31, hi8(_eronly)
|
||||
ldi r16, hh8(_eronly)
|
||||
out _SFR_IO_ADDR(RAMPZ), r16
|
||||
rjmp .Lcopystart
|
||||
|
||||
.Lcopyloop:
|
||||
elpm r0, Z+
|
||||
st X+, r0
|
||||
|
||||
.Lcopystart:
|
||||
cpi r26, lo8(__data_end)
|
||||
cpc r27, r17
|
||||
brne .Lcopyloop
|
||||
|
||||
/* Now start NuttX */
|
||||
|
||||
call os_start /* Start NuttX */
|
||||
jmp exit
|
||||
.endfunc
|
||||
|
||||
/****************************************************************************
|
||||
* Heap Base
|
||||
****************************************************************************/
|
||||
|
||||
/* This global variable is unsigned long g_heapbase and is
|
||||
* exported from here only because of its coupling to other
|
||||
* uses of _ebss in this file
|
||||
*/
|
||||
|
||||
.data
|
||||
.globl g_heapbase
|
||||
.type g_heapbase, object
|
||||
g_heapbase:
|
||||
.word _ebss+CONFIG_IDLETHREAD_STACKSIZE
|
||||
.size g_heapbase, .-g_heapbase
|
||||
.end
|
Loading…
Reference in New Issue
Block a user