# HG changeset patch # User kaveh # Date 2014-01-22 18:13:37 # Node ID 8c4e597b71381c753328fa323712c366254dca7f # Parent 9b3a6ca137a3d27692f0cd4a3dc66c2f0dc6e9aa Improved dfu target, now generates dfu file automatically if needed. Added Nano-particle board. diff --git a/bsp/src/stm32f4/Nano-particle/Nano-particle.pro b/bsp/src/stm32f4/Nano-particle/Nano-particle.pro new file mode 100644 --- /dev/null +++ b/bsp/src/stm32f4/Nano-particle/Nano-particle.pro @@ -0,0 +1,21 @@ +TEMPLATE = lib + +TARGET=bsp +CONFIG += bsp + +BSP=Nano-particle + +UCMODEL=stm32f4 + +SOURCES += bsp.c + +HEADERS += bsp.h + +LIBS+= -lgpio -luart -li2c -lspi -lpwm + +BSPFILE = bsp.pri + +OTHER_FILES += bsp.pri + + + diff --git a/bsp/src/stm32f4/Nano-particle/bsp.c b/bsp/src/stm32f4/Nano-particle/bsp.c new file mode 100644 --- /dev/null +++ b/bsp/src/stm32f4/Nano-particle/bsp.c @@ -0,0 +1,91 @@ +/*------------------------------------------------------------------------------ +-- This file is a part of the libuc, microcontroler library +-- Copyright (C) 2014, Kaveh Mohamadabadi +-- +-- This program is free software; you can redistribute it and/or modify +-- it under the terms of the GNU General Public License as published by +-- the Free Software Foundation; either version 3 of the License, or +-- (at your option) any later version. +-- +-- This program is distributed in the hope that it will be useful, +-- but WITHOUT ANY WARRANTY; without even the implied warranty of +-- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +-- GNU General Public License for more details. +-- +-- You should have received a copy of the GNU General Public License +-- along with this program; if not, write to the Free Software +-- Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +------------------------------------------------------------------------------- +-- Author : Kaveh Mohamadabadi +-- Mail : kaveh.mohamadabadi@gmail.com +-------------------------------------------------------------------------------*/ +#include "bsp.h" +#include +#include +#include +#include +#include +uint32_t OSC0 =12000000; +uint32_t INTOSC =16000000; +uint32_t RTCOSC =32768; +uint32_t currentCpuFreq=0; +extern streamdevice* __opnfiles__[__MAX_OPENED_FILES__]; +gpio_t TickLed = LED1; + +float VREF0 =(float)3.3; + +int bsp_init() +{ + int i=0; + for(i=0;i<32;i++) + { + __opnfiles__[i] = NULL; + } + bsp_GPIO_init(); + bsp_uart_init(); + printf("\r================================================================\n\r"); + printf("================================================================\n\r"); + printf(BSP); + printf(" initialised\n\r"); + printf("================================================================\n\r"); + return 1; +} + +void bsp_GPIO_init() +{ + +} + +void bsp_uart_init() +{ + if(__opnfiles__[1]==NULL) + { +// streamdevice* fd1 = (streamdevice*)malloc(sizeof(streamdevice)); +// uart_t uart = uartopenandconfig(uart3,uartparitynone | uart8bits | uartonestop,19200,PB10,PB11,-1,-1); +// uartmkstreamdev(uart,fd1); +// __opnfiles__[1] = fd1; //stdo +// __opnfiles__[0] = fd1; //stdi + } + else + { +// uartopenandconfig(2,uartparitynone | uart8bits | uartonestop,115200,PB10,PB11,-1,-1); + } +} + +void bsp_spi_init() +{ + +} + + +void bsp_iic_init() +{ + +} + + + + + + + diff --git a/bsp/src/stm32f4/Nano-particle/bsp.h b/bsp/src/stm32f4/Nano-particle/bsp.h new file mode 100644 --- /dev/null +++ b/bsp/src/stm32f4/Nano-particle/bsp.h @@ -0,0 +1,68 @@ +/*------------------------------------------------------------------------------ +-- This file is a part of the libuc, microcontroler library +-- Copyright (C) 2014, Kaveh Mohamadabadi +-- +-- This program is free software; you can redistribute it and/or modify +-- it under the terms of the GNU General Public License as published by +-- the Free Software Foundation; either version 3 of the License, or +-- (at your option) any later version. +-- +-- This program is distributed in the hope that it will be useful, +-- but WITHOUT ANY WARRANTY; without even the implied warranty of +-- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +-- GNU General Public License for more details. +-- +-- You should have received a copy of the GNU General Public License +-- along with this program; if not, write to the Free Software +-- Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +------------------------------------------------------------------------------- +-- Author : Kaveh Mohamadabadi +-- Mail : kaveh.mohamadabadi@gmail.com +-------------------------------------------------------------------------------*/ +#ifndef BSP_H +#define BSP_H +#include +#include + +#define __MAX_OPENED_FILES__ 32 +#define __FS_ROOT_SIZE__ 32 + +#define LED1 PD12 +#define LED2 PD13 + +extern float VREF0; + +extern uint32_t OSC0; +extern uint32_t currentCpuFreq; + + + +extern int bsp_init(); + +extern void bsp_GPIO_init(); +extern void bsp_uart_init(); +extern void bsp_iic_init(); +extern void bsp_spi_init(); + + + +#endif + + + + + + + + + + + + + + + + + + + diff --git a/bsp/src/stm32f4/stm32f4.pro b/bsp/src/stm32f4/stm32f4.pro --- a/bsp/src/stm32f4/stm32f4.pro +++ b/bsp/src/stm32f4/stm32f4.pro @@ -11,7 +11,8 @@ SUBDIRS += STM32F4Discovery \ OPLAYER \ STM32-E407 \ STM32F429Discovery \ - STM32F4Discovery_35LCD + STM32F4Discovery_35LCD \ + Nano-particle diff --git a/include/PERIPHERALS/pwm.h b/include/PERIPHERALS/pwm.h --- a/include/PERIPHERALS/pwm.h +++ b/include/PERIPHERALS/pwm.h @@ -19,7 +19,7 @@ -- Author : Kaveh Mohamadabadi -- Mail : kaveh.mohamadabadi@gmail.com -------------------------------------------------------------------------------*/ - + /// \defgroup PWM /*! \file pwm.h \brief PWM api. @@ -49,6 +49,7 @@ A simple example to configure and use PW } \endcode +\ingroup PWM */ #ifndef PWM_H @@ -58,6 +59,14 @@ A simple example to configure and use PW #ifdef __cplusplus extern "C" { #endif +/** + * @brief PWM open function + * + * This function opens the given PWM, it should turn it ON iff needed and enable it. + * @param PWM The PWM module and channel PWM1_CH6 for example + * @return The 0 on success or -1 if it fails. + * @ingroup PWM + */ extern int pwmopen(int PWM,uint32_t pin); extern int pwmsetconfig(int PWM,uint32_t freq,float dutyCycle); extern int pwmsetdutycycle(int PWM,float dutyCycle); diff --git a/mkspecs/features/stm32f4/qmake.conf b/mkspecs/features/stm32f4/qmake.conf --- a/mkspecs/features/stm32f4/qmake.conf +++ b/mkspecs/features/stm32f4/qmake.conf @@ -57,7 +57,11 @@ contains( TEMPLATE, app ) { stflash.target = stflash stflash.commands = cd $$DESTDIR && st-flash write $(QMAKE_TARGET).bin 0x08000000 + dfu_file.target = $$DESTDIR/$(QMAKE_TARGET).dfu + dfu_file.commands = python $$[QT_INSTALL_BINS]/dfu.py -b 0x08000000:$$DESTDIR/$(QMAKE_TARGET).bin $$DESTDIR/$(QMAKE_TARGET).dfu + dfu_file.depends = $$DESTDIR/$(QMAKE_TARGET) dfu.target = dfu + dfu.depends = $$DESTDIR/$(QMAKE_TARGET).dfu dfu.commands = cd $$DESTDIR && dfu-util d 0483:df11 -c 1 -i 0 -a 0 -s 0x08000000 -D $(QMAKE_TARGET).bin 0x08000000 gdb-server.target = gdb-server gdb-server.commands = st-util -p 3333 & @@ -65,7 +69,7 @@ contains( TEMPLATE, app ) { nemiver.target = nemiver nemiver.commands = cd $$DESTDIR && nemiver --remote=localhost:3333 --gdb-binary=`which arm-none-eabi-gdb` $(QMAKE_TARGET) nemiver.depends = gdb-server - QMAKE_EXTRA_TARGETS += stflash dfu nemiver gdb-server + QMAKE_EXTRA_TARGETS += dfu_file stflash dfu nemiver gdb-server }