Skip to content

Commit 8f59bac

Browse files
dhylandsdpgeorge
authored andcommitted
stamhal: Add definitions for MCU_SERIES_F4 and MCU_SERIES_F7
1 parent be66a9e commit 8f59bac

File tree

10 files changed

+23
-25
lines changed

10 files changed

+23
-25
lines changed

stmhal/Makefile

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -45,8 +45,8 @@ INC += -I../lib/netutils
4545
INC += -I../lib/timeutils
4646

4747
CFLAGS_CORTEX_M = -mthumb -mabi=aapcs-linux -mfpu=fpv4-sp-d16 -mfloat-abi=hard -fsingle-precision-constant -Wdouble-promotion
48-
CFLAGS_MCU_f4 = $(CFLAGS_CORTEX_M) -mtune=cortex-m4 -mcpu=cortex-m4
49-
CFLAGS_MCU_f7 = $(CFLAGS_CORTEX_M) -mtune=cortex-m7 -mcpu=cortex-m7
48+
CFLAGS_MCU_f4 = $(CFLAGS_CORTEX_M) -mtune=cortex-m4 -mcpu=cortex-m4 -DMCU_SERIES_F4
49+
CFLAGS_MCU_f7 = $(CFLAGS_CORTEX_M) -mtune=cortex-m7 -mcpu=cortex-m7 -DMCU_SERIES_F7
5050

5151
CFLAGS = $(INC) -Wall -Wpointer-arith -Werror -ansi -std=gnu99 -nostdlib $(CFLAGS_MOD)
5252
CFLAGS += $(CFLAGS_MCU_$(MCU_SERIES))

