##// END OF EJS Templates
Sync
jeandet@pc-de-jeandet3.LAB-LPP.LOCAL -
r42:ee74c90426e9 dev_alexis
parent child
Show More
@@ -1,132 +1,126
1 1 /*------------------------------------------------------------------------------
2 2 -- This file is a part of the libuc, microcontroler library
3 3 -- Copyright (C) 2011, Alexis Jeandet
4 4 --
5 5 -- This program is free software; you can redistribute it and/or modify
6 6 -- it under the terms of the GNU General Public License as published by
7 7 -- the Free Software Foundation; either version 3 of the License, or
8 8 -- (at your option) any later version.
9 9 --
10 10 -- This program is distributed in the hope that it will be useful,
11 11 -- but WITHOUT ANY WARRANTY; without even the implied warranty of
12 12 -- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 13 -- GNU General Public License for more details.
14 14 --
15 15 -- You should have received a copy of the GNU General Public License
16 16 -- along with this program; if not, write to the Free Software
17 17 -- Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
18 18 -------------------------------------------------------------------------------
19 19 -- Author : Alexis Jeandet
20 20 -- Mail : alexis.jeandet@gmail.com
21 21 -------------------------------------------------------------------------------*/
22 22 #include "bsp.h"
23 23 #include <streamdevices.h>
24 24 #include <malloc.h>
25 25 #include <gpio.h>
26 26 #include <uart.h>
27 27 #include <stdio.h>
28 28 uint32_t OSC0 =8000000;
29 29 uint32_t INTOSC =16000000;
30 30 uint32_t RTCOSC =32768;
31 31 uint32_t currentCpuFreq=0;
32 32 extern streamdevice* __opnfiles__[__MAX_OPENED_FILES__];
33 33
34 34 float VREF0 =(float)3.3;
35 35
36 36 int bsp_init()
37 37 {
38 38 int i=0;
39 39 for(i=0;i<32;i++)
40 40 {
41 41 __opnfiles__[i] = NULL;
42 42 }
43 43 bsp_GPIO_init();
44 44 bsp_uart_init();
45 45 printf("\r================================================================\n\r");
46 46 printf("================================================================\n\r");
47 47 printf(BSP);
48 48 printf(" initialised\n\r");
49 49 printf("================================================================\n\r");
50 50 return 1;
51 51 }
52 52
53 53 void bsp_GPIO_init()
54 54 {
55 gpio_t gpio1 = gpioopen(PD12);//gpioopen(LED1); //PD9 D=> 0x0300 9 => 0x0009
56 gpio_t gpio2 = gpioopen(PD13);//gpioopen(LED2);
57 gpio_t gpio3 = gpioopen(PD14);//gpioopen(LED2);
58 gpio_t gpio4 = gpioopen(PD15);//gpioopen(LED2);
55 gpio_t gpio1 = gpioopen(PC6);//gpioopen(LED1); //PD9 D=> 0x0300 9 => 0x0009
56 gpio_t gpio2 = gpioopen(PC7);//gpioopen(LED2);
59 57 gpiosetspeed(&gpio1,gpiohighspeed);
60 58 gpiosetspeed(&gpio2,gpiohighspeed);
61 gpiosetspeed(&gpio3,gpiohighspeed);
62 gpiosetspeed(&gpio4,gpiohighspeed);
63 59 gpiosetdir(&gpio1,gpiooutdir);
64 gpiosetdir(&gpio3,gpiooutdir);
65 60 gpiosetdir(&gpio2,gpiooutdir);
66 gpiosetdir(&gpio4,gpiooutdir);
67 61 }
68 62
69 63 void bsp_uart_init()
70 64 {
71 65 if(__opnfiles__[1]==NULL)
72 66 {
73 67 //uart_t* uart1 = (uart_t*)malloc(sizeof(uart_t));
74 68 streamdevice* fd1 = (streamdevice*)malloc(sizeof(streamdevice));
75 uart_t uart = uartopenandconfig(uart3,uartparitynone | uart8bits | uartonestop,115200,PB10,PB11,-1,-1);
69 uart_t uart = uartopenandconfig(uart3,uartparitynone | uart8bits | uartonestop,115200,LED2,LED1,-1,-1);
76 70 uartmkstreamdev(uart,fd1);
77 71 __opnfiles__[1] = fd1;
78 72 }
79 73 else
80 74 {
81 uartopenandconfig(2,uartparitynone | uart8bits | uartonestop,115200,PB10,PB11,-1,-1);
75 uartopenandconfig(uart3,uartparitynone | uart8bits | uartonestop,115200,LED2,LED1,-1,-1);
82 76 }
83 77 }
84 78
85 79 void bsp_spi_init()
86 80 {
87 81
88 82 }
89 83
90 84
91 85 void bsp_iic_init()
92 86 {
93 87
94 88 }
95 89
96 90 void bsp_SD_init()
97 91 {
98 92
99 93 }
100 94
101 95 void vs10XXclearXCS(){}
102 96 void vs10XXsetXCS(){}
103 97 int vs10XXDREQ()
104 98 {
105 99 return 1;
106 100 }
107 101
108 102
109 103 void bsppowersdcard(char onoff) //always ON
110 104 {
111 105
112 106 }
113 107
114 108 char bspsdcardpresent()
115 109 {
116 110 return 0;
117 111 }
118 112
119 113 char bspsdcardwriteprotected()
120 114 {
121 115 return 0;
122 116 }
123 117
124 118 void bspsdcardselect(char YESNO)
125 119 {
126 120
127 121 }
128 122
129 123
130 124
131 125
132 126
@@ -1,109 +1,109
1 1 #include <stdio.h>
2 2 #include <fat32.h>
3 3 #include <gpio.h>
4 4 #include <uart.h>
5 5 #include <stm32f4xx.h>
6 6 #include <math.h>
7 7 #include <bsp.h>
8 8 #include <i2c.h>
9 9 #include <CS43L22.h>
10 10 #include <ina226.h>
11 11 #include <fonts.h>
12 12 #include <stdlib.h>
13 13 #include <core.h>
14 14
15 15
16 16 extern streamdevice* __opnfiles__[];
17 17
18 18 #define LCD_COLOR_WHITE 0xFFFF
19 19 #define LCD_COLOR_BLACK 0x0000
20 20 #define LCD_COLOR_GREY 0xF7DE
21 21 #define LCD_COLOR_BLUE 0x001F
22 22 #define LCD_COLOR_BLUE2 0x051F
23 23 #define LCD_COLOR_RED 0xF800
24 24 #define LCD_COLOR_MAGENTA 0xF81F
25 25 #define LCD_COLOR_GREEN 0x07E0
26 26 #define LCD_COLOR_CYAN 0x7FFF
27 27 #define LCD_COLOR_YELLOW 0xFFE0
28 28
29 29
30 30 void monkDemo()
31 31 {
32 32 while(1)
33 33 {
34 34 lcd0.paintText(&lcd0," ",10,Monk_24.Height+10,&Monk_24,LCD_COLOR_BLACK);
35 35 lcd0.paintText(&lcd0," ",230-Monk_24.Width,310,&Monk_24,LCD_COLOR_BLUE);
36 36 for(volatile int i=0;i<(1024*1024*16);i++);
37 37 lcd0.paintFilRect(&lcd0,0,0,240,320,LCD_COLOR_WHITE,1,LCD_COLOR_WHITE);
38 38 for(volatile int i=0;i<(1024*1024*4);i++);
39 39 }
40 40 }
41 41
42 42
43 43 void randBoxesDemo()
44 44 {
45 45 int16_t x,y,w,h,t,r;
46 46 x=rand()%240;
47 47 y=rand()%320;
48 48 w=rand()%(240-x);
49 49 if(x>y)
50 50 r=(rand()%(y))%(320-y);
51 51 else
52 52 r=(rand()%(x))%(240-x);
53 53 h=rand()%(320-y);
54 54 t=rand()%(10);
55 55 ili9328paintFilRect(&lcd0,x,y,w,h,rand(),t,rand());
56 56 ili9328paintFilCirc(&lcd0,x,y,r,rand(),t,rand());
57 57 //delay_100us(10);
58 58 //for(volatile int i=0;i<(1024*2);i++);
59 59 }
60 60
61 61 int main()
62 62 {
63 63 INA226_t ina5VSens,ina33VSens,ina15VSens;
64 64 gpioset(PSU_DISABLE);
65 65 volatile int16_t* regtest=(volatile int16_t*)0x60000000;
66 66 volatile int16_t* regtest2=(volatile int16_t*)(0x61FFFFF0);
67 67 //ina226open(&ina5VSens,i2c2,INA226_MODE_SHUNT_VOLTAGE_CONTINUOUS|INA226_AVERAGES_16|INA226_BUS_CONV_8244us|INA226_SHUNT_CONV_8244us,0,0,15,1000000);
68 68 //ina226open(&ina15VSens,i2c2,INA226_MODE_SHUNT_VOLTAGE_CONTINUOUS|INA226_AVERAGES_16|INA226_BUS_CONV_8244us|INA226_SHUNT_CONV_8244us,1,0,15,1000000);
69 69 *regtest=(int16_t)0;
70 70 printf("LCD ID=%x\n\r",0xFFFF&(*regtest2));
71 71 printf("Sys Tick=%d\n\r",SysTick->VAL);
72 72 printf("Sys Tick=%d\n\r",SysTick->VAL);
73 73 printf("Sys Tick=%d\n\r",SysTick->VAL);
74 74 printf("Sys Tick=%d\n\r",SysTick->VAL);
75 75 ili9328paintFilRect(&lcd0,1,1,3,3,LCD_COLOR_BLACK,1,LCD_COLOR_WHITE);
76 while(1)randBoxesDemo();
76 while(1)monkDemo(); //randBoxesDemo();
77 77 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))
78 78 {
79 79 printf("Can't open 3.3V monitor\n\r");
80 80 }
81 81 int current5V,current33V,current15V;
82 82 printf("\t5V\t3.3V\n\r");
83 83 while(1)
84 84 {
85 85 for(volatile int i=0;i<1024*1024;i++);
86 86 gpioset(LED1);
87 87 gpioclr(LED2);
88 88 for(volatile int i=0;i<1024*1024;i++);
89 89 gpioclr(LED1);
90 90 gpioset(LED2);
91 91 //current5V = ina226getCurrent(&ina5VSens);
92 92 current33V = ina226getCurrent(&ina33VSens);
93 93 //current15V = ina226getCurrent(&ina15VSens);
94 94 //current = ina226getReg(&Psens1,INA226_Current_Reg);
95 95 //printf("%duA %dmA\t%duA %dmA\n\r",current5V,current5V/1000,current33V,current33V/1000);
96 96 printf("%duA %dmA\n\r",current33V,current33V/1000);
97 97 }
98 98 printf("hello world\n\r");
99 99 return 0;
100 100 }
101 101
102 102
103 103
104 104
105 105
106 106
107 107
108 108
109 109
@@ -1,12 +1,13
1 1 TEMPLATE = app
2 2 CONFIG += console
3 3 CONFIG -= qt
4 4
5 5 #BSP = BEAGLESYNTH
6 BSP = SOLAR_LFR_PSU
6 #BSP = SOLAR_LFR_PSU
7 BSP=M4Stick
7 8 include($$(libuc2)/bsp/cfg/$$BSP/bsp.pri)
8 9 #include($$(libuc2)/rules/stm32f4-arm-none-eabi-gcc/rules.pri)
9 10
10 11 SOURCES += \
11 12 main.c
12 13
@@ -1,45 +1,43
1 1 #include <stdio.h>
2 2 #include <fat32.h>
3 3 #include <gpio.h>
4 4 #include <uart.h>
5 5 #include <stm32f4xx.h>
6 6 #include <bsp.h>
7
7 #include <core.h>
8 8
9 9 extern streamdevice* __opnfiles__[];
10 10
11 11 int main()
12 12 {
13 //gpioset(PSU_DISABLE);
14 while(1)
13 while(1)
15 14 {
16 for(volatile int i=0;i<1024*2048;i++);
17 15 gpioset(LED1);
18 16 gpioclr(LED2);
19 for(volatile int i=0;i<1024*2048;i++);
20 17 gpioclr(LED1);
21 18 gpioset(LED2);
19 printf("Hello\n\r");
22 20 }
23 21 printf("hello world\n\r");
24 22 return 0;
25 23 }
26 24
27 25
28 26
29 27 void USART3_IRQHandler(void)
30 28 {
31 29 while(1)
32 30 {
33 31 for(volatile int i=0;i<1024*2048;i++);
34 32 gpioset(PD12);
35 33 gpioclr(PD14);
36 34 for(volatile int i=0;i<1024*2048;i++);
37 35 gpioclr(PD12);
38 36 gpioset(PD14);
39 37 }
40 38 }
41 39
42 40
43 41
44 42
45 43
@@ -1,60 +1,60
1 1 #include "stm32f4xx.h"
2 2 #include <stdint.h>
3 3 #include <stdlib.h>
4 4 #include <stdio.h>
5 5 #include <bsp.h>
6 6 #include <stm32f4xx_rcc.h>
7 7 #include <core.h>
8 8 extern int main();
9 9
10 10
11 11
12 12 void cpu_init()
13 13 {
14 14 extern uint32_t currentCpuFreq;
15 currentCpuFreq = 180*1000*1000;
15 currentCpuFreq = 16*1000*1000;
16 16 enable_FPU();
17 17 RCC->CR |= (uint32_t)0x00000001;
18 18 FLASH->ACR = FLASH_ACR_ICEN |FLASH_ACR_DCEN |FLASH_ACR_LATENCY_5WS;
19 19 reset_AHB1();
20 20 reset_AHB2();
21 21 reset_APB1();
22 22 reset_APB2();
23 23 RCC->CR |= (uint32_t)0x00000001;
24 24 FLASH->ACR = FLASH_ACR_ICEN |FLASH_ACR_DCEN |FLASH_ACR_LATENCY_5WS;
25 25 RCC->CFGR = 0x00000000;
26 26 RCC->CIR = 0x00000000;
27 27 SCB->VTOR = FLASH_BASE;
28 28 RCC->APB1ENR |= RCC_APB1ENR_PWREN;
29 29 PWR->CR |= PWR_CR_PMODE;
30 30 currentCpuFreq=setCpuFreq(currentCpuFreq);
31 31 currentCpuFreq=getCpuFreq();
32 32 configureSysTick();
33 33 bsp_init();
34 34 printf("SysTick Configured to reach 100us period\n\r");
35 35 RCC_ClocksTypeDef RCC_ClocksStatus;
36 36 RCC_GetClocksFreq(&RCC_ClocksStatus);
37 37 printf("PLL Configured got:\n\r SYS=%uHz\n\r CPU=%uHz\n\r APB1=%uHz\n\r APB2=%uHz\n\r",(unsigned int)RCC_ClocksStatus.SYSCLK_Frequency,(unsigned int)RCC_ClocksStatus.HCLK_Frequency,(unsigned int)RCC_ClocksStatus.PCLK1_Frequency,(unsigned int)RCC_ClocksStatus.PCLK2_Frequency);
38 38 printf("Enter Main\n\r");
39 39 int res=main();
40 40 printf("\n\rprogram exited with code ");
41 41 printf("%u",res);
42 42 printf("\n\r");
43 43 while(1)
44 44 {
45 45 for(volatile int i=0;i<1024*64;i++);
46 46 gpioset(PD14);
47 47 for(volatile int i=0;i<1024*64;i++);
48 48 gpioclr(PD14);
49 49 }
50 50 }
51 51
52 52
53 53
54 54
55 55
56 56
57 57
58 58
59 59
60 60
General Comments 0
You need to be logged in to leave comments. Login now