diff --git a/bsp/src/STM32F4Eval/bsp.c b/bsp/src/STM32F4Eval/bsp.c --- a/bsp/src/STM32F4Eval/bsp.c +++ b/bsp/src/STM32F4Eval/bsp.c @@ -247,7 +247,7 @@ void bsp_spi_init() void bsp_iic_init() { - i2copenandconfig(i2c1,0,100000,PB9,PB6); + i2copenandconfig(i2c1,0,10000,PB9,PB6); } void bsp_SD_init() diff --git a/examples/BeagleSynthHelloSupMon/BeagleSynthHelloSupMon.pro b/examples/BeagleSynthHelloSupMon/BeagleSynthHelloSupMon.pro --- a/examples/BeagleSynthHelloSupMon/BeagleSynthHelloSupMon.pro +++ b/examples/BeagleSynthHelloSupMon/BeagleSynthHelloSupMon.pro @@ -3,7 +3,7 @@ CONFIG += cpu UCMODEL=stm32f4 -DEFINES += CPUFREQ=40000000 +DEFINES += CPUFREQ=80000000 BSP = BEAGLESYNTH #BSP = SOLAR_LFR_PSU diff --git a/examples/BeagleSynthHelloSupMon/main.c b/examples/BeagleSynthHelloSupMon/main.c --- a/examples/BeagleSynthHelloSupMon/main.c +++ b/examples/BeagleSynthHelloSupMon/main.c @@ -39,6 +39,40 @@ void setUartAsStdout() __opnfiles__[1] = fd1; } +void printSupplyStatus(int cur5v,int cur33v,int cur15v, int volt5v, int volt33v, int volt15v) +{ + char buffer[64]; + int i=0; + int power5V=(cur5v*(volt5v/1000))/1000,power33V=(cur33v*(volt33v/1000))/1000,power15V=(cur15v*(volt15v/1000))/1000; +#define clearBuff for(i=0;i<64;i++)buffer[i]='\0' + + ili9328paintFilRect(&lcd0,5,5,230,7*(ComicSansMS_18.Height+10)+50,LCD_COLOR_BLACK,4,LCD_COLOR_WHITE); + ili9328paintFilRect(&lcd0,5,7*(ComicSansMS_18.Height+10)+50,230,320 - (7*(ComicSansMS_18.Height+10)+50),LCD_COLOR_BLACK,4,LCD_COLOR_WHITE); + clearBuff; + sprintf(buffer,"%.3fV %dmA",volt5v/1000000.0,cur5v); + ili9328paintText(&lcd0,buffer,10,0*(ComicSansMS_18.Height+10)+50,&ComicSansMS_18,LCD_COLOR_BLACK); + clearBuff; + sprintf(buffer,"%dmW",power5V); + ili9328paintText(&lcd0,buffer,10,1*(ComicSansMS_18.Height+10)+50,&ComicSansMS_18,LCD_COLOR_BLACK); + clearBuff; + sprintf(buffer,"%.3fV %dmA",volt33v/1000000.0,cur33v); + ili9328paintText(&lcd0,buffer,10,2*(ComicSansMS_18.Height+10)+50,&ComicSansMS_18,LCD_COLOR_BLACK); + clearBuff; + sprintf(buffer,"%dmW",power33V); + ili9328paintText(&lcd0,buffer,10,3*(ComicSansMS_18.Height+10)+50,&ComicSansMS_18,LCD_COLOR_BLACK); + clearBuff; + sprintf(buffer,"%.3fV %dmA",volt15v/1000000.0,cur15v); + ili9328paintText(&lcd0,buffer,10,4*(ComicSansMS_18.Height+10)+50,&ComicSansMS_18,LCD_COLOR_BLACK); + clearBuff; + sprintf(buffer,"%dmW",power15V); + ili9328paintText(&lcd0,buffer,10,5*(ComicSansMS_18.Height+10)+50,&ComicSansMS_18,LCD_COLOR_BLACK); + + clearBuff; + sprintf(buffer,"Total = %dmW",power5V+power33V+power15V); + ili9328paintText(&lcd0,buffer,10,320-10-20,&ComicSansMS_18,LCD_COLOR_BLACK); + +} + int main() { delay_100us(20000); @@ -46,11 +80,13 @@ int main() gpioset(PSU_DISABLE);//enable psu! setUartAsStdout(); //ili9328paintFilRect(&lcd0,0,0,240,320,LCD_COLOR_BLACK,1,LCD_COLOR_BLACK); - if(-1==ina226open(&ina33VSens,i2c2,INA226_MODE_SHUNT_VOLTAGE_CONTINUOUS|INA226_AVERAGES_16|INA226_BUS_CONV_8244us|INA226_SHUNT_CONV_8244us,0,0,15,1000000)) + + ili9328paintFilRect(&lcd0,5,5,230,310,LCD_COLOR_BLACK,4,LCD_COLOR_WHITE); + 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"); } - if(-1==ina226open(&ina5VSens,i2c2,INA226_MODE_SHUNT_VOLTAGE_CONTINUOUS|INA226_AVERAGES_16|INA226_BUS_CONV_8244us|INA226_SHUNT_CONV_8244us,0,1,15,1000000)) + if(-1==ina226open(&ina5VSens,i2c2,INA226_MODE_SHUNT_VOLTAGE_CONTINUOUS|INA226_AVERAGES_16|INA226_BUS_CONV_8244us|INA226_SHUNT_CONV_8244us,0,0,15,1000000)) { printf("Can't open 5V monitor\n\r"); } @@ -58,15 +94,19 @@ int main() { printf("Can't open 1.5V monitor\n\r"); } - int current5V,current33V,current15V; + int current5V,current33V,current15V,volt5v, volt33v, volt15v; while(1) { current5V = ina226getCurrent(&ina5VSens); current33V = ina226getCurrent(&ina33VSens); current15V = ina226getCurrent(&ina15VSens); - printf("%dmA\n\r",current15V/1000); - printf("%dmA\n\r",current33V/1000); - printf("%dmA\n\r",current5V/1000); + volt5v = ina226getBusVoltage(&ina5VSens); + volt33v = ina226getBusVoltage(&ina33VSens); + volt15v = ina226getBusVoltage(&ina15VSens); + printf("%fV\t%dmA\n\r",volt15v/1000000.0,current15V/1000); + printf("%fV\t%dmA\n\r",volt33v/1000000.0,current33V/1000); + printf("%fV\t%dmA\n\r",volt5v/1000000.0,current5V/1000); + printSupplyStatus(current5V/1000,current33V/1000,current15V/1000,volt5v, volt33v, volt15v); delay_100us(10000); } printf("Exit\n\r"); diff --git a/examples/lcdTerminal/main.c b/examples/lcdTerminal/main.c --- a/examples/lcdTerminal/main.c +++ b/examples/lcdTerminal/main.c @@ -7,6 +7,7 @@ #include #include #include +#include #include #include #include @@ -34,6 +35,18 @@ void testAudioDAC() printf("dac ID = %d\n\r",ID); } +void testIOEXPender() +{ + STMPE811_t ioexp1,ioexp2; + char data[2]={0,0}; + i2cwrite(i2c1,0x50,data,1); + + //i2cread(i2c1,0x88,data,2); +// stmpe811init(&ioexp1,i2c1,0); +// stmpe811init(&ioexp2,i2c1,1); +// printf("Scan for IOEXPANDER:\n\r ID1=%d\n\rID2=%d",stmpe811getID(&ioexp1),stmpe811getID(&ioexp2)); +} + int main() { delay_100us(10000); @@ -48,16 +61,16 @@ int main() int i=0; terminal_t terminal0,terminal1; terminal_init(&terminal0,&lcd0,&ComicSansMS_18,fd1); - terminal_init(&terminal1,&lcd0,&ComicSansMS_18,&fd2); - terminal_setgeometry(&terminal0,5,5,terminal0.LCD->width-10,(terminal0.LCD->height/2)-10); - terminal_setbackgroundColor(&terminal1,0xFFFF); - terminal_settextColor(&terminal1,0x0000); - terminal_setgeometry(&terminal1,5,(terminal0.LCD->height/2)+5,terminal0.LCD->width-10,(terminal0.LCD->height/2)-10); + //terminal_init(&terminal1,&lcd0,&ComicSansMS_18,&fd2); + terminal_setgeometry(&terminal0,5,5,terminal0.LCD->width-10,(terminal0.LCD->height)-10); + //terminal_setbackgroundColor(&terminal1,0xFFFF); + //terminal_settextColor(&terminal1,0x0000); + //terminal_setgeometry(&terminal1,5,(terminal0.LCD->height/2)+5,terminal0.LCD->width-10,(terminal0.LCD->height/2)-10); printf("Line cnt :\n \t%d\n",terminal0.lineCount); printf("Column cnt :\n \t%d\n",terminal0.columnCount); printf("CPU Freq :\n \t%dMHz\n",getCpuFreq()/1000000); //testAudioDAC(); - i2cwrite(i2c1,0x4a," ",1); + testIOEXPender(); while(1) { i%=1000; diff --git a/lib/src/common/EEPROMS/24LCXX/24LC0X/24LC0X.c b/lib/src/common/EEPROMS/24LCXX/24LC0X/24LC0X.c --- a/lib/src/common/EEPROMS/24LCXX/24LC0X/24LC0X.c +++ b/lib/src/common/EEPROMS/24LCXX/24LC0X/24LC0X.c @@ -40,7 +40,7 @@ void eeprom24lc0xopen(eeprom24lc0xDev* d if(size == 1024) dev->size = 1; } -void eeprom24lc0xpagewrite(eeprom24lc0xDev dev,unsigned char address,unsigned char* page) +void eeprom24lc0xpagewrite(eeprom24lc0xDev* dev,unsigned char address,unsigned char* page) { int cmdcnt=1,datacnt=8; //i2cwrite(dev.iicdev,address,page) @@ -48,21 +48,21 @@ void eeprom24lc0xpagewrite(eeprom24lc0xD } -void eeprom24lc0xpageread(eeprom24lc0xDev dev,unsigned char address,unsigned char* page) +void eeprom24lc0xpageread(eeprom24lc0xDev* dev,unsigned char address,unsigned char* page) { int cmdcnt=1,datacnt=8; /*i2cwrite(dev.iicdev,dev.devAddress,&address,&cmdcnt); i2cread(dev.iicdev,dev.devAddress,page,&datacnt);*/ } -void eeprom24lc0xbytewrite(eeprom24lc0xDev dev,unsigned char address,unsigned char data) +void eeprom24lc0xbytewrite(eeprom24lc0xDev* dev,unsigned char address,unsigned char data) { int cmdcnt=1,datacnt=1; //i2cwrite2(dev.iicdev,dev.devAddress,&address,&cmdcnt,&data,&datacnt); } -unsigned char eeprom24lc0xbyteread(eeprom24lc0xDev dev,unsigned char address) +unsigned char eeprom24lc0xbyteread(eeprom24lc0xDev* dev,unsigned char address) { int cmdcnt=1,datacnt=1; unsigned char data = 0; @@ -72,7 +72,7 @@ unsigned char eeprom24lc0xbyteread(eepro } -void eeprom24lc0xreadn(eeprom24lc0xDev dev,unsigned char address,unsigned char* data, unsigned int count) +void eeprom24lc0xreadn(eeprom24lc0xDev* dev,unsigned char address,unsigned char* data, unsigned int count) { int cmdcnt=1,datacnt=count; /* i2cwrite(dev.iicdev,dev.devAddress,&address,&cmdcnt); @@ -80,7 +80,7 @@ void eeprom24lc0xreadn(eeprom24lc0xDev d } -void eeprom24lc0xwriten(eeprom24lc0xDev dev,unsigned char address,unsigned char* data, unsigned int count) +void eeprom24lc0xwriten(eeprom24lc0xDev* dev,unsigned char address,unsigned char* data, unsigned int count) { int cmdcnt=1,datacnt=8; while(count >8) diff --git a/lib/src/common/EEPROMS/24LCXX/24LC0X/24LC0X.pro b/lib/src/common/EEPROMS/24LCXX/24LC0X/24LC0X.pro --- a/lib/src/common/EEPROMS/24LCXX/24LC0X/24LC0X.pro +++ b/lib/src/common/EEPROMS/24LCXX/24LC0X/24LC0X.pro @@ -2,7 +2,8 @@ TEMPLATE = lib OBJECTS_DIR = obj SOURCES += 24LC0X.c -HEADERS += ../../../includes/24LC0X.h +HEADERS += ../../../includes/24LC0X.h \ + ../../../../includes/24LC0X.h INCLUDEPATH += ../../../includes \ ../../CPU/STM32F4xx_StdPeriph_Driver/inc \ diff --git a/lib/src/common/GRAPHIC/CONTROLERS/ILI9328/ili9328.c b/lib/src/common/GRAPHIC/CONTROLERS/ILI9328/ili9328.c --- a/lib/src/common/GRAPHIC/CONTROLERS/ILI9328/ili9328.c +++ b/lib/src/common/GRAPHIC/CONTROLERS/ILI9328/ili9328.c @@ -337,7 +337,7 @@ void ili9328paintText(LCD_t* LCD,char* b uint16_t tmp[w]; uint16_t linenum=0,charnum=0; uint8_t line=0; - while(*buffer) + while(*buffer!='\0') { ili9328setFrame(LCD,Xpos+(charnum*w),Ypos-h,w,1); LCD->interface->readGRAM(tmp,w); diff --git a/lib/src/common/GRAPHIC/GRAPHIC.pro b/lib/src/common/GRAPHIC/GRAPHIC.pro --- a/lib/src/common/GRAPHIC/GRAPHIC.pro +++ b/lib/src/common/GRAPHIC/GRAPHIC.pro @@ -1,5 +1,6 @@ TEMPLATE = subdirs SUBDIRS += CONTROLERS \ + TC_CONTROLERS \ GUI diff --git a/lib/src/common/GRAPHIC/TC_CONTROLERS/STMPE811/STMPE811.c b/lib/src/common/GRAPHIC/TC_CONTROLERS/STMPE811/STMPE811.c new file mode 100644 --- /dev/null +++ b/lib/src/common/GRAPHIC/TC_CONTROLERS/STMPE811/STMPE811.c @@ -0,0 +1,69 @@ +/*------------------------------------------------------------------------------ +-- This file is a part of the libuc, microcontroler library +-- Copyright (C) 2013, 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 + +int stmpe811init(STMPE811_t *dev, i2c_t i2cdev, uint8_t A0) +{ + + dev->devAddress = 0x82; + if(A0) dev->devAddress = 0x88; + dev->i2cdev = i2cdev; + return 1; +} + +int stmpe811getID(STMPE811_t *dev) +{ + if(dev != NULL) + { + char DATA[2]; + DATA[0]=STMPE811_REGISTER_CHIP_ID; + i2cwrite(dev->i2cdev,dev->devAddress,DATA,1); + i2cread(dev->i2cdev,dev->devAddress,DATA,2); + uint16_t val=DATA[0]; + val=(val<<8)+DATA[1]; + return val; + } + return -1; +} + + + + + + + + + + + + + + + + + + + + + + diff --git a/lib/src/common/GRAPHIC/TC_CONTROLERS/STMPE811/STMPE811.pro b/lib/src/common/GRAPHIC/TC_CONTROLERS/STMPE811/STMPE811.pro new file mode 100644 --- /dev/null +++ b/lib/src/common/GRAPHIC/TC_CONTROLERS/STMPE811/STMPE811.pro @@ -0,0 +1,4 @@ +TEMPLATE = subdirs +CONFIG += ordered + +SUBDIRS += ./STMPE811_STM32F4.pro diff --git a/lib/src/common/GRAPHIC/TC_CONTROLERS/STMPE811/STMPE811_STM32F4.pro b/lib/src/common/GRAPHIC/TC_CONTROLERS/STMPE811/STMPE811_STM32F4.pro new file mode 100644 --- /dev/null +++ b/lib/src/common/GRAPHIC/TC_CONTROLERS/STMPE811/STMPE811_STM32F4.pro @@ -0,0 +1,28 @@ +TEMPLATE = lib +OBJECTS_DIR = obj +TARGET = STMPE811 + +SOURCES += \ + STMPE811.c + +DEFINES -= __OPTIMIZED_MATH + +INCLUDEPATH += ../../../../includes \ + ../../../CPU/STM32F4xx_StdPeriph_Driver/inc \ + ../../../CPU/CMSIS/Include \ + ../../../../includes/GRAPHIC/CONTROLERS \ + ../../../../includes/GRAPHIC/TC_CONTROLERS \ + ../../../../includes/GRAPHIC/GUI/FONTS \ + ../../../../includes/GRAPHIC/GUI/Widgets + + +UCMODEL=stm32f4 + +target.path = $$[QT_INSTALL_LIBS]/$$UCMODEL +INSTALLS += target + +HEADERS += \ + ../../../../includes/GRAPHIC/TC_CONTROLERS/STMPE811.h \ + ../../../../includes/GRAPHIC/TC_CONTROLERS/genericTC_Controler.h + + diff --git a/lib/src/common/GRAPHIC/TC_CONTROLERS/TC_CONTROLERS.pro b/lib/src/common/GRAPHIC/TC_CONTROLERS/TC_CONTROLERS.pro new file mode 100644 --- /dev/null +++ b/lib/src/common/GRAPHIC/TC_CONTROLERS/TC_CONTROLERS.pro @@ -0,0 +1,9 @@ +TEMPLATE = subdirs +SUBDIRS += STMPE811 + + + + + + + diff --git a/lib/src/common/Threading/Threading.pro b/lib/src/common/Threading/Threading.pro --- a/lib/src/common/Threading/Threading.pro +++ b/lib/src/common/Threading/Threading.pro @@ -12,3 +12,10 @@ UCMODEL=stm32f4 target.path = $$[QT_INSTALL_LIBS]/$$UCMODEL INSTALLS += target + +HEADERS += \ + ../../includes/thread.h + + + + diff --git a/lib/src/includes/24LC0X.h b/lib/src/includes/24LC0X.h --- a/lib/src/includes/24LC0X.h +++ b/lib/src/includes/24LC0X.h @@ -36,12 +36,12 @@ typedef struct eeprom24lc0xDev extern void eeprom24lc0xopen(eeprom24lc0xDev* dev,i2c_t iicdev,unsigned char A0_A1_A2_val,unsigned int size); -extern void eeprom24lc0xpagewrite(eeprom24lc0xDev dev,unsigned char address,unsigned char* page); -extern void eeprom24lc0xpageread(eeprom24lc0xDev dev,unsigned char address,unsigned char* page); -extern void eeprom24lc0xbytewrite(eeprom24lc0xDev dev,unsigned char address,unsigned char data); -extern unsigned char eeprom24lc0xbyteread(eeprom24lc0xDev dev,unsigned char address); -extern void eeprom24lc0xreadn(eeprom24lc0xDev dev,unsigned char address,unsigned char* data, unsigned int count); -extern void eeprom24lc0xwriten(eeprom24lc0xDev dev,unsigned char address,unsigned char* data, unsigned int count); +extern void eeprom24lc0xpagewrite(eeprom24lc0xDev* dev,unsigned char address,unsigned char* page); +extern void eeprom24lc0xpageread(eeprom24lc0xDev* dev,unsigned char address,unsigned char* page); +extern void eeprom24lc0xbytewrite(eeprom24lc0xDev* dev,unsigned char address,unsigned char data); +extern unsigned char eeprom24lc0xbyteread(eeprom24lc0xDev* dev,unsigned char address); +extern void eeprom24lc0xreadn(eeprom24lc0xDev* dev,unsigned char address,unsigned char* data, unsigned int count); +extern void eeprom24lc0xwriten(eeprom24lc0xDev* dev,unsigned char address,unsigned char* data, unsigned int count); diff --git a/lib/src/includes/GRAPHIC/TC_CONTROLERS/STMPE811.h b/lib/src/includes/GRAPHIC/TC_CONTROLERS/STMPE811.h new file mode 100644 --- /dev/null +++ b/lib/src/includes/GRAPHIC/TC_CONTROLERS/STMPE811.h @@ -0,0 +1,115 @@ +/*------------------------------------------------------------------------------ +-- This file is a part of the libuc, microcontroler library +-- Copyright (C) 2013, 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 STMPE811_H +#define STMPE811_H +#include +#include +#include +#include +#include +#include + +typedef struct STMPE811_t +{ + i2c_t i2cdev; + uint8_t devAddress; +}STMPE811_t; + + +extern int stmpe811init(STMPE811_t *dev, i2c_t i2cdev, uint8_t A0); +extern int stmpe811getID(STMPE811_t *dev); + + + +#define STMPE811_REGISTER_CHIP_ID ((uint32_t) 0x0000 ) +#define STMPE811_REGISTER_ID_VER ((uint32_t) 0x0002 ) +#define STMPE811_REGISTER_SYS_CTRL1 ((uint32_t) 0x0003 ) +#define STMPE811_REGISTER_SYS_CTRL2 ((uint32_t) 0x0004 ) +#define STMPE811_REGISTER_SPI_CFG ((uint32_t) 0x0008 ) +#define STMPE811_REGISTER_INT_CTRL ((uint32_t) 0x0009 ) +#define STMPE811_REGISTER_INT_EN ((uint32_t) 0x000A ) +#define STMPE811_REGISTER_INT_STA ((uint32_t) 0x000B ) +#define STMPE811_REGISTER_GPIO_EN ((uint32_t) 0x000C ) +#define STMPE811_REGISTER_GPIO_INT_STA ((uint32_t) 0x000D ) +#define STMPE811_REGISTER_ADC_INT_EN ((uint32_t) 0x000E ) +#define STMPE811_REGISTER_ADC_INT_STA ((uint32_t) 0x000F ) +#define STMPE811_REGISTER_GPIO_SET_PIN ((uint32_t) 0x0010 ) +#define STMPE811_REGISTER_GPIO_CLR_PIN ((uint32_t) 0x0011 ) +#define STMPE811_REGISTER_GPIO_MP_STA ((uint32_t) 0x0012 ) +#define STMPE811_REGISTER_GPIO_DIR ((uint32_t) 0x0013 ) +#define STMPE811_REGISTER_GPIO_ED ((uint32_t) 0x0014 ) +#define STMPE811_REGISTER_GPIO_RE ((uint32_t) 0x0015 ) +#define STMPE811_REGISTER_GPIO_FE ((uint32_t) 0x0016 ) +#define STMPE811_REGISTER_GPIO_AF ((uint32_t) 0x0017 ) +#define STMPE811_REGISTER_ADC_CTRL1 ((uint32_t) 0x0020 ) +#define STMPE811_REGISTER_ADC_CTRL2 ((uint32_t) 0x0021 ) +#define STMPE811_REGISTER_ADC_CAPT ((uint32_t) 0x0022 ) +#define STMPE811_REGISTER_ADC_DATA_CH0 ((uint32_t) 0x0030 ) +#define STMPE811_REGISTER_ADC_DATA_CH1 ((uint32_t) 0x0032 ) +#define STMPE811_REGISTER_ADC_DATA_CH2 ((uint32_t) 0x0034 ) +#define STMPE811_REGISTER_ADC_DATA_CH3 ((uint32_t) 0x0036 ) +#define STMPE811_REGISTER_ADC_DATA_CH4 ((uint32_t) 0x0038 ) +#define STMPE811_REGISTER_ADC_DATA_CH5 ((uint32_t) 0x003A ) +#define STMPE811_REGISTER_ADC_DATA_CH6 ((uint32_t) 0x003C ) +#define STMPE811_REGISTER_ADC_DATA_CH7 ((uint32_t) 0x003E ) +#define STMPE811_REGISTER_TSC_CTRL ((uint32_t) 0x0040 ) +#define STMPE811_REGISTER_TSC_CFG ((uint32_t) 0x0041 ) +#define STMPE811_REGISTER_WDW_TR_X ((uint32_t) 0x0042 ) +#define STMPE811_REGISTER_WDW_TR_Y ((uint32_t) 0x0044 ) +#define STMPE811_REGISTER_WDW_BL_X ((uint32_t) 0x0046 ) +#define STMPE811_REGISTER_WDW_BL_Y ((uint32_t) 0x0048 ) +#define STMPE811_REGISTER_FIFO_TH ((uint32_t) 0x004A ) +#define STMPE811_REGISTER_FIFO_STA ((uint32_t) 0x004B ) +#define STMPE811_REGISTER_FIFO_SIZE ((uint32_t) 0x004C ) +#define STMPE811_REGISTER_TSC_DATA_X ((uint32_t) 0x004D ) +#define STMPE811_REGISTER_TSC_DATA_Y ((uint32_t) 0x004F ) +#define STMPE811_REGISTER_TSC_DATA_Z ((uint32_t) 0x0051 ) +#define STMPE811_REGISTER_TSC_DATA_XYZ ((uint32_t) 0x0052 ) +#define STMPE811_REGISTER_TSC_FRACTION_Z ((uint32_t) 0x0056 ) +#define STMPE811_REGISTER_TSC_DATA ((uint32_t) 0x0057 ) +#define STMPE811_REGISTER_TSC_I_DRIVE ((uint32_t) 0x0058 ) +#define STMPE811_REGISTER_TSC_SHIELD ((uint32_t) 0x0059 ) +#define STMPE811_REGISTER_TEMP_CTRL ((uint32_t) 0x0060 ) +#define STMPE811_REGISTER_TEMP_DATA ((uint32_t) 0x0061 ) +#define STMPE811_REGISTER_TEMP_TH ((uint32_t) 0x0062 ) + + +#endif + + + + + + + + + + + + + + + + + + + diff --git a/lib/src/includes/GRAPHIC/TC_CONTROLERS/genericTC_Controler.h b/lib/src/includes/GRAPHIC/TC_CONTROLERS/genericTC_Controler.h new file mode 100644 --- /dev/null +++ b/lib/src/includes/GRAPHIC/TC_CONTROLERS/genericTC_Controler.h @@ -0,0 +1,37 @@ +/*------------------------------------------------------------------------------ +-- This file is a part of the libuc, microcontroler library +-- Copyright (C) 2013, 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 GENERICTC_CONTROLER_H +#define GENERICTC_CONTROLER_H + +#include +#include +#include + + + + +#endif /*GENERICTC_CONTROLER_H*/ + + + + + diff --git a/lib/src/includes/thread.h b/lib/src/includes/thread.h --- a/lib/src/includes/thread.h +++ b/lib/src/includes/thread.h @@ -29,20 +29,29 @@ extern "C" { #endif +/* + This structure holds the thread context. To do so, you need to keep a track of the programm counter, + to change the stack pointer for each thread and to save all registers needing to be saved. Since the + number of regiter to be saved vary from one processor to an other, it's easier to save them in the + owner thread stack; +*/ typedef struct thread_t { int (*func)(void*); void* __stack__; - int __stackSize__; - int __stackPointer__; - int __programcounter__; + void* __programmCounter__; + void* __registers__; }thread_t; -int threadcreate(thread_t* thread,void* stack,int stackSize); -int threadstart(thread_t* thread); -int threadstop(thread_t* thread); +extern int threadcreate(thread_t* thread,void* stack,int stackSize); +extern int threadstart(thread_t* thread); +extern int threadstop(thread_t* thread); +#ifdef __THREAD_PRIVATE__ +extern void __cpusavecontext(void* dataspace); +extern void __cpurestorecontext(void* dataspace); +#endif #ifdef __cplusplus } diff --git a/lib/src/lib.pro b/lib/src/lib.pro --- a/lib/src/lib.pro +++ b/lib/src/lib.pro @@ -7,6 +7,7 @@ SUBDIRS += common headers.files = includes/*.h \ includes/GRAPHIC/CONTROLERS/*.h \ + includes/GRAPHIC/TC_CONTROLERS/*.h \ includes/GRAPHIC/GUI/FONTS/*.h \ includes/GRAPHIC/GUI/Widgets/*.h diff --git a/lib/src/stm32f4/CORE/core.pro b/lib/src/stm32f4/CORE/core.pro --- a/lib/src/stm32f4/CORE/core.pro +++ b/lib/src/stm32f4/CORE/core.pro @@ -2,7 +2,8 @@ TEMPLATE = lib OBJECTS_DIR = obj SOURCES += \ - core.c + core.c \ + threads.c INCLUDEPATH += ../../includes \ ../CPU/STM32F4xx_StdPeriph_Driver/inc \ diff --git a/lib/src/stm32f4/CORE/threads.c b/lib/src/stm32f4/CORE/threads.c new file mode 100644 --- /dev/null +++ b/lib/src/stm32f4/CORE/threads.c @@ -0,0 +1,81 @@ +/*------------------------------------------------------------------------------ +-- This file is a part of the libuc, microcontroler library +-- Copyright (C) 2013, 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 +-------------------------------------------------------------------------------*/ + + +#define __THREAD_PRIVATE__ +#include + +/* + For CM4 cf lazy Stacking and context switching form ARM + List of automatically saved registers: + R0 + R1 + R2 + R3 + R4 + R5 + R6 + R7 + R8 + R9 + R10 + R11 + R12 + R13(SP) + R14(LR) + R15(PC) + xPSR + S0 to S15 (if enabled) + + List of registers to save: + S16 to S31 +*/ + + +void __cpusavecontext(void* dataspace) +{ + +} + +void __cpurestorecontext(void* dataspace) +{ + +} + + + + + + + + + + + + + + + + + + + diff --git a/lib/src/stm32f4/I2C/i2c.c b/lib/src/stm32f4/I2C/i2c.c --- a/lib/src/stm32f4/I2C/i2c.c +++ b/lib/src/stm32f4/I2C/i2c.c @@ -69,8 +69,6 @@ i2c_t i2copenandconfig(int count,uint32_ i2cclose(dev); i2csetpins(dev,SDA,SCL); i2copen(count); - //i2cenable(count); - //I2C_TypeDef* _dev_ = _i2c_dev_table[(int)dev]; i2csetspeed(dev,speed); i2cenable(count); } diff --git a/mkspecs/common/libuc2libs.conf b/mkspecs/common/libuc2libs.conf --- a/mkspecs/common/libuc2libs.conf +++ b/mkspecs/common/libuc2libs.conf @@ -1,12 +1,13 @@ INCLUDEPATH += $$[QT_INSTALL_HEADERS] \ $$[QT_INSTALL_HEADERS]/GRAPHIC/CONTROLERS \ + $$[QT_INSTALL_HEADERS]/GRAPHIC/TC_CONTROLERS \ $$[QT_INSTALL_HEADERS]/GRAPHIC/GUI/FONTS \ $$[QT_INSTALL_HEADERS]/GRAPHIC/GUI/Widgets \ $$[QT_INSTALL_HEADERS]/$$ARCH -LIBS += -L$$[QT_INSTALL_LIBS]/$$ARCH -lterminal -lCS43L22 -lina226 -lili9328 -lfonts -lsdcard -lfat32 -lmbr -luart -li2c -lgpio -lspi -lcpu -lcore -lm +LIBS += -L$$[QT_INSTALL_LIBS]/$$ARCH -lterminal -lCS43L22 -lina226 -lili9328 -lSTMPE811 -lfonts -lsdcard -lfat32 -lmbr -luart -li2c -lgpio -lspi -lcpu -lcore -lm