diff --git a/bsp/includes/BEAGLESYNTH/bsp.h b/bsp/includes/BEAGLESYNTH/bsp.h --- a/bsp/includes/BEAGLESYNTH/bsp.h +++ b/bsp/includes/BEAGLESYNTH/bsp.h @@ -25,6 +25,8 @@ #include #include #include +#include +#include #define __MAX_OPENED_FILES__ 4 #define __FS_ROOT_SIZE__ 4 @@ -37,6 +39,7 @@ #endif */ + #define LED1 PF6 #define LED2 PF7 #define LED3 PF8 @@ -49,6 +52,8 @@ extern float VREF0; extern uint32_t currentCpuFreq; +extern LCD_t lcd0; + extern int bsp_init(); diff --git a/bsp/src/BEAGLESYNTH/bsp.c b/bsp/src/BEAGLESYNTH/bsp.c --- a/bsp/src/BEAGLESYNTH/bsp.c +++ b/bsp/src/BEAGLESYNTH/bsp.c @@ -33,6 +33,11 @@ uint32_t INTOSC =16000000; uint32_t RTCOSC =32768; uint32_t currentCpuFreq=0; extern streamdevice* __opnfiles__[__MAX_OPENED_FILES__]; +LCD_t lcd0; +LCD_IF_t lcdIF0; + +volatile int16_t* lcd0_CMD=(volatile int16_t*)0x60000000; +volatile int16_t* lcd0_DATA=(volatile int16_t*)(0x60000000+(1<<20)); float VREF0 =(float)3.3; @@ -98,7 +103,7 @@ void bsp_uart_init() } } - +void bsp_lcd0_write_reg(uint32_t reg,uint32_t data); void bsp_FSMC_init() { #define GPIOGETPORT(gpio) ((GPIO_TypeDef*)(((((uint32_t)gpio) & (uint32_t)0x0000FF00)*(uint32_t)4) + (uint32_t)GPIOA)) @@ -159,6 +164,10 @@ void bsp_FSMC_init() /* Enable FSMC NOR/SRAM Bank3 */ FSMC_NORSRAMCmd(FSMC_Bank1_NORSRAM1, ENABLE); + lcdIF0.writereg=&bsp_lcd0_write_reg; + lcd0.interface=&lcdIF0; + lcd0.init=&ili9328init; + lcd0.init(&lcd0); } void bsp_spi_init() @@ -206,6 +215,12 @@ void bspsdcardselect(char YESNO) } +void bsp_lcd0_write_reg(uint32_t reg,uint32_t data) +{ + *lcd0_CMD=(uint16_t)reg; + *lcd0_DATA=(uint16_t)data; +} + diff --git a/examples/BeagleSynthHello/main.c b/examples/BeagleSynthHello/main.c --- a/examples/BeagleSynthHello/main.c +++ b/examples/BeagleSynthHello/main.c @@ -19,8 +19,19 @@ int main() volatile int16_t* regtest2=(volatile int16_t*)(0x60000000+(1<<20)); //ina226open(&ina5VSens,i2c2,INA226_MODE_SHUNT_VOLTAGE_CONTINUOUS|INA226_AVERAGES_16|INA226_BUS_CONV_8244us|INA226_SHUNT_CONV_8244us,0,0,15,1000000); //ina226open(&ina15VSens,i2c2,INA226_MODE_SHUNT_VOLTAGE_CONTINUOUS|INA226_AVERAGES_16|INA226_BUS_CONV_8244us|INA226_SHUNT_CONV_8244us,1,0,15,1000000); - *regtest=0; + *regtest=(int16_t)0; printf("LCD ID=%x\n\r",0xFFFF&(*regtest2)); + *regtest=(int16_t)ILI9328_REGISTER_ENTRYMODE; + printf("ILI9328_REGISTER_ENTRYMODE=%x\n\r",0xFFFF&(*regtest2)); + *regtest=(int16_t)0x20; + *regtest2=(int16_t)0x0; + *regtest=(int16_t)0x21; + *regtest2=(int16_t)0x0; + *regtest=(int16_t)0x22; + for(volatile int i=0;i<1024*64;i++) + { + *regtest2=(int16_t)i; + } if(-1==ina226open(&ina33VSens,i2c2,INA226_MODE_SHUNT_VOLTAGE_CONTINUOUS|INA226_AVERAGES_16|INA226_BUS_CONV_8244us|INA226_SHUNT_CONV_8244us,0,1,15,1000000)) { printf("Can't open 3.3V monitor\n\r"); diff --git a/lib/includes/GRAPHIC/CONTROLERS/genericLCD_Controler.h b/lib/includes/GRAPHIC/CONTROLERS/genericLCD_Controler.h new file mode 100644 --- /dev/null +++ b/lib/includes/GRAPHIC/CONTROLERS/genericLCD_Controler.h @@ -0,0 +1,53 @@ +/*------------------------------------------------------------------------------ +-- This file is a part of the libuc, microcontroler library +-- Copyright (C) 2012, 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 +-------------------------------------------------------------------------------*/ +#ifndef GENERICLCD_CONTROLER_H +#define GENERICLCD_CONTROLER_H + +#include +#include + + +typedef struct LCD_IF_t +{ + int (*init)(); + void (*writereg)(uint32_t reg,uint32_t data); + uint32_t (*readreg)(uint32_t reg); + void (*writeGRAM)(void* buffer,uint32_t count); + void (*readGRAM)(void* buffer,uint32_t count); +}LCD_IF_t; + +typedef struct LCD_t +{ + LCD_IF_t* interface; + int (*init)(struct LCD_t* LCD); + void (*paint)(struct LCD_t* LCD,void* buffer,uint16_t Xpos,uint16_t Ypos,uint16_t Width,uint16_t Height); + uint16_t width; + uint16_t height; +}LCD_t; + + +#endif /*GENERICLCD_CONTROLER_H*/ + + + + + diff --git a/lib/includes/GRAPHIC/CONTROLERS/ili9328.h b/lib/includes/GRAPHIC/CONTROLERS/ili9328.h new file mode 100644 --- /dev/null +++ b/lib/includes/GRAPHIC/CONTROLERS/ili9328.h @@ -0,0 +1,88 @@ +/*------------------------------------------------------------------------------ +-- This file is a part of the libuc, microcontroler library +-- Copyright (C) 2012, 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 +-------------------------------------------------------------------------------*/ +#ifndef ILI9328_H +#define ILI9328_H + +#include +#include + +extern int ili9328init(struct LCD_t* LCD); +extern void ili9328paint_t(LCD_t* LCD,void* buffer,uint16_t Xpos,uint16_t Ypos,uint16_t Width,uint16_t Height); + +#define ILI9328_REGISTER_DRIVERCODEREAD ((uint16_t) 0x0000 ) +#define ILI9328_REGISTER_DRIVEROUTPUTCONTROL1 ((uint16_t) 0x0001 ) +#define ILI9328_REGISTER_LCDDRIVINGCONTROL ((uint16_t) 0x0002 ) +#define ILI9328_REGISTER_ENTRYMODE ((uint16_t) 0x0003 ) +#define ILI9328_REGISTER_RESIZECONTROL ((uint16_t) 0x0004 ) +#define ILI9328_REGISTER_DISPLAYCONTROL1 ((uint16_t) 0x0007 ) +#define ILI9328_REGISTER_DISPLAYCONTROL2 ((uint16_t) 0x0008 ) +#define ILI9328_REGISTER_DISPLAYCONTROL3 ((uint16_t) 0x0009 ) +#define ILI9328_REGISTER_DISPLAYCONTROL4 ((uint16_t) 0x000A ) +#define ILI9328_REGISTER_RGBDISPLAYINTERFACECONTROL1 ((uint16_t) 0x000C ) +#define ILI9328_REGISTER_FRAMEMAKERPOSITION ((uint16_t) 0x000D ) +#define ILI9328_REGISTER_RGBDISPLAYINTERFACECONTROL2 ((uint16_t) 0x000F ) +#define ILI9328_REGISTER_POWERCONTROL1 ((uint16_t) 0x0010 ) +#define ILI9328_REGISTER_POWERCONTROL2 ((uint16_t) 0x0011 ) +#define ILI9328_REGISTER_POWERCONTROL3 ((uint16_t) 0x0012 ) +#define ILI9328_REGISTER_POWERCONTROL4 ((uint16_t) 0x0013 ) +#define ILI9328_REGISTER_HORIZONTALGRAMADDRESSSET ((uint16_t) 0x0020 ) +#define ILI9328_REGISTER_VERTICALGRAMADDRESSSET ((uint16_t) 0x0021 ) +#define ILI9328_REGISTER_WRITEDATATOGRAM ((uint16_t) 0x0022 ) +#define ILI9328_REGISTER_POWERCONTROL7 ((uint16_t) 0x0029 ) +#define ILI9328_REGISTER_FRAMERATEANDCOLORCONTROL ((uint16_t) 0x002B ) +#define ILI9328_REGISTER_GAMMACONTROL1 ((uint16_t) 0x0030 ) +#define ILI9328_REGISTER_GAMMACONTROL2 ((uint16_t) 0x0031 ) +#define ILI9328_REGISTER_GAMMACONTROL3 ((uint16_t) 0x0032 ) +#define ILI9328_REGISTER_GAMMACONTROL4 ((uint16_t) 0x0035 ) +#define ILI9328_REGISTER_GAMMACONTROL5 ((uint16_t) 0x0036 ) +#define ILI9328_REGISTER_GAMMACONTROL6 ((uint16_t) 0x0037 ) +#define ILI9328_REGISTER_GAMMACONTROL7 ((uint16_t) 0x0038 ) +#define ILI9328_REGISTER_GAMMACONTROL8 ((uint16_t) 0x0039 ) +#define ILI9328_REGISTER_GAMMACONTROL9 ((uint16_t) 0x003C ) +#define ILI9328_REGISTER_GAMMACONTROL10 ((uint16_t) 0x003D ) +#define ILI9328_REGISTER_HORIZONTALADDRESSSTARTPOSITION ((uint16_t) 0x0050 ) +#define ILI9328_REGISTER_HORIZONTALADDRESSENDPOSITION ((uint16_t) 0x0051 ) +#define ILI9328_REGISTER_VERTICALADDRESSSTARTPOSITION ((uint16_t) 0x0052 ) +#define ILI9328_REGISTER_VERTICALADDRESSENDPOSITION ((uint16_t) 0x0053 ) +#define ILI9328_REGISTER_DRIVEROUTPUTCONTROL2 ((uint16_t) 0x0060 ) +#define ILI9328_REGISTER_BASEIMAGEDISPLAYCONTROL ((uint16_t) 0x0061 ) +#define ILI9328_REGISTER_VERTICALSCROLLCONTROL ((uint16_t) 0x006A ) +#define ILI9328_REGISTER_PARTIALIMAGE1DISPLAYPOSITION ((uint16_t) 0x0080 ) +#define ILI9328_REGISTER_PARTIALIMAGE1AREASTARTLINE ((uint16_t) 0x0081 ) +#define ILI9328_REGISTER_PARTIALIMAGE1AREAENDLINE ((uint16_t) 0x0082 ) +#define ILI9328_REGISTER_PARTIALIMAGE2DISPLAYPOSITION ((uint16_t) 0x0083 ) +#define ILI9328_REGISTER_PARTIALIMAGE2AREASTARTLINE ((uint16_t) 0x0084 ) +#define ILI9328_REGISTER_PARTIALIMAGE2AREAENDLINE ((uint16_t) 0x0085 ) +#define ILI9328_REGISTER_PANELINTERFACECONTROL1 ((uint16_t) 0x0090 ) +#define ILI9328_REGISTER_PANELINTERFACECONTROL2 ((uint16_t) 0x0092 ) +#define ILI9328_REGISTER_PANELINTERFACECONTROL4 ((uint16_t) 0x0095 ) +#define ILI9328_REGISTER_OTPVCMPROGRAMMINGCONTROL ((uint16_t) 0x00A1 ) +#define ILI9328_REGISTER_OTPVCMSTATUSANDENABLE ((uint16_t) 0x00A2 ) +#define ILI9328_REGISTER_OTPPROGRAMMINGIDKEY ((uint16_t) 0x00A5 ) + + +#endif + + + + + diff --git a/lib/src/common/GRAPHIC/CONTROLERS/CONTROLERS.pro b/lib/src/common/GRAPHIC/CONTROLERS/CONTROLERS.pro new file mode 100644 --- /dev/null +++ b/lib/src/common/GRAPHIC/CONTROLERS/CONTROLERS.pro @@ -0,0 +1,9 @@ +TEMPLATE = subdirs +SUBDIRS += ILI9328 + + + + + + + diff --git a/lib/src/common/GRAPHIC/CONTROLERS/ILI9328/ILI9328.pro b/lib/src/common/GRAPHIC/CONTROLERS/ILI9328/ILI9328.pro new file mode 100644 --- /dev/null +++ b/lib/src/common/GRAPHIC/CONTROLERS/ILI9328/ILI9328.pro @@ -0,0 +1,4 @@ +TEMPLATE = subdirs +CONFIG += ordered + +SUBDIRS += ./ili9328_STM32F4.pro diff --git a/lib/src/common/GRAPHIC/CONTROLERS/ILI9328/ili9328.c b/lib/src/common/GRAPHIC/CONTROLERS/ILI9328/ili9328.c new file mode 100644 --- /dev/null +++ b/lib/src/common/GRAPHIC/CONTROLERS/ILI9328/ili9328.c @@ -0,0 +1,90 @@ +/*------------------------------------------------------------------------------ +-- This file is a part of the libuc, microcontroler library +-- Copyright (C) 2012, 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 +#include +#include + +#define _delay_(del) for(volatile int _d_e_l_=0;_d_e_l_<(del);_d_e_l_++); + +void ili9328paint_t(LCD_t* LCD,void* buffer,uint16_t Xpos,uint16_t Ypos,uint16_t Width,uint16_t Height) +{ + if((LCD!=NULL) && (LCD->interface!=NULL) && (LCD->interface->writeGRAM!=NULL) && (LCD->width<(Xpos+Width)) && (LCD->height<(Ypos+Height))) + { + uint16_t* castedBuff=(uint16_t*)buffer; + for(int i=0;iinterface->writeGRAM(castedBuff+(i*Width),Width); + } + } +} + +int ili9328init(struct LCD_t* LCD) +{ + if((LCD!=NULL) && (LCD->interface!=NULL) && (LCD->interface->writereg!=NULL)) + { + LCD->interface->writereg(ILI9328_REGISTER_DRIVEROUTPUTCONTROL1, 0x0100); // Driver Output Control Register (R01h) + LCD->interface->writereg(ILI9328_REGISTER_LCDDRIVINGCONTROL, 0x0700); // LCD Driving Waveform Control (R02h) + LCD->interface->writereg(ILI9328_REGISTER_ENTRYMODE, 0x1030); // Entry Mode (R03h) + LCD->interface->writereg(ILI9328_REGISTER_DISPLAYCONTROL2, 0x0302); + LCD->interface->writereg(ILI9328_REGISTER_DISPLAYCONTROL3, 0x0000); + LCD->interface->writereg(ILI9328_REGISTER_DISPLAYCONTROL4, 0x0000); // Fmark On + LCD->interface->writereg(ILI9328_REGISTER_POWERCONTROL1, 0x0000); // Power Control 1 (R10h) + LCD->interface->writereg(ILI9328_REGISTER_POWERCONTROL2, 0x0007); // Power Control 2 (R11h) + LCD->interface->writereg(ILI9328_REGISTER_POWERCONTROL3, 0x0000); // Power Control 3 (R12h) + LCD->interface->writereg(ILI9328_REGISTER_POWERCONTROL4, 0x0000); // Power Control 4 (R13h) + _delay_(10000000); + LCD->interface->writereg(ILI9328_REGISTER_POWERCONTROL1, 0x14B0); // Power Control 1 (R10h) + _delay_(5000000); + LCD->interface->writereg(ILI9328_REGISTER_POWERCONTROL2, 0x0007); // Power Control 2 (R11h) + _delay_(5000000); + LCD->interface->writereg(ILI9328_REGISTER_POWERCONTROL3, 0x008E); // Power Control 3 (R12h) + LCD->interface->writereg(ILI9328_REGISTER_POWERCONTROL4, 0x0C00); // Power Control 4 (R13h) + LCD->interface->writereg(ILI9328_REGISTER_POWERCONTROL7, 0x0015); // NVM read data 2 (R29h) + _delay_(5000000); + LCD->interface->writereg(ILI9328_REGISTER_GAMMACONTROL1, 0x0000); // Gamma Control 1 + LCD->interface->writereg(ILI9328_REGISTER_GAMMACONTROL2, 0x0107); // Gamma Control 2 + LCD->interface->writereg(ILI9328_REGISTER_GAMMACONTROL3, 0x0000); // Gamma Control 3 + LCD->interface->writereg(ILI9328_REGISTER_GAMMACONTROL4, 0x0203); // Gamma Control 4 + LCD->interface->writereg(ILI9328_REGISTER_GAMMACONTROL5, 0x0402); // Gamma Control 5 + LCD->interface->writereg(ILI9328_REGISTER_GAMMACONTROL6, 0x0000); // Gamma Control 6 + LCD->interface->writereg(ILI9328_REGISTER_GAMMACONTROL7, 0x0207); // Gamma Control 7 + LCD->interface->writereg(ILI9328_REGISTER_GAMMACONTROL8, 0x0000); // Gamma Control 8 + LCD->interface->writereg(ILI9328_REGISTER_GAMMACONTROL9, 0x0203); // Gamma Control 9 + LCD->interface->writereg(ILI9328_REGISTER_GAMMACONTROL10, 0x0403); // Gamma Control 10 + LCD->interface->writereg(ILI9328_REGISTER_HORIZONTALADDRESSSTARTPOSITION, 0x0000); // Window Horizontal RAM Address Start (R50h) + LCD->interface->writereg(ILI9328_REGISTER_HORIZONTALADDRESSENDPOSITION, 240 - 1); // Window Horizontal RAM Address End (R51h) + LCD->interface->writereg(ILI9328_REGISTER_VERTICALADDRESSSTARTPOSITION, 0X0000); // Window Vertical RAM Address Start (R52h) + LCD->interface->writereg(ILI9328_REGISTER_VERTICALADDRESSENDPOSITION, 320 - 1); // Window Vertical RAM Address End (R53h) + LCD->interface->writereg(ILI9328_REGISTER_DRIVEROUTPUTCONTROL2, 0xa700); // Driver Output Control (R60h) + LCD->interface->writereg(ILI9328_REGISTER_BASEIMAGEDISPLAYCONTROL, 0x0003); // Driver Output Control (R61h) - enable VLE + LCD->interface->writereg(ILI9328_REGISTER_PANELINTERFACECONTROL1, 0X0010); // Panel Interface Control 1 (R90h) + // Display On + LCD->interface->writereg(ILI9328_REGISTER_DISPLAYCONTROL1, 0x0133); // Display Control (R07h) + _delay_(5000000); + LCD->interface->writereg(ILI9328_REGISTER_ENTRYMODE, 0x1030); + LCD->interface->writereg(ILI9328_REGISTER_DRIVEROUTPUTCONTROL1, 0x0100); + //ili9328WriteCmd(ILI9328_REGISTER_WRITEDATATOGRAM); + } + return 0; +} + + diff --git a/lib/src/common/GRAPHIC/CONTROLERS/ILI9328/ili9328_STM32F4.pro b/lib/src/common/GRAPHIC/CONTROLERS/ILI9328/ili9328_STM32F4.pro new file mode 100644 --- /dev/null +++ b/lib/src/common/GRAPHIC/CONTROLERS/ILI9328/ili9328_STM32F4.pro @@ -0,0 +1,11 @@ +TEMPLATE = lib +CONFIG += console +CONFIG -= qt +TARGET = ili9328 +include($$(libuc2)/rules/stm32f4-arm-none-eabi-gcc/rules.pri) + +SOURCES += \ + ili9328.c + +HEADERS += \ + $$(libuc2)/lib/includes/GRAPHIC/CONTROLERS/ili9328.h diff --git a/lib/src/common/GRAPHIC/GRAPHIC.pro b/lib/src/common/GRAPHIC/GRAPHIC.pro new file mode 100644 --- /dev/null +++ b/lib/src/common/GRAPHIC/GRAPHIC.pro @@ -0,0 +1,9 @@ +TEMPLATE = subdirs +SUBDIRS += CONTROLERS + + + + + + + diff --git a/lib/src/common/common.pro b/lib/src/common/common.pro --- a/lib/src/common/common.pro +++ b/lib/src/common/common.pro @@ -1,6 +1,9 @@ -TEMPLATE = dir -SUBDIRS += HEXVIEWER \ - FILE_SYSTEM +TEMPLATE = subdirs + +SUBDIRS += FILE_SYSTEM \ + AUDIO \ + POWER \ + GRAPHIC diff --git a/lib/src/lib.pro b/lib/src/lib.pro --- a/lib/src/lib.pro +++ b/lib/src/lib.pro @@ -3,9 +3,7 @@ CONFIG += ordered SUBDIRS += stm32f4 -SUBDIRS += common/FILE_SYSTEM \ - common/AUDIO \ - common/POWER +SUBDIRS += common # common/STREAMDEVICES \ # common/STRINGS \ diff --git a/rules/common/librules.pri b/rules/common/librules.pri --- a/rules/common/librules.pri +++ b/rules/common/librules.pri @@ -4,12 +4,14 @@ LIBUC_LIBS_DIR = $$libuc2/lib INCLUDEPATH += $$LIBUC_LIBS_DIR/includes \ + $$LIBUC_LIBS_DIR/includes/GRAPHIC/CONTROLERS \ $$LIBUC_LIBS_DIR/includes/$$ARCH LIBUC_BIN_LIBS_DIR = $$LIBUC_LIBS_DIR/bin/$$ARCH + LIBS += -L$$LIBUC_LIBS_DIR/bin/$$ARCH \ - -lCS43L22 -lina226 + -lCS43L22 -lina226 -lili9328 LIBS += -L$$LIBUC_LIBS_DIR/bin/$$ARCH \ -lsdcard