Skip to content

Commit 3d775ac

Browse files
committed
added variant black_f4 + cleanup old F1 anf F2 definitions
1 parent e49f7fa commit 3d775ac

25 files changed

Lines changed: 122 additions & 197 deletions

STM32F4/boards.txt

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,34 @@ discovery_f407.build.error_led_port=GPIOD
2929
discovery_f407.build.error_led_pin=14
3030
discovery_f407.build.board=STM32DiscoveryF407
3131

32+
##############################################################
33+
black_f407vet6.name=STM32 Black F407VET6
34+
35+
black_f407vet6.upload.tool=stlink_upload
36+
black_f407vet6.upload.protocol=stlink
37+
38+
black_f407vet6.upload.file_type=bin
39+
black_f407vet6.upload.ram.maximum_size=65535
40+
black_f407vet6.upload.flash.maximum_size=514288
41+
black_f407vet6.upload.maximum_size=514288
42+
43+
#black_f407vet6.upload.usbID=0483:3748
44+
#black_f407vet6.upload.altID=1
45+
#black_f407vet6.upload.auto_reset=true
46+
47+
black_f407vet6.build.mcu=cortex-m4
48+
black_f407vet6.build.f_cpu=168000000L
49+
black_f407vet6.build.core=maple
50+
black_f407vet6.build.extra_flags=-mthumb -DSTM32_HIGH_DENSITY -DSTM32F4 -DBOARD_black_f4
51+
black_f407vet6.build.ldscript=ld/jtag.ld
52+
black_f407vet6.build.variant=black_f407vet6
53+
black_f407vet6.build.variant_system_lib=lib_f407.a
54+
black_f407vet6.build.vect=VECT_TAB_BASE
55+
black_f407vet6.build.density=STM32_HIGH_DENSITY
56+
black_f407vet6.build.error_led_port=GPIOA
57+
black_f407vet6.build.error_led_pin=7
58+
black_f407vet6.build.board=STM32BlackF407VET6
59+
3260
##############################################################
3361
stm32f4stamp.name=STM32F4Stamp F405
3462

STM32F4/cores/maple/boards.cpp

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -41,9 +41,7 @@
4141
#include "adc.h"
4242
#include "timer.h"
4343
#include "usb.h"
44-
#ifdef STM32F2
45-
//#include "usbF4.h"
46-
#endif
44+
4745

