##// END OF EJS Templates
Sync
jeandet -
r57:5929eacb0c63 dev_alexis
parent child
Show More
@@ -0,0 +1,69
1 /*------------------------------------------------------------------------------
2 -- This file is a part of the libuc, microcontroler library
3 -- Copyright (C) 2013, Alexis Jeandet
4 --
5 -- This program is free software; you can redistribute it and/or modify
6 -- it under the terms of the GNU General Public License as published by
7 -- the Free Software Foundation; either version 3 of the License, or
8 -- (at your option) any later version.
9 --
10 -- This program is distributed in the hope that it will be useful,
11 -- but WITHOUT ANY WARRANTY; without even the implied warranty of
12 -- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 -- GNU General Public License for more details.
14 --
15 -- You should have received a copy of the GNU General Public License
16 -- along with this program; if not, write to the Free Software
17 -- Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
18 -------------------------------------------------------------------------------
19 -- Author : Alexis Jeandet
20 -- Mail : alexis.jeandet@gmail.com
21 -------------------------------------------------------------------------------*/
22
23 #include <STMPE811.h>
24
25 int stmpe811init(STMPE811_t *dev, i2c_t i2cdev, uint8_t A0)
26 {
27
28 dev->devAddress = 0x82;
29 if(A0) dev->devAddress = 0x88;
30 dev->i2cdev = i2cdev;
31 return 1;
32 }
33
34 int stmpe811getID(STMPE811_t *dev)
35 {
36 if(dev != NULL)
37 {
38 char DATA[2];
39 DATA[0]=STMPE811_REGISTER_CHIP_ID;
40 i2cwrite(dev->i2cdev,dev->devAddress,DATA,1);
41 i2cread(dev->i2cdev,dev->devAddress,DATA,2);
42 uint16_t val=DATA[0];
43 val=(val<<8)+DATA[1];
44 return val;
45 }
46 return -1;
47 }
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
@@ -0,0 +1,4
1 TEMPLATE = subdirs
2 CONFIG += ordered
3
4 SUBDIRS += ./STMPE811_STM32F4.pro
@@ -0,0 +1,28
1 TEMPLATE = lib
2 OBJECTS_DIR = obj
3 TARGET = STMPE811
4
5 SOURCES += \
6 STMPE811.c
7
8 DEFINES -= __OPTIMIZED_MATH
9
10 INCLUDEPATH += ../../../../includes \
11 ../../../CPU/STM32F4xx_StdPeriph_Driver/inc \
12 ../../../CPU/CMSIS/Include \
13 ../../../../includes/GRAPHIC/CONTROLERS \
14 ../../../../includes/GRAPHIC/TC_CONTROLERS \
15 ../../../../includes/GRAPHIC/GUI/FONTS \
16 ../../../../includes/GRAPHIC/GUI/Widgets
17
18
19 UCMODEL=stm32f4
20
21 target.path = $$[QT_INSTALL_LIBS]/$$UCMODEL
22 INSTALLS += target
23
24 HEADERS += \
25 ../../../../includes/GRAPHIC/TC_CONTROLERS/STMPE811.h \
26 ../../../../includes/GRAPHIC/TC_CONTROLERS/genericTC_Controler.h
27
28
@@ -0,0 +1,9
1 TEMPLATE = subdirs
2 SUBDIRS += STMPE811
3
4
5
6
7
8
9
@@ -0,0 +1,115
1 /*------------------------------------------------------------------------------
2 -- This file is a part of the libuc, microcontroler library
3 -- Copyright (C) 2013, Alexis Jeandet
4 --
5 -- This program is free software; you can redistribute it and/or modify
6 -- it under the terms of the GNU General Public License as published by
7 -- the Free Software Foundation; either version 3 of the License, or
8 -- (at your option) any later version.
9 --
10 -- This program is distributed in the hope that it will be useful,
11 -- but WITHOUT ANY WARRANTY; without even the implied warranty of
12 -- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 -- GNU General Public License for more details.
14 --
15 -- You should have received a copy of the GNU General Public License
16 -- along with this program; if not, write to the Free Software
17 -- Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
18 -------------------------------------------------------------------------------
19 -- Author : Alexis Jeandet
20 -- Mail : alexis.jeandet@gmail.com
21 -------------------------------------------------------------------------------*/
22 #ifndef STMPE811_H
23 #define STMPE811_H
24 #include <stdio.h>
25 #include <uhandle.h>
26 #include <genericTC_Controler.h>
27 #include <stdint.h>
28 #include <fonts.h>
29 #include <i2c.h>
30
31 typedef struct STMPE811_t
32 {
33 i2c_t i2cdev;
34 uint8_t devAddress;
35 }STMPE811_t;
36
37
38 extern int stmpe811init(STMPE811_t *dev, i2c_t i2cdev, uint8_t A0);
39 extern int stmpe811getID(STMPE811_t *dev);
40
41
42
43 #define STMPE811_REGISTER_CHIP_ID ((uint32_t) 0x0000 )
44 #define STMPE811_REGISTER_ID_VER ((uint32_t) 0x0002 )
45 #define STMPE811_REGISTER_SYS_CTRL1 ((uint32_t) 0x0003 )
46 #define STMPE811_REGISTER_SYS_CTRL2 ((uint32_t) 0x0004 )
47 #define STMPE811_REGISTER_SPI_CFG ((uint32_t) 0x0008 )
48 #define STMPE811_REGISTER_INT_CTRL ((uint32_t) 0x0009 )
49 #define STMPE811_REGISTER_INT_EN ((uint32_t) 0x000A )
50 #define STMPE811_REGISTER_INT_STA ((uint32_t) 0x000B )
51 #define STMPE811_REGISTER_GPIO_EN ((uint32_t) 0x000C )
52 #define STMPE811_REGISTER_GPIO_INT_STA ((uint32_t) 0x000D )
53 #define STMPE811_REGISTER_ADC_INT_EN ((uint32_t) 0x000E )
54 #define STMPE811_REGISTER_ADC_INT_STA ((uint32_t) 0x000F )
55 #define STMPE811_REGISTER_GPIO_SET_PIN ((uint32_t) 0x0010 )
56 #define STMPE811_REGISTER_GPIO_CLR_PIN ((uint32_t) 0x0011 )
57 #define STMPE811_REGISTER_GPIO_MP_STA ((uint32_t) 0x0012 )
58 #define STMPE811_REGISTER_GPIO_DIR ((uint32_t) 0x0013 )
59 #define STMPE811_REGISTER_GPIO_ED ((uint32_t) 0x0014 )
60 #define STMPE811_REGISTER_GPIO_RE ((uint32_t) 0x0015 )
61 #define STMPE811_REGISTER_GPIO_FE ((uint32_t) 0x0016 )
62 #define STMPE811_REGISTER_GPIO_AF ((uint32_t) 0x0017 )
63 #define STMPE811_REGISTER_ADC_CTRL1 ((uint32_t) 0x0020 )
64 #define STMPE811_REGISTER_ADC_CTRL2 ((uint32_t) 0x0021 )
65 #define STMPE811_REGISTER_ADC_CAPT ((uint32_t) 0x0022 )
66 #define STMPE811_REGISTER_ADC_DATA_CH0 ((uint32_t) 0x0030 )
67 #define STMPE811_REGISTER_ADC_DATA_CH1 ((uint32_t) 0x0032 )
68 #define STMPE811_REGISTER_ADC_DATA_CH2 ((uint32_t) 0x0034 )
69 #define STMPE811_REGISTER_ADC_DATA_CH3 ((uint32_t) 0x0036 )
70 #define STMPE811_REGISTER_ADC_DATA_CH4 ((uint32_t) 0x0038 )
71 #define STMPE811_REGISTER_ADC_DATA_CH5 ((uint32_t) 0x003A )
72 #define STMPE811_REGISTER_ADC_DATA_CH6 ((uint32_t) 0x003C )
73 #define STMPE811_REGISTER_ADC_DATA_CH7 ((uint32_t) 0x003E )
74 #define STMPE811_REGISTER_TSC_CTRL ((uint32_t) 0x0040 )
75 #define STMPE811_REGISTER_TSC_CFG ((uint32_t) 0x0041 )
76 #define STMPE811_REGISTER_WDW_TR_X ((uint32_t) 0x0042 )
77 #define STMPE811_REGISTER_WDW_TR_Y ((uint32_t) 0x0044 )
78 #define STMPE811_REGISTER_WDW_BL_X ((uint32_t) 0x0046 )
79 #define STMPE811_REGISTER_WDW_BL_Y ((uint32_t) 0x0048 )
80 #define STMPE811_REGISTER_FIFO_TH ((uint32_t) 0x004A )
81 #define STMPE811_REGISTER_FIFO_STA ((uint32_t) 0x004B )
82 #define STMPE811_REGISTER_FIFO_SIZE ((uint32_t) 0x004C )
83 #define STMPE811_REGISTER_TSC_DATA_X ((uint32_t) 0x004D )
84 #define STMPE811_REGISTER_TSC_DATA_Y ((uint32_t) 0x004F )
85 #define STMPE811_REGISTER_TSC_DATA_Z ((uint32_t) 0x0051 )
86 #define STMPE811_REGISTER_TSC_DATA_XYZ ((uint32_t) 0x0052 )
87 #define STMPE811_REGISTER_TSC_FRACTION_Z ((uint32_t) 0x0056 )
88 #define STMPE811_REGISTER_TSC_DATA ((uint32_t) 0x0057 )
89 #define STMPE811_REGISTER_TSC_I_DRIVE ((uint32_t) 0x0058 )
90 #define STMPE811_REGISTER_TSC_SHIELD ((uint32_t) 0x0059 )
91 #define STMPE811_REGISTER_TEMP_CTRL ((uint32_t) 0x0060 )
92 #define STMPE811_REGISTER_TEMP_DATA ((uint32_t) 0x0061 )
93 #define STMPE811_REGISTER_TEMP_TH ((uint32_t) 0x0062 )
94
95
96 #endif
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
@@ -0,0 +1,37
1 /*------------------------------------------------------------------------------
2 -- This file is a part of the libuc, microcontroler library
3 -- Copyright (C) 2013, Alexis Jeandet
4 --
5 -- This program is free software; you can redistribute it and/or modify
6 -- it under the terms of the GNU General Public License as published by
7 -- the Free Software Foundation; either version 3 of the License, or
8 -- (at your option) any later version.
9 --
10 -- This program is distributed in the hope that it will be useful,
11 -- but WITHOUT ANY WARRANTY; without even the implied warranty of
12 -- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 -- GNU General Public License for more details.
14 --
15 -- You should have received a copy of the GNU General Public License
16 -- along with this program; if not, write to the Free Software
17 -- Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
18 -------------------------------------------------------------------------------
19 -- Author : Alexis Jeandet
20 -- Mail : alexis.jeandet@gmail.com
21 -------------------------------------------------------------------------------*/
22 #ifndef GENERICTC_CONTROLER_H
23 #define GENERICTC_CONTROLER_H
24
25 #include <uhandle.h>
26 #include <stdint.h>
27 #include <fonts.h>
28
29
30
31
32 #endif /*GENERICTC_CONTROLER_H*/
33
34
35
36
37
@@ -0,0 +1,81
1 /*------------------------------------------------------------------------------
2 -- This file is a part of the libuc, microcontroler library
3 -- Copyright (C) 2013, Alexis Jeandet
4 --
5 -- This program is free software; you can redistribute it and/or modify
6 -- it under the terms of the GNU General Public License as published by
7 -- the Free Software Foundation; either version 3 of the License, or
8 -- (at your option) any later version.
9 --
10 -- This program is distributed in the hope that it will be useful,
11 -- but WITHOUT ANY WARRANTY; without even the implied warranty of
12 -- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 -- GNU General Public License for more details.
14 --
15 -- You should have received a copy of the GNU General Public License
16 -- along with this program; if not, write to the Free Software
17 -- Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
18 -------------------------------------------------------------------------------
19 -- Author : Alexis Jeandet
20 -- Mail : alexis.jeandet@gmail.com
21 -------------------------------------------------------------------------------*/
22
23
24 #define __THREAD_PRIVATE__
25 #include <thread.h>
26
27 /*
28 For CM4 cf lazy Stacking and context switching form ARM
29 List of automatically saved registers:
30 R0
31 R1
32 R2
33 R3
34 R4
35 R5
36 R6
37 R7
38 R8
39 R9
40 R10
41 R11
42 R12
43 R13(SP)
44 R14(LR)
45 R15(PC)
46 xPSR
47 S0 to S15 (if enabled)
48
49 List of registers to save:
50 S16 to S31
51 */
52
53
54 void __cpusavecontext(void* dataspace)
55 {
56
57 }
58
59 void __cpurestorecontext(void* dataspace)
60 {
61
62 }
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
@@ -247,7 +247,7 void bsp_spi_init()
247
247
248 void bsp_iic_init()
248 void bsp_iic_init()
249 {
249 {
250 i2copenandconfig(i2c1,0,100000,PB9,PB6);
250 i2copenandconfig(i2c1,0,10000,PB9,PB6);
251 }
251 }
252
252
253 void bsp_SD_init()
253 void bsp_SD_init()
@@ -3,7 +3,7 CONFIG += cpu
3
3
4
4
5 UCMODEL=stm32f4
5 UCMODEL=stm32f4
6 DEFINES += CPUFREQ=40000000
6 DEFINES += CPUFREQ=80000000
7
7
8 BSP = BEAGLESYNTH
8 BSP = BEAGLESYNTH
9 #BSP = SOLAR_LFR_PSU
9 #BSP = SOLAR_LFR_PSU
@@ -39,6 +39,40 void setUartAsStdout()
39 __opnfiles__[1] = fd1;
39 __opnfiles__[1] = fd1;
40 }
40 }
41
41
42 void printSupplyStatus(int cur5v,int cur33v,int cur15v, int volt5v, int volt33v, int volt15v)
43 {
44 char buffer[64];
45 int i=0;
46 int power5V=(cur5v*(volt5v/1000))/1000,power33V=(cur33v*(volt33v/1000))/1000,power15V=(cur15v*(volt15v/1000))/1000;
47 #define clearBuff for(i=0;i<64;i++)buffer[i]='\0'
48
49 ili9328paintFilRect(&lcd0,5,5,230,7*(ComicSansMS_18.Height+10)+50,LCD_COLOR_BLACK,4,LCD_COLOR_WHITE);
50 ili9328paintFilRect(&lcd0,5,7*(ComicSansMS_18.Height+10)+50,230,320 - (7*(ComicSansMS_18.Height+10)+50),LCD_COLOR_BLACK,4,LCD_COLOR_WHITE);
51 clearBuff;
52 sprintf(buffer,"%.3fV %dmA",volt5v/1000000.0,cur5v);
53 ili9328paintText(&lcd0,buffer,10,0*(ComicSansMS_18.Height+10)+50,&ComicSansMS_18,LCD_COLOR_BLACK);
54 clearBuff;
55 sprintf(buffer,"%dmW",power5V);
56 ili9328paintText(&lcd0,buffer,10,1*(ComicSansMS_18.Height+10)+50,&ComicSansMS_18,LCD_COLOR_BLACK);
57 clearBuff;
58 sprintf(buffer,"%.3fV %dmA",volt33v/1000000.0,cur33v);
59 ili9328paintText(&lcd0,buffer,10,2*(ComicSansMS_18.Height+10)+50,&ComicSansMS_18,LCD_COLOR_BLACK);
60 clearBuff;
61 sprintf(buffer,"%dmW",power33V);
62 ili9328paintText(&lcd0,buffer,10,3*(ComicSansMS_18.Height+10)+50,&ComicSansMS_18,LCD_COLOR_BLACK);
63 clearBuff;
64 sprintf(buffer,"%.3fV %dmA",volt15v/1000000.0,cur15v);
65 ili9328paintText(&lcd0,buffer,10,4*(ComicSansMS_18.Height+10)+50,&ComicSansMS_18,LCD_COLOR_BLACK);
66 clearBuff;
67 sprintf(buffer,"%dmW",power15V);
68 ili9328paintText(&lcd0,buffer,10,5*(ComicSansMS_18.Height+10)+50,&ComicSansMS_18,LCD_COLOR_BLACK);
69
70 clearBuff;
71 sprintf(buffer,"Total = %dmW",power5V+power33V+power15V);
72 ili9328paintText(&lcd0,buffer,10,320-10-20,&ComicSansMS_18,LCD_COLOR_BLACK);
73
74 }
75
42 int main()
76 int main()
43 {
77 {
44 delay_100us(20000);
78 delay_100us(20000);
@@ -46,11 +80,13 int main()
46 gpioset(PSU_DISABLE);//enable psu!
80 gpioset(PSU_DISABLE);//enable psu!
47 setUartAsStdout();
81 setUartAsStdout();
48 //ili9328paintFilRect(&lcd0,0,0,240,320,LCD_COLOR_BLACK,1,LCD_COLOR_BLACK);
82 //ili9328paintFilRect(&lcd0,0,0,240,320,LCD_COLOR_BLACK,1,LCD_COLOR_BLACK);
49 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))
83
84 ili9328paintFilRect(&lcd0,5,5,230,310,LCD_COLOR_BLACK,4,LCD_COLOR_WHITE);
85 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))
50 {
86 {
51 printf("Can't open 3.3V monitor\n\r");
87 printf("Can't open 3.3V monitor\n\r");
52 }
88 }
53 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))
89 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))
54 {
90 {
55 printf("Can't open 5V monitor\n\r");
91 printf("Can't open 5V monitor\n\r");
56 }
92 }
@@ -58,15 +94,19 int main()
58 {
94 {
59 printf("Can't open 1.5V monitor\n\r");
95 printf("Can't open 1.5V monitor\n\r");
60 }
96 }
61 int current5V,current33V,current15V;
97 int current5V,current33V,current15V,volt5v, volt33v, volt15v;
62 while(1)
98 while(1)
63 {
99 {
64 current5V = ina226getCurrent(&ina5VSens);
100 current5V = ina226getCurrent(&ina5VSens);
65 current33V = ina226getCurrent(&ina33VSens);
101 current33V = ina226getCurrent(&ina33VSens);
66 current15V = ina226getCurrent(&ina15VSens);
102 current15V = ina226getCurrent(&ina15VSens);
67 printf("%dmA\n\r",current15V/1000);
103 volt5v = ina226getBusVoltage(&ina5VSens);
68 printf("%dmA\n\r",current33V/1000);
104 volt33v = ina226getBusVoltage(&ina33VSens);
69 printf("%dmA\n\r",current5V/1000);
105 volt15v = ina226getBusVoltage(&ina15VSens);
106 printf("%fV\t%dmA\n\r",volt15v/1000000.0,current15V/1000);
107 printf("%fV\t%dmA\n\r",volt33v/1000000.0,current33V/1000);
108 printf("%fV\t%dmA\n\r",volt5v/1000000.0,current5V/1000);
109 printSupplyStatus(current5V/1000,current33V/1000,current15V/1000,volt5v, volt33v, volt15v);
70 delay_100us(10000);
110 delay_100us(10000);
71 }
111 }
72 printf("Exit\n\r");
112 printf("Exit\n\r");
@@ -7,6 +7,7
7 #include <bsp.h>
7 #include <bsp.h>
8 #include <i2c.h>
8 #include <i2c.h>
9 #include <CS43L22.h>
9 #include <CS43L22.h>
10 #include <STMPE811.h>
10 #include <ina226.h>
11 #include <ina226.h>
11 #include <fonts.h>
12 #include <fonts.h>
12 #include <stdlib.h>
13 #include <stdlib.h>
@@ -34,6 +35,18 void testAudioDAC()
34 printf("dac ID = %d\n\r",ID);
35 printf("dac ID = %d\n\r",ID);
35 }
36 }
36
37
38 void testIOEXPender()
39 {
40 STMPE811_t ioexp1,ioexp2;
41 char data[2]={0,0};
42 i2cwrite(i2c1,0x50,data,1);
43
44 //i2cread(i2c1,0x88,data,2);
45 // stmpe811init(&ioexp1,i2c1,0);
46 // stmpe811init(&ioexp2,i2c1,1);
47 // printf("Scan for IOEXPANDER:\n\r ID1=%d\n\rID2=%d",stmpe811getID(&ioexp1),stmpe811getID(&ioexp2));
48 }
49
37 int main()
50 int main()
38 {
51 {
39 delay_100us(10000);
52 delay_100us(10000);
@@ -48,16 +61,16 int main()
48 int i=0;
61 int i=0;
49 terminal_t terminal0,terminal1;
62 terminal_t terminal0,terminal1;
50 terminal_init(&terminal0,&lcd0,&ComicSansMS_18,fd1);
63 terminal_init(&terminal0,&lcd0,&ComicSansMS_18,fd1);
51 terminal_init(&terminal1,&lcd0,&ComicSansMS_18,&fd2);
64 //terminal_init(&terminal1,&lcd0,&ComicSansMS_18,&fd2);
52 terminal_setgeometry(&terminal0,5,5,terminal0.LCD->width-10,(terminal0.LCD->height/2)-10);
65 terminal_setgeometry(&terminal0,5,5,terminal0.LCD->width-10,(terminal0.LCD->height)-10);
53 terminal_setbackgroundColor(&terminal1,0xFFFF);
66 //terminal_setbackgroundColor(&terminal1,0xFFFF);
54 terminal_settextColor(&terminal1,0x0000);
67 //terminal_settextColor(&terminal1,0x0000);
55 terminal_setgeometry(&terminal1,5,(terminal0.LCD->height/2)+5,terminal0.LCD->width-10,(terminal0.LCD->height/2)-10);
68 //terminal_setgeometry(&terminal1,5,(terminal0.LCD->height/2)+5,terminal0.LCD->width-10,(terminal0.LCD->height/2)-10);
56 printf("Line cnt :\n \t%d\n",terminal0.lineCount);
69 printf("Line cnt :\n \t%d\n",terminal0.lineCount);
57 printf("Column cnt :\n \t%d\n",terminal0.columnCount);
70 printf("Column cnt :\n \t%d\n",terminal0.columnCount);
58 printf("CPU Freq :\n \t%dMHz\n",getCpuFreq()/1000000);
71 printf("CPU Freq :\n \t%dMHz\n",getCpuFreq()/1000000);
59 //testAudioDAC();
72 //testAudioDAC();
60 i2cwrite(i2c1,0x4a," ",1);
73 testIOEXPender();
61 while(1)
74 while(1)
62 {
75 {
63 i%=1000;
76 i%=1000;
@@ -40,7 +40,7 void eeprom24lc0xopen(eeprom24lc0xDev* d
40 if(size == 1024) dev->size = 1;
40 if(size == 1024) dev->size = 1;
41 }
41 }
42
42
43 void eeprom24lc0xpagewrite(eeprom24lc0xDev dev,unsigned char address,unsigned char* page)
43 void eeprom24lc0xpagewrite(eeprom24lc0xDev* dev,unsigned char address,unsigned char* page)
44 {
44 {
45 int cmdcnt=1,datacnt=8;
45 int cmdcnt=1,datacnt=8;
46 //i2cwrite(dev.iicdev,address,page)
46 //i2cwrite(dev.iicdev,address,page)
@@ -48,21 +48,21 void eeprom24lc0xpagewrite(eeprom24lc0xD
48 }
48 }
49
49
50
50
51 void eeprom24lc0xpageread(eeprom24lc0xDev dev,unsigned char address,unsigned char* page)
51 void eeprom24lc0xpageread(eeprom24lc0xDev* dev,unsigned char address,unsigned char* page)
52 {
52 {
53 int cmdcnt=1,datacnt=8;
53 int cmdcnt=1,datacnt=8;
54 /*i2cwrite(dev.iicdev,dev.devAddress,&address,&cmdcnt);
54 /*i2cwrite(dev.iicdev,dev.devAddress,&address,&cmdcnt);
55 i2cread(dev.iicdev,dev.devAddress,page,&datacnt);*/
55 i2cread(dev.iicdev,dev.devAddress,page,&datacnt);*/
56 }
56 }
57
57
58 void eeprom24lc0xbytewrite(eeprom24lc0xDev dev,unsigned char address,unsigned char data)
58 void eeprom24lc0xbytewrite(eeprom24lc0xDev* dev,unsigned char address,unsigned char data)
59 {
59 {
60 int cmdcnt=1,datacnt=1;
60 int cmdcnt=1,datacnt=1;
61 //i2cwrite2(dev.iicdev,dev.devAddress,&address,&cmdcnt,&data,&datacnt);
61 //i2cwrite2(dev.iicdev,dev.devAddress,&address,&cmdcnt,&data,&datacnt);
62 }
62 }
63
63
64
64
65 unsigned char eeprom24lc0xbyteread(eeprom24lc0xDev dev,unsigned char address)
65 unsigned char eeprom24lc0xbyteread(eeprom24lc0xDev* dev,unsigned char address)
66 {
66 {
67 int cmdcnt=1,datacnt=1;
67 int cmdcnt=1,datacnt=1;
68 unsigned char data = 0;
68 unsigned char data = 0;
@@ -72,7 +72,7 unsigned char eeprom24lc0xbyteread(eepro
72 }
72 }
73
73
74
74
75 void eeprom24lc0xreadn(eeprom24lc0xDev dev,unsigned char address,unsigned char* data, unsigned int count)
75 void eeprom24lc0xreadn(eeprom24lc0xDev* dev,unsigned char address,unsigned char* data, unsigned int count)
76 {
76 {
77 int cmdcnt=1,datacnt=count;
77 int cmdcnt=1,datacnt=count;
78 /* i2cwrite(dev.iicdev,dev.devAddress,&address,&cmdcnt);
78 /* i2cwrite(dev.iicdev,dev.devAddress,&address,&cmdcnt);
@@ -80,7 +80,7 void eeprom24lc0xreadn(eeprom24lc0xDev d
80
80
81 }
81 }
82
82
83 void eeprom24lc0xwriten(eeprom24lc0xDev dev,unsigned char address,unsigned char* data, unsigned int count)
83 void eeprom24lc0xwriten(eeprom24lc0xDev* dev,unsigned char address,unsigned char* data, unsigned int count)
84 {
84 {
85 int cmdcnt=1,datacnt=8;
85 int cmdcnt=1,datacnt=8;
86 while(count >8)
86 while(count >8)
@@ -2,7 +2,8 TEMPLATE = lib
2 OBJECTS_DIR = obj
2 OBJECTS_DIR = obj
3
3
4 SOURCES += 24LC0X.c
4 SOURCES += 24LC0X.c
5 HEADERS += ../../../includes/24LC0X.h
5 HEADERS += ../../../includes/24LC0X.h \
6 ../../../../includes/24LC0X.h
6
7
7 INCLUDEPATH += ../../../includes \
8 INCLUDEPATH += ../../../includes \
8 ../../CPU/STM32F4xx_StdPeriph_Driver/inc \
9 ../../CPU/STM32F4xx_StdPeriph_Driver/inc \
@@ -337,7 +337,7 void ili9328paintText(LCD_t* LCD,char* b
337 uint16_t tmp[w];
337 uint16_t tmp[w];
338 uint16_t linenum=0,charnum=0;
338 uint16_t linenum=0,charnum=0;
339 uint8_t line=0;
339 uint8_t line=0;
340 while(*buffer)
340 while(*buffer!='\0')
341 {
341 {
342 ili9328setFrame(LCD,Xpos+(charnum*w),Ypos-h,w,1);
342 ili9328setFrame(LCD,Xpos+(charnum*w),Ypos-h,w,1);
343 LCD->interface->readGRAM(tmp,w);
343 LCD->interface->readGRAM(tmp,w);
@@ -1,5 +1,6
1 TEMPLATE = subdirs
1 TEMPLATE = subdirs
2 SUBDIRS += CONTROLERS \
2 SUBDIRS += CONTROLERS \
3 TC_CONTROLERS \
3 GUI
4 GUI
4
5
5
6
@@ -12,3 +12,10 UCMODEL=stm32f4
12
12
13 target.path = $$[QT_INSTALL_LIBS]/$$UCMODEL
13 target.path = $$[QT_INSTALL_LIBS]/$$UCMODEL
14 INSTALLS += target
14 INSTALLS += target
15
16 HEADERS += \
17 ../../includes/thread.h
18
19
20
21
@@ -36,12 +36,12 typedef struct eeprom24lc0xDev
36
36
37 extern void eeprom24lc0xopen(eeprom24lc0xDev* dev,i2c_t iicdev,unsigned char A0_A1_A2_val,unsigned int size);
37 extern void eeprom24lc0xopen(eeprom24lc0xDev* dev,i2c_t iicdev,unsigned char A0_A1_A2_val,unsigned int size);
38
38
39 extern void eeprom24lc0xpagewrite(eeprom24lc0xDev dev,unsigned char address,unsigned char* page);
39 extern void eeprom24lc0xpagewrite(eeprom24lc0xDev* dev,unsigned char address,unsigned char* page);
40 extern void eeprom24lc0xpageread(eeprom24lc0xDev dev,unsigned char address,unsigned char* page);
40 extern void eeprom24lc0xpageread(eeprom24lc0xDev* dev,unsigned char address,unsigned char* page);
41 extern void eeprom24lc0xbytewrite(eeprom24lc0xDev dev,unsigned char address,unsigned char data);
41 extern void eeprom24lc0xbytewrite(eeprom24lc0xDev* dev,unsigned char address,unsigned char data);
42 extern unsigned char eeprom24lc0xbyteread(eeprom24lc0xDev dev,unsigned char address);
42 extern unsigned char eeprom24lc0xbyteread(eeprom24lc0xDev* dev,unsigned char address);
43 extern void eeprom24lc0xreadn(eeprom24lc0xDev dev,unsigned char address,unsigned char* data, unsigned int count);
43 extern void eeprom24lc0xreadn(eeprom24lc0xDev* dev,unsigned char address,unsigned char* data, unsigned int count);
44 extern void eeprom24lc0xwriten(eeprom24lc0xDev dev,unsigned char address,unsigned char* data, unsigned int count);
44 extern void eeprom24lc0xwriten(eeprom24lc0xDev* dev,unsigned char address,unsigned char* data, unsigned int count);
45
45
46
46
47
47
@@ -29,20 +29,29
29 extern "C" {
29 extern "C" {
30 #endif
30 #endif
31
31
32 /*
33 This structure holds the thread context. To do so, you need to keep a track of the programm counter,
34 to change the stack pointer for each thread and to save all registers needing to be saved. Since the
35 number of regiter to be saved vary from one processor to an other, it's easier to save them in the
36 owner thread stack;
37 */
32 typedef struct thread_t
38 typedef struct thread_t
33 {
39 {
34 int (*func)(void*);
40 int (*func)(void*);
35 void* __stack__;
41 void* __stack__;
36 int __stackSize__;
42 void* __programmCounter__;
37 int __stackPointer__;
43 void* __registers__;
38 int __programcounter__;
39 }thread_t;
44 }thread_t;
40
45
41
46
42 int threadcreate(thread_t* thread,void* stack,int stackSize);
47 extern int threadcreate(thread_t* thread,void* stack,int stackSize);
43 int threadstart(thread_t* thread);
48 extern int threadstart(thread_t* thread);
44 int threadstop(thread_t* thread);
49 extern int threadstop(thread_t* thread);
45
50
51 #ifdef __THREAD_PRIVATE__
52 extern void __cpusavecontext(void* dataspace);
53 extern void __cpurestorecontext(void* dataspace);
54 #endif
46
55
47 #ifdef __cplusplus
56 #ifdef __cplusplus
48 }
57 }
@@ -7,6 +7,7 SUBDIRS += common
7
7
8 headers.files = includes/*.h \
8 headers.files = includes/*.h \
9 includes/GRAPHIC/CONTROLERS/*.h \
9 includes/GRAPHIC/CONTROLERS/*.h \
10 includes/GRAPHIC/TC_CONTROLERS/*.h \
10 includes/GRAPHIC/GUI/FONTS/*.h \
11 includes/GRAPHIC/GUI/FONTS/*.h \
11 includes/GRAPHIC/GUI/Widgets/*.h
12 includes/GRAPHIC/GUI/Widgets/*.h
12
13
@@ -2,7 +2,8 TEMPLATE = lib
2 OBJECTS_DIR = obj
2 OBJECTS_DIR = obj
3
3
4 SOURCES += \
4 SOURCES += \
5 core.c
5 core.c \
6 threads.c
6
7
7 INCLUDEPATH += ../../includes \
8 INCLUDEPATH += ../../includes \
8 ../CPU/STM32F4xx_StdPeriph_Driver/inc \
9 ../CPU/STM32F4xx_StdPeriph_Driver/inc \
@@ -69,8 +69,6 i2c_t i2copenandconfig(int count,uint32_
69 i2cclose(dev);
69 i2cclose(dev);
70 i2csetpins(dev,SDA,SCL);
70 i2csetpins(dev,SDA,SCL);
71 i2copen(count);
71 i2copen(count);
72 //i2cenable(count);
73 //I2C_TypeDef* _dev_ = _i2c_dev_table[(int)dev];
74 i2csetspeed(dev,speed);
72 i2csetspeed(dev,speed);
75 i2cenable(count);
73 i2cenable(count);
76 }
74 }
@@ -1,12 +1,13
1
1
2 INCLUDEPATH += $$[QT_INSTALL_HEADERS] \
2 INCLUDEPATH += $$[QT_INSTALL_HEADERS] \
3 $$[QT_INSTALL_HEADERS]/GRAPHIC/CONTROLERS \
3 $$[QT_INSTALL_HEADERS]/GRAPHIC/CONTROLERS \
4 $$[QT_INSTALL_HEADERS]/GRAPHIC/TC_CONTROLERS \
4 $$[QT_INSTALL_HEADERS]/GRAPHIC/GUI/FONTS \
5 $$[QT_INSTALL_HEADERS]/GRAPHIC/GUI/FONTS \
5 $$[QT_INSTALL_HEADERS]/GRAPHIC/GUI/Widgets \
6 $$[QT_INSTALL_HEADERS]/GRAPHIC/GUI/Widgets \
6 $$[QT_INSTALL_HEADERS]/$$ARCH
7 $$[QT_INSTALL_HEADERS]/$$ARCH
7
8
8
9
9 LIBS += -L$$[QT_INSTALL_LIBS]/$$ARCH -lterminal -lCS43L22 -lina226 -lili9328 -lfonts -lsdcard -lfat32 -lmbr -luart -li2c -lgpio -lspi -lcpu -lcore -lm
10 LIBS += -L$$[QT_INSTALL_LIBS]/$$ARCH -lterminal -lCS43L22 -lina226 -lili9328 -lSTMPE811 -lfonts -lsdcard -lfat32 -lmbr -luart -li2c -lgpio -lspi -lcpu -lcore -lm
10
11
11
12
12
13
General Comments 0
You need to be logged in to leave comments. Login now