Skip to content

Commit

Permalink
Merge branch 'master' into cdc
Browse files Browse the repository at this point in the history
  • Loading branch information
ghent360 committed Feb 23, 2019
2 parents e1fab94 + 54478a1 commit 3eb08f8
Show file tree
Hide file tree
Showing 21 changed files with 1,538 additions and 548 deletions.
4 changes: 4 additions & 0 deletions README.md
Expand Up @@ -115,6 +115,10 @@ User can add a STM32 based board following this [wiki](https://github.com/stm32d
| :---: | --- | :---: | :--- |
| :green_heart: | [RAK811 LoRa Tracker](https://www.rakwireless.com/en/) | *1.4.0* | Basic support |

| Status | Sparky flight controllers | Release | Comment |
| :---: | --- | :---: | :--- |
| :yellow_heart: | [Sparky V1](https://github.com/TauLabs/TauLabs/wiki/Sparky) | **1.5.1/1.6.0** | |

## Next release

See [milestones](https://github.com/stm32duino/Arduino_Core_STM32/milestones) to have an overview of the next release content.
Expand Down
72 changes: 72 additions & 0 deletions boards.txt
Expand Up @@ -709,6 +709,33 @@ GenF4.menu.upload_method.bmpMethod=BMP (Black Magic Probe)
GenF4.menu.upload_method.bmpMethod.upload.protocol=gdb_bmp
GenF4.menu.upload_method.bmpMethod.upload.tool=bmp_upload

###############################
# Sparky Flight Controllers

Sparky.name=Sparky flight controllers

Sparky.build.vid=0x0483
Sparky.build.core=arduino
Sparky.build.board=Sparky
Sparky.build.extra_flags=-D{build.product_line} {build.enable_usb} {build.xSerial}

# Sparky_V1 board
# Support: Serial1 (USART1 on PA10, PA9)
Sparky.menu.pnum.Sparky_V1=Sparky V1
Sparky.menu.pnum.Sparky_V1.upload.maximum_size=262144
Sparky.menu.pnum.Sparky_V1.upload.maximum_data_size=40960
Sparky.menu.pnum.Sparky_V1.build.mcu=cortex-m4 -mfpu=fpv4-sp-d16 -mfloat-abi=hard
Sparky.menu.pnum.Sparky_V1.build.board=Sparky_V1
Sparky.menu.pnum.Sparky_V1.build.series=STM32F3xx
Sparky.menu.pnum.Sparky_V1.build.product_line=STM32F303xC
Sparky.menu.pnum.Sparky_V1.build.variant=SPARKY_F303CC
Sparky.menu.pnum.Sparky_V1.build.cmsis_lib_gcc=arm_cortexM4l_math

# Upload menu
Sparky.menu.upload_method.STLinkMethod=STLink
Sparky.menu.upload_method.STLinkMethod.upload.protocol=STLink
Sparky.menu.upload_method.STLinkMethod.upload.tool=stlink_upload

################################################################################
# RAK boards

Expand Down Expand Up @@ -897,6 +924,12 @@ GenF4.menu.xserial.none.build.xSerial=-DHAL_UART_MODULE_ENABLED -DHWSERIAL_NONE
GenF4.menu.xserial.disabled=Disabled (no Serial support)
GenF4.menu.xserial.disabled.build.xSerial=

Sparky.menu.xserial.generic=Enabled (generic 'Serial')
Sparky.menu.xserial.none=Enabled (no generic 'Serial')
Sparky.menu.xserial.none.build.xSerial=-DHAL_UART_MODULE_ENABLED -DHWSERIAL_NONE
Sparky.menu.xserial.disabled=Disabled (no Serial support)
Sparky.menu.xserial.disabled.build.xSerial=

RAK.menu.xserial.generic=Enabled (generic 'Serial')
RAK.menu.xserial.none=Enabled (no generic 'Serial')
RAK.menu.xserial.none.build.xSerial=-DHAL_UART_MODULE_ENABLED -DHWSERIAL_NONE
Expand Down Expand Up @@ -988,6 +1021,17 @@ GenF4.menu.xusb.HS.build.usb_speed=-DUSE_USB_HS
GenF4.menu.xusb.HSFS=High Speed in Full Speed mode
GenF4.menu.xusb.HSFS.build.usb_speed=-DUSE_USB_HS -DUSE_USB_HS_IN_FS

Sparky.menu.usb.none=None
Sparky.menu.usb.CDCgen=CDC (generic 'Serial' supersede U(S)ART)
Sparky.menu.usb.CDCgen.build.enable_usb={build.usb_flags} -DUSBD_USE_CDC
Sparky.menu.usb.CDC=CDC (no generic 'Serial')
Sparky.menu.usb.CDC.build.enable_usb={build.usb_flags} -DUSBD_USE_CDC -DDISABLE_GENERIC_SERIALUSB
Sparky.menu.xusb.FS=Low/Full Speed
Sparky.menu.xusb.HS=High Speed
Sparky.menu.xusb.HS.build.usb_speed=-DUSE_USB_HS
Sparky.menu.xusb.HSFS=High Speed in Full Speed mode
Sparky.menu.xusb.HSFS.build.usb_speed=-DUSE_USB_HS -DUSE_USB_HS_IN_FS

3dprinter.menu.usb.none=None
3dprinter.menu.usb.CDCgen=CDC (generic 'Serial' supersede U(S)ART)
3dprinter.menu.usb.CDCgen.build.enable_usb={build.usb_flags} -DUSBD_USE_CDC
Expand Down Expand Up @@ -1127,6 +1171,24 @@ GenF4.menu.opt.o3lto.build.flags.optimize=-O3 -flto
GenF4.menu.opt.ogstd=Debug (-g)
GenF4.menu.opt.ogstd.build.flags.optimize=-g -Og

Sparky.menu.opt.osstd=Smallest (-Os default)
Sparky.menu.opt.oslto=Smallest (-Os) with LTO
Sparky.menu.opt.oslto.build.flags.optimize=-Os -flto
Sparky.menu.opt.o1std=Fast (-O1)
Sparky.menu.opt.o1std.build.flags.optimize=-O1
Sparky.menu.opt.o1lto=Fast (-O1) with LTO
Sparky.menu.opt.o1lto.build.flags.optimize=-O1 -flto
Sparky.menu.opt.o2std=Faster (-O2)
Sparky.menu.opt.o2std.build.flags.optimize=-O2
Sparky.menu.opt.o2lto=Faster (-O2) with LTO
Sparky.menu.opt.o2lto.build.flags.optimize=-O2 -flto
Sparky.menu.opt.o3std=Fastest (-O3)
Sparky.menu.opt.o3std.build.flags.optimize=-O3
Sparky.menu.opt.o3lto=Fastest (-O3) with LTO
Sparky.menu.opt.o3lto.build.flags.optimize=-O3 -flto
Sparky.menu.opt.ogstd=Debug (-g)
Sparky.menu.opt.ogstd.build.flags.optimize=-g -Og

RAK.menu.opt.osstd=Smallest (-Os default)
RAK.menu.opt.oslto=Smallest (-Os) with LTO
RAK.menu.opt.oslto.build.flags.optimize=-Os -flto
Expand Down Expand Up @@ -1234,6 +1296,16 @@ GenF4.menu.rtlib.nanofps.build.flags.ldspecs=--specs=nano.specs -u _printf_float
GenF4.menu.rtlib.full=Newlib Standard
GenF4.menu.rtlib.full.build.flags.ldspecs=

Sparky.menu.rtlib.nano=Newlib Nano (default)
Sparky.menu.rtlib.nanofp=Newlib Nano + Float Printf
Sparky.menu.rtlib.nanofp.build.flags.ldspecs=--specs=nano.specs -u _printf_float
Sparky.menu.rtlib.nanofs=Newlib Nano + Float Scanf
Sparky.menu.rtlib.nanofs.build.flags.ldspecs=--specs=nano.specs -u _scanf_float
Sparky.menu.rtlib.nanofps=Newlib Nano + Float Printf/Scanf
Sparky.menu.rtlib.nanofps.build.flags.ldspecs=--specs=nano.specs -u _printf_float -u _scanf_float
Sparky.menu.rtlib.full=Newlib Standard
Sparky.menu.rtlib.full.build.flags.ldspecs=

RAK.menu.rtlib.nano=Newlib Nano (default)
RAK.menu.rtlib.nanofp=Newlib Nano + Float Printf
RAK.menu.rtlib.nanofp.build.flags.ldspecs=--specs=nano.specs -u _printf_float
Expand Down
8 changes: 4 additions & 4 deletions cores/arduino/board.h
Expand Up @@ -5,9 +5,6 @@
* Core and peripherals registers definitions
*/
#include "interrupt.h"
#ifdef __cplusplus
extern "C" {
#endif // __cplusplus
#include "analog.h"
#include "clock.h"
#include "core_callback.h"
Expand All @@ -21,8 +18,11 @@ extern "C" {
#include "twi.h"
#include "uart.h"

#ifdef __cplusplus
extern "C" {
#endif /* __cplusplus */
void init(void) ;
#ifdef __cplusplus
}
#endif // __cplusplus
#endif /* __cplusplus */
#endif /* _BOARD_H_ */
66 changes: 3 additions & 63 deletions cores/arduino/stm32/analog.c
Expand Up @@ -35,17 +35,6 @@
*
******************************************************************************
*/
/** @addtogroup CMSIS
* @{
*/

/** @addtogroup stm32f4xx_system
* @{
*/

/** @addtogroup STM32F4xx_System_Private_Includes
* @{
*/
#include "stm32_def.h"
#include "analog.h"
#include "timer.h"
Expand All @@ -55,20 +44,7 @@
extern "C" {
#endif

/**
* @}
*/

/** @addtogroup STM32F4xx_System_Private_TypesDefinitions
* @{
*/
/**
* @}
*/

/** @addtogroup STM32F4xx_System_Private_Defines
* @{
*/
/* Private_Defines */
#if defined(ADC_SAMPLETIME_8CYCLES_5)
#define SAMPLINGTIME ADC_SAMPLETIME_8CYCLES_5;
#elif defined(ADC_SAMPLETIME_12CYCLES_5)
Expand Down Expand Up @@ -102,30 +78,11 @@ extern "C" {
#ifndef ADC_REGULAR_RANK_1
#define ADC_REGULAR_RANK_1 1
#endif
/**
* @}
*/

/** @addtogroup STM32F4xx_System_Private_Macros
* @{
*/

/**
* @}
*/

/** @addtogroup STM32F4xx_System_Private_Variables
* @{
*/
/* Private_Variables */
static PinName g_current_pin = NC;

/**
* @}
*/

/** @addtogroup STM32F4xx_System_Private_FunctionPrototypes
* @{
*/
/* Private Functions */
static uint32_t get_adc_channel(PinName pin)
{
uint32_t function = pinmap_function(pin, PinMap_ADC);
Expand Down Expand Up @@ -804,23 +761,6 @@ void pwm_stop(PinName pin)
HAL_TIM_PWM_DeInit(&timHandle);
}


/**
* @}
*/


/**
* @}
*/

/**
* @}
*/

/**
* @}
*/
#ifdef __cplusplus
}
#endif
Expand Down
3 changes: 0 additions & 3 deletions cores/arduino/stm32/analog.h
Expand Up @@ -47,9 +47,6 @@
extern "C" {
#endif

/* Exported types ------------------------------------------------------------*/
/* Exported constants --------------------------------------------------------*/
/* Exported macro ------------------------------------------------------------*/
/* Exported functions ------------------------------------------------------- */
void dac_write_value(PinName pin, uint32_t value, uint8_t do_init);
void dac_stop(PinName pin);
Expand Down
68 changes: 5 additions & 63 deletions cores/arduino/stm32/interrupt.cpp
Expand Up @@ -35,57 +35,21 @@
*
******************************************************************************
*/
/** @addtogroup CMSIS
* @{
*/

/** @addtogroup stm32f4xx_system
* @{
*/

/** @addtogroup STM32F4xx_System_Private_Includes
* @{
*/
#include "stm32_def.h"
#include "interrupt.h"

/**
* @}
*/

/** @addtogroup STM32F4xx_System_Private_TypesDefinitions
* @{
*/
/* Private Types */

/*As we can have only one interrupt/pin id, don't need to get the port info*/
typedef struct {
IRQn_Type irqnb;
std::function<void(void)> callback;
} gpio_irq_conf_str;

/**
* @}
*/

/** @addtogroup STM32F4xx_System_Private_Defines
* @{
*/
/* Private_Defines */
#define NB_EXTI (16)
/**
* @}
*/

/** @addtogroup STM32F4xx_System_Private_Macros
* @{
*/

/**
* @}
*/

/** @addtogroup STM32F4xx_System_Private_Variables
* @{
*/
/* Private Variables */
static gpio_irq_conf_str gpio_irq_conf[NB_EXTI] = {
#if defined (STM32F0xx) || defined (STM32L0xx)
{.irqnb = EXTI0_1_IRQn, .callback = NULL}, //GPIO_PIN_0
Expand Down Expand Up @@ -123,25 +87,14 @@ static gpio_irq_conf_str gpio_irq_conf[NB_EXTI] = {
{.irqnb = EXTI15_10_IRQn, .callback = NULL} //GPIO_PIN_15
#endif
};
/**
* @}
*/

/** @addtogroup STM32F4xx_System_Private_FunctionPrototypes
* @{
*/

static uint8_t get_pin_id(uint16_t pin);

/**
* @}
*/
/* Private Functions */
/**
* @brief This function returns the pin ID function of the HAL PIN definition
* @param pin : one of the gpio pin
* @retval None
*/
uint8_t get_pin_id(uint16_t pin)
static uint8_t get_pin_id(uint16_t pin)
{
uint8_t id = 0;

Expand Down Expand Up @@ -397,15 +350,4 @@ void EXTI15_10_IRQHandler(void)
}
#endif
#endif
/**
* @}
*/

/**
* @}
*/

/**
* @}
*/
/************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/
3 changes: 0 additions & 3 deletions cores/arduino/stm32/interrupt.h
Expand Up @@ -54,9 +54,6 @@ typedef std::function<void(void)> callback_function_t;
void stm32_interrupt_enable(GPIO_TypeDef *port, uint16_t pin, callback_function_t callback, uint32_t mode);
#endif

/* Exported types ------------------------------------------------------------*/
/* Exported constants --------------------------------------------------------*/
/* Exported macro ------------------------------------------------------------*/
/* Exported functions ------------------------------------------------------- */
void stm32_interrupt_enable(GPIO_TypeDef *port, uint16_t pin, void (*callback)(void), uint32_t mode);
void stm32_interrupt_disable(GPIO_TypeDef *port, uint16_t pin);
Expand Down
11 changes: 9 additions & 2 deletions cores/arduino/stm32/rtc.c
Expand Up @@ -146,9 +146,16 @@ static void RTC_initClock(sourceClock_t source)
#ifndef RCC_RTCCLKSOURCE_HSE_DIVX
#define RCC_RTCCLKSOURCE_HSE_DIVX 0x00000300U
#endif /* RCC_RTCCLKSOURCE_HSE_DIVX */
for (HSEDiv = 2; HSEDiv < 32; HSEDiv++) {
#if defined(STM32H7xx)
#define HSEDIV_MAX 64
#define HSESHIFT 12
#else
#define HSEDIV_MAX 32
#define HSESHIFT 16
#endif
for (HSEDiv = 2; HSEDiv < HSEDIV_MAX; HSEDiv++) {
if ((HSE_VALUE / HSEDiv) <= HSE_RTC_MAX) {
PeriphClkInit.RTCClockSelection = (HSEDiv << 16) | RCC_RTCCLKSOURCE_HSE_DIVX;
PeriphClkInit.RTCClockSelection = (HSEDiv << HSESHIFT) | RCC_RTCCLKSOURCE_HSE_DIVX;
break;
}
}
Expand Down

0 comments on commit 3eb08f8

Please sign in to comment.