4846
static void setupFlash(void);
4947
static void setupClocks(void);
@@ -59,7 +57,7 @@ void init(void) {
5957
systick_init(SYSTICK_RELOAD_VAL);
6058
gpio_init_all();
6159

62-
#ifdef STM32F2
60+
#ifdef STM32F4
6361
rcc_clk_enable(RCC_SYSCFG);
6462
#else
6563
afio_init();
@@ -84,11 +82,13 @@ bool boardUsesPin(uint8 pin) {
8482
}
8583

8684
static void setupFlash(void) {
85+
/*
8786
#ifndef STM32F2
8887
// for F2 and F4 CPUs this is done in SetupClock...(), e.g. in SetupClock168MHz()
8988
flash_enable_prefetch();
9089
flash_set_latency(FLASH_WAIT_STATE_2);
9190
#endif
91+
*/
9292
}
9393

9494
/*
@@ -121,8 +121,8 @@ static void setupNVIC() {
121121
static void adcDefaultConfig(const adc_dev* dev);
122122

123123
static void setupADC() {
124-
#ifdef STM32F2
125-
setupADC_F2();
124+
#ifdef STM32F4
125+
setupADC_F4();
126126
#else
127127
rcc_set_prescaler(RCC_PRESCALER_ADC, RCC_ADCPRE_PCLK_DIV_6);
128128
#endif

STM32F4/cores/maple/boards.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -140,6 +140,8 @@ bool boardUsesPin(uint8 pin);
140140
#include "aeroquad32mini.h"
141141
#elif defined(BOARD_discovery_f4)
142142
#include "discovery_f4.h"
143+
#elif defined(BOARD_black_f4)
144+
#include "black_f4.h"
143145
#elif defined(BOARD_freeflight)
144146
#include "freeflight.h"
145147
#else

STM32F4/cores/maple/io.h

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@
3333
#ifndef _IO_H_
3434
#define _IO_H_
3535

36+
#include <inttypes.h>
3637
#include "gpio.h"
3738
#include "adc.h"
3839

@@ -179,9 +180,11 @@ static inline void toggleLED() {
179180
* accomplished portably over all LeafLabs boards by calling
180181
* pinMode(BOARD_BUTTON_PIN, INPUT).
181182
*
183+
* @param button - one of available on-board buttons (up to 3 for black F4)
184+
*
182185
* @see pinMode()
183186
*/
184-
uint8 isButtonPressed();
187+
uint8 isButtonPressed(uint8_t button);
185188

186189
/**
187190
* Wait until the button is pressed and released, timing out if no
@@ -195,12 +198,14 @@ uint8 isButtonPressed();
195198
* button is pressed. If timeout_millis is left out (or 0), wait
196199
* forever.
197200
*
201+
* @param button - one of available on-board buttons (up to 3 for black F4)
202+
*
198203
* @return true, if the button was pressed; false, if the timeout was
199204
* reached.
200205
*
201206
* @see pinMode()
202207
*/
203-
uint8 waitForButtonPress(uint32 timeout_millis=0);
208+
uint8 waitForButtonPress(uint8_t button, uint32 timeout_millis=0);
204209

205210
/**
206211
* Shift out a byte of data, one bit at a time.

STM32F4/cores/maple/libmaple/HardwareSerial.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -92,7 +92,7 @@ void HardwareSerial::begin(uint32 baud) {
9292

9393
const stm32_pin_info *txi = &PIN_MAP[tx_pin];
9494
const stm32_pin_info *rxi = &PIN_MAP[rx_pin];
95-
#ifdef STM32F2
95+
#ifdef STM32F4
9696
// int af = 7<<8;
9797
if (usart_device == UART4 || usart_device == UART5) {
9898
gpio_set_af_mode(txi->gpio_device, txi->gpio_bit, 8);

STM32F4/cores/maple/libmaple/adc.c

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,7 @@ const adc_dev *ADC3 = &adc3;
7474
*/
7575
void adc_init(const adc_dev *dev) {
7676
rcc_clk_enable(dev->clk_id);
77-
#ifdef STM32F2
77+
#ifdef STM32F4
7878
if(dev->clk_id == RCC_ADC1) {
7979
rcc_reset_dev(dev->clk_id);
8080
}
@@ -136,7 +136,9 @@ void adc_set_sample_rate(const adc_dev *dev, adc_smp_rate smp_rate) {
136136
* @brief Calibrate an ADC peripheral
137137
* @param dev adc device
138138
*/
139-
void adc_calibrate(const adc_dev *dev) {
139+
void adc_calibrate(const adc_dev *dev)
140+
{
141+
/*
140142
#ifndef STM32F2
141143
__io uint32 *rstcal_bit = bb_perip(&(dev->regs->CR2), 3);
142144
__io uint32 *cal_bit = bb_perip(&(dev->regs->CR2), 2);
@@ -149,6 +151,7 @@ void adc_calibrate(const adc_dev *dev) {
149151
while (*cal_bit)
150152
;
151153
#endif
154+
*/
152155
}
153156

154157
/**
@@ -171,8 +174,8 @@ uint16 adc_read(const adc_dev *dev, uint8 channel) {
171174
return (uint16)(regs->DR & ADC_DR_DATA);
172175
}
173176

174-
void setupADC_F2() {
175-
#ifdef STM32F2
177+
void setupADC_F4(void)
178+
{
176179
uint32 tmpreg1 = 0;
177180

178181
tmpreg1 = ADC_COMMON->CCR;
@@ -196,5 +199,4 @@ void setupADC_F2() {
196199

197200
/* Write to ADC CCR */
198201
ADC_COMMON->CCR = tmpreg1;
199-
#endif
200202
}

STM32F4/cores/maple/libmaple/adc.h

Lines changed: 14 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -42,17 +42,15 @@ extern "C"{
4242
#endif
4343

4444

45-
#ifdef STM32F2
46-
typedef struct
47-
{
48-
__io uint32 CSR; /*!< ADC Common status register, Address offset: ADC1 base address + 0x300 */
49-
__io uint32 CCR; /*!< ADC common control register, Address offset: ADC1 base address + 0x304 */
50-
__io uint32 CDR; /*!< ADC common regular data register for dual
51-
AND triple modes, Address offset: ADC1 base address + 0x308 */
52-
} ADC_Common_TypeDef;
45+
typedef struct
46+
{
47+
__io uint32 CSR; /*!< ADC Common status register, Address offset: ADC1 base address + 0x300 */
48+
__io uint32 CCR; /*!< ADC common control register, Address offset: ADC1 base address + 0x304 */
49+
__io uint32 CDR; /*!< ADC common regular data register for dual
50+
AND triple modes, Address offset: ADC1 base address + 0x308 */
51+
} ADC_Common_TypeDef;
5352
#define ADC_COMMON ((ADC_Common_TypeDef *) 0x40012300)
5453

55-
#endif
5654

5755
/** ADC register map type. */
5856
typedef struct adc_reg_map {
@@ -94,23 +92,12 @@ extern const adc_dev *ADC3;
9492
* Register map base pointers
9593
*/
9694

97-
#ifdef STM32F2
98-
/** ADC1 register map base pointer. */
99-
#define ADC1_BASE ((struct adc_reg_map*)0x40012000)
100-
/** ADC2 register map base pointer. */
101-
#define ADC2_BASE ((struct adc_reg_map*)0x40012100)
102-
/** ADC3 register map base pointer. */
103-
#define ADC3_BASE ((struct adc_reg_map*)0x40012200)
104-
#else
105-
/** ADC1 register map base pointer. */
106-
#define ADC1_BASE ((struct adc_reg_map*)0x40012400)
107-
/** ADC2 register map base pointer. */
108-
#define ADC2_BASE ((struct adc_reg_map*)0x40012800)
109-
#ifdef STM32_HIGH_DENSITY
110-
/** ADC3 register map base pointer. */
111-
#define ADC3_BASE ((struct adc_reg_map*)0x40013C00)
112-
#endif
113-
#endif
95+
/** ADC1 register map base pointer. */
96+
#define ADC1_BASE ((struct adc_reg_map*)0x40012000)
97+
/** ADC2 register map base pointer. */
98+
#define ADC2_BASE ((struct adc_reg_map*)0x40012100)
99+
/** ADC3 register map base pointer. */
100+
#define ADC3_BASE ((struct adc_reg_map*)0x40012200)
114101

115102
/*
116103
* Register bit definitions
@@ -167,17 +154,10 @@ extern const adc_dev *ADC3;
167154
#define ADC_CR2_JEXTTRIG_BIT 15
168155
#define ADC_CR2_EXTTRIG_BIT 20
169156
#define ADC_CR2_TSEREFE_BIT 23
170-
#ifdef STM32F2
171157
#define ADC_CR2_JSWSTART_BIT 22
172158
#define ADC_CR2_SWSTART_BIT 30
173159
#define ADC_CR2_EXTSEL (0x0F000000)
174160
#define ADC_CR2_JEXTSEL (0x000F0000)
175-
#else
176-
#define ADC_CR2_JSWSTART_BIT 21
177-
#define ADC_CR2_SWSTART_BIT 22
178-
#define ADC_CR2_EXTSEL (0x000E0000)
179-
#define ADC_CR2_JEXTSEL (0x00007000)
180-
#endif
181161

182162

183163

@@ -388,7 +368,7 @@ static inline void adc_disable_all(void) {
388368
adc_foreach(adc_disable);
389369
}
390370

391-
void setupADC_F2();
371+
extern void setupADC_F4(void);
392372

393373
#ifdef __cplusplus
394374
} // extern "C"

STM32F4/cores/maple/libmaple/dma.h

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -30,9 +30,4 @@
3030
* @brief Direct Memory Access peripheral support
3131
*/
3232

33-
#ifdef STM32F2
34-
#include "dmaF2.h"
35-
#include <libmaple/dma_common.h>
36-
#else
37-
#include "dmaF1.h"
38-
#endif
33+
#include "dmaF4.h"

STM32F4/cores/maple/libmaple/exti.h

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -52,11 +52,7 @@ typedef struct exti_reg_map {
5252
} exti_reg_map;
5353

5454
/** EXTI register map base pointer */
55-
#ifdef STM32F2
5655
#define EXTI_BASE ((struct exti_reg_map*)0x40013C00)
57-
#else
58-
#define EXTI_BASE ((struct exti_reg_map*)0x40010400)
59-
#endif
6056

6157
/** External interrupt trigger mode */
6258
typedef enum exti_trigger_mode {

STM32F4/cores/maple/libmaple/gpio.h

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -31,8 +31,5 @@
3131
* (AFIO) prototypes, defines, and inlined access functions.
3232
*/
3333

34-
#ifdef STM32F2
35-
#include "gpioF2.h"
36-
#else
37-
#include "gpioF1.h"
38-
#endif
34+
35+
#include "gpioF4.h"

0 commit comments

Comments
 (0)