##// END OF EJS Templates
Added Simulator target to run code on x86 and debug functions....
Added Simulator target to run code on x86 and debug functions. Fixed some bugs on terminal widget.

File last commit:

r56:bf21d93f0037 dev_alexis
r63:68dfbccdd813 dev_alexis
Show More
bsp.c
312 lines | 8.4 KiB | text/x-c | CLexer
jeandet@pc-de-jeandet3.LAB-LPP.LOCAL
Now uses qmake to compile an Qt-creator compatible!
r18 /*------------------------------------------------------------------------------
-- 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
Factorised stream device structure to reduce memory usage....
r51 -- Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
jeandet@pc-de-jeandet3.LAB-LPP.LOCAL
Now uses qmake to compile an Qt-creator compatible!
r18 -------------------------------------------------------------------------------
-- 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>
jeandet@pc-de-jeandet3.LAB-LPP.LOCAL
sync
r25 #include <stm32f4xx_gpio.h>
jeandet@pc-de-jeandet3.LAB-LPP.LOCAL
I2C library partially validated, ina226 library partially validated.
r30 #include <stm32f4xx_fsmc.h>
jeandet@PC-DE-JEANDET.lab-lpp.local
sync
r29 #include <i2c.h>
jeandet@pc-de-jeandet3.LAB-LPP.LOCAL
Sync
r39 #include <core.h>
Factorised stream device structure to reduce memory usage....
r51 #include <terminal.h>
jeandet@pc-de-jeandet3.LAB-LPP.LOCAL
Now uses qmake to compile an Qt-creator compatible!
r18 uint32_t OSC0 =8000000;
uint32_t INTOSC =16000000;
uint32_t RTCOSC =32768;
uint32_t currentCpuFreq=0;
extern streamdevice* __opnfiles__[__MAX_OPENED_FILES__];
jeandet@PC-DE-JEANDET.lab-lpp.local
sync
r36
LCD_IF_t lcdIF0={
.init = &bsp_FSMC_init,
.writereg = &bsp_lcd0_write_reg,
.readreg = &bsp_lcd0_read_reg,
.writeGRAM = &bsp_lcd0_writeGRAM,
.readGRAM = &bsp_lcd0_readGRAM
};
LCD_t lcd0={
.interface = &lcdIF0,
.init = &ili9328init,
.paint = &ili9328paint,
jeandet@PC-DE-JEANDET.lab-lpp.local
Improved Font Renderer
r38 .paintText = &ili9328paintText,
.paintFilRect = &ili9328paintFilRect,
jeandet@PC-DE-JEANDET.lab-lpp.local
sync
r36 .refreshenable = &ili9328refreshenable,
.width= 240,
.height = 320
};
jeandet@PC-DE-JEANDET.lab-lpp.local
sync
r32
Factorised stream device structure to reduce memory usage....
r51 terminal_t terminal0;
jeandet@PC-DE-JEANDET.lab-lpp.local
sync
r34 volatile int16_t* lcd0_CMD=(volatile int16_t*) 0x60000000;
volatile int16_t* lcd0_DATA=(volatile int16_t*)(0x61FFFFF0);
jeandet@pc-de-jeandet3.LAB-LPP.LOCAL
Now uses qmake to compile an Qt-creator compatible!
r18
float VREF0 =(float)3.3;
int bsp_init()
{
int i=0;
for(i=0;i<32;i++)
jeandet@PC-DE-JEANDET.lab-lpp.local
sync
r21 {
jeandet@pc-de-jeandet3.LAB-LPP.LOCAL
Now uses qmake to compile an Qt-creator compatible!
r18 __opnfiles__[i] = NULL;
}
bsp_GPIO_init();
bsp_uart_init();
jeandet@PC-DE-JEANDET.lab-lpp.local
sync
r29 bsp_iic_init();
jeandet@pc-de-jeandet3.LAB-LPP.LOCAL
I2C library partially validated, ina226 library partially validated.
r30 bsp_FSMC_init();
Factorised stream device structure to reduce memory usage....
r51 bsp_GTerm_init();
printf("\r=====================\n\r");
printf( "=====================\n\r");
jeandet@pc-de-jeandet3.LAB-LPP.LOCAL
Now uses qmake to compile an Qt-creator compatible!
r18 printf(BSP);
printf(" initialised\n\r");
Factorised stream device structure to reduce memory usage....
r51 printf( "=====================\n\r");
jeandet@pc-de-jeandet3.LAB-LPP.LOCAL
Now uses qmake to compile an Qt-creator compatible!
r18 return 1;
}
void bsp_GPIO_init()
{
jeandet@PC-DE-JEANDET.lab-lpp.local
sync
r21 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);
jeandet@pc-de-jeandet3.LAB-LPP.LOCAL
Now uses qmake to compile an Qt-creator compatible!
r18 gpiosetspeed(&gpio1,gpiohighspeed);
gpiosetspeed(&gpio2,gpiohighspeed);
gpiosetspeed(&gpio3,gpiohighspeed);
gpiosetspeed(&gpio4,gpiohighspeed);
jeandet@PC-DE-JEANDET.lab-lpp.local
sync
r21 gpiosetspeed(&gpio5,gpiohighspeed);
gpiosetspeed(&gpio6,gpiohighspeed);
gpiosetspeed(&gpio7,gpiohighspeed);
gpioclr(PSU_DISABLE);
jeandet@pc-de-jeandet3.LAB-LPP.LOCAL
Now uses qmake to compile an Qt-creator compatible!
r18 gpiosetdir(&gpio1,gpiooutdir);
gpiosetdir(&gpio3,gpiooutdir);
gpiosetdir(&gpio2,gpiooutdir);
gpiosetdir(&gpio4,gpiooutdir);
jeandet@PC-DE-JEANDET.lab-lpp.local
sync
r21 gpiosetdir(&gpio5,gpioindir);
gpiosetdir(&gpio6,gpioindir);
gpiosetdir(&gpio7,gpioindir);
gpioclr(PSU_DISABLE);
jeandet@pc-de-jeandet3.LAB-LPP.LOCAL
Now uses qmake to compile an Qt-creator compatible!
r18 }
void bsp_uart_init()
{
Factorised stream device structure to reduce memory usage....
r51 //if(__opnfiles__[1]==NULL)
//{
//uart_t* uart1 = (uart_t*)malloc(sizeof(uart_t));
// streamdevice* fd1 = (streamdevice*)malloc(sizeof(streamdevice));
// uart_t uart = uartopenandconfig(uart1,uartparitynone | uart8bits | uartonestop,115200,PA9,PA10,-1,-1);
//uartmkstreamdev(uart,fd1);
//__opnfiles__[1] = fd1;
//}
//else
//{
uartopenandconfig(0,uartparitynone | uart8bits | uartonestop,115200,PA9,PA10,-1,-1);
//}
jeandet@pc-de-jeandet3.LAB-LPP.LOCAL
sync
r25 }
jeandet@PC-DE-JEANDET.lab-lpp.local
sync
r36
jeandet@pc-de-jeandet3.LAB-LPP.LOCAL
sync
r35
jeandet@PC-DE-JEANDET.lab-lpp.local
sync
r36 int bsp_FSMC_init()
jeandet@pc-de-jeandet3.LAB-LPP.LOCAL
sync
r25 {
Factorised stream device structure to reduce memory usage....
r51 #define GPIOGETPORT(gpio) ((GPIO_TypeDef*)(((((uint32_t)gpio) & (uint32_t)0x0000FF00)*(uint32_t)4) + (uint32_t)GPIOA))
#define GPIOPORTNUM(gpio) (((uint32_t)(gpio) & (uint32_t)0x0000FF00)>>(uint32_t)8)
jeandet@pc-de-jeandet3.LAB-LPP.LOCAL
sync
r25
jeandet@PC-DE-JEANDET.lab-lpp.local
sync
r34 gpio_t gpio1 = gpioopen(LCD_RESET);
gpiosetspeed(&gpio1,gpiohighspeed);
gpiosetdir(&gpio1,gpiooutdir);
gpioclr(LCD_RESET);
jeandet@pc-de-jeandet3.LAB-LPP.LOCAL
sync
r25 gpio_t LCD_DBxList[]={PD14,PD15,PD0,PD1,PE7,PE8,PE9,PE10,PE11,PE12,PE13,PE14,PE15\
,PD8,PD9,PD10,PD4,PD5,PD7,PE4};
for(int i=0;i<20;i++)
{
gpio_t LCD_DBx = gpioopen(LCD_DBxList[i]);
LCD_DBx |= gpiohighspeed | gpioaf | gpiopushpulltype | gpionopulltype;
gpiosetconfig(&LCD_DBx);
GPIO_PinAFConfig(GPIOGETPORT(LCD_DBx), (uint8_t)(LCD_DBx & 0xF), GPIO_AF_FSMC);
jeandet@pc-de-jeandet3.LAB-LPP.LOCAL
Now uses qmake to compile an Qt-creator compatible!
r18 }
jeandet@pc-de-jeandet3.LAB-LPP.LOCAL
I2C library partially validated, ina226 library partially validated.
r30
FSMC_NORSRAMInitTypeDef FSMC_NORSRAMInitStructure;
FSMC_NORSRAMTimingInitTypeDef p;
/* Enable FSMC clock */
RCC_AHB3PeriphClockCmd(RCC_AHB3Periph_FSMC, ENABLE);
Factorised stream device structure to reduce memory usage....
r51 /*-- FSMC Configuration ------------------------------------------------------*/
/*----------------------- SRAM Bank 3 ----------------------------------------*/
jeandet@pc-de-jeandet3.LAB-LPP.LOCAL
I2C library partially validated, ina226 library partially validated.
r30 /* FSMC_Bank1_NORSRAM4 configuration */
jeandet@pc-de-jeandet3.LAB-LPP.LOCAL
sync
r35 //p.FSMC_AddressSetupTime = 5;
jeandet@pc-de-jeandet3.LAB-LPP.LOCAL
added text painter on ili9328
r37 p.FSMC_AddressSetupTime = 1;
jeandet@pc-de-jeandet3.LAB-LPP.LOCAL
I2C library partially validated, ina226 library partially validated.
r30 p.FSMC_AddressHoldTime = 0;
jeandet@pc-de-jeandet3.LAB-LPP.LOCAL
sync
r35 //p.FSMC_DataSetupTime = 9;
jeandet@pc-de-jeandet3.LAB-LPP.LOCAL
Sync
r39 p.FSMC_DataSetupTime = getCpuFreq()/14545450 ;// 11;
jeandet@pc-de-jeandet3.LAB-LPP.LOCAL
I2C library partially validated, ina226 library partially validated.
r30 p.FSMC_BusTurnAroundDuration = 0;
p.FSMC_CLKDivision = 0;
p.FSMC_DataLatency = 0;
p.FSMC_AccessMode = FSMC_AccessMode_A;
/* Color LCD configuration ------------------------------------
LCD configured as follow:
- Data/Address MUX = Disable
- Memory Type = SRAM
- Data Width = 16bit
- Write Operation = Enable
- Extended Mode = Enable
- Asynchronous Wait = Disable */
FSMC_NORSRAMInitStructure.FSMC_Bank = FSMC_Bank1_NORSRAM1;
FSMC_NORSRAMInitStructure.FSMC_DataAddressMux = FSMC_DataAddressMux_Disable;
FSMC_NORSRAMInitStructure.FSMC_MemoryType = FSMC_MemoryType_SRAM;
FSMC_NORSRAMInitStructure.FSMC_MemoryDataWidth = FSMC_MemoryDataWidth_16b;
FSMC_NORSRAMInitStructure.FSMC_BurstAccessMode = FSMC_BurstAccessMode_Disable;
FSMC_NORSRAMInitStructure.FSMC_AsynchronousWait = FSMC_AsynchronousWait_Disable;
FSMC_NORSRAMInitStructure.FSMC_WaitSignalPolarity = FSMC_WaitSignalPolarity_Low;
FSMC_NORSRAMInitStructure.FSMC_WrapMode = FSMC_WrapMode_Disable;
FSMC_NORSRAMInitStructure.FSMC_WaitSignalActive = FSMC_WaitSignalActive_BeforeWaitState;
FSMC_NORSRAMInitStructure.FSMC_WriteOperation = FSMC_WriteOperation_Enable;
FSMC_NORSRAMInitStructure.FSMC_WaitSignal = FSMC_WaitSignal_Disable;
FSMC_NORSRAMInitStructure.FSMC_ExtendedMode = FSMC_ExtendedMode_Disable;
FSMC_NORSRAMInitStructure.FSMC_WriteBurst = FSMC_WriteBurst_Disable;
FSMC_NORSRAMInitStructure.FSMC_ReadWriteTimingStruct = &p;
FSMC_NORSRAMInitStructure.FSMC_WriteTimingStruct = &p;
FSMC_NORSRAMInit(&FSMC_NORSRAMInitStructure);
jeandet@pc-de-jeandet3.LAB-LPP.LOCAL
sync
r33 /* Enable FSMC NOR/SRAM Bank1 */
jeandet@pc-de-jeandet3.LAB-LPP.LOCAL
I2C library partially validated, ina226 library partially validated.
r30 FSMC_NORSRAMCmd(FSMC_Bank1_NORSRAM1, ENABLE);
jeandet@PC-DE-JEANDET.lab-lpp.local
sync
r34 gpioset(LCD_RESET);
jeandet@PC-DE-JEANDET.lab-lpp.local
sync
r32 lcd0.init(&lcd0);
jeandet@PC-DE-JEANDET.lab-lpp.local
sync
r36 return 1;
jeandet@pc-de-jeandet3.LAB-LPP.LOCAL
Now uses qmake to compile an Qt-creator compatible!
r18 }
void bsp_spi_init()
{
}
void bsp_iic_init()
{
Corrected bug #591
r56 i2copenandconfig(i2c2,0,10000,PF0,PF1);
jeandet@pc-de-jeandet3.LAB-LPP.LOCAL
Now uses qmake to compile an Qt-creator compatible!
r18 }
void bsp_SD_init()
{
jeandet@PC-DE-JEANDET.lab-lpp.local
sync
r21
jeandet@pc-de-jeandet3.LAB-LPP.LOCAL
Now uses qmake to compile an Qt-creator compatible!
r18 }
void vs10XXclearXCS(){}
void vs10XXsetXCS(){}
int vs10XXDREQ()
{
jeandet@PC-DE-JEANDET.lab-lpp.local
sync
r21 return 1;
jeandet@pc-de-jeandet3.LAB-LPP.LOCAL
Now uses qmake to compile an Qt-creator compatible!
r18 }
void bsppowersdcard(char onoff) //always ON
{
jeandet@PC-DE-JEANDET.lab-lpp.local
sync
r21
jeandet@pc-de-jeandet3.LAB-LPP.LOCAL
Now uses qmake to compile an Qt-creator compatible!
r18 }
char bspsdcardpresent()
{
jeandet@PC-DE-JEANDET.lab-lpp.local
sync
r21 return 0;
jeandet@pc-de-jeandet3.LAB-LPP.LOCAL
Now uses qmake to compile an Qt-creator compatible!
r18 }
char bspsdcardwriteprotected()
{
jeandet@PC-DE-JEANDET.lab-lpp.local
sync
r21 return 0;
jeandet@pc-de-jeandet3.LAB-LPP.LOCAL
Now uses qmake to compile an Qt-creator compatible!
r18 }
void bspsdcardselect(char YESNO)
{
jeandet@PC-DE-JEANDET.lab-lpp.local
sync
r21
jeandet@pc-de-jeandet3.LAB-LPP.LOCAL
Now uses qmake to compile an Qt-creator compatible!
r18 }
jeandet@PC-DE-JEANDET.lab-lpp.local
sync
r32 void bsp_lcd0_write_reg(uint32_t reg,uint32_t data)
{
*lcd0_CMD=(uint16_t)reg;
*lcd0_DATA=(uint16_t)data;
}
jeandet@pc-de-jeandet3.LAB-LPP.LOCAL
Now uses qmake to compile an Qt-creator compatible!
r18
jeandet@pc-de-jeandet3.LAB-LPP.LOCAL
sync
r35 uint32_t bsp_lcd0_read_reg(uint32_t reg)
{
*lcd0_CMD=(uint16_t)reg;
Factorised stream device structure to reduce memory usage....
r51 return (uint16_t)*lcd0_DATA;
jeandet@pc-de-jeandet3.LAB-LPP.LOCAL
sync
r35 }
void bsp_lcd0_writeGRAM(void* buffer,uint32_t count)
{
*lcd0_CMD=(uint16_t)ILI9328_REGISTER_WRITEDATATOGRAM;
uint16_t* castedBuff=(uint16_t*)buffer;
jeandet@PC-DE-JEANDET.lab-lpp.local
sync
r36 for(int i=0;i<(int)count;i++)
jeandet@pc-de-jeandet3.LAB-LPP.LOCAL
sync
r35 {
Factorised stream device structure to reduce memory usage....
r51 *lcd0_DATA=castedBuff[i];
jeandet@pc-de-jeandet3.LAB-LPP.LOCAL
sync
r35 }
}
void bsp_lcd0_readGRAM(void* buffer,uint32_t count)
{
*lcd0_CMD=(uint16_t)ILI9328_REGISTER_WRITEDATATOGRAM;
uint16_t* castedBuff=(uint16_t*)buffer;
castedBuff[0]=*lcd0_DATA;
jeandet@PC-DE-JEANDET.lab-lpp.local
sync
r36 for(int i=0;i<(int)count;i++)
jeandet@pc-de-jeandet3.LAB-LPP.LOCAL
sync
r35 {
Factorised stream device structure to reduce memory usage....
r51 castedBuff[i]=*lcd0_DATA;
}
}
void bsp_GTerm_init()
{
if(__opnfiles__[1]==NULL)
{
//uart_t* uart1 = (uart_t*)malloc(sizeof(uart_t));
streamdevice* fd1 = (streamdevice*)malloc(sizeof(streamdevice));
terminal_init(&terminal0 ,&lcd0,&ComicSansMS_8,fd1);
__opnfiles__[1] = fd1;
}
else
{
jeandet@pc-de-jeandet3.LAB-LPP.LOCAL
sync
r35 }
}
jeandet@pc-de-jeandet3.LAB-LPP.LOCAL
Now uses qmake to compile an Qt-creator compatible!
r18
jeandet@PC-DE-JEANDET.lab-lpp.local
sync
r32
jeandet@pc-de-jeandet3.LAB-LPP.LOCAL
sync
r35
Factorised stream device structure to reduce memory usage....
r51
Corrected bug #591
r56