##// END OF EJS Templates
sync
jeandet@PC-DE-JEANDET.lab-lpp.local -
r34:da27034d4b78 dev_alexis
parent child
Show More
@@ -1,97 +1,99
1 /*------------------------------------------------------------------------------
1 /*------------------------------------------------------------------------------
2 -- This file is a part of the libuc, microcontroler library
2 -- This file is a part of the libuc, microcontroler library
3 -- Copyright (C) 2011, Alexis Jeandet
3 -- Copyright (C) 2011, Alexis Jeandet
4 --
4 --
5 -- This program is free software; you can redistribute it and/or modify
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
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
7 -- the Free Software Foundation; either version 3 of the License, or
8 -- (at your option) any later version.
8 -- (at your option) any later version.
9 --
9 --
10 -- This program is distributed in the hope that it will be useful,
10 -- This program is distributed in the hope that it will be useful,
11 -- but WITHOUT ANY WARRANTY; without even the implied warranty of
11 -- but WITHOUT ANY WARRANTY; without even the implied warranty of
12 -- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 -- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 -- GNU General Public License for more details.
13 -- GNU General Public License for more details.
14 --
14 --
15 -- You should have received a copy of the GNU General Public License
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
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
17 -- Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
18 -------------------------------------------------------------------------------
18 -------------------------------------------------------------------------------
19 -- Author : Alexis Jeandet
19 -- Author : Alexis Jeandet
20 -- Mail : alexis.jeandet@gmail.com
20 -- Mail : alexis.jeandet@gmail.com
21 -------------------------------------------------------------------------------*/
21 -------------------------------------------------------------------------------*/
22 #ifndef BSP_H
22 #ifndef BSP_H
23 #define BSP_H
23 #define BSP_H
24 #include <stm32f4xx.h>
24 #include <stm32f4xx.h>
25 #include <stm32f4xx_gpio.h>
25 #include <stm32f4xx_gpio.h>
26 #include <stm32f4xx_rcc.h>
26 #include <stm32f4xx_rcc.h>
27 #include <gpio.h>
27 #include <gpio.h>
28 #include <ili9328.h>
28 #include <ili9328.h>
29 #include <genericLCD_Controler.h>
29 #include <genericLCD_Controler.h>
30
30
31 #define __MAX_OPENED_FILES__ 4
31 #define __MAX_OPENED_FILES__ 4
32 #define __FS_ROOT_SIZE__ 4
32 #define __FS_ROOT_SIZE__ 4
33 /*
33 /*
34 #ifndef PD8
34 #ifndef PD8
35 #define PD8
35 #define PD8
36 #endif
36 #endif
37 #ifndef PD9
37 #ifndef PD9
38 #define PD9
38 #define PD9
39 #endif
39 #endif
40 */
40 */
41
41
42
42
43 #define LED1 PF6
43 #define LED1 PF6
44 #define LED2 PF7
44 #define LED2 PF7
45 #define LED3 PF8
45 #define LED3 PF8
46
46
47 #define PSU_DISABLE PH2
47 #define PSU_DISABLE PH2
48 #define PSU_ALERT_5V PF2
48 #define PSU_ALERT_5V PF2
49 #define PSU_ALERT_1_5V PF3
49 #define PSU_ALERT_1_5V PF3
50 #define PSU_ALERT_3_3V PF4
50 #define PSU_ALERT_3_3V PF4
51
51
52 #define LCD_RESET PE2
53
52 extern float VREF0;
54 extern float VREF0;
53
55
54 extern uint32_t currentCpuFreq;
56 extern uint32_t currentCpuFreq;
55 extern LCD_t lcd0;
57 extern LCD_t lcd0;
56
58
57
59
58 extern int bsp_init();
60 extern int bsp_init();
59
61
60 extern void bsp_GPIO_init();
62 extern void bsp_GPIO_init();
61 extern void bsp_uart_init();
63 extern void bsp_uart_init();
62 extern void bsp_iic_init();
64 extern void bsp_iic_init();
63 extern void bsp_spi_init();
65 extern void bsp_spi_init();
64 extern void bsp_SD_init();
66 extern void bsp_SD_init();
65 extern void bsp_FSMC_init();
67 extern void bsp_FSMC_init();
66
68
67 /* VS1053 */
69 /* VS1053 */
68 extern void clearXCS();
70 extern void clearXCS();
69 extern void setXCS();
71 extern void setXCS();
70 extern int vs10XXDREQ();
72 extern int vs10XXDREQ();
71
73
72 /* SD CARD */
74 /* SD CARD */
73 void bsppowersdcard(char onoff);
75 void bsppowersdcard(char onoff);
74 char bspsdcardpresent();
76 char bspsdcardpresent();
75 void bspsdcardselect(char YESNO);
77 void bspsdcardselect(char YESNO);
76 char bspsdcardwriteprotected();
78 char bspsdcardwriteprotected();
77
79
78 #endif
80 #endif
79
81
80
82
81
83
82
84
83
85
84
86
85
87
86
88
87
89
88
90
89
91
90
92
91
93
92
94
93
95
94
96
95
97
96
98
97
99
@@ -1,230 +1,232
1 /*------------------------------------------------------------------------------
1 /*------------------------------------------------------------------------------
2 -- This file is a part of the libuc, microcontroler library
2 -- This file is a part of the libuc, microcontroler library
3 -- Copyright (C) 2011, Alexis Jeandet
3 -- Copyright (C) 2011, Alexis Jeandet
4 --
4 --
5 -- This program is free software; you can redistribute it and/or modify
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
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
7 -- the Free Software Foundation; either version 3 of the License, or
8 -- (at your option) any later version.
8 -- (at your option) any later version.
9 --
9 --
10 -- This program is distributed in the hope that it will be useful,
10 -- This program is distributed in the hope that it will be useful,
11 -- but WITHOUT ANY WARRANTY; without even the implied warranty of
11 -- but WITHOUT ANY WARRANTY; without even the implied warranty of
12 -- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 -- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 -- GNU General Public License for more details.
13 -- GNU General Public License for more details.
14 --
14 --
15 -- You should have received a copy of the GNU General Public License
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
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
17 -- Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
18 -------------------------------------------------------------------------------
18 -------------------------------------------------------------------------------
19 -- Author : Alexis Jeandet
19 -- Author : Alexis Jeandet
20 -- Mail : alexis.jeandet@gmail.com
20 -- Mail : alexis.jeandet@gmail.com
21 -------------------------------------------------------------------------------*/
21 -------------------------------------------------------------------------------*/
22 #include "bsp.h"
22 #include "bsp.h"
23 #include <streamdevices.h>
23 #include <streamdevices.h>
24 #include <malloc.h>
24 #include <malloc.h>
25 #include <gpio.h>
25 #include <gpio.h>
26 #include <uart.h>
26 #include <uart.h>
27 #include <stdio.h>
27 #include <stdio.h>
28 #include <stm32f4xx_gpio.h>
28 #include <stm32f4xx_gpio.h>
29 #include <stm32f4xx_fsmc.h>
29 #include <stm32f4xx_fsmc.h>
30 #include <i2c.h>
30 #include <i2c.h>
31 uint32_t OSC0 =8000000;
31 uint32_t OSC0 =8000000;
32 uint32_t INTOSC =16000000;
32 uint32_t INTOSC =16000000;
33 uint32_t RTCOSC =32768;
33 uint32_t RTCOSC =32768;
34 uint32_t currentCpuFreq=0;
34 uint32_t currentCpuFreq=0;
35 extern streamdevice* __opnfiles__[__MAX_OPENED_FILES__];
35 extern streamdevice* __opnfiles__[__MAX_OPENED_FILES__];
36 LCD_t lcd0;
36 LCD_t lcd0;
37 LCD_IF_t lcdIF0;
37 LCD_IF_t lcdIF0;
38
38
39 volatile int16_t* lcd0_CMD=(volatile int16_t*)0x60000000;
39 volatile int16_t* lcd0_CMD=(volatile int16_t*) 0x60000000;
40 volatile int16_t* lcd0_DATA=(volatile int16_t*)(0x60000000+(1<<20));
40 volatile int16_t* lcd0_DATA=(volatile int16_t*)(0x61FFFFF0);
41
41
42 float VREF0 =(float)3.3;
42 float VREF0 =(float)3.3;
43
43
44 int bsp_init()
44 int bsp_init()
45 {
45 {
46 int i=0;
46 int i=0;
47 for(i=0;i<32;i++)
47 for(i=0;i<32;i++)
48 {
48 {
49 __opnfiles__[i] = NULL;
49 __opnfiles__[i] = NULL;
50 }
50 }
51 bsp_GPIO_init();
51 bsp_GPIO_init();
52 bsp_uart_init();
52 bsp_uart_init();
53 bsp_iic_init();
53 bsp_iic_init();
54 bsp_FSMC_init();
54 bsp_FSMC_init();
55 printf("\r================================================================\n\r");
55 printf("\r================================================================\n\r");
56 printf("================================================================\n\r");
56 printf("================================================================\n\r");
57 printf(BSP);
57 printf(BSP);
58 printf(" initialised\n\r");
58 printf(" initialised\n\r");
59 printf("================================================================\n\r");
59 printf("================================================================\n\r");
60 return 1;
60 return 1;
61 }
61 }
62
62
63 void bsp_GPIO_init()
63 void bsp_GPIO_init()
64 {
64 {
65 gpio_t gpio1 = gpioopen(LED1);
65 gpio_t gpio1 = gpioopen(LED1);
66 gpio_t gpio2 = gpioopen(LED2);
66 gpio_t gpio2 = gpioopen(LED2);
67 gpio_t gpio3 = gpioopen(LED3);
67 gpio_t gpio3 = gpioopen(LED3);
68 gpio_t gpio4 = gpioopen(PSU_DISABLE);
68 gpio_t gpio4 = gpioopen(PSU_DISABLE);
69 gpio_t gpio5 = gpioopen(PSU_ALERT_5V);
69 gpio_t gpio5 = gpioopen(PSU_ALERT_5V);
70 gpio_t gpio6 = gpioopen(PSU_ALERT_1_5V);
70 gpio_t gpio6 = gpioopen(PSU_ALERT_1_5V);
71 gpio_t gpio7 = gpioopen(PSU_ALERT_3_3V);
71 gpio_t gpio7 = gpioopen(PSU_ALERT_3_3V);
72 gpiosetspeed(&gpio1,gpiohighspeed);
72 gpiosetspeed(&gpio1,gpiohighspeed);
73 gpiosetspeed(&gpio2,gpiohighspeed);
73 gpiosetspeed(&gpio2,gpiohighspeed);
74 gpiosetspeed(&gpio3,gpiohighspeed);
74 gpiosetspeed(&gpio3,gpiohighspeed);
75 gpiosetspeed(&gpio4,gpiohighspeed);
75 gpiosetspeed(&gpio4,gpiohighspeed);
76 gpiosetspeed(&gpio5,gpiohighspeed);
76 gpiosetspeed(&gpio5,gpiohighspeed);
77 gpiosetspeed(&gpio6,gpiohighspeed);
77 gpiosetspeed(&gpio6,gpiohighspeed);
78 gpiosetspeed(&gpio7,gpiohighspeed);
78 gpiosetspeed(&gpio7,gpiohighspeed);
79 gpioclr(PSU_DISABLE);
79 gpioclr(PSU_DISABLE);
80 gpiosetdir(&gpio1,gpiooutdir);
80 gpiosetdir(&gpio1,gpiooutdir);
81 gpiosetdir(&gpio3,gpiooutdir);
81 gpiosetdir(&gpio3,gpiooutdir);
82 gpiosetdir(&gpio2,gpiooutdir);
82 gpiosetdir(&gpio2,gpiooutdir);
83 gpiosetdir(&gpio4,gpiooutdir);
83 gpiosetdir(&gpio4,gpiooutdir);
84 gpiosetdir(&gpio5,gpioindir);
84 gpiosetdir(&gpio5,gpioindir);
85 gpiosetdir(&gpio6,gpioindir);
85 gpiosetdir(&gpio6,gpioindir);
86 gpiosetdir(&gpio7,gpioindir);
86 gpiosetdir(&gpio7,gpioindir);
87 gpioclr(PSU_DISABLE);
87 gpioclr(PSU_DISABLE);
88 }
88 }
89
89
90 void bsp_uart_init()
90 void bsp_uart_init()
91 {
91 {
92 if(__opnfiles__[1]==NULL)
92 if(__opnfiles__[1]==NULL)
93 {
93 {
94 //uart_t* uart1 = (uart_t*)malloc(sizeof(uart_t));
94 //uart_t* uart1 = (uart_t*)malloc(sizeof(uart_t));
95 streamdevice* fd1 = (streamdevice*)malloc(sizeof(streamdevice));
95 streamdevice* fd1 = (streamdevice*)malloc(sizeof(streamdevice));
96 uart_t uart = uartopenandconfig(uart1,uartparitynone | uart8bits | uartonestop,115200,PA9,PA10,-1,-1);
96 uart_t uart = uartopenandconfig(uart1,uartparitynone | uart8bits | uartonestop,115200,PA9,PA10,-1,-1);
97 uartmkstreamdev(uart,fd1);
97 uartmkstreamdev(uart,fd1);
98 __opnfiles__[1] = fd1;
98 __opnfiles__[1] = fd1;
99 }
99 }
100 else
100 else
101 {
101 {
102 uartopenandconfig(0,uartparitynone | uart8bits | uartonestop,115200,PA9,PA10,-1,-1);
102 uartopenandconfig(0,uartparitynone | uart8bits | uartonestop,115200,PA9,PA10,-1,-1);
103 }
103 }
104 }
104 }
105
105
106 void bsp_lcd0_write_reg(uint32_t reg,uint32_t data);
106 void bsp_lcd0_write_reg(uint32_t reg,uint32_t data);
107 void bsp_FSMC_init()
107 void bsp_FSMC_init()
108 {
108 {
109 #define GPIOGETPORT(gpio) ((GPIO_TypeDef*)(((((uint32_t)gpio) & (uint32_t)0x0000FF00)*(uint32_t)4) + (uint32_t)GPIOA))
109 #define GPIOGETPORT(gpio) ((GPIO_TypeDef*)(((((uint32_t)gpio) & (uint32_t)0x0000FF00)*(uint32_t)4) + (uint32_t)GPIOA))
110 #define GPIOPORTNUM(gpio) (((uint32_t)(gpio) & (uint32_t)0x0000FF00)>>(uint32_t)8)
110 #define GPIOPORTNUM(gpio) (((uint32_t)(gpio) & (uint32_t)0x0000FF00)>>(uint32_t)8)
111
111
112 gpio_t gpio1 = gpioopen(LCD_RESET);
113 gpiosetspeed(&gpio1,gpiohighspeed);
114 gpiosetdir(&gpio1,gpiooutdir);
115 gpioclr(LCD_RESET);
116
112 gpio_t LCD_DBxList[]={PD14,PD15,PD0,PD1,PE7,PE8,PE9,PE10,PE11,PE12,PE13,PE14,PE15\
117 gpio_t LCD_DBxList[]={PD14,PD15,PD0,PD1,PE7,PE8,PE9,PE10,PE11,PE12,PE13,PE14,PE15\
113 ,PD8,PD9,PD10,PD4,PD5,PD7,PE4};
118 ,PD8,PD9,PD10,PD4,PD5,PD7,PE4};
114 for(int i=0;i<20;i++)
119 for(int i=0;i<20;i++)
115 {
120 {
116 gpio_t LCD_DBx = gpioopen(LCD_DBxList[i]);
121 gpio_t LCD_DBx = gpioopen(LCD_DBxList[i]);
117 LCD_DBx |= gpiohighspeed | gpioaf | gpiopushpulltype | gpionopulltype;
122 LCD_DBx |= gpiohighspeed | gpioaf | gpiopushpulltype | gpionopulltype;
118 gpiosetconfig(&LCD_DBx);
123 gpiosetconfig(&LCD_DBx);
119 GPIO_PinAFConfig(GPIOGETPORT(LCD_DBx), (uint8_t)(LCD_DBx & 0xF), GPIO_AF_FSMC);
124 GPIO_PinAFConfig(GPIOGETPORT(LCD_DBx), (uint8_t)(LCD_DBx & 0xF), GPIO_AF_FSMC);
120 }
125 }
121
126
122 FSMC_NORSRAMInitTypeDef FSMC_NORSRAMInitStructure;
127 FSMC_NORSRAMInitTypeDef FSMC_NORSRAMInitStructure;
123 FSMC_NORSRAMTimingInitTypeDef p;
128 FSMC_NORSRAMTimingInitTypeDef p;
124
129
125 /* Enable FSMC clock */
130 /* Enable FSMC clock */
126 RCC_AHB3PeriphClockCmd(RCC_AHB3Periph_FSMC, ENABLE);
131 RCC_AHB3PeriphClockCmd(RCC_AHB3Periph_FSMC, ENABLE);
127
132
128 /*-- FSMC Configuration ------------------------------------------------------*/
133 /*-- FSMC Configuration ------------------------------------------------------*/
129 /*----------------------- SRAM Bank 3 ----------------------------------------*/
134 /*----------------------- SRAM Bank 3 ----------------------------------------*/
130 /* FSMC_Bank1_NORSRAM4 configuration */
135 /* FSMC_Bank1_NORSRAM4 configuration */
131 p.FSMC_AddressSetupTime = 5;
136 p.FSMC_AddressSetupTime = 5;
132 p.FSMC_AddressHoldTime = 0;
137 p.FSMC_AddressHoldTime = 0;
133 p.FSMC_DataSetupTime = 9;
138 p.FSMC_DataSetupTime = 9;
134 p.FSMC_BusTurnAroundDuration = 0;
139 p.FSMC_BusTurnAroundDuration = 0;
135 p.FSMC_CLKDivision = 0;
140 p.FSMC_CLKDivision = 0;
136 p.FSMC_DataLatency = 0;
141 p.FSMC_DataLatency = 0;
137 p.FSMC_AccessMode = FSMC_AccessMode_A;
142 p.FSMC_AccessMode = FSMC_AccessMode_A;
138 /* Color LCD configuration ------------------------------------
143 /* Color LCD configuration ------------------------------------
139 LCD configured as follow:
144 LCD configured as follow:
140 - Data/Address MUX = Disable
145 - Data/Address MUX = Disable
141 - Memory Type = SRAM
146 - Memory Type = SRAM
142 - Data Width = 16bit
147 - Data Width = 16bit
143 - Write Operation = Enable
148 - Write Operation = Enable
144 - Extended Mode = Enable
149 - Extended Mode = Enable
145 - Asynchronous Wait = Disable */
150 - Asynchronous Wait = Disable */
146
151
147 FSMC_NORSRAMInitStructure.FSMC_Bank = FSMC_Bank1_NORSRAM1;
152 FSMC_NORSRAMInitStructure.FSMC_Bank = FSMC_Bank1_NORSRAM1;
148 FSMC_NORSRAMInitStructure.FSMC_DataAddressMux = FSMC_DataAddressMux_Disable;
153 FSMC_NORSRAMInitStructure.FSMC_DataAddressMux = FSMC_DataAddressMux_Disable;
149 FSMC_NORSRAMInitStructure.FSMC_MemoryType = FSMC_MemoryType_SRAM;
154 FSMC_NORSRAMInitStructure.FSMC_MemoryType = FSMC_MemoryType_SRAM;
150 FSMC_NORSRAMInitStructure.FSMC_MemoryDataWidth = FSMC_MemoryDataWidth_16b;
155 FSMC_NORSRAMInitStructure.FSMC_MemoryDataWidth = FSMC_MemoryDataWidth_16b;
151 FSMC_NORSRAMInitStructure.FSMC_BurstAccessMode = FSMC_BurstAccessMode_Disable;
156 FSMC_NORSRAMInitStructure.FSMC_BurstAccessMode = FSMC_BurstAccessMode_Disable;
152 FSMC_NORSRAMInitStructure.FSMC_AsynchronousWait = FSMC_AsynchronousWait_Disable;
157 FSMC_NORSRAMInitStructure.FSMC_AsynchronousWait = FSMC_AsynchronousWait_Disable;
153 FSMC_NORSRAMInitStructure.FSMC_WaitSignalPolarity = FSMC_WaitSignalPolarity_Low;
158 FSMC_NORSRAMInitStructure.FSMC_WaitSignalPolarity = FSMC_WaitSignalPolarity_Low;
154 FSMC_NORSRAMInitStructure.FSMC_WrapMode = FSMC_WrapMode_Disable;
159 FSMC_NORSRAMInitStructure.FSMC_WrapMode = FSMC_WrapMode_Disable;
155 FSMC_NORSRAMInitStructure.FSMC_WaitSignalActive = FSMC_WaitSignalActive_BeforeWaitState;
160 FSMC_NORSRAMInitStructure.FSMC_WaitSignalActive = FSMC_WaitSignalActive_BeforeWaitState;
156 FSMC_NORSRAMInitStructure.FSMC_WriteOperation = FSMC_WriteOperation_Enable;
161 FSMC_NORSRAMInitStructure.FSMC_WriteOperation = FSMC_WriteOperation_Enable;
157 FSMC_NORSRAMInitStructure.FSMC_WaitSignal = FSMC_WaitSignal_Disable;
162 FSMC_NORSRAMInitStructure.FSMC_WaitSignal = FSMC_WaitSignal_Disable;
158 FSMC_NORSRAMInitStructure.FSMC_ExtendedMode = FSMC_ExtendedMode_Disable;
163 FSMC_NORSRAMInitStructure.FSMC_ExtendedMode = FSMC_ExtendedMode_Disable;
159 FSMC_NORSRAMInitStructure.FSMC_WriteBurst = FSMC_WriteBurst_Disable;
164 FSMC_NORSRAMInitStructure.FSMC_WriteBurst = FSMC_WriteBurst_Disable;
160 FSMC_NORSRAMInitStructure.FSMC_ReadWriteTimingStruct = &p;
165 FSMC_NORSRAMInitStructure.FSMC_ReadWriteTimingStruct = &p;
161 FSMC_NORSRAMInitStructure.FSMC_WriteTimingStruct = &p;
166 FSMC_NORSRAMInitStructure.FSMC_WriteTimingStruct = &p;
162
167
163 FSMC_NORSRAMInit(&FSMC_NORSRAMInitStructure);
168 FSMC_NORSRAMInit(&FSMC_NORSRAMInitStructure);
164
169
165 /* Enable FSMC NOR/SRAM Bank1 */
170 /* Enable FSMC NOR/SRAM Bank1 */
166 FSMC_NORSRAMCmd(FSMC_Bank1_NORSRAM1, ENABLE);
171 FSMC_NORSRAMCmd(FSMC_Bank1_NORSRAM1, ENABLE);
167 lcdIF0.writereg=&bsp_lcd0_write_reg;
172 lcdIF0.writereg=&bsp_lcd0_write_reg;
168 lcd0.interface=&lcdIF0;
173 lcd0.interface=&lcdIF0;
169 lcd0.init=&ili9328init;
174 lcd0.init=&ili9328init;
175 gpioset(LCD_RESET);
170 lcd0.init(&lcd0);
176 lcd0.init(&lcd0);
171 }
177 }
172
178
173 void bsp_spi_init()
179 void bsp_spi_init()
174 {
180 {
175
181
176 }
182 }
177
183
178
184
179 void bsp_iic_init()
185 void bsp_iic_init()
180 {
186 {
181 i2copenandconfig(i2c2,0,400000,PF0,PF1);
187 i2copenandconfig(i2c2,0,400000,PF0,PF1);
182 }
188 }
183
189
184 void bsp_SD_init()
190 void bsp_SD_init()
185 {
191 {
186
192
187 }
193 }
188
194
189 void vs10XXclearXCS(){}
195 void vs10XXclearXCS(){}
190 void vs10XXsetXCS(){}
196 void vs10XXsetXCS(){}
191 int vs10XXDREQ()
197 int vs10XXDREQ()
192 {
198 {
193 return 1;
199 return 1;
194 }
200 }
195
201
196
202
197 void bsppowersdcard(char onoff) //always ON
203 void bsppowersdcard(char onoff) //always ON
198 {
204 {
199
205
200 }
206 }
201
207
202 char bspsdcardpresent()
208 char bspsdcardpresent()
203 {
209 {
204 return 0;
210 return 0;
205 }
211 }
206
212
207 char bspsdcardwriteprotected()
213 char bspsdcardwriteprotected()
208 {
214 {
209 return 0;
215 return 0;
210 }
216 }
211
217
212 void bspsdcardselect(char YESNO)
218 void bspsdcardselect(char YESNO)
213 {
219 {
214
220
215 }
221 }
216
222
217
223
218 void bsp_lcd0_write_reg(uint32_t reg,uint32_t data)
224 void bsp_lcd0_write_reg(uint32_t reg,uint32_t data)
219 {
225 {
220 *lcd0_CMD=(uint16_t)reg;
226 *lcd0_CMD=(uint16_t)reg;
221 *lcd0_DATA=(uint16_t)data;
227 *lcd0_DATA=(uint16_t)data;
222 printf("Write to 0x%x 0x%x\n\r",reg,data);
223 *lcd0_CMD=(uint16_t)reg;
224 data = *lcd0_DATA;
225 printf("Readback to 0x%x 0x%x\n\r",reg,data);
226 }
228 }
227
229
228
230
229
231
230
232
@@ -1,87 +1,73
1 #include <stdio.h>
1 #include <stdio.h>
2 #include <fat32.h>
2 #include <fat32.h>
3 #include <gpio.h>
3 #include <gpio.h>
4 #include <uart.h>
4 #include <uart.h>
5 #include <stm32f4xx.h>
5 #include <stm32f4xx.h>
6 #include <bsp.h>
6 #include <bsp.h>
7 #include <i2c.h>
7 #include <i2c.h>
8 #include <CS43L22.h>
8 #include <CS43L22.h>
9 #include <ina226.h>
9 #include <ina226.h>
10
10
11
11
12 extern streamdevice* __opnfiles__[];
12 extern streamdevice* __opnfiles__[];
13
13
14 int main()
14 int main()
15 {
15 {
16 INA226_t ina5VSens,ina33VSens,ina15VSens;
16 INA226_t ina5VSens,ina33VSens,ina15VSens;
17 gpioset(PSU_DISABLE);
17 gpioset(PSU_DISABLE);
18 volatile int16_t* regtest=(volatile int16_t*)0x60000000;
18 volatile int16_t* regtest=(volatile int16_t*)0x60000000;
19 volatile int16_t* regtest2=(volatile int16_t*)(0x60000000+(1<<20));
19 volatile int16_t* regtest2=(volatile int16_t*)(0x61FFFFF0);
20 //ina226open(&ina5VSens,i2c2,INA226_MODE_SHUNT_VOLTAGE_CONTINUOUS|INA226_AVERAGES_16|INA226_BUS_CONV_8244us|INA226_SHUNT_CONV_8244us,0,0,15,1000000);
20 //ina226open(&ina5VSens,i2c2,INA226_MODE_SHUNT_VOLTAGE_CONTINUOUS|INA226_AVERAGES_16|INA226_BUS_CONV_8244us|INA226_SHUNT_CONV_8244us,0,0,15,1000000);
21 //ina226open(&ina15VSens,i2c2,INA226_MODE_SHUNT_VOLTAGE_CONTINUOUS|INA226_AVERAGES_16|INA226_BUS_CONV_8244us|INA226_SHUNT_CONV_8244us,1,0,15,1000000);
21 //ina226open(&ina15VSens,i2c2,INA226_MODE_SHUNT_VOLTAGE_CONTINUOUS|INA226_AVERAGES_16|INA226_BUS_CONV_8244us|INA226_SHUNT_CONV_8244us,1,0,15,1000000);
22 *regtest=(int16_t)0;
22 *regtest=(int16_t)0;
23 printf("LCD ID=%x\n\r",0xFFFF&(*regtest2));
23 printf("LCD ID=%x\n\r",0xFFFF&(*regtest2));
24 *regtest=(int16_t)ILI9328_REGISTER_ENTRYMODE;
24 //*regtest=(int16_t)ILI9328_REGISTER_ENTRYMODE;
25 *regtest2=(int16_t)0x1008;
25 //*regtest2=(int16_t)0x1008;
26 *regtest=(int16_t)0x20;
26 *regtest=(int16_t)0x20;
27 *regtest2=(int16_t)0x0;
27 *regtest2=(int16_t)0x0;
28 *regtest=(int16_t)0x21;
28 *regtest=(int16_t)0x21;
29 *regtest2=(int16_t)0x0;
29 *regtest2=(int16_t)0x0;
30 *regtest=(int16_t)0x22;
30 *regtest=(int16_t)0x22;
31 for(volatile int i=0;i<32;i++)
31 for(volatile int i=0;i<(320*240);i++)
32 {
32 {
33 *regtest=(int16_t)0x20;
34 *regtest2=(int16_t)i;
33 *regtest2=(int16_t)i;
35 *regtest=(int16_t)0x21;
34 for(volatile int l=0;l<(1024);l++);
36 *regtest2=(int16_t)0x0;
35
37 *regtest=(int16_t)0x22;
38 *regtest2=(int16_t)-i;
39 }
36 }
40 *regtest=(int16_t)ILI9328_REGISTER_ENTRYMODE;
37 //*regtest=(int16_t)ILI9328_REGISTER_ENTRYMODE;
41 *regtest2=(int16_t)0x1018;
38 //*regtest2=(int16_t)0x1018;
42
43 for(volatile int i=0;i<32;i++)
44 {
45 *regtest=(int16_t)0x20;
46 *regtest2=(int16_t)i;
47 *regtest=(int16_t)0x21;
48 *regtest2=(int16_t)0x0;
49 *regtest=(int16_t)0x22;
50 int16_t test=*regtest2;
51 printf("DATA@%d=%x\n\r",i,0xFFFF&(*regtest2));
52 }
53
39
54 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))
40 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))
55 {
41 {
56 printf("Can't open 3.3V monitor\n\r");
42 printf("Can't open 3.3V monitor\n\r");
57 }
43 }
58
44
59 int current5V,current33V,current15V;
45 int current5V,current33V,current15V;
60 printf("\t5V\t3.3V\n\r");
46 printf("\t5V\t3.3V\n\r");
61 while(1)
47 while(1)
62 {
48 {
63 for(volatile int i=0;i<1024*1024;i++);
49 for(volatile int i=0;i<1024*1024;i++);
64 gpioset(LED1);
50 gpioset(LED1);
65 gpioclr(LED2);
51 gpioclr(LED2);
66 for(volatile int i=0;i<1024*1024;i++);
52 for(volatile int i=0;i<1024*1024;i++);
67 gpioclr(LED1);
53 gpioclr(LED1);
68 gpioset(LED2);
54 gpioset(LED2);
69 //current5V = ina226getCurrent(&ina5VSens);
55 //current5V = ina226getCurrent(&ina5VSens);
70 current33V = ina226getCurrent(&ina33VSens);
56 current33V = ina226getCurrent(&ina33VSens);
71 //current15V = ina226getCurrent(&ina15VSens);
57 //current15V = ina226getCurrent(&ina15VSens);
72 //current = ina226getReg(&Psens1,INA226_Current_Reg);
58 //current = ina226getReg(&Psens1,INA226_Current_Reg);
73 //printf("%duA %dmA\t%duA %dmA\n\r",current5V,current5V/1000,current33V,current33V/1000);
59 //printf("%duA %dmA\t%duA %dmA\n\r",current5V,current5V/1000,current33V,current33V/1000);
74 printf("%duA %dmA\n\r",current33V,current33V/1000);
60 printf("%duA %dmA\n\r",current33V,current33V/1000);
75 }
61 }
76 printf("hello world\n\r");
62 printf("hello world\n\r");
77 return 0;
63 return 0;
78 }
64 }
79
65
80
66
81
67
82
68
83
69
84
70
85
71
86
72
87
73
General Comments 0
You need to be logged in to leave comments. Login now