mirror of
https://github.com/apache/nuttx.git
synced 2026-06-06 16:50:55 +08:00
Add skeleton of AVR32 init
git-svn-id: svn://svn.code.sf.net/p/nuttx/code/trunk@2975 42af7a65-404d-4744-a932-0658087f49c3
This commit is contained in:
@@ -1,7 +1,7 @@
|
||||
/****************************************************************************
|
||||
* arch/arm/src/stm32/stm32_serial.c
|
||||
*
|
||||
* Copyright (C) 2009 Gregory Nutt. All rights reserved.
|
||||
* Copyright (C) 2009-2010 Gregory Nutt. All rights reserved.
|
||||
* Author: Gregory Nutt <spudmonkey@racsa.co.cr>
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
@@ -340,7 +340,7 @@ static inline uint32_t up_serialin(struct up_dev_s *priv, int offset)
|
||||
|
||||
static inline void up_serialout(struct up_dev_s *priv, int offset, uint32_t value)
|
||||
{
|
||||
putreg16(value, priv->usartbase + offset);
|
||||
putreg32(value, priv->usartbase + offset);
|
||||
}
|
||||
|
||||
/****************************************************************************
|
||||
|
||||
@@ -50,7 +50,7 @@ CMN_CSRCS = up_assert.c up_blocktask.c up_copystate.c up_createstack.c \
|
||||
# Required AT91UC3 files
|
||||
|
||||
CHIP_ASRCS =
|
||||
CHIP_CSRCS =
|
||||
CHIP_CSRCS = at91uc3_lowinit.c at91uc3_serial.c
|
||||
|
||||
# Configuration-dependent AT91UC3 files
|
||||
|
||||
|
||||
Executable
+125
@@ -0,0 +1,125 @@
|
||||
/************************************************************************************
|
||||
* arch/avr/src/at91uc3/at91uc3_config.h
|
||||
*
|
||||
* Copyright (C) 2010 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_AT91UC3_AT91UC3_CONFIG_H
|
||||
#define __ARCH_AVR_SRC_AT91UC3_AT91UC3_CONFIG_H
|
||||
|
||||
/************************************************************************************
|
||||
* Included Files
|
||||
************************************************************************************/
|
||||
|
||||
#include <nuttx/config.h>
|
||||
#include "chip.h"
|
||||
|
||||
/************************************************************************************
|
||||
* Pre-processor Definitions
|
||||
************************************************************************************/
|
||||
|
||||
/* USART can be configured as a number of different devices (Only UART is supported
|
||||
* here now, that will be extended). Check for consistency between USART enable
|
||||
* options.
|
||||
*/
|
||||
|
||||
#if AVR32_NUSART < 1
|
||||
# undef CONFIG_AVR32_USART0
|
||||
# undef CONFIG_AVR32_USART1
|
||||
# undef CONFIG_AVR32_USART2
|
||||
#endif
|
||||
#if AVR32_NUSART < 2
|
||||
# undef CONFIG_AVR32_USART1
|
||||
# undef CONFIG_AVR32_USART2
|
||||
#endif
|
||||
#if AVR32_NUSART < 3
|
||||
# undef CONFIG_AVR32_USART2
|
||||
#endif
|
||||
|
||||
#ifndef CONFIG_AVR32_USART0
|
||||
# undef CONFIG_AVR32_USART0_RS232
|
||||
# undef CONFIG_AVR32_USART0_SPI
|
||||
#endif
|
||||
#ifndef CONFIG_AVR32_USART1
|
||||
# undef CONFIG_AVR32_USART1_RS232
|
||||
# undef CONFIG_AVR32_USART1_SPI
|
||||
#endif
|
||||
#ifndef CONFIG_AVR32_USART2
|
||||
# undef CONFIG_AVR32_USART2_RS232
|
||||
# undef CONFIG_AVR32_USART2_SPI
|
||||
#endif
|
||||
|
||||
/* Is any UART configured? */
|
||||
|
||||
#if defined(CONFIG_AVR32_USART0_RS232) || \
|
||||
defined(CONFIG_AVR32_USART1_RS232) || \
|
||||
defined(CONFIG_AVR32_USART2_RS232)
|
||||
# define HAVE_RS232_DEVICE
|
||||
#else
|
||||
# undef HAVE_RS232_DEVICE
|
||||
#endif
|
||||
|
||||
/* Is there a serial console? */
|
||||
|
||||
#if defined(CONFIG_USART0_SERIAL_CONSOLE) && defined(CONFIG_AVR32_USART0_RS232)
|
||||
# undef CONFIG_USART1_SERIAL_CONSOLE
|
||||
# undef CONFIG_USART2_SERIAL_CONSOLE
|
||||
# define HAVE_SERIAL_CONSOLE 1
|
||||
#elif defined(CONFIG_USART1_SERIAL_CONSOLE) && defined(CONFIG_AVR32_USART10_RS232)
|
||||
# undef CONFIG_USART0_SERIAL_CONSOLE
|
||||
# undef CONFIG_USART2_SERIAL_CONSOLE
|
||||
# define HAVE_SERIAL_CONSOLE 1
|
||||
#elif defined(CONFIG_USART2_SERIAL_CONSOLE) && defined(CONFIG_AVR32_USART20_RS232)
|
||||
# undef CONFIG_USART0_SERIAL_CONSOLE
|
||||
# undef CONFIG_USART1_SERIAL_CONSOLE
|
||||
# define HAVE_SERIAL_CONSOLE 1
|
||||
#else
|
||||
# undef CONFIG_USART0_SERIAL_CONSOLE
|
||||
# undef CONFIG_USART1_SERIAL_CONSOLE
|
||||
# undef CONFIG_USART2_SERIAL_CONSOLE
|
||||
# undef HAVE_SERIAL_CONSOLE
|
||||
#endif
|
||||
|
||||
/************************************************************************************
|
||||
* Public Types
|
||||
************************************************************************************/
|
||||
|
||||
/************************************************************************************
|
||||
* Public Data
|
||||
************************************************************************************/
|
||||
|
||||
/************************************************************************************
|
||||
* Public Functions
|
||||
************************************************************************************/
|
||||
|
||||
#endif /* __ARCH_AVR_SRC_AT91UC3_AT91UC3_CONFIG_H */
|
||||
|
||||
@@ -58,5 +58,26 @@
|
||||
* Public Functions
|
||||
************************************************************************************/
|
||||
|
||||
/************************************************************************************
|
||||
* Name: at91uc3_clkinit
|
||||
*
|
||||
* Description:
|
||||
* Initialiaze clock/PLL settings per the definitions in the board.h file.
|
||||
*
|
||||
************************************************************************************/
|
||||
|
||||
extern void at91uc3_clkinitialize(void);
|
||||
|
||||
/************************************************************************************
|
||||
* Name: at91uc3_boardinit
|
||||
*
|
||||
* Description:
|
||||
* This function must be provided by the board-specific logic in the directory
|
||||
* configs/<board-name>/up_boot.c.
|
||||
*
|
||||
************************************************************************************/
|
||||
|
||||
extern void at91uc3_boardinitialize(void);
|
||||
|
||||
#endif /* __ARCH_AVR_SRC_AVR32_AT91UC3_INTERNAL_H */
|
||||
|
||||
|
||||
@@ -0,0 +1,102 @@
|
||||
/**************************************************************************
|
||||
* arch/avr/src/at91uc3/at91uc3_lowinit.c
|
||||
*
|
||||
* Copyright (C) 2010 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>
|
||||
|
||||
#include "at91uc3_config.h"
|
||||
#include "up_internal.h"
|
||||
#include "at91uc3_internal.h"
|
||||
|
||||
/**************************************************************************
|
||||
* Private Definitions
|
||||
**************************************************************************/
|
||||
|
||||
/**************************************************************************
|
||||
* Private Types
|
||||
**************************************************************************/
|
||||
|
||||
/**************************************************************************
|
||||
* Private Function Prototypes
|
||||
**************************************************************************/
|
||||
|
||||
/**************************************************************************
|
||||
* Global Variables
|
||||
**************************************************************************/
|
||||
|
||||
/**************************************************************************
|
||||
* Private Variables
|
||||
**************************************************************************/
|
||||
|
||||
/**************************************************************************
|
||||
* Private Functions
|
||||
**************************************************************************/
|
||||
|
||||
/**************************************************************************
|
||||
* Public Functions
|
||||
**************************************************************************/
|
||||
|
||||
/**************************************************************************
|
||||
* Name: up_lowinit
|
||||
*
|
||||
* Description:
|
||||
* This performs basic initialization of the USART used for the serial
|
||||
* console. Its purpose is to get the console output availabe as soon
|
||||
* as possible.
|
||||
*
|
||||
**************************************************************************/
|
||||
|
||||
void up_lowinit(void)
|
||||
{
|
||||
/* Initialize MCU clocking */
|
||||
|
||||
at91uc3_clkinitialize();
|
||||
|
||||
/* Perform early serial initialization (so that we will have debug output
|
||||
* available as soon as possible.
|
||||
*/
|
||||
|
||||
up_earlyserialinit();
|
||||
|
||||
/* Perform board-level initialization */
|
||||
|
||||
at91uc3_boardinitialize();
|
||||
|
||||
}
|
||||
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -55,7 +55,6 @@
|
||||
.global _eronly /* Start of .data section in FLASH */
|
||||
#endif
|
||||
.global up_lowinit /* Perform low level initialization */
|
||||
.global up_boardinit /* Low-level board initialization */
|
||||
.global os_start /* NuttX entry point */
|
||||
.global vectors /* Vector base address */
|
||||
|
||||
@@ -63,20 +62,6 @@
|
||||
* Macros
|
||||
****************************************************************************/
|
||||
|
||||
#ifdef CONFIG_DEBUG
|
||||
.macro showprogress, code
|
||||
.endm
|
||||
.macro doputc, code
|
||||
mov r12, \code
|
||||
mcall up_putc
|
||||
.endm
|
||||
#else
|
||||
.macro showprogress, code
|
||||
.endm
|
||||
.macro doputc, code
|
||||
.endm
|
||||
#endif
|
||||
|
||||
/****************************************************************************
|
||||
* OS Entry Point
|
||||
****************************************************************************/
|
||||
@@ -105,7 +90,6 @@ __start:
|
||||
/* Enable exception processing */
|
||||
|
||||
csrf AVR32_SR_EM_SHIFT
|
||||
showprogress 'A'
|
||||
|
||||
/* Clear system BSS section */
|
||||
|
||||
@@ -119,8 +103,6 @@ __start:
|
||||
cp r0, r1 /* Finished? */
|
||||
brlo 1b /* No... keep looping */
|
||||
|
||||
showprogress 'B'
|
||||
|
||||
/* Copy system .data sections to new home in RAM. */
|
||||
|
||||
#ifdef CONFIG_BOOT_RUNFROMFLASH
|
||||
@@ -136,7 +118,6 @@ __start:
|
||||
cp r0, r1 /* Finished? */
|
||||
brlo 3b /* No... keep looping */
|
||||
|
||||
showprogress 'C'
|
||||
#endif
|
||||
|
||||
/* Clear the frame pointer and link register since this is the outermost
|
||||
@@ -150,12 +131,6 @@ __start:
|
||||
|
||||
mcall up_lowinit
|
||||
|
||||
doputc 'D'
|
||||
|
||||
/* Board specific early initialization */
|
||||
|
||||
mcall up_ledinit
|
||||
|
||||
/* Then jump to OS entry (will not return) */
|
||||
|
||||
rjmp os_start
|
||||
|
||||
@@ -175,7 +175,7 @@ extern uint32_t *up_va2pte(uintptr_t vaddr);
|
||||
# define up_pginitialize()
|
||||
#endif /* CONFIG_PAGING */
|
||||
|
||||
/* Defined in up_allocateheap.c */
|
||||
/* Defined in common/up_allocateheap.c or chip/xxx_allocateheap.c */
|
||||
|
||||
#if CONFIG_MM_REGIONS > 1
|
||||
void up_addregion(void);
|
||||
@@ -183,7 +183,15 @@ void up_addregion(void);
|
||||
# define up_addregion()
|
||||
#endif
|
||||
|
||||
/* Defined in up_serial.c */
|
||||
/* Defined in chip/xxx_lowinit.c. This function is called from the
|
||||
* head.S file just before jumping to os_start(). This function
|
||||
* performs whatever very low level initialization that is needed
|
||||
* before the OS gets started (clocks, console, LEDs, etc.)
|
||||
*/
|
||||
|
||||
extern void up_lowinit(void);
|
||||
|
||||
/* Defined in chip/xxx_serial.c */
|
||||
|
||||
#if CONFIG_NFILE_DESCRIPTORS > 0
|
||||
extern void up_earlyserialinit(void);
|
||||
@@ -201,27 +209,25 @@ extern void lowconsole_init(void);
|
||||
# define lowconsole_init()
|
||||
#endif
|
||||
|
||||
/* Defined in up_timerisr.c */
|
||||
/* Defined in chip/xxx_timerisr.c */
|
||||
|
||||
extern void up_timerinit(void);
|
||||
|
||||
/* Defined in up_irq.c */
|
||||
/* Defined in chip/xxx_irq.c */
|
||||
|
||||
extern void up_maskack_irq(int irq);
|
||||
|
||||
/* Defined in board/up_leds.c */
|
||||
/* Defined in configs/<board-name>/src/up_leds.c */
|
||||
|
||||
#ifdef CONFIG_ARCH_LEDS
|
||||
extern void up_ledinit(void);
|
||||
extern void up_ledon(int led);
|
||||
extern void up_ledoff(int led);
|
||||
#else
|
||||
# define up_ledinit()
|
||||
# define up_ledon(led)
|
||||
# define up_ledoff(led)
|
||||
#endif
|
||||
|
||||
/* Defined in board/up_network.c */
|
||||
/* Defined in chip/xxx_ethernet.c */
|
||||
|
||||
#ifdef CONFIG_NET
|
||||
extern void up_netinitialize(void);
|
||||
@@ -229,7 +235,7 @@ extern void up_netinitialize(void);
|
||||
# define up_netinitialize()
|
||||
#endif
|
||||
|
||||
/* Defined in board/up_ethernet.c */
|
||||
/* Defined in chip/xxx_usbdev.c */
|
||||
|
||||
#ifdef CONFIG_USBDEV
|
||||
extern void up_usbinitialize(void);
|
||||
|
||||
@@ -101,14 +101,20 @@ CONFIG_AVR32_AVRTOOLSL=n
|
||||
#
|
||||
# CONFIG_AVR32_USARTn - Enable support for USARTn
|
||||
# CONFIG_AVR32_USARTn_RS232 - Configure USARTn as an RS232 interface.
|
||||
# CONFIG_AVR32_USARTn_SPI - Configure USARTn as an SPI interface.
|
||||
#
|
||||
|
||||
CONFIG_AVR32_USART0=y
|
||||
CONFIG_AVR32_USART1=n
|
||||
CONFIG_AVR32_USART2=n
|
||||
CONFIG_AVR32_USART0_RS232=y
|
||||
CONFIG_AVR32_USART1_RS232=y
|
||||
CONFIG_AVR32_USART2_RS232=y
|
||||
CONFIG_AVR32_USART0_SPI=n
|
||||
|
||||
CONFIG_AVR32_USART1=n
|
||||
CONFIG_AVR32_USART1_RS232=n
|
||||
CONFIG_AVR32_USART1_SPI=n
|
||||
|
||||
CONFIG_AVR32_USART2=n
|
||||
CONFIG_AVR32_USART2_RS232=n
|
||||
CONFIG_AVR32_USART2_SPI=n
|
||||
|
||||
#
|
||||
# AVR32 specific serial device driver settings
|
||||
|
||||
@@ -48,7 +48,7 @@
|
||||
* Definitions
|
||||
************************************************************************************/
|
||||
|
||||
/* AT91DEV1 GPIO Pin Definitions ****************************************************/
|
||||
/* AVRDEV1 GPIO Pin Definitions *****************************************************/
|
||||
|
||||
/************************************************************************************
|
||||
* Public Types
|
||||
@@ -64,6 +64,17 @@
|
||||
* Public Functions
|
||||
************************************************************************************/
|
||||
|
||||
/************************************************************************************
|
||||
* Name: avr32dev1_ledinitialize
|
||||
*
|
||||
* Description:
|
||||
* Configure on-board LEDs if LED support has been selected.
|
||||
************************************************************************************/
|
||||
|
||||
#ifdef CONFIG_ARCH_LEDS
|
||||
extern void avr32dev1_ledinitialize(void);
|
||||
#endif
|
||||
|
||||
#endif /* __ASSEMBLY__ */
|
||||
#endif /* _CONFIGS_AT91DEV1_SRC_AT91DEV1_INTERNAL_H */
|
||||
|
||||
|
||||
@@ -63,7 +63,7 @@
|
||||
************************************************************************************/
|
||||
|
||||
/************************************************************************************
|
||||
* Name: avr32_boardinitialize
|
||||
* Name: at91uc3_boardinitialize
|
||||
*
|
||||
* Description:
|
||||
* All AVR32 architectures must provide the following entry point. This entry point
|
||||
@@ -72,13 +72,13 @@
|
||||
*
|
||||
************************************************************************************/
|
||||
|
||||
void avr32_boardinitialize(void)
|
||||
void at91uc3_boardinitialize(void)
|
||||
{
|
||||
/* Configure SPI chip selects */
|
||||
|
||||
/* Configure on-board LEDs if LED support has been selected. */
|
||||
|
||||
#ifdef CONFIG_ARCH_LEDS
|
||||
up_ledinit();
|
||||
avr32dev1_ledinitialize();
|
||||
#endif
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user