@@ -0,0 +1,21 | |||
|
1 | TEMPLATE = lib | |
|
2 | ||
|
3 | TARGET=bsp | |
|
4 | CONFIG += bsp | |
|
5 | ||
|
6 | BSP=Nano-particle | |
|
7 | ||
|
8 | UCMODEL=stm32f4 | |
|
9 | ||
|
10 | SOURCES += bsp.c | |
|
11 | ||
|
12 | HEADERS += bsp.h | |
|
13 | ||
|
14 | LIBS+= -lgpio -luart -li2c -lspi -lpwm | |
|
15 | ||
|
16 | BSPFILE = bsp.pri | |
|
17 | ||
|
18 | OTHER_FILES += bsp.pri | |
|
19 | ||
|
20 | ||
|
21 |
@@ -0,0 +1,91 | |||
|
1 | /*------------------------------------------------------------------------------ | |
|
2 | -- This file is a part of the libuc, microcontroler library | |
|
3 | -- Copyright (C) 2014, Kaveh Mohamadabadi | |
|
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 : Kaveh Mohamadabadi | |
|
20 | -- Mail : kaveh.mohamadabadi@gmail.com | |
|
21 | -------------------------------------------------------------------------------*/ | |
|
22 | #include "bsp.h" | |
|
23 | #include <streamdevices.h> | |
|
24 | #include <malloc.h> | |
|
25 | #include <gpio.h> | |
|
26 | #include <uart.h> | |
|
27 | #include <stdio.h> | |
|
28 | uint32_t OSC0 =12000000; | |
|
29 | uint32_t INTOSC =16000000; | |
|
30 | uint32_t RTCOSC =32768; | |
|
31 | uint32_t currentCpuFreq=0; | |
|
32 | extern streamdevice* __opnfiles__[__MAX_OPENED_FILES__]; | |
|
33 | gpio_t TickLed = LED1; | |
|
34 | ||
|
35 | float VREF0 =(float)3.3; | |
|
36 | ||
|
37 | int bsp_init() | |
|
38 | { | |
|
39 | int i=0; | |
|
40 | for(i=0;i<32;i++) | |
|
41 | { | |
|
42 | __opnfiles__[i] = NULL; | |
|
43 | } | |
|
44 | bsp_GPIO_init(); | |
|
45 | bsp_uart_init(); | |
|
46 | printf("\r================================================================\n\r"); | |
|
47 | printf("================================================================\n\r"); | |
|
48 | printf(BSP); | |
|
49 | printf(" initialised\n\r"); | |
|
50 | printf("================================================================\n\r"); | |
|
51 | return 1; | |
|
52 | } | |
|
53 | ||
|
54 | void bsp_GPIO_init() | |
|
55 | { | |
|
56 | ||
|
57 | } | |
|
58 | ||
|
59 | void bsp_uart_init() | |
|
60 | { | |
|
61 | if(__opnfiles__[1]==NULL) | |
|
62 | { | |
|
63 | // streamdevice* fd1 = (streamdevice*)malloc(sizeof(streamdevice)); | |
|
64 | // uart_t uart = uartopenandconfig(uart3,uartparitynone | uart8bits | uartonestop,19200,PB10,PB11,-1,-1); | |
|
65 | // uartmkstreamdev(uart,fd1); | |
|
66 | // __opnfiles__[1] = fd1; //stdo | |
|
67 | // __opnfiles__[0] = fd1; //stdi | |
|
68 | } | |
|
69 | else | |
|
70 | { | |
|
71 | // uartopenandconfig(2,uartparitynone | uart8bits | uartonestop,115200,PB10,PB11,-1,-1); | |
|
72 | } | |
|
73 | } | |
|
74 | ||
|
75 | void bsp_spi_init() | |
|
76 | { | |
|
77 | ||
|
78 | } | |
|
79 | ||
|
80 | ||
|
81 | void bsp_iic_init() | |
|
82 | { | |
|
83 | ||
|
84 | } | |
|
85 | ||
|
86 | ||
|
87 | ||
|
88 | ||
|
89 | ||
|
90 | ||
|
91 |
@@ -0,0 +1,68 | |||
|
1 | /*------------------------------------------------------------------------------ | |
|
2 | -- This file is a part of the libuc, microcontroler library | |
|
3 | -- Copyright (C) 2014, Kaveh Mohamadabadi | |
|
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 : Kaveh Mohamadabadi | |
|
20 | -- Mail : kaveh.mohamadabadi@gmail.com | |
|
21 | -------------------------------------------------------------------------------*/ | |
|
22 | #ifndef BSP_H | |
|
23 | #define BSP_H | |
|
24 | #include <stm32f4xx.h> | |
|
25 | #include <gpio.h> | |
|
26 | ||
|
27 | #define __MAX_OPENED_FILES__ 32 | |
|
28 | #define __FS_ROOT_SIZE__ 32 | |
|
29 | ||
|
30 | #define LED1 PD12 | |
|
31 | #define LED2 PD13 | |
|
32 | ||
|
33 | extern float VREF0; | |
|
34 | ||
|
35 | extern uint32_t OSC0; | |
|
36 | extern uint32_t currentCpuFreq; | |
|
37 | ||
|
38 | ||
|
39 | ||
|
40 | extern int bsp_init(); | |
|
41 | ||
|
42 | extern void bsp_GPIO_init(); | |
|
43 | extern void bsp_uart_init(); | |
|
44 | extern void bsp_iic_init(); | |
|
45 | extern void bsp_spi_init(); | |
|
46 | ||
|
47 | ||
|
48 | ||
|
49 | #endif | |
|
50 | ||
|
51 | ||
|
52 | ||
|
53 | ||
|
54 | ||
|
55 | ||
|
56 | ||
|
57 | ||
|
58 | ||
|
59 | ||
|
60 | ||
|
61 | ||
|
62 | ||
|
63 | ||
|
64 | ||
|
65 | ||
|
66 | ||
|
67 | ||
|
68 |
@@ -11,7 +11,8 SUBDIRS += STM32F4Discovery \ | |||
|
11 | 11 | OPLAYER \ |
|
12 | 12 | STM32-E407 \ |
|
13 | 13 | STM32F429Discovery \ |
|
14 | STM32F4Discovery_35LCD | |
|
14 | STM32F4Discovery_35LCD \ | |
|
15 | Nano-particle | |
|
15 | 16 | |
|
16 | 17 | |
|
17 | 18 |
@@ -19,7 +19,7 | |||
|
19 | 19 | -- Author : Kaveh Mohamadabadi |
|
20 | 20 | -- Mail : kaveh.mohamadabadi@gmail.com |
|
21 | 21 | -------------------------------------------------------------------------------*/ |
|
22 | ||
|
22 | /// \defgroup PWM | |
|
23 | 23 | /*! \file pwm.h |
|
24 | 24 | \brief PWM api. |
|
25 | 25 | |
@@ -49,6 +49,7 A simple example to configure and use PW | |||
|
49 | 49 | } |
|
50 | 50 | |
|
51 | 51 | \endcode |
|
52 | \ingroup PWM | |
|
52 | 53 | |
|
53 | 54 | */ |
|
54 | 55 | #ifndef PWM_H |
@@ -58,6 +59,14 A simple example to configure and use PW | |||
|
58 | 59 | #ifdef __cplusplus |
|
59 | 60 | extern "C" { |
|
60 | 61 | #endif |
|
62 | /** | |
|
63 | * @brief PWM open function | |
|
64 | * | |
|
65 | * This function opens the given PWM, it should turn it ON iff needed and enable it. | |
|
66 | * @param PWM The PWM module and channel PWM1_CH6 for example | |
|
67 | * @return The 0 on success or -1 if it fails. | |
|
68 | * @ingroup PWM | |
|
69 | */ | |
|
61 | 70 | extern int pwmopen(int PWM,uint32_t pin); |
|
62 | 71 | extern int pwmsetconfig(int PWM,uint32_t freq,float dutyCycle); |
|
63 | 72 | extern int pwmsetdutycycle(int PWM,float dutyCycle); |
@@ -57,7 +57,11 contains( TEMPLATE, app ) { | |||
|
57 | 57 | |
|
58 | 58 | stflash.target = stflash |
|
59 | 59 | stflash.commands = cd $$DESTDIR && st-flash write $(QMAKE_TARGET).bin 0x08000000 |
|
60 | dfu_file.target = $$DESTDIR/$(QMAKE_TARGET).dfu | |
|
61 | dfu_file.commands = python $$[QT_INSTALL_BINS]/dfu.py -b 0x08000000:$$DESTDIR/$(QMAKE_TARGET).bin $$DESTDIR/$(QMAKE_TARGET).dfu | |
|
62 | dfu_file.depends = $$DESTDIR/$(QMAKE_TARGET) | |
|
60 | 63 | dfu.target = dfu |
|
64 | dfu.depends = $$DESTDIR/$(QMAKE_TARGET).dfu | |
|
61 | 65 | dfu.commands = cd $$DESTDIR && dfu-util d 0483:df11 -c 1 -i 0 -a 0 -s 0x08000000 -D $(QMAKE_TARGET).bin 0x08000000 |
|
62 | 66 | gdb-server.target = gdb-server |
|
63 | 67 | gdb-server.commands = st-util -p 3333 & |
@@ -65,7 +69,7 contains( TEMPLATE, app ) { | |||
|
65 | 69 | nemiver.target = nemiver |
|
66 | 70 | nemiver.commands = cd $$DESTDIR && nemiver --remote=localhost:3333 --gdb-binary=`which arm-none-eabi-gdb` $(QMAKE_TARGET) |
|
67 | 71 | nemiver.depends = gdb-server |
|
68 | QMAKE_EXTRA_TARGETS += stflash dfu nemiver gdb-server | |
|
72 | QMAKE_EXTRA_TARGETS += dfu_file stflash dfu nemiver gdb-server | |
|
69 | 73 | } |
|
70 | 74 | |
|
71 | 75 |
General Comments 0
You need to be logged in to leave comments.
Login now