1
0
mirror of https://github.com/esp8266/Arduino.git synced 2025-07-30 16:24:09 +03:00

[sam] fixing last stupid commit

This commit is contained in:
Thibaut VIARD
2011-09-06 21:05:41 +02:00
parent 8f01f92e87
commit a5d2349761
550 changed files with 16866 additions and 17198 deletions

View File

@ -1,46 +1,33 @@
/* ----------------------------------------------------------------------------
* ATMEL Microcontroller Software Support
* ----------------------------------------------------------------------------
* Copyright (c) 2009, Atmel Corporation
/*! \file *********************************************************************
*
* All rights reserved.
* \brief This file contains the default exception handlers.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
* \par Purpose
*
* - Redistributions of source code must retain the above copyright notice,
* this list of conditions and the disclaimer below.
*
* Atmel's name may not be used to endorse or promote products derived from
* this software without specific prior written permission.
*
* DISCLAIMER: THIS SOFTWARE IS PROVIDED BY ATMEL "AS IS" AND ANY EXPRESS OR
* IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT ARE
* DISCLAIMED. IN NO EVENT SHALL ATMEL 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.
* ----------------------------------------------------------------------------
*/
/**
* \file
* This file contains the default exception handlers.
* This file provides basic support for Cortex-M processor based
* microcontrollers.
*
* \note
* The exception handler has weak aliases.
* As they are weak aliases, any function with the same name will override
* this definition.
*/
*
* \author Atmel Corporation: http://www.atmel.com \n
* Support and FAQ: http://support.atmel.no/
*
******************************************************************************/
/* $asf_license$ */
#include "exceptions.h"
/*----------------------------------------------------------------------------
* Exported functions
*----------------------------------------------------------------------------*/
/* @cond 0 */
/**INDENT-OFF**/
#ifdef __cplusplus
extern "C" {
#endif
/**INDENT-ON**/
/* @endcond */
#ifdef __GNUC__
/* Cortex-M3 core handlers */
@ -88,7 +75,7 @@ extern void USART0_IrqHandler( void ) __attribute__ ((weak, alias ("Dummy_Handle
extern void USART1_IrqHandler( void ) __attribute__ ((weak, alias ("Dummy_Handler"))) ;
extern void USBD_IrqHandler( void ) __attribute__ ((weak, alias ("Dummy_Handler"))) ;
extern void WDT_IrqHandler( void ) __attribute__ ((weak, alias ("Dummy_Handler"))) ;
#endif // __GNUC__
#endif /* __GNUC__ */
#ifdef __ICCARM__
/* Cortex-M3 core handlers */
@ -136,12 +123,20 @@ extern void WDT_IrqHandler( void ) __attribute__ ((weak, alias ("Dummy_Handler")
#pragma weak USART1_IrqHandler=Dummy_Handler
#pragma weak USBD_IrqHandler=Dummy_Handler
#pragma weak WDT_IrqHandler=Dummy_Handler
#endif // __ICCARM__
#endif /* __ICCARM__ */
/**
* \brief Default interrupt handler for not used irq.
* \brief Default interrupt handler for unused IRQs.
*/
void Dummy_Handler( void )
{
while ( 1 ) ;
while ( 1 ) {}
}
/* @cond 0 */
/**INDENT-OFF**/
#ifdef __cplusplus
}
#endif
/**INDENT-ON**/
/* @endcond */

View File

@ -1,50 +1,33 @@
/* ----------------------------------------------------------------------------
* ATMEL Microcontroller Software Support
* ----------------------------------------------------------------------------
* Copyright (c) 2009, Atmel Corporation
/*! \file *********************************************************************
*
* All rights reserved.
* \brief This file contains the interface for default exception handlers.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
* \par Purpose
*
* - Redistributions of source code must retain the above copyright notice,
* this list of conditions and the disclaimer below.
* This file provides basic support for Cortex-M processor based
* microcontrollers.
*
* Atmel's name may not be used to endorse or promote products derived from
* this software without specific prior written permission.
* \author Atmel Corporation: http://www.atmel.com \n
* Support and FAQ: http://support.atmel.no/
*
* DISCLAIMER: THIS SOFTWARE IS PROVIDED BY ATMEL "AS IS" AND ANY EXPRESS OR
* IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT ARE
* DISCLAIMED. IN NO EVENT SHALL ATMEL 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.
* ----------------------------------------------------------------------------
*/
******************************************************************************/
/**
* \file
* Interface for default exception handlers.
*/
/* $asf_license$ */
#ifndef _EXCEPTIONS_
#define _EXCEPTIONS_
/*----------------------------------------------------------------------------
* Types
*----------------------------------------------------------------------------*/
/* @cond 0 */
/**INDENT-OFF**/
#ifdef __cplusplus
extern "C" {
#endif
/**INDENT-ON**/
/* @endcond */
/* Function prototype for exception table items (interrupt handler). */
typedef void( *IntFunc )( void ) ;
/*----------------------------------------------------------------------------
* Exported functions
*----------------------------------------------------------------------------*/
/* Default empty handler */
extern void Dummy_Handler( void ) ;
@ -94,5 +77,12 @@ extern void USART1_IrqHandler( void ) ;
extern void USBD_IrqHandler( void ) ;
extern void WDT_IrqHandler( void ) ;
/* @cond 0 */
/**INDENT-OFF**/
#ifdef __cplusplus
}
#endif
/**INDENT-ON**/
/* @endcond */
#endif /* _EXCEPTIONS_ */

View File

@ -17,7 +17,7 @@
*------------------------------------------------------------------------------*/
#include "exceptions.h"
#include "sam3sd8.h"
#include "sam3s8.h"
#include "system_sam3sd8.h"
/*----------------------------------------------------------------------------

View File

@ -1,61 +1,33 @@
/* ----------------------------------------------------------------------------
* ATMEL Microcontroller Software Support
* ----------------------------------------------------------------------------
* Copyright (c) 2009, Atmel Corporation
/*! \file *********************************************************************
*
* All rights reserved.
* \brief Provides the low-level initialization functions that called
* on chip startup.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
* \par Purpose
*
* - Redistributions of source code must retain the above copyright notice,
* this list of conditions and the disclaimer below.
* This file provides basic support for Cortex-M processor based
* microcontrollers.
*
* Atmel's name may not be used to endorse or promote products derived from
* this software without specific prior written permission.
* \author Atmel Corporation: http://www.atmel.com \n
* Support and FAQ: http://support.atmel.no/
*
* DISCLAIMER: THIS SOFTWARE IS PROVIDED BY ATMEL "AS IS" AND ANY EXPRESS OR
* IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT ARE
* DISCLAIMED. IN NO EVENT SHALL ATMEL 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.
* ----------------------------------------------------------------------------
*/
******************************************************************************/
/**
* \file
*
* Provides the low-level initialization function that called on chip startup.
*/
/*----------------------------------------------------------------------------
* Headers
*----------------------------------------------------------------------------*/
/* $asf_license$ */
#include "system_sam3sd8.h"
#include "sam3sd8.h"
#include "sam3s8.h"
#include "sam3s_ek2.h"
/*----------------------------------------------------------------------------
* Local definitions
*----------------------------------------------------------------------------*/
/* @cond 0 */
/**INDENT-OFF**/
#ifdef __cplusplus
extern "C" {
#endif
/**INDENT-ON**/
/* @endcond */
/* Clock settings at 48MHz */
#if (BOARD_MCK == 48000000)
#define BOARD_OSCOUNT (CKGR_MOR_MOSCXTST(0x8))
#define BOARD_PLLAR (CKGR_PLLAR_STUCKTO1 \
| CKGR_PLLAR_MULA(0x7) \
| CKGR_PLLAR_PLLACOUNT(0x3f) \
| CKGR_PLLAR_DIVA(0x1))
#define BOARD_MCKR (PMC_MCKR_PRES_CLK_2 | PMC_MCKR_CSS_PLLA_CLK)
/* Clock settings at 64MHz */
#elif (BOARD_MCK == 64000000)
/* Clock settings (64MHz) */
#define BOARD_OSCOUNT (CKGR_MOR_MOSCXTST(0x8))
#define BOARD_PLLAR (CKGR_PLLAR_STUCKTO1 \
| CKGR_PLLAR_MULA(0xf) \
@ -63,28 +35,20 @@
| CKGR_PLLAR_DIVA(0x3))
#define BOARD_MCKR (PMC_MCKR_PRES_CLK | PMC_MCKR_CSS_PLLA_CLK)
#else
#error "No settings for current BOARD_MCK."
#endif
/* Clock Definitions */
#define XTAL32 ( 32768UL) /* 32k crystal frequency */
#define OSC32_CLK ( XTAL32) /* 32k oscillator frequency */
#define ERC_OSC ( 32000UL) /* Embedded RC oscillator freqquency */
#define EFRC_OSC ( 4000000UL) /* Embedded fast RC oscillator freq */
#define MAINCK_XTAL_HZ (12000000UL) /* External crystal frequency */
#define MCK_HZ (64000000UL) /* Processor frequency */
/*----------------------------------------------------------------------------
Define clocks
*----------------------------------------------------------------------------*/
#define XTAL32 ( 32768UL) /* 32k crystal frequency */
#define OSC32_CLK ( XTAL32) /* 32k oscillator frequency */
#define ERC_OSC ( 32000UL) /* Embedded RC oscillator freqquency */
#define EFRC_OSC ( 4000000UL) /* Embedded fast RC oscillator freq */
uint32_t SystemCoreClock = 4000000; // FIXME: default mainck should be generated by sock!!!
/* FIXME: should be generated by sock */
uint32_t SystemCoreClock = EFRC_OSC;
/**
* Initialize the system
*
* @param none
* @return none
*
* @brief Setup the microcontroller system.
* Initialize the System and update the SystemFrequency variable.
* \brief Setup the microcontroller system.
* Initialize the System and update the SystemFrequency variable.
*/
extern void SystemInit( void )
{
@ -116,8 +80,8 @@ extern void SystemInit( void )
/* Switch to PLLA */
PMC->PMC_MCKR = BOARD_MCKR ;
while (!(PMC->PMC_SR & PMC_SR_MCKRDY));
SystemCoreClock = BOARD_MCK;
SystemCoreClock = MCK_HZ;
}
extern void SystemCoreClockUpdate( void )
@ -127,15 +91,15 @@ extern void SystemCoreClockUpdate( void )
case PMC_MCKR_CSS_SLOW_CLK: /* Slow clock */
if (SUPC->SUPC_SR & SUPC_SR_OSCSEL)
SystemCoreClock = OSC32_CLK;
else
else
SystemCoreClock = ERC_OSC;
break;
case PMC_MCKR_CSS_MAIN_CLK: /* Main clock */
if (PMC->CKGR_MOR & CKGR_MOR_MOSCSEL)
SystemCoreClock = BOARD_OSC_MAINCK_XTAL_HZ;
SystemCoreClock = MAINCK_XTAL_HZ;
else {
SystemCoreClock = EFRC_OSC;
switch (PMC->CKGR_MOR & CKGR_MOR_MOSCRCF_Msk) {
case CKGR_MOR_MOSCRCF_4MHz:
break;
@ -153,10 +117,10 @@ extern void SystemCoreClockUpdate( void )
case PMC_MCKR_CSS_PLLA_CLK: /* PLLA clock */
case PMC_MCKR_CSS_PLLB_CLK: /* PLLB clock */
if (PMC->CKGR_MOR & CKGR_MOR_MOSCSEL)
SystemCoreClock = BOARD_OSC_MAINCK_XTAL_HZ;
SystemCoreClock = MAINCK_XTAL_HZ;
else {
SystemCoreClock = EFRC_OSC;
switch (PMC->CKGR_MOR & CKGR_MOR_MOSCRCF_Msk) {
case CKGR_MOR_MOSCRCF_4MHz:
break;
@ -176,13 +140,21 @@ extern void SystemCoreClockUpdate( void )
}
else {
SystemCoreClock *= ((((PMC->CKGR_PLLBR) >> CKGR_PLLBR_MULB_Pos) & 0x7FF) + 1);
SystemCoreClock /= ((((PMC->CKGR_PLLBR) >> CKGR_PLLBR_DIVB_Pos) & 0x0FF));
SystemCoreClock /= ((((PMC->CKGR_PLLBR) >> CKGR_PLLBR_DIVB_Pos) & 0x0FF));
}
break;
}
if ((PMC->PMC_MCKR & PMC_MCKR_PRES_Msk) == PMC_MCKR_PRES_CLK_3)
SystemCoreClock /= 3;
else
else
SystemCoreClock >>= ((PMC->PMC_MCKR & PMC_MCKR_PRES_Msk) >> PMC_MCKR_PRES_Pos);
}
/* @cond 0 */
/**INDENT-OFF**/
#ifdef __cplusplus
}
#endif
/**INDENT-ON**/
/* @endcond */