##// END OF EJS Templates
Changed entry point from main to libuc_main, added hello world example.
jeandet -
r78:230ad3b6f43f dev_alexis
parent child
Show More
@@ -0,0 +1,16
1 UCMODEL=simulator
2
3 TEMPLATE = app
4
5 BSP = SIMULATOR
6
7
8 SOURCES += \
9 main.c
10
11
12
13
14
15
16
@@ -0,0 +1,47
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 alexis.jeandet@member.fsf.org
20 -------------------------------------------------------------------------------*/
21 /**
22 * This file is a simple hello world example it should run on any supported
23 * board/architecture couple. To change target board and architecture modify
24 * the project file. The value BSP contains the board name, and UCMODEL contain
25 * the target architecture.
26 */
27 #include <stdio.h>
28
29
30 int libuc_main()
31 {
32 /**
33 Depending on the board the printf can be directed on one uart or LCD screen or
34 any other stream device.
35 */
36 printf("hello world\n\r");
37 return 0;
38 }
39
40
41
42
43
44
45
46
47
@@ -58,7 +58,7 void randBoxesDemo()
58 //for(volatile int i=0;i<(1024*2);i++);
58 //for(volatile int i=0;i<(1024*2);i++);
59 }
59 }
60
60
61 int main()
61 int libuc_main()
62 {
62 {
63 INA226_t ina5VSens,ina33VSens,ina15VSens;
63 INA226_t ina5VSens,ina33VSens,ina15VSens;
64 gpioset(PSU_DISABLE);
64 gpioset(PSU_DISABLE);
@@ -73,7 +73,7 void printSupplyStatus(int cur5v,int cur
73
73
74 }
74 }
75
75
76 int main()
76 int libuc_main()
77 {
77 {
78 delay_100us(20000);
78 delay_100us(20000);
79 INA226_t ina5VSens,ina33VSens,ina15VSens;
79 INA226_t ina5VSens,ina33VSens,ina15VSens;
@@ -75,7 +75,7 void sample()
75 }
75 }
76 }
76 }
77
77
78 int main()
78 int libuc_main()
79 {
79 {
80 int32_t data[8];
80 int32_t data[8];
81 char test=0;
81 char test=0;
@@ -34,7 +34,7 void resetHold(int rhstate)
34 gpiosetval(PC2,rhstate);
34 gpiosetval(PC2,rhstate);
35 }
35 }
36
36
37 int main()
37 int libuc_main()
38 {
38 {
39 spiopenandconfig(spi2,spiclkfirstedge|spimaster|spimsbfirst|spi8bits,10000,PB15,PB14,PB13,-1);
39 spiopenandconfig(spi2,spiclkfirstedge|spimaster|spimsbfirst|spi8bits,10000,PB15,PB14,PB13,-1);
40 //spiopenandconfig(spi2,spiclkfirstedge|spimaster|spimsbfirst|spi8bits,10000,PB15,PB14,PB13,PB12);
40 //spiopenandconfig(spi2,spiclkfirstedge|spimaster|spimsbfirst|spi8bits,10000,PB15,PB14,PB13,PB12);
@@ -2,7 +2,7
2 #include <fat32.h>
2 #include <fat32.h>
3 #include <gpio.h>
3 #include <gpio.h>
4
4
5 int main()
5 int libuc_main()
6 {
6 {
7 gpio_t gpio1 = gpioopen(PD12);//gpioopen(LED1); //PD9 D=> 0x0300 9 => 0x0009
7 gpio_t gpio1 = gpioopen(PD12);//gpioopen(LED1); //PD9 D=> 0x0300 9 => 0x0009
8 gpio_t gpio2 = gpioopen(PD13);//gpioopen(LED2);
8 gpio_t gpio2 = gpioopen(PD13);//gpioopen(LED2);
@@ -7,7 +7,7
7 #include <sdcard.h>
7 #include <sdcard.h>
8
8
9
9
10 int main()
10 int libuc_main()
11 {
11 {
12 blkdevice dev;
12 blkdevice dev;
13 dikpartition part;
13 dikpartition part;
@@ -207,7 +207,7 int main1()
207 while(1);
207 while(1);
208 }
208 }
209
209
210 int main()
210 int libuc_main()
211 {
211 {
212 extern terminal_t terminal0;
212 extern terminal_t terminal0;
213 extern volatile vs10XXDev audioCodec0;
213 extern volatile vs10XXDev audioCodec0;
@@ -1,7 +1,7
1 #include <stdio.h>
1 #include <stdio.h>
2
2
3
3
4 int main()
4 int libuc_main()
5 {
5 {
6 printf("Hello world from project 'STM32F4IT'!\n");
6 printf("Hello world from project 'STM32F4IT'!\n");
7 return 0;
7 return 0;
@@ -54,7 +54,7 float32_t Ak[MAX_BLOCKSIZE*2];
54 extern streamdevice* __opnfiles__[__MAX_OPENED_FILES__];
54 extern streamdevice* __opnfiles__[__MAX_OPENED_FILES__];
55
55
56
56
57 int main()
57 int libuc_main()
58 {
58 {
59
59
60 arm_status status; /* Status of the example */
60 arm_status status; /* Status of the example */
@@ -20,7 +20,8 CONFIG += ordered
20 }
20 }
21 contains( UCMODEL, simulator ){
21 contains( UCMODEL, simulator ){
22 SUBDIRS += \
22 SUBDIRS += \
23 TEST_SIMULATOR
23 TEST_SIMULATOR \
24 helloWorld
24 }
25 }
25 }
26 }
26
27
@@ -59,7 +59,7 void randBoxesDemo()
59 ili9328paintFilCirc(&lcd0,x,y,r,rand(),t,rand());
59 ili9328paintFilCirc(&lcd0,x,y,r,rand(),t,rand());
60 }
60 }
61
61
62 int main()
62 int libuc_main()
63 {
63 {
64 uint16_t innerbuffer[16];
64 uint16_t innerbuffer[16];
65 uint16_t outterbuffer[16];
65 uint16_t outterbuffer[16];
@@ -85,7 +85,7 int _terminal_writenc(terminal_t* termin
85 return n;
85 return n;
86 }
86 }
87
87
88 int main()
88 int libuc_main()
89 {
89 {
90 delay_100us(10000);
90 delay_100us(10000);
91 uint16_t innerbuffer[16];
91 uint16_t innerbuffer[16];
@@ -7,7 +7,7
7 extern LCD_t lcd0;
7 extern LCD_t lcd0;
8 extern void ssd2119paintFilCirc_old(LCD_t* LCD,uint16_t Xpos,uint16_t Ypos,uint16_t r,uint32_t contColor,uint16_t contSz,uint32_t fillColor);
8 extern void ssd2119paintFilCirc_old(LCD_t* LCD,uint16_t Xpos,uint16_t Ypos,uint16_t r,uint32_t contColor,uint16_t contSz,uint32_t fillColor);
9
9
10 int main(void)
10 int libuc_main()
11 {
11 {
12 printf("Hello World!\n\r");
12 printf("Hello World!\n\r");
13 printf("SSD2119 Device Code = 0x%x\n\r",lcd0.interface->readreg(SSD2119_REGISTER_DEVICE_CODE_READ));
13 printf("SSD2119 Device Code = 0x%x\n\r",lcd0.interface->readreg(SSD2119_REGISTER_DEVICE_CODE_READ));
@@ -72,53 +72,8 typedef enum
72
72
73 #define ADCCONVMODEMASK 0x10
73 #define ADCCONVMODEMASK 0x10
74
74
75 typedef enum
76 {
77 spiclkinhlow = 0x00,
78 spiclkinhhigh = 0x20
79 }spiclkinhlvl_t;
80
81 #define SPICLKINHLVLMASK 0x20
82
75
83
76
84 typedef enum
85 {
86 spiclkfirstedge = 0x00,
87 spiclksecondedge = 0x40
88 }spiclkphase_t;
89
90 #define SPICLKPHASEMASK 0x40
91
92 typedef enum
93 {
94 spimsbfirst = 0x00,
95 spilsbfirst = 0x80
96 }spibitorder_t;
97
98 #define SPIBITORDERMASK 0x80
99
100
101 extern int spiopen(int count,spi_t* spidev);
102 extern int spiopenandconfig(int count,spi_t* spidev,uint32_t cfg,uint32_t speed,uint32_t MOSIpin,uint32_t MISOpin,uint32_t SCKpin,uint32_t SCSpin);
103 extern int spiclose(spi_t* spidev);
104 extern int spisetpins(spi_t* spidev,uint32_t MOSIpin,uint32_t MISOpin,uint32_t SCKpin,uint32_t SCSpin);
105 extern int spienable(spi_t* spidev);
106 extern int spidisable(spi_t* spidev);
107 extern int spisetconfig(spi_t* spidev);
108 extern int spisetspeed(spi_t* spidev, uint32_t speed);
109 extern int spisetbitorder(spi_t* spidev,spibitorder_t order);
110 extern int spisetdatabits(spi_t* spidev,spibits_t bitscnt);
111 extern int spisetclkinhlevel(spi_t* spidev,spiclkinhlvl_t level);
112 extern int spisetclkphase(spi_t* spidev,spiclkphase_t phase);
113 extern int spiputw(spi_t* spidev,uint16_t data);
114 extern uint16_t spigetw(spi_t* spidev);
115 extern int spiputs(spi_t* spidev,char* s);
116 extern int spigets(spi_t* spidev,char* s);
117 extern int spiputnw(spi_t* spidev,uint16_t* w,int n);
118 extern int spigetnw(spi_t* spidev,uint16_t* w,int n);
119 extern int spiputnc(spi_t* spidev,char* c,int n);
120 extern int spigetnc(spi_t* spidev,char* c,int n);
121 extern int spiavailiabledata(spi_t* spidev);
122
77
123 #ifdef __cplusplus
78 #ifdef __cplusplus
124 }
79 }
@@ -1,4 +1,4
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) 2012, Alexis Jeandet
3 -- Copyright (C) 2012, Alexis Jeandet
4 --
4 --
@@ -15,9 +15,8
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 alexis.jeandet@member.fsf.org
20 -- @Mail : alexis.jeandet@gmail.com
21 -------------------------------------------------------------------------------*/
20 -------------------------------------------------------------------------------*/
22
21
23 /*! \file gpio.h
22 /*! \file gpio.h
@@ -205,6 +204,8 extern void gpiosetval(gpio_t gpio,int v
205 */
204 */
206 extern int gpiogetval(gpio_t gpio);
205 extern int gpiogetval(gpio_t gpio);
207
206
207 #ifndef DOXYGEN_SHOULD_SKIP_THIS
208
208 #define GPIOISINPUT(gpio) (((gpio) & GPIODIRMASK)==gpioindir)
209 #define GPIOISINPUT(gpio) (((gpio) & GPIODIRMASK)==gpioindir)
209 #define GPIOISOUTPUT(gpio) (((gpio) & GPIOSPEEDMASK)==gpiooutdir)
210 #define GPIOISOUTPUT(gpio) (((gpio) & GPIOSPEEDMASK)==gpiooutdir)
210
211
@@ -220,7 +221,6 extern int gpiogetval(gpio_t gpio);
220 #define GPIOISPULLUP(GPIO) (((gpio) & GPIOPULLTYPEMASK)==gpiopulluptype)
221 #define GPIOISPULLUP(GPIO) (((gpio) & GPIOPULLTYPEMASK)==gpiopulluptype)
221 #define GPIOISPULLDOWN(GPIO) (((gpio) & GPIOPULLTYPEMASK)==gpiopulldowntype)
222 #define GPIOISPULLDOWN(GPIO) (((gpio) & GPIOPULLTYPEMASK)==gpiopulldowntype)
222
223
223 #ifndef DOXYGEN_SHOULD_SKIP_THIS
224
224
225 #define PA0 ((0<<8)+0)
225 #define PA0 ((0<<8)+0)
226 #define PA1 ((0<<8)+1)
226 #define PA1 ((0<<8)+1)
@@ -23,7 +23,6
23 #define INA226_H
23 #define INA226_H
24
24
25 #include <i2c.h>
25 #include <i2c.h>
26 //#include <uhandle.h>
27
26
28 typedef struct INA226_t
27 typedef struct INA226_t
29 {
28 {
@@ -27,7 +27,7
27 extern "C" {
27 extern "C" {
28 #endif
28 #endif
29
29
30 /*
30 /*!
31 This structure holds the thread context. To do so, you need to keep a track of the programm counter,
31 This structure holds the thread context. To do so, you need to keep a track of the programm counter,
32 to change the stack pointer for each thread and to save all registers needing to be saved. Since the
32 to change the stack pointer for each thread and to save all registers needing to be saved. Since the
33 number of regiter to be saved vary from one processor to an other, it's easier to save them in the
33 number of regiter to be saved vary from one processor to an other, it's easier to save them in the
@@ -1,15 +1,14
1 #include "stm32f4xx.h"
1 #include "stm32f4xx.h"
2 #include <stdint.h>
3 #include <stdlib.h>
2 #include <stdlib.h>
4 #include <stdio.h>
3 #include <stdio.h>
5 #include <bsp.h>
4 #include <bsp.h>
6 #include <stm32f4xx_rcc.h>
5 #include <stm32f4xx_rcc.h>
7 #include <core.h>
6 #include <core.h>
8 extern int main();
7 extern int libuc_main();
9
8
10
9
11
10
12 void cpu_init()
11 void main()
13 {
12 {
14 extern uint32_t currentCpuFreq;
13 extern uint32_t currentCpuFreq;
15 #ifndef CPUFREQ
14 #ifndef CPUFREQ
@@ -37,9 +36,13 void cpu_init()
37 printf("SysTick Configured to reach 100us period\n\r");
36 printf("SysTick Configured to reach 100us period\n\r");
38 RCC_ClocksTypeDef RCC_ClocksStatus;
37 RCC_ClocksTypeDef RCC_ClocksStatus;
39 RCC_GetClocksFreq(&RCC_ClocksStatus);
38 RCC_GetClocksFreq(&RCC_ClocksStatus);
40 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);
39 printf("PLL Configured got:\n\r SYS=%uHz\n\r CPU=%uHz\n\r APB1=%uHz\n\r APB2=%uHz\n\r",
40 (unsigned int)RCC_ClocksStatus.SYSCLK_Frequency,
41 (unsigned int)RCC_ClocksStatus.HCLK_Frequency,
42 (unsigned int)RCC_ClocksStatus.PCLK1_Frequency,
43 (unsigned int)RCC_ClocksStatus.PCLK2_Frequency);
41 printf("Enter Main\n\r");
44 printf("Enter Main\n\r");
42 int res=main();
45 int res=libuc_main();
43 printf("\n\rprogram exited with code ");
46 printf("\n\rprogram exited with code ");
44 printf("%u",res);
47 printf("%u",res);
45 printf("\n\r");
48 printf("\n\r");
@@ -55,7 +55,7 LoopFillZerobss:
55 cmp r2, r3
55 cmp r2, r3
56 bcc FillZerobss
56 bcc FillZerobss
57
57
58 bl cpu_init
58 bl main
59 bx lr
59 bx lr
60 .size Reset_Handler, .-Reset_Handler
60 .size Reset_Handler, .-Reset_Handler
61
61
@@ -34,10 +34,12 ENTRY(Reset_Handler)
34
34
35 /* Highest address of the user mode stack */
35 /* Highest address of the user mode stack */
36 _estack = 0x20020000; /* end of 128K RAM on AHB bus*/
36 _estack = 0x20020000; /* end of 128K RAM on AHB bus*/
37 _eMainStack = 0x1002000; /* end of 64K CCMRAM on AHB bus*/
37
38
38 /* Generate a link error if heap and stack don't fit into RAM */
39 /* Generate a link error if heap and stack don't fit into RAM */
39 _Min_Heap_Size = 0x2000; /* required amount of heap */
40 _Min_Heap_Size = 0x2000; /* required amount of heap */
40 _Min_Stack_Size = 0x2000; /* required amount of stack */
41 _Min_Stack_Size = 0x2000; /* required amount of stack */
42 _Min_MainStack_Size = 0x2000; /* required amount of stack 0x2000=8kB*/
41
43
42 /* Specify the memory areas */
44 /* Specify the memory areas */
43 MEMORY
45 MEMORY
@@ -149,6 +151,7 SECTIONS
149 . = ALIGN(4);
151 . = ALIGN(4);
150 } >RAM
152 } >RAM
151
153
154
152 /* MEMORY_bank1 section, code must be located here explicitly */
155 /* MEMORY_bank1 section, code must be located here explicitly */
153 /* Example: extern int foo(void) __attribute__ ((section (".mb1text"))); */
156 /* Example: extern int foo(void) __attribute__ ((section (".mb1text"))); */
154 .memory_b1_text :
157 .memory_b1_text :
@@ -22,7 +22,6
22 #include <CS43L22.h>
22 #include <CS43L22.h>
23 #include <stdio.h>
23 #include <stdio.h>
24 #include <stddef.h>
24 #include <stddef.h>
25 #include <spi.h>
26
25
27 int cs43l22open(CS43L22_t* dev,i2c_t i2cdev, uint8_t A0)
26 int cs43l22open(CS43L22_t* dev,i2c_t i2cdev, uint8_t A0)
28 {
27 {
@@ -19,11 +19,9
19 #-- Author : Alexis Jeandet
19 #-- Author : Alexis Jeandet
20 #-- Mail : alexis.jeandet@member.fsf.org
20 #-- Mail : alexis.jeandet@member.fsf.org
21 #-------------------------------------------------------------------------------*/
21 #-------------------------------------------------------------------------------*/
22 #include <spi.h>
23 #include <VS10XX.h>
22 #include <VS10XX.h>
24 #include <core.h>
23 #include <core.h>
25 #include <stdio.h>
24 #include <stdio.h>
26 //#include <bsp.h>
27
25
28 void vs10XXopen(vs10XXDev *codec, spi_t dev, void (*setxCS)(char), void (*setxRST)(char), void (*setxDCS)(char), int (*getDREQ)())
26 void vs10XXopen(vs10XXDev *codec, spi_t dev, void (*setxCS)(char), void (*setxRST)(char), void (*setxDCS)(char), int (*getDREQ)())
29 {
27 {
@@ -20,7 +20,6
20 -- Mail : alexis.jeandet@member.fsf.org
20 -- Mail : alexis.jeandet@member.fsf.org
21 -------------------------------------------------------------------------------*/
21 -------------------------------------------------------------------------------*/
22 #include <24LC0X.h>
22 #include <24LC0X.h>
23 #include <i2c.h>
24 #include <core.h>
23 #include <core.h>
25 /*
24 /*
26 struct 24LC0X_str
25 struct 24LC0X_str
@@ -22,8 +22,6
22 #define FAT32_PRIVATE
22 #define FAT32_PRIVATE
23 #include <fat32.h>
23 #include <fat32.h>
24 #include <stdio.h>
24 #include <stdio.h>
25 #include <stdint.h>
26 #include <hexviewer.h>
27
25
28 char fat32buff[512];
26 char fat32buff[512];
29 uint32_t lastSecAddrs=-1;
27 uint32_t lastSecAddrs=-1;
@@ -25,7 +25,6
25 #include <stddef.h>
25 #include <stddef.h>
26 #include <core.h>
26 #include <core.h>
27 #include <math.h>
27 #include <math.h>
28 #include <stdint.h>
29 #include <malloc.h>
28 #include <malloc.h>
30
29
31 #ifdef __OPTIMIZED_MATH
30 #ifdef __OPTIMIZED_MATH
@@ -19,11 +19,8
19 -- Author : Alexis Jeandet
19 -- Author : Alexis Jeandet
20 -- Mail : alexis.jeandet@member.fsf.org
20 -- Mail : alexis.jeandet@member.fsf.org
21 -------------------------------------------------------------------------------*/
21 -------------------------------------------------------------------------------*/
22 #include <widget.h>
23 #include <terminal.h>
22 #include <terminal.h>
24 #include <stdint.h>
25 #include <stdio.h>
23 #include <stdio.h>
26 #include <gpio.h>
27 #include <core.h>
24 #include <core.h>
28 #include <malloc.h>
25 #include <malloc.h>
29
26
@@ -2,7 +2,7 TEMPLATE = lib
2 CONFIG += libuc2lib
2 CONFIG += libuc2lib
3 OBJECTS_DIR = obj
3 OBJECTS_DIR = obj
4
4
5 TARGET=Threading
5 TARGET=threading
6 SOURCES += thread.c
6 SOURCES += thread.c
7
7
8
8
@@ -30,7 +30,7
30 struct thread_t* prev;
30 struct thread_t* prev;
31 struct thread_t* next;
31 struct thread_t* next;
32 */
32 */
33 thread_t mainThread;
33 extern thread_t mainThread;
34
34
35 int threadcreate(thread_t *thread, void *stack, int stackSize, int (*entry)(void*))
35 int threadcreate(thread_t *thread, void *stack, int stackSize, int (*entry)(void*))
36 {
36 {
@@ -21,7 +21,6
21 -------------------------------------------------------------------------------*/
21 -------------------------------------------------------------------------------*/
22 #include <core.h>
22 #include <core.h>
23 #include <stm32f4xx_rcc.h>
23 #include <stm32f4xx_rcc.h>
24 #include <stdint.h>
25 #include <stdlib.h>
24 #include <stdlib.h>
26 #include <stdio.h>
25 #include <stdio.h>
27 #include <core_cm4.h>
26 #include <core_cm4.h>
@@ -50,6 +50,13
50 S16 to S31
50 S16 to S31
51 */
51 */
52
52
53 #ifndef __mainThreadStackSize__
54 #define __mainThreadStackSize__ (8*1024)
55 #endif
56
57 char __mainThreadStack__[__mainThreadStackSize__]__attribute__ ((aligned (4)));
58 thread_t mainThread;
59
53
60
54 void __cpusavecontext(void* dataspace)
61 void __cpusavecontext(void* dataspace)
55 {
62 {
@@ -63,15 +70,14 void __cpurestorecontext(void* dataspace
63
70
64 void __initThreading()
71 void __initThreading()
65 {
72 {
66 extern int main();
73 extern int libuc_main();
67 extern thread_t mainThread;
74 thread_t mainThread;
68 mainThread.func=main;
75 mainThread.func=libuc_main;
69 mainThread.next=NULL;
76 mainThread.next=NULL;
70 mainThread.prev=NULL;
77 mainThread.prev=NULL;
71 mainThread.priority=0;
78 mainThread.priority=0;
72 /*The main stack address is given on address 0*/
79 mainThread.__stack__=(void*)__mainThreadStack__;
73 mainThread.__stack__=*((int*)0);
80 mainThread.stackSize=__mainThreadStackSize__;
74 mainThread.stackSize=0;
75 }
81 }
76
82
77
83
@@ -1,15 +1,14
1 #include "stm32f4xx.h"
1 #include "stm32f4xx.h"
2 #include <stdint.h>
3 #include <stdlib.h>
2 #include <stdlib.h>
4 #include <stdio.h>
3 #include <stdio.h>
5 #include <bsp.h>
4 #include <bsp.h>
6 #include <stm32f4xx_rcc.h>
5 #include <stm32f4xx_rcc.h>
7 #include <core.h>
6 #include <core.h>
8 extern int main();
7 extern int libuc_main();
9
8
10
9
11
10
12 void cpu_init()
11 void main()
13 {
12 {
14 extern uint32_t currentCpuFreq;
13 extern uint32_t currentCpuFreq;
15 #ifndef CPUFREQ
14 #ifndef CPUFREQ
@@ -37,9 +36,13 void cpu_init()
37 printf("SysTick Configured to reach 100us period\n\r");
36 printf("SysTick Configured to reach 100us period\n\r");
38 RCC_ClocksTypeDef RCC_ClocksStatus;
37 RCC_ClocksTypeDef RCC_ClocksStatus;
39 RCC_GetClocksFreq(&RCC_ClocksStatus);
38 RCC_GetClocksFreq(&RCC_ClocksStatus);
40 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);
39 printf("PLL Configured got:\n\r SYS=%uHz\n\r CPU=%uHz\n\r APB1=%uHz\n\r APB2=%uHz\n\r",
40 (unsigned int)RCC_ClocksStatus.SYSCLK_Frequency,
41 (unsigned int)RCC_ClocksStatus.HCLK_Frequency,
42 (unsigned int)RCC_ClocksStatus.PCLK1_Frequency,
43 (unsigned int)RCC_ClocksStatus.PCLK2_Frequency);
41 printf("Enter Main\n\r");
44 printf("Enter Main\n\r");
42 int res=main();
45 int res=libuc_main();
43 printf("\n\rprogram exited with code ");
46 printf("\n\rprogram exited with code ");
44 printf("%u",res);
47 printf("%u",res);
45 printf("\n\r");
48 printf("\n\r");
@@ -55,7 +55,7 LoopFillZerobss:
55 cmp r2, r3
55 cmp r2, r3
56 bcc FillZerobss
56 bcc FillZerobss
57
57
58 bl cpu_init
58 bl main
59 bx lr
59 bx lr
60 .size Reset_Handler, .-Reset_Handler
60 .size Reset_Handler, .-Reset_Handler
61
61
@@ -34,10 +34,12 ENTRY(Reset_Handler)
34
34
35 /* Highest address of the user mode stack */
35 /* Highest address of the user mode stack */
36 _estack = 0x20020000; /* end of 128K RAM on AHB bus*/
36 _estack = 0x20020000; /* end of 128K RAM on AHB bus*/
37 _eMainStack = 0x1002000; /* end of 64K CCMRAM on AHB bus*/
37
38
38 /* Generate a link error if heap and stack don't fit into RAM */
39 /* Generate a link error if heap and stack don't fit into RAM */
39 _Min_Heap_Size = 0x2000; /* required amount of heap */
40 _Min_Heap_Size = 0x2000; /* required amount of heap */
40 _Min_Stack_Size = 0x2000; /* required amount of stack */
41 _Min_Stack_Size = 0x2000; /* required amount of stack */
42 _Min_MainStack_Size = 0x2000; /* required amount of stack 0x2000=8kB*/
41
43
42 /* Specify the memory areas */
44 /* Specify the memory areas */
43 MEMORY
45 MEMORY
@@ -149,6 +151,7 SECTIONS
149 . = ALIGN(4);
151 . = ALIGN(4);
150 } >RAM
152 } >RAM
151
153
154
152 /* MEMORY_bank1 section, code must be located here explicitly */
155 /* MEMORY_bank1 section, code must be located here explicitly */
153 /* Example: extern int foo(void) __attribute__ ((section (".mb1text"))); */
156 /* Example: extern int foo(void) __attribute__ ((section (".mb1text"))); */
154 .memory_b1_text :
157 .memory_b1_text :
@@ -20,14 +20,11
20 -- Mail : alexis.jeandet@member.fsf.org
20 -- Mail : alexis.jeandet@member.fsf.org
21 -------------------------------------------------------------------------------*/
21 -------------------------------------------------------------------------------*/
22
22
23 #include <i2c.h>
24 #include <stm32f4xx_usart.h>
25 #include <stm32f4xx_rcc.h>
23 #include <stm32f4xx_rcc.h>
26 #include <stm32f4xx_gpio.h>
24 #include <stm32f4xx_gpio.h>
27 #include <stm32f4xx_sdio.h>
25 #include <stm32f4xx_sdio.h>
28 #include <gpio.h>
26 #include <gpio.h>
29 #include <core.h>
27 #include <core.h>
30 #include <sdcard.h>
31 #include <sdcard-sdio.h>
28 #include <sdcard-sdio.h>
32
29
33 void sdcardsdiomake(sdcardDev* sdcard,UHANDLE phy,void (*rcvr_mmc) (UHANDLE,char *,uint32_t ),void (*xmit_mmc) (UHANDLE,const char *,uint32_t ),void (*setspeed) (UHANDLE phy,uint32_t speed),uint32_t (*getspeed) (UHANDLE phy))
30 void sdcardsdiomake(sdcardDev* sdcard,UHANDLE phy,void (*rcvr_mmc) (UHANDLE,char *,uint32_t ),void (*xmit_mmc) (UHANDLE,const char *,uint32_t ),void (*setspeed) (UHANDLE phy,uint32_t speed),uint32_t (*getspeed) (UHANDLE phy))
@@ -21,7 +21,6
21 -------------------------------------------------------------------------------*/
21 -------------------------------------------------------------------------------*/
22
22
23 #include <uart.h>
23 #include <uart.h>
24 #include <stm32f4xx_usart.h>
25 #include <stm32f4xx_rcc.h>
24 #include <stm32f4xx_rcc.h>
26 #include <stm32f4xx_gpio.h>
25 #include <stm32f4xx_gpio.h>
27 #include <gpio.h>
26 #include <gpio.h>
General Comments 0
You need to be logged in to leave comments. Login now