##// END OF EJS Templates
just backup
just backup

File last commit:

r11:798f00e676fa default
r12:cc0fb1c881c0 default
Show More
bsp.c
136 lines | 3.3 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;
float VREF0 =(float)3.3;
uartDev* UART0=(uartDev*)0;
uartDev* UART1=(uartDev*)0;
uartDev* UART2=(uartDev*)0;
uartDev* UART3=(uartDev*)0;
i2cDev* IIC0=(i2cDev*)0;
i2cDev* IIC1=(i2cDev*)0;
i2cDev* IIC2=(i2cDev*)0;
sspDev* SSP0=(sspDev*)0;
sspDev* SSP1=(sspDev*)0;
eeprom24lc0xDev eeprom0;
int bsp_init()
{
bsp_GPIO_init();
coresetCpuFreq(20000000);
currentCpuFreq=coregetCpuFreq();
coresetCpuFreq(60000000);
currentCpuFreq=coregetCpuFreq();
bsp_uart_init();
bsp_iic_init();
bsp_ssp_init();
return 0;
}
void bsp_GPIO_init()
{
LPC_SC->PCONP |= ( 1 << 15 ); // power up GPIO
LPC_GPIO2->FIODIR |=255;
LEDS_OFF;
}
void bsp_uart_init()
{
LPC_SC->PCONP |= ( 1 << 24 ); // power up UART3
LPC_SC->PCONP |= ( 1 << 4 ); // power up UART1
LPC_PINCON->PINSEL0 |= (1<<4);
LPC_PINCON->PINSEL0 &= ~(1<<5);
LPC_PINCON->PINSEL0 |= (1<<6);
LPC_PINCON->PINSEL0 &= ~(1<<7);
LPC_PINCON->PINSEL0 |= (1<<20);
LPC_PINCON->PINSEL0 &= ~(1<<21);
LPC_PINCON->PINSEL0 |= (1<<22);
LPC_PINCON->PINSEL0 &= ~(1<<23);
UART0= uartopen(0);
uartsetup(UART0,38400,8,1,uartNoParity);
UART2= uartopen(2);
uartsetup(UART2,38400,8,1,uartNoParity);
}
void bsp_ssp_init()
{
SSP0 = sspopen(0); // power up SSP0
ssppowerup(SSP0);
sspsetpclkfactor(SSP0,1);
LPC_PINCON->PINSEL3 |= (3<<14); //MISO0 on P1.23
LPC_PINCON->PINSEL3 |= (3<<16); //MOSI0 on P1.24
LPC_PINCON->PINSEL3 |= (3<<8); //SCK0 on P1.24
LPC_PINCON->PINSEL3 |= (3<<10); //SSEL0 on P1.21
sspsetup(SSP0,8,FFSPI|CLKINHLOW|CKfirstEdge,loopbackOFF|MASTERMODE, 250000);
enableSSP(SSP0);
}
void bsp_iic_init()
{
LPC_SC->PCONP |= ( 1 << 7 ); // power up IIC0
LPC_PINCON->PINSEL1 |= (1<<22);
LPC_PINCON->PINSEL1 &= ~(1<<23);
LPC_PINCON->PINSEL1 |= (1<<24);
LPC_PINCON->PINSEL1 &= ~(1<<25);
IIC0 = i2copen(0);
i2csetdatarate(IIC0,100000);
eeprom24lc0xopen(&eeprom0,IIC0,0,2048);
}
void consoleputc(char c)
{
uartputc(UART0,c);
}
char consolegetc()
{
return uartgetc(UART0);
}
void vs10XXclearXCS(){}
void vs10XXsetXCS(){}
int vs10XXDREQ()
{
return 1;
}