##// END OF EJS Templates
Added STM32F4 target, improved rules files, added additional Include folder var...
Added STM32F4 target, improved rules files, added additional Include folder var for project files.

File last commit:

r12:cc0fb1c881c0 default
r14:c6ae61909bfd default
Show More
bsp.c
88 lines | 2.4 KiB | text/x-c | CLexer
/*------------------------------------------------------------------------------
-- This file is a part of the libuc, microcontroler library
-- Copyright (C) 2011, Alexis Jeandet
--
-- This program is free software; you can redistribute it and/or modify
-- it under the terms of the GNU General Public License as published by
-- the Free Software Foundation; either version 3 of the License, or
-- (at your option) any later version.
--
-- This program is distributed in the hope that it will be useful,
-- but WITHOUT ANY WARRANTY; without even the implied warranty of
-- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-- GNU General Public License for more details.
--
-- You should have received a copy of the GNU General Public License
-- along with this program; if not, write to the Free Software
-- Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
-------------------------------------------------------------------------------
-- Author : Alexis Jeandet
-- Mail : alexis.jeandet@gmail.com
-------------------------------------------------------------------------------*/
#include "bsp.h"
#include "core.h"
unsigned int OSC0 =12000000;
unsigned int INTOSC =4000000;
unsigned int RTCOSC =32768;
unsigned int currentCpuFreq=0;
uartDev UART0=(uartDev)0;
uartDev UART1=(uartDev)0;
uartDev UART2=(uartDev)0;
uartDev UART3=(uartDev)0;
int bsp_init()
{
bsp_GPIO_init();
coresetCpuFreq(40000000);
currentCpuFreq=coregetCpuFreq();
coresetCpuFreq(80000000);
currentCpuFreq=coregetCpuFreq();
bsp_uart_init();
return 0;
}
void bsp_GPIO_init()
{
LPC_SC->PCONP |= ( 1 << 15 ); // power up GPIO
LPC_GPIO1->FIODIR |= (1<<18)+(1<<20)+(1<<21)+(1<<23); // puts P1.18 20 21 23 into output mode.
LED1_OFF;
LED2_OFF;
LED3_OFF;
LED4_OFF;
}
void bsp_uart_init()
{
LPC_SC->PCONP |= ( 1 << 25 ); // power up UART3
LPC_SC->PCONP |= ( 1 << 4 ); // power up UART1
LPC_PINCON->PINSEL0 |= (1<<1);
LPC_PINCON->PINSEL0 &= ~(1<<0);
LPC_PINCON->PINSEL0 |= (1<<3);
LPC_PINCON->PINSEL0 &= ~(1<<2);
LPC_PINCON->PINSEL0 |= (1<<30);
LPC_PINCON->PINSEL0 &= ~(1<<31);
LPC_PINCON->PINSEL1 |= (1<<0);
LPC_PINCON->PINSEL1 &= ~(1<<1);
UART3= uartopen(3);
uartsetup(UART3,9600,8,1,uartNoParity);
UART1= uartopen(1);
uartsetup(UART1,38400,8,1,uartNoParity);
}
void consoleputc(char c)
{
uartputc(UART1,c);
}
char consolegetc()
{
return uartgetc(UART1);
}