2014-05-15 08:49:20 +02:00
|
|
|
/*
|
|
|
|
* Copyright (C) 2008-2009, Freie Universitaet Berlin
|
|
|
|
*
|
2014-07-31 19:45:27 +02:00
|
|
|
* This file is subject to the terms and conditions of the GNU Lesser
|
|
|
|
* General Public License v2.1. See the file LICENSE in the top level
|
|
|
|
* directory for more details.
|
2014-05-15 08:49:20 +02:00
|
|
|
*/
|
2010-12-06 16:06:14 +01:00
|
|
|
|
|
|
|
/**
|
|
|
|
* @ingroup msba2
|
|
|
|
* @{
|
|
|
|
*/
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @file
|
|
|
|
* @brief MSB-A2 board initialization
|
|
|
|
*
|
|
|
|
* @author Heiko Will
|
|
|
|
* @author Kaspar Schleiser
|
|
|
|
* @author Michael Baar <baar@inf.fu-berlin.de>
|
2014-07-31 20:34:28 +02:00
|
|
|
* @author Zakaria Kasmi <zkasmi@inf.fu-berlin.de>
|
2010-12-06 16:06:14 +01:00
|
|
|
* @note $Id$
|
|
|
|
*/
|
|
|
|
#include <string.h>
|
2013-12-16 17:54:58 +01:00
|
|
|
#include "board.h"
|
2014-01-20 19:38:01 +01:00
|
|
|
#include "msba2_common.h"
|
2013-12-16 17:54:58 +01:00
|
|
|
#include "lpc23xx.h"
|
|
|
|
#include "cpu.h"
|
2010-12-06 16:06:14 +01:00
|
|
|
|
2014-07-31 20:34:28 +02:00
|
|
|
#define CL_CPU_DIV 4
|
2010-12-06 16:06:14 +01:00
|
|
|
|
2015-07-17 10:05:33 +02:00
|
|
|
#define WD_INTERVAL 10 /**< number of seconds before WD triggers */
|
2013-11-25 16:51:18 +01:00
|
|
|
|
2010-12-06 16:06:14 +01:00
|
|
|
/*---------------------------------------------------------------------------*/
|
|
|
|
/**
|
|
|
|
* @brief Enabling MAM and setting number of clocks used for Flash memory fetch
|
|
|
|
* @internal
|
|
|
|
*/
|
|
|
|
static void
|
|
|
|
init_mam(void)
|
|
|
|
{
|
|
|
|
MAMCR = 0x0000;
|
|
|
|
MAMTIM = 0x0003;
|
|
|
|
MAMCR = 0x0002;
|
|
|
|
}
|
|
|
|
/*---------------------------------------------------------------------------*/
|
2013-09-19 16:53:35 +02:00
|
|
|
void init_clks2(void)
|
|
|
|
{
|
2010-12-06 16:06:14 +01:00
|
|
|
// Wait for the PLL to lock to set frequency
|
2013-09-19 16:53:35 +02:00
|
|
|
while (!(PLLSTAT & BIT26));
|
2010-12-06 16:06:14 +01:00
|
|
|
|
|
|
|
// Connect the PLL as the clock source
|
|
|
|
PLLCON = 0x0003;
|
|
|
|
pllfeed();
|
|
|
|
|
|
|
|
/* Check connect bit status */
|
|
|
|
while (!(PLLSTAT & BIT25));
|
|
|
|
}
|
|
|
|
|
2013-11-25 16:51:18 +01:00
|
|
|
void watchdog_init(void)
|
|
|
|
{
|
|
|
|
WDCLKSEL = 0; // clock source: RC oscillator
|
|
|
|
WDMOD &= ~WDTOF; // clear time-out flag
|
|
|
|
WDTC = (F_RC_OSCILLATOR / 4) * WD_INTERVAL;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2010-12-06 16:06:14 +01:00
|
|
|
void bl_init_clks(void)
|
|
|
|
{
|
2013-11-25 16:51:18 +01:00
|
|
|
watchdog_init();
|
2010-12-06 16:06:14 +01:00
|
|
|
PCONP = PCRTC; // switch off everything except RTC
|
|
|
|
init_clks1();
|
|
|
|
init_clks2();
|
|
|
|
init_mam();
|
|
|
|
}
|
|
|
|
|
2013-08-07 12:25:03 +02:00
|
|
|
/*---------------------------------------------------------------------------*/
|