2013-08-07 12:25:03 +02:00
|
|
|
/*
|
|
|
|
* main.c - Main function of the SRF02 ultrasonic sensor project.
|
|
|
|
* Copyright (C) 2013 Zakaria Kasmi <zkasmi@inf.fu-berlin.de>
|
|
|
|
*
|
2014-07-31 20:15:03 +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.
|
2013-08-07 12:25:03 +02: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>
|
2013-08-07 12:25:03 +02:00
|
|
|
*
|
|
|
|
* @note $Id$
|
|
|
|
*/
|
|
|
|
|
2013-12-16 17:54:58 +01:00
|
|
|
#include "board.h"
|
|
|
|
#include "cpu.h"
|
2010-09-22 15:10:42 +02:00
|
|
|
|
|
|
|
void bl_init_ports(void)
|
|
|
|
{
|
2015-06-09 12:45:35 +02:00
|
|
|
gpio_init_ports();
|
2010-09-22 15:10:42 +02:00
|
|
|
|
|
|
|
/* UART0 */
|
|
|
|
PINSEL0 |= BIT4 + BIT6; // RxD0 and TxD0
|
|
|
|
PINSEL0 &= ~(BIT5 + BIT7);
|
|
|
|
|
|
|
|
/* LEDS */
|
2016-03-11 18:04:26 +01:00
|
|
|
FIO3DIR |= LED0_MASK;
|
|
|
|
FIO3DIR |= LED1_MASK;
|
2013-07-29 16:41:43 +02:00
|
|
|
|
2016-03-11 18:04:26 +01:00
|
|
|
LED0_OFF;
|
|
|
|
LED0_OFF;
|
2010-09-22 15:10:42 +02:00
|
|
|
}
|
2010-12-06 16:06:14 +01:00
|
|
|
|
2013-08-07 12:25:03 +02:00
|
|
|
void init_clks1(void)
|
|
|
|
{
|
|
|
|
// Disconnect PLL
|
|
|
|
PLLCON &= ~0x0002;
|
|
|
|
pllfeed();
|
|
|
|
|
|
|
|
// Disable PLL
|
|
|
|
PLLCON &= ~0x0001;
|
|
|
|
pllfeed();
|
|
|
|
|
|
|
|
SCS |= 0x20; // Enable main OSC
|
2013-09-19 16:53:35 +02:00
|
|
|
|
|
|
|
while (!(SCS & 0x40)); // Wait until main OSC is usable
|
2013-08-07 12:25:03 +02:00
|
|
|
|
|
|
|
/* select main OSC, 16MHz, as the PLL clock source */
|
|
|
|
CLKSRCSEL = 0x0001;
|
|
|
|
|
|
|
|
// Setting Multiplier and Divider values
|
|
|
|
PLLCFG = 0x0008; // M=9 N=1 Fcco = 288 MHz
|
|
|
|
pllfeed();
|
|
|
|
|
|
|
|
// Enabling the PLL */
|
|
|
|
PLLCON = 0x0001;
|
|
|
|
pllfeed();
|
|
|
|
|
|
|
|
/* Set clock divider to 4 (value+1) */
|
|
|
|
CCLKCFG = CL_CPU_DIV - 1; // Fcpu = 72 MHz
|
|
|
|
|
|
|
|
#if USE_USB
|
|
|
|
USBCLKCFG = USBCLKDivValue; /* usbclk = 288 MHz/6 = 48 MHz */
|
|
|
|
#endif
|
2013-09-19 16:53:35 +02:00
|
|
|
}
|