@@ -0,0 +1,33 | |||||
|
1 | #ifndef DAC_LIB_H | |||
|
2 | #define DAC_LIB_H | |||
|
3 | ||||
|
4 | #define DAC1_12bit_right_align 0x40007408 | |||
|
5 | #define DAC1_12bit_left_align 0x4000740C | |||
|
6 | #define DAC1_8bit_right_align 0x40007410 | |||
|
7 | #define DAC2_12bit_right_align 0x40007414 | |||
|
8 | #define DAC2_12bit_left_align 0x40007418 | |||
|
9 | #define DAC2_8bit_right_align 0x4000741C | |||
|
10 | #define DAC_Dual_12bit_right_align 0x40007420 | |||
|
11 | #define DAC_Dual_12bit_left_align 0x40007424 | |||
|
12 | #define DAC_Dual_8bit_right_align 0x40007428 | |||
|
13 | #define DAC_Dual_8bit_left_align 0x4000742C | |||
|
14 | ||||
|
15 | #define DAC1 0 | |||
|
16 | #define DAC2 1 | |||
|
17 | ||||
|
18 | #define timer2 1 | |||
|
19 | #define timer3 2 | |||
|
20 | #define timer4 3 | |||
|
21 | #define timer5 4 | |||
|
22 | #define timer6 5 | |||
|
23 | #define timer7 6 | |||
|
24 | #define timer8 7 | |||
|
25 | ||||
|
26 | ||||
|
27 | extern int dacopen(uint32_t pin); | |||
|
28 | extern int dacsetconfig(int timer, int buffer_size, int dac,uint32_t dac_type, uint32_t freq,uint32_t data); | |||
|
29 | ||||
|
30 | ||||
|
31 | ||||
|
32 | ||||
|
33 | #endif // DAC_LIB_H |
@@ -0,0 +1,127 | |||||
|
1 | #include <stdio.h> | |||
|
2 | //#include <bsp.h> | |||
|
3 | #include <stm32f4xx_rcc.h> | |||
|
4 | #include <stm32f4xx_tim.h> | |||
|
5 | #include <stm32f4xx_dac.h> | |||
|
6 | #include <stm32f4xx_gpio.h> | |||
|
7 | #include <stm32f4xx_dma.h> | |||
|
8 | #include <stm32f4xx.h> | |||
|
9 | #include <gpio.h> | |||
|
10 | #include <stm32f4xx.h> | |||
|
11 | ||||
|
12 | ||||
|
13 | #define DAC_DHR12R2_ADDRESS 0x40007414 | |||
|
14 | #define DAC_DHR8R1_ADDRESS 0x40007410 | |||
|
15 | ||||
|
16 | #define DAC1_12bit_right_align 0x40007408 | |||
|
17 | #define DAC1_12bit_left_align 0x4000740C | |||
|
18 | #define DAC1_8bit_right_align 0x40007410 | |||
|
19 | #define DAC2_12bit_right_align 0x40007414 | |||
|
20 | #define DAC2_12bit_left_align 0x40007418 | |||
|
21 | #define DAC2_8bit_right_align 0x4000741C | |||
|
22 | #define DAC_Dual_12bit_right_align 0x40007420 | |||
|
23 | #define DAC_Dual_12bit_left_align 0x40007424 | |||
|
24 | #define DAC_Dual_8bit_right_align 0x40007428 | |||
|
25 | #define DAC_Dual_8bit_left_align 0x4000742C | |||
|
26 | ||||
|
27 | ||||
|
28 | ||||
|
29 | const TIM_TypeDef* _timer_dev_table[14]={TIM1,TIM2,TIM3,TIM4,TIM5,TIM6,TIM7, | |||
|
30 | TIM8,TIM9,TIM10,TIM11,TIM12,TIM13,TIM14}; | |||
|
31 | #define DAC1 0 | |||
|
32 | #define DAC2 1 | |||
|
33 | ||||
|
34 | #define timer2 1 | |||
|
35 | #define timer3 2 | |||
|
36 | #define timer4 3 | |||
|
37 | #define timer5 4 | |||
|
38 | #define timer6 5 | |||
|
39 | #define timer7 6 | |||
|
40 | #define timer8 7 | |||
|
41 | ||||
|
42 | DAC_InitTypeDef DAC_InitStructure; | |||
|
43 | ||||
|
44 | int dacopen(uint32_t pin) | |||
|
45 | { | |||
|
46 | #define GPIOGETPORT(gpio) ((GPIO_TypeDef*)(((((uint32_t)gpio) & (uint32_t)0x0000FF00)*(uint32_t)4) + (uint32_t)GPIOA)) | |||
|
47 | #define GPIOPORTNUM(gpio) (((uint32_t)(gpio) & (uint32_t)0x0000FF00)>>(uint32_t)8) | |||
|
48 | RCC_AHB1PeriphClockCmd(RCC_AHB1Periph_DMA1 , ENABLE); | |||
|
49 | RCC_APB1PeriphClockCmd(RCC_APB1Periph_DAC, ENABLE); | |||
|
50 | gpio_t DACOUT; | |||
|
51 | DACOUT = gpioopen(pin); | |||
|
52 | DACOUT |= gpioan | gpionopulltype; | |||
|
53 | gpiosetconfig(&DACOUT); | |||
|
54 | return 0; | |||
|
55 | } | |||
|
56 | ||||
|
57 | int dacsetconfig(int timer, int buffer_size, int dac,uint32_t dac_type, uint32_t freq,uint32_t data) | |||
|
58 | { | |||
|
59 | TIM_TypeDef* tim = _timer_dev_table[timer]; | |||
|
60 | TIM_TimeBaseInitTypeDef TIM_TimeBaseStructure; | |||
|
61 | if(timer>=timer2 && timer <= timer7)RCC_APB1PeriphClockCmd((1<<(timer-1)), ENABLE); | |||
|
62 | if(timer==timer8)RCC_APB2PeriphClockCmd(RCC_APB2Periph_TIM8, ENABLE); | |||
|
63 | uint32_t timfreq = (81300)*buffer_size/(freq); | |||
|
64 | TIM_TimeBaseStructInit(&TIM_TimeBaseStructure); | |||
|
65 | TIM_TimeBaseStructure.TIM_Period = timfreq; | |||
|
66 | TIM_TimeBaseStructure.TIM_Prescaler = 0; | |||
|
67 | TIM_TimeBaseStructure.TIM_ClockDivision = 0; | |||
|
68 | TIM_TimeBaseStructure.TIM_CounterMode = TIM_CounterMode_Up; | |||
|
69 | TIM_TimeBaseInit(tim, &TIM_TimeBaseStructure); | |||
|
70 | TIM_SelectOutputTrigger(tim, TIM_TRGOSource_Update); | |||
|
71 | TIM_Cmd(tim, ENABLE); | |||
|
72 | ||||
|
73 | DMA_InitTypeDef DMA_InitStructure; | |||
|
74 | if (timer == timer2)DAC_InitStructure.DAC_Trigger = DAC_Trigger_T2_TRGO; | |||
|
75 | if (timer == timer4)DAC_InitStructure.DAC_Trigger = DAC_Trigger_T4_TRGO; | |||
|
76 | if (timer == timer5)DAC_InitStructure.DAC_Trigger = DAC_Trigger_T5_TRGO; | |||
|
77 | if (timer == timer6)DAC_InitStructure.DAC_Trigger = DAC_Trigger_T6_TRGO; | |||
|
78 | if (timer == timer7)DAC_InitStructure.DAC_Trigger = DAC_Trigger_T7_TRGO; | |||
|
79 | if (timer == timer8)DAC_InitStructure.DAC_Trigger = DAC_Trigger_T8_TRGO; | |||
|
80 | DAC_InitStructure.DAC_WaveGeneration = DAC_WaveGeneration_None; | |||
|
81 | DAC_InitStructure.DAC_OutputBuffer = DAC_OutputBuffer_Enable; | |||
|
82 | if (dac == DAC1){ | |||
|
83 | DAC_Init(DAC_Channel_1, &DAC_InitStructure); | |||
|
84 | DMA_DeInit(DMA1_Stream5); | |||
|
85 | } | |||
|
86 | ||||
|
87 | if (dac == DAC2){ | |||
|
88 | DAC_Init(DAC_Channel_2, &DAC_InitStructure); | |||
|
89 | DMA_DeInit(DMA1_Stream6); | |||
|
90 | } | |||
|
91 | ||||
|
92 | DMA_InitStructure.DMA_Channel = DMA_Channel_7; | |||
|
93 | DMA_InitStructure.DMA_PeripheralBaseAddr = (uint32_t)dac_type; | |||
|
94 | DMA_InitStructure.DMA_Memory0BaseAddr = (uint32_t)data; | |||
|
95 | DMA_InitStructure.DMA_DIR = DMA_DIR_MemoryToPeripheral; | |||
|
96 | DMA_InitStructure.DMA_BufferSize = buffer_size; | |||
|
97 | DMA_InitStructure.DMA_PeripheralInc = DMA_PeripheralInc_Disable; | |||
|
98 | DMA_InitStructure.DMA_DIR = DMA_DIR_MemoryToPeripheral; | |||
|
99 | DMA_InitStructure.DMA_MemoryInc = DMA_MemoryInc_Enable; | |||
|
100 | DMA_InitStructure.DMA_PeripheralDataSize = DMA_PeripheralDataSize_HalfWord; | |||
|
101 | DMA_InitStructure.DMA_MemoryDataSize = DMA_MemoryDataSize_HalfWord; | |||
|
102 | DMA_InitStructure.DMA_Mode = DMA_Mode_Circular; | |||
|
103 | DMA_InitStructure.DMA_Priority = DMA_Priority_High; | |||
|
104 | DMA_InitStructure.DMA_FIFOMode = DMA_FIFOMode_Disable; | |||
|
105 | DMA_InitStructure.DMA_FIFOThreshold = DMA_FIFOThreshold_HalfFull; | |||
|
106 | DMA_InitStructure.DMA_MemoryBurst = DMA_MemoryBurst_Single; | |||
|
107 | DMA_InitStructure.DMA_PeripheralBurst = DMA_PeripheralBurst_Single; | |||
|
108 | ||||
|
109 | if (dac == DAC1){ | |||
|
110 | DMA_Init(DMA1_Stream5, &DMA_InitStructure); | |||
|
111 | DMA_Cmd(DMA1_Stream5, ENABLE); | |||
|
112 | DAC_DMACmd(DAC_Channel_1, ENABLE); | |||
|
113 | DAC_Cmd(DAC_Channel_1, ENABLE); | |||
|
114 | ||||
|
115 | } | |||
|
116 | if (dac == DAC2){ | |||
|
117 | DMA_Init(DMA1_Stream6, &DMA_InitStructure); | |||
|
118 | DMA_Cmd(DMA1_Stream6, ENABLE); | |||
|
119 | DAC_DMACmd(DAC_Channel_2, ENABLE); | |||
|
120 | DAC_Cmd(DAC_Channel_2, ENABLE); | |||
|
121 | ||||
|
122 | } | |||
|
123 | return 0; | |||
|
124 | ||||
|
125 | } | |||
|
126 | ||||
|
127 |
@@ -1,91 +1,101 | |||||
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) 2014, Kaveh Mohamadabadi |
|
3 | -- Copyright (C) 2014, Kaveh Mohamadabadi | |
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 : Kaveh Mohamadabadi |
|
19 | -- Author : Kaveh Mohamadabadi | |
20 | -- Mail : kaveh.mohamadabadi@gmail.com |
|
20 | -- Mail : kaveh.mohamadabadi@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 | uint32_t OSC0 =12000000; |
|
28 | uint32_t OSC0 =12000000; | |
29 | uint32_t INTOSC =16000000; |
|
29 | uint32_t INTOSC =16000000; | |
30 | uint32_t RTCOSC =32768; |
|
30 | uint32_t RTCOSC =32768; | |
31 | uint32_t currentCpuFreq=0; |
|
31 | uint32_t currentCpuFreq=0; | |
32 | extern streamdevice* __opnfiles__[__MAX_OPENED_FILES__]; |
|
32 | extern streamdevice* __opnfiles__[__MAX_OPENED_FILES__]; | |
33 | gpio_t TickLed = LED1; |
|
33 | gpio_t TickLed = LED1; | |
34 |
|
34 | |||
35 | float VREF0 =(float)3.3; |
|
35 | float VREF0 =(float)3.3; | |
36 |
|
36 | |||
37 | int bsp_init() |
|
37 | int bsp_init() | |
38 | { |
|
38 | { | |
39 | int i=0; |
|
39 | int i=0; | |
40 | for(i=0;i<32;i++) |
|
40 | for(i=0;i<32;i++) | |
41 | { |
|
41 | { | |
42 | __opnfiles__[i] = NULL; |
|
42 | __opnfiles__[i] = NULL; | |
43 | } |
|
43 | } | |
44 | bsp_GPIO_init(); |
|
44 | bsp_GPIO_init(); | |
45 | bsp_uart_init(); |
|
45 | bsp_uart_init(); | |
46 | printf("\r================================================================\n\r"); |
|
46 | printf("\r================================================================\n\r"); | |
47 | printf("================================================================\n\r"); |
|
47 | printf("================================================================\n\r"); | |
48 | printf(BSP); |
|
48 | printf(BSP); | |
49 | printf(" initialised\n\r"); |
|
49 | printf(" initialised\n\r"); | |
50 | printf("================================================================\n\r"); |
|
50 | printf("================================================================\n\r"); | |
51 | return 1; |
|
51 | return 1; | |
52 | } |
|
52 | } | |
|
53 | void bsp_GPIO_init() | |||
|
54 | { | |||
|
55 | gpio_t LED_list[]={LED1, LED2, LED3}; | |||
|
56 | gpio_t LEDx; | |||
|
57 | for (int i=0;2;i++) | |||
|
58 | { | |||
|
59 | LEDx=gpioopen(LED_list[i]); | |||
|
60 | gpiosetdir(&LEDx,gpiooutdir); | |||
|
61 | } | |||
|
62 | } | |||
53 |
|
63 | |||
54 | void bsp_GPIO_init() |
|
64 | void bsp_GPIO_init() | |
55 | { |
|
65 | { | |
56 |
|
66 | |||
57 | } |
|
67 | } | |
58 |
|
68 | |||
59 | void bsp_uart_init() |
|
69 | void bsp_uart_init() | |
60 | { |
|
70 | { | |
61 | if(__opnfiles__[1]==NULL) |
|
71 | if(__opnfiles__[1]==NULL) | |
62 | { |
|
72 | { | |
63 | // streamdevice* fd1 = (streamdevice*)malloc(sizeof(streamdevice)); |
|
73 | // streamdevice* fd1 = (streamdevice*)malloc(sizeof(streamdevice)); | |
64 | // uart_t uart = uartopenandconfig(uart3,uartparitynone | uart8bits | uartonestop,19200,PB10,PB11,-1,-1); |
|
74 | // uart_t uart = uartopenandconfig(uart3,uartparitynone | uart8bits | uartonestop,19200,PB10,PB11,-1,-1); | |
65 | // uartmkstreamdev(uart,fd1); |
|
75 | // uartmkstreamdev(uart,fd1); | |
66 | // __opnfiles__[1] = fd1; //stdo |
|
76 | // __opnfiles__[1] = fd1; //stdo | |
67 | // __opnfiles__[0] = fd1; //stdi |
|
77 | // __opnfiles__[0] = fd1; //stdi | |
68 | } |
|
78 | } | |
69 | else |
|
79 | else | |
70 | { |
|
80 | { | |
71 | // uartopenandconfig(2,uartparitynone | uart8bits | uartonestop,115200,PB10,PB11,-1,-1); |
|
81 | // uartopenandconfig(2,uartparitynone | uart8bits | uartonestop,115200,PB10,PB11,-1,-1); | |
72 | } |
|
82 | } | |
73 | } |
|
83 | } | |
74 |
|
84 | |||
75 | void bsp_spi_init() |
|
85 | void bsp_spi_init() | |
76 | { |
|
86 | { | |
77 |
|
87 | |||
78 | } |
|
88 | } | |
79 |
|
89 | |||
80 |
|
90 | |||
81 | void bsp_iic_init() |
|
91 | void bsp_iic_init() | |
82 | { |
|
92 | { | |
83 |
|
93 | |||
84 | } |
|
94 | } | |
85 |
|
95 | |||
86 |
|
96 | |||
87 |
|
97 | |||
88 |
|
98 | |||
89 |
|
99 | |||
90 |
|
100 | |||
91 |
|
101 |
@@ -1,68 +1,69 | |||||
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) 2014, Kaveh Mohamadabadi |
|
3 | -- Copyright (C) 2014, Kaveh Mohamadabadi | |
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 : Kaveh Mohamadabadi |
|
19 | -- Author : Kaveh Mohamadabadi | |
20 | -- Mail : kaveh.mohamadabadi@gmail.com |
|
20 | -- Mail : kaveh.mohamadabadi@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 <gpio.h> |
|
25 | #include <gpio.h> | |
26 |
|
26 | |||
27 | #define __MAX_OPENED_FILES__ 32 |
|
27 | #define __MAX_OPENED_FILES__ 32 | |
28 | #define __FS_ROOT_SIZE__ 32 |
|
28 | #define __FS_ROOT_SIZE__ 32 | |
29 |
|
29 | |||
30 |
#define LED1 P |
|
30 | #define LED1 PA0 | |
31 |
#define LED2 P |
|
31 | #define LED2 PA1 | |
|
32 | #define LED3 PA2 | |||
32 |
|
33 | |||
33 | extern float VREF0; |
|
34 | extern float VREF0; | |
34 |
|
35 | |||
35 | extern uint32_t OSC0; |
|
36 | extern uint32_t OSC0; | |
36 | extern uint32_t currentCpuFreq; |
|
37 | extern uint32_t currentCpuFreq; | |
37 |
|
38 | |||
38 |
|
39 | |||
39 |
|
40 | |||
40 | extern int bsp_init(); |
|
41 | extern int bsp_init(); | |
41 |
|
42 | |||
42 | extern void bsp_GPIO_init(); |
|
43 | extern void bsp_GPIO_init(); | |
43 | extern void bsp_uart_init(); |
|
44 | extern void bsp_uart_init(); | |
44 | extern void bsp_iic_init(); |
|
45 | extern void bsp_iic_init(); | |
45 | extern void bsp_spi_init(); |
|
46 | extern void bsp_spi_init(); | |
46 |
|
47 | |||
47 |
|
48 | |||
48 |
|
49 | |||
49 | #endif |
|
50 | #endif | |
50 |
|
51 | |||
51 |
|
52 | |||
52 |
|
53 | |||
53 |
|
54 | |||
54 |
|
55 | |||
55 |
|
56 | |||
56 |
|
57 | |||
57 |
|
58 | |||
58 |
|
59 | |||
59 |
|
60 | |||
60 |
|
61 | |||
61 |
|
62 | |||
62 |
|
63 | |||
63 |
|
64 | |||
64 |
|
65 | |||
65 |
|
66 | |||
66 |
|
67 | |||
67 |
|
68 | |||
68 |
|
69 |
@@ -1,19 +1,19 | |||||
1 | TEMPLATE = lib |
|
1 | TEMPLATE = lib | |
2 |
|
2 | |||
3 | TARGET=bsp |
|
3 | TARGET=bsp | |
4 | CONFIG += bsp |
|
4 | CONFIG += bsp | |
5 |
|
5 | |||
6 | BSP=STM32F4Discovery |
|
6 | BSP=STM32F4Discovery | |
7 |
|
7 | |||
8 | UCMODEL=stm32f4 |
|
8 | UCMODEL=stm32f4 | |
9 |
|
9 | |||
10 | SOURCES += bsp.c |
|
10 | SOURCES += bsp.c | |
11 |
|
11 | |||
12 | HEADERS += bsp.h |
|
12 | HEADERS += bsp.h | |
13 |
|
13 | |||
14 | LIBS+= -lgpio -luart -li2c -lspi -lpwm |
|
14 | LIBS+= -lgpio -luart -li2c -lspi -lpwm -ldac | |
15 |
|
15 | |||
16 | BSPFILE = bsp.pri |
|
16 | BSPFILE = bsp.pri | |
17 |
|
17 | |||
18 |
|
18 | |||
19 |
|
19 |
@@ -1,22 +1,21 | |||||
1 | TEMPLATE = subdirs |
|
1 | TEMPLATE = subdirs | |
2 | CONFIG += ordered |
|
2 | CONFIG += ordered | |
3 | SUBDIRS += STM32F4Discovery \ |
|
3 | SUBDIRS += STM32F4Discovery \ | |
4 | M4Stick \ |
|
4 | M4Stick \ | |
5 | M4StickV2 \ |
|
5 | M4StickV2 \ | |
6 | SOLAR_LFR_PSU \ |
|
6 | SOLAR_LFR_PSU \ | |
7 | BEAGLESYNTH \ |
|
7 | BEAGLESYNTH \ | |
8 | STM32F4Eval \ |
|
8 | STM32F4Eval \ | |
9 | STM32F4Discovery-EXT \ |
|
9 | STM32F4Discovery-EXT \ | |
10 | STM32F4Discovery-ILI9328-8bits \ |
|
10 | STM32F4Discovery-ILI9328-8bits \ | |
11 | OPLAYER \ |
|
11 | OPLAYER \ | |
12 | STM32-E407 \ |
|
12 | STM32-E407 \ | |
13 | STM32F429Discovery \ |
|
13 | STM32F429Discovery \ | |
14 |
STM32F4Discovery_35LCD |
|
14 | STM32F4Discovery_35LCD | |
15 | Nano-particle |
|
|||
16 |
|
15 | |||
17 |
|
16 | |||
18 |
|
17 | |||
19 |
|
18 | |||
20 |
|
19 | |||
21 |
|
20 | |||
22 |
|
21 |
@@ -1,56 +1,57 | |||||
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 <stdint.h> |
|
22 | #include <stdint.h> | |
23 | #ifdef __cplusplus |
|
23 | #ifdef __cplusplus | |
24 | extern "C" { |
|
24 | extern "C" { | |
25 | #endif |
|
25 | #endif | |
26 | extern volatile uint32_t tickCounter; |
|
26 | extern volatile uint32_t tickCounter; | |
27 | extern uint32_t getAPB1Freq(); |
|
27 | extern uint32_t getAPB1Freq(); | |
28 | extern uint32_t getAPB2Freq(); |
|
28 | extern uint32_t getAPB2Freq(); | |
29 | extern uint32_t getCpuFreq(); |
|
29 | extern uint32_t getCpuFreq(); | |
30 | extern int setCpuFreq(uint32_t freq); |
|
30 | extern int setCpuFreq(uint32_t freq); | |
31 | extern int optimizePLLcfg(uint32_t freq, uint32_t srcfreq,uint32_t PLLM,uint32_t* PLLP, uint32_t* PLLN,uint8_t* AHBPRindx); |
|
31 | extern int optimizePLLcfg(uint32_t freq, uint32_t srcfreq,uint32_t PLLM,uint32_t* PLLP, uint32_t* PLLN,uint8_t* AHBPRindx); | |
32 | extern int setPll(uint32_t freq); |
|
32 | extern int setPll(uint32_t freq); | |
33 | extern void enable_FPU(); |
|
33 | extern void enable_FPU(); | |
34 | extern void reset_AHB1(); |
|
34 | extern void reset_AHB1(); | |
35 | extern void reset_AHB2(); |
|
35 | extern void reset_AHB2(); | |
36 | extern void reset_APB1(); |
|
36 | extern void reset_APB1(); | |
37 | extern void reset_APB2(); |
|
37 | extern void reset_APB2(); | |
38 | extern void configureSysTick(); |
|
38 | extern void configureSysTick(); | |
|
39 | extern void delay_us(uint32_t value); | |||
39 | extern void delay_100us(uint32_t value); |
|
40 | extern void delay_100us(uint32_t value); | |
40 | extern void SysTick_Handler(void); |
|
41 | extern void SysTick_Handler(void); | |
41 |
|
42 | |||
42 | #ifdef __cplusplus |
|
43 | #ifdef __cplusplus | |
43 | } |
|
44 | } | |
44 | #endif |
|
45 | #endif | |
45 |
|
46 | |||
46 |
|
47 | |||
47 |
|
48 | |||
48 |
|
49 | |||
49 |
|
50 | |||
50 |
|
51 | |||
51 |
|
52 | |||
52 |
|
53 | |||
53 |
|
54 | |||
54 |
|
55 | |||
55 |
|
56 | |||
56 |
|
57 |
@@ -1,15 +1,16 | |||||
1 | TEMPLATE = subdirs |
|
1 | TEMPLATE = subdirs | |
2 | CONFIG += ordered |
|
2 | CONFIG += ordered | |
3 |
|
3 | |||
4 | SUBDIRS = CORE/core.pro \ |
|
4 | SUBDIRS = CORE/core.pro \ | |
5 | CPU/cpu.pro \ |
|
5 | CPU/cpu.pro \ | |
6 | GPIO/gpio.pro \ |
|
6 | GPIO/gpio.pro \ | |
7 | UART/uart.pro \ |
|
7 | UART/uart.pro \ | |
8 | SPI/spi.pro \ |
|
8 | SPI/spi.pro \ | |
9 | I2C/i2c.pro \ |
|
9 | I2C/i2c.pro \ | |
10 | PWM/pwm.pro \ |
|
10 | PWM/pwm.pro \ | |
|
11 | DAC/dac.pro\ | |||
11 | SDCARD-SDIO/sdcard-sdio.pro |
|
12 | SDCARD-SDIO/sdcard-sdio.pro | |
12 |
|
13 | |||
13 |
|
14 | |||
14 |
|
15 | |||
15 |
|
16 |
1 | NO CONTENT: file was removed |
|
NO CONTENT: file was removed |
General Comments 0
You need to be logged in to leave comments.
Login now