|
|
/*------------------------------------------------------------------------------
|
|
|
-- 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 <streamdevices.h>
|
|
|
#include <malloc.h>
|
|
|
#include <gpio.h>
|
|
|
#include <uart.h>
|
|
|
#include <stdio.h>
|
|
|
uint32_t OSC0 =8000000;
|
|
|
uint32_t INTOSC =16000000;
|
|
|
uint32_t RTCOSC =32768;
|
|
|
uint32_t currentCpuFreq=0;
|
|
|
extern streamdevice* __opnfiles__[__MAX_OPENED_FILES__];
|
|
|
|
|
|
float VREF0 =(float)3.3;
|
|
|
|
|
|
int bsp_init()
|
|
|
{
|
|
|
int i=0;
|
|
|
for(i=0;i<32;i++)
|
|
|
{
|
|
|
__opnfiles__[i] = NULL;
|
|
|
}
|
|
|
bsp_GPIO_init();
|
|
|
bsp_uart_init();
|
|
|
printf("\r================================================================\n\r");
|
|
|
printf("================================================================\n\r");
|
|
|
printf(BSP);
|
|
|
printf(" initialised\n\r");
|
|
|
printf("================================================================\n\r");
|
|
|
return 1;
|
|
|
}
|
|
|
|
|
|
void bsp_GPIO_init()
|
|
|
{
|
|
|
gpio_t gpio1 = gpioopen(LED1);
|
|
|
gpio_t gpio2 = gpioopen(LED2);
|
|
|
gpio_t gpio3 = gpioopen(LED3);
|
|
|
gpio_t gpio4 = gpioopen(PSU_DISABLE);
|
|
|
gpio_t gpio5 = gpioopen(PSU_ALERT_5V);
|
|
|
gpio_t gpio6 = gpioopen(PSU_ALERT_1_5V);
|
|
|
gpio_t gpio7 = gpioopen(PSU_ALERT_3_3V);
|
|
|
gpiosetspeed(&gpio1,gpiohighspeed);
|
|
|
gpiosetspeed(&gpio2,gpiohighspeed);
|
|
|
gpiosetspeed(&gpio3,gpiohighspeed);
|
|
|
gpiosetspeed(&gpio4,gpiohighspeed);
|
|
|
gpiosetspeed(&gpio5,gpiohighspeed);
|
|
|
gpiosetspeed(&gpio6,gpiohighspeed);
|
|
|
gpiosetspeed(&gpio7,gpiohighspeed);
|
|
|
gpioclr(PSU_DISABLE);
|
|
|
gpiosetdir(&gpio1,gpiooutdir);
|
|
|
gpiosetdir(&gpio3,gpiooutdir);
|
|
|
gpiosetdir(&gpio2,gpiooutdir);
|
|
|
gpiosetdir(&gpio4,gpiooutdir);
|
|
|
gpiosetdir(&gpio5,gpioindir);
|
|
|
gpiosetdir(&gpio6,gpioindir);
|
|
|
gpiosetdir(&gpio7,gpioindir);
|
|
|
gpioclr(PSU_DISABLE);
|
|
|
}
|
|
|
|
|
|
void bsp_uart_init()
|
|
|
{
|
|
|
if(__opnfiles__[1]==NULL)
|
|
|
{
|
|
|
uart_t* uart1 = (uart_t*)malloc(sizeof(uart_t));
|
|
|
streamdevice* fd1 = (streamdevice*)malloc(sizeof(streamdevice));
|
|
|
uartopenandconfig(0,uart1,uartparitynone | uart8bits | uartonestop,115200,PA9,PA10,-1,-1);
|
|
|
uartmkstreamdev(uart1,fd1);
|
|
|
__opnfiles__[1] = fd1;
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
uartopenandconfig(0,(uart_t*)__opnfiles__[1]->_stream,uartparitynone | uart8bits | uartonestop,115200,PA9,PA10,-1,-1);
|
|
|
}
|
|
|
}
|
|
|
|
|
|
void bsp_spi_init()
|
|
|
{
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
void bsp_iic_init()
|
|
|
{
|
|
|
|
|
|
}
|
|
|
|
|
|
void bsp_SD_init()
|
|
|
{
|
|
|
|
|
|
}
|
|
|
|
|
|
void vs10XXclearXCS(){}
|
|
|
void vs10XXsetXCS(){}
|
|
|
int vs10XXDREQ()
|
|
|
{
|
|
|
return 1;
|
|
|
}
|
|
|
|
|
|
|
|
|
void bsppowersdcard(char onoff) //always ON
|
|
|
{
|
|
|
|
|
|
}
|
|
|
|
|
|
char bspsdcardpresent()
|
|
|
{
|
|
|
return 0;
|
|
|
}
|
|
|
|
|
|
char bspsdcardwriteprotected()
|
|
|
{
|
|
|
return 0;
|
|
|
}
|
|
|
|
|
|
void bspsdcardselect(char YESNO)
|
|
|
{
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|