stmhal/extint.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -188,7 +188,7 @@ void extint_enable(uint line) {
188188
if (line >= EXTI_NUM_VECTORS) {
189189
return;
190190
}
191-
#if defined(STM32F7)
191+
#if defined(MCU_SERIES_F7)
192192
// The Cortex-M7 doesn't have bitband support.
193193
mp_uint_t irq_state = disable_irq();
194194
if (pyb_extint_mode[line] == EXTI_Mode_Interrupt) {
@@ -210,7 +210,7 @@ void extint_disable(uint line) {
210210
return;
211211
}
212212

213-
#if defined(STM32F7)
213+
#if defined(MCU_SERIES_F7)
214214
// The Cortex-M7 doesn't have bitband support.
215215
mp_uint_t irq_state = disable_irq();
216216
EXTI->IMR &= ~(1 << line);

stmhal/extint.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@
3636
#define EXTI_USB_OTG_HS_WAKEUP (20)
3737
#define EXTI_RTC_TIMESTAMP (21)
3838
#define EXTI_RTC_WAKEUP (22)
39-
#if defined(STM32F7)
39+
#if defined(MCU_SERIES_F7)
4040
#define EXTI_LPTIM1_ASYNC_EVENT (23)
4141
#endif
4242

stmhal/flash.c

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -28,13 +28,11 @@
2828

2929
#include "flash.h"
3030

31-
#if defined(STM32F7)
31+
#if defined(MCU_SERIES_F7)
32+
3233
// FLASH_FLAG_PGSERR (Programming Sequence Error) was renamed to
3334
// FLASH_FLAG_ERSERR (Erasing Sequence Error) in STM32F7
3435
#define FLASH_FLAG_PGSERR FLASH_FLAG_ERSERR
35-
#endif
36-
37-
#if defined(STM32F7)
3836

3937
/* Base address of the Flash sectors */
4038
#define ADDR_FLASH_SECTOR_0 ((uint32_t)0x08000000) /* Base @ of Sector 0, 32 Kbytes */
@@ -68,7 +66,7 @@
6866
#define ADDR_FLASH_END ((uint32_t)0x08100000) /* 1 Mbytes total */
6967
#endif
7068

71-
#endif
69+
#endif // MCU_SERIES_F7
7270

7371
static const uint32_t flash_info_table[26] = {
7472
ADDR_FLASH_SECTOR_0, FLASH_SECTOR_0,

stmhal/modpyb.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,7 @@ STATIC NORETURN mp_obj_t pyb_bootloader(void) {
7474
HAL_RCC_DeInit();
7575
HAL_DeInit();
7676

77-
#if defined(STM32F7)
77+
#if defined(MCU_SERIES_F7)
7878
// arm-none-eabi-gcc 4.9.0 does not correctly inline this
7979
// MSP function, so we write it out explicitly here.
8080
//__set_MSP(*((uint32_t*) 0x1FF00000));
@@ -462,7 +462,7 @@ MP_DEFINE_CONST_FUN_OBJ_0(pyb_stop_obj, pyb_stop);
462462

463463
/// \function standby()
464464
STATIC mp_obj_t pyb_standby(void) {
465-
#if defined(STM32F7)
465+
#if defined(MCU_SERIES_F7)
466466
printf("pyb.standby not supported yet\n");
467467
#else
468468
// We need to clear the PWR wake-up-flag before entering standby, since

stmhal/mpconfigport.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -135,7 +135,7 @@ extern const struct _mp_obj_module_t mp_module_network;
135135
{ MP_OBJ_NEW_QSTR(MP_QSTR_pyb), (mp_obj_t)&pyb_module }, \
136136
{ MP_OBJ_NEW_QSTR(MP_QSTR_stm), (mp_obj_t)&stm_module }, \
137137

138-
#if defined(STM32F7)
138+
#if defined(MCU_SERIES_F7)
139139
#define PYB_EXTI_NUM_VECTORS (24)
140140
#else
141141
#define PYB_EXTI_NUM_VECTORS (23)

stmhal/mphal.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33

44
// Basic GPIO functions
55
#define GPIO_read_pin(gpio, pin) (((gpio)->IDR >> (pin)) & 1)
6-
#if defined(STM32F7)
6+
#if defined(MCU_SERIES_F7)
77
#define GPIO_set_pin(gpio, pin_mask) (((gpio)->BSRR) = (pin_mask))
88
#define GPIO_clear_pin(gpio, pin_mask) (((gpio)->BSRR) = ((pin_mask) << 16))
99
#else

stmhal/startup_stm32.S

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@
4444
*/
4545

4646
.syntax unified
47-
#if STM32F7
47+
#if defined(MCU_SERIES_M7)
4848
.cpu cortex-m7
4949
#else
5050
.cpu cortex-m4
@@ -211,7 +211,7 @@ g_pfnVectors:
211211
.word TIM8_TRG_COM_TIM14_IRQHandler /* TIM8 Trigger and Commutation and TIM14 */
212212
.word TIM8_CC_IRQHandler /* TIM8 Capture Compare */
213213
.word DMA1_Stream7_IRQHandler /* DMA1 Stream7 */
214-
#if defined(STM32F7)
214+
#if defined(MCU_SERIES_F7)
215215
.word FMC_IRQHandler /* FMC */
216216
.word SDMMC1_IRQHandler /* SDMMC1 */
217217
#else
@@ -251,7 +251,7 @@ g_pfnVectors:
251251
.word HASH_RNG_IRQHandler /* Hash and Rng */
252252
.word FPU_IRQHandler /* FPU */
253253

254-
#if defined(STM32F7)
254+
#if defined(MCU_SERIES_F7)
255255
.word UART7_IRQHandler /* UART7 */
256256
.word UART8_IRQHandler /* UART8 */
257257
.word SPI4_IRQHandler /* SPI4 */
@@ -448,7 +448,7 @@ g_pfnVectors:
448448
.weak DMA1_Stream7_IRQHandler
449449
.thumb_set DMA1_Stream7_IRQHandler,Default_Handler
450450

451-
#if defined(STM32F7)
451+
#if defined(MCU_SERIES_F7)
452452
.weak FMC_IRQHandler
453453
.thumb_set FMC_IRQHandler,Default_Handler
454454

@@ -554,7 +554,7 @@ g_pfnVectors:
554554

555555
.weak FPU_IRQHandler
556556
.thumb_set FPU_IRQHandler,Default_Handler
557-
#if defined(STM32F7)
557+
#if defined(MCU_SERIES_F7)
558558
.weak UART7_IRQHandler
559559
.thumb_set UART7_IRQHandler,Default_Handler
560560

stmhal/system_stm32.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -283,7 +283,7 @@ void SystemClock_Config(void)
283283
__fatal_error("HAL_RCC_OscConfig");
284284
}
285285

286-
#if defined(STM32F7)
286+
#if defined(MCU_SERIES_F7)
287287
/* Activate the OverDrive to reach the 200 MHz Frequency */
288288
if (HAL_PWREx_EnableOverDrive() != HAL_OK)
289289
{
@@ -308,7 +308,7 @@ void SystemClock_Config(void)
308308
__fatal_error("HAL_RCC_ClockConfig");
309309
}
310310

311-
#if defined(STM32F7)
311+
#if defined(MCU_SERIES_F7)
312312
// The DFU bootloader changes the clocksource register from its default power
313313
// on reset value, so we set it back here, so the clocksources are the same
314314
// whether we were started from DFU or from a power on reset.

stmhal/uart.c

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@
3636
#include "pybioctl.h"
3737
#include MICROPY_HAL_H
3838

39-
//TODO: Add UART7/8 support for STM32F7
39+
//TODO: Add UART7/8 support for MCU_SERIES_F7
4040

4141
/// \moduleref pyb
4242
/// \class UART - duplex serial communication bus
@@ -316,7 +316,7 @@ int uart_rx_char(pyb_uart_obj_t *self) {
316316
return data;
317317
} else {
318318
// no buffering
319-
#if defined(STM32F7)
319+
#if defined(MCU_SERIES_F7)
320320
return self->uart.Instance->RDR & self->char_mask;
321321
#else
322322
return self->uart.Instance->DR & self->char_mask;
@@ -354,7 +354,7 @@ void uart_irq_handler(mp_uint_t uart_id) {
354354
}
355355

356356
if (__HAL_UART_GET_FLAG(&self->uart, UART_FLAG_RXNE) != RESET) {
357-
#if defined(STM32F7)
357+
#if defined(MCU_SERIES_F7)
358358
int data = self->uart.Instance->RDR; // clears UART_FLAG_RXNE
359359
#else
360360
int data = self->uart.Instance->DR; // clears UART_FLAG_RXNE
@@ -714,7 +714,7 @@ STATIC MP_DEFINE_CONST_FUN_OBJ_1(pyb_uart_readchar_obj, pyb_uart_readchar);
714714
// uart.sendbreak()
715715
STATIC mp_obj_t pyb_uart_sendbreak(mp_obj_t self_in) {
716716
pyb_uart_obj_t *self = self_in;
717-
#if defined(STM32F7)
717+
#if defined(MCU_SERIES_F7)
718718
self->uart.Instance->RQR = USART_RQR_SBKRQ; // write-only register
719719
#else
720720
self->uart.Instance->CR1 |= USART_CR1_SBK;

0 commit comments

Comments
 (0)