Skip to content

Commit 73e8b7e

Browse files
committed
stm32: Update components to work with new H7xx HAL.
1 parent 9083166 commit 73e8b7e

File tree

7 files changed

+13
-7
lines changed

7 files changed

+13
-7
lines changed

ports/stm32/adc.c

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -110,7 +110,6 @@
110110
#define ADC_CAL1 ((uint16_t*)(0x1FF1E820))
111111
#define ADC_CAL2 ((uint16_t*)(0x1FF1E840))
112112
#define ADC_CAL_BITS (16)
113-
#define ADC_CHANNEL_VBAT ADC_CHANNEL_VBAT_DIV4
114113

115114
#elif defined(STM32L4)
116115

@@ -247,7 +246,6 @@ STATIC void adcx_init_periph(ADC_HandleTypeDef *adch, uint32_t resolution) {
247246
adch->Init.DMAContinuousRequests = DISABLE;
248247
#elif defined(STM32H7)
249248
adch->Init.ClockPrescaler = ADC_CLOCK_SYNC_PCLK_DIV4;
250-
adch->Init.BoostMode = ENABLE;
251249
adch->Init.ScanConvMode = DISABLE;
252250
adch->Init.LowPowerAutoWait = DISABLE;
253251
adch->Init.Overrun = ADC_OVR_DATA_OVERWRITTEN;

ports/stm32/boards/stm32h7xx_hal_conf_base.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@
2828

2929
// Include various HAL modules for convenience
3030
#include "stm32h7xx_hal_dma.h"
31+
#include "stm32h7xx_hal_mdma.h"
3132
#include "stm32h7xx_hal_adc.h"
3233
#include "stm32h7xx_hal_cortex.h"
3334
#include "stm32h7xx_hal_crc.h"

ports/stm32/mphalport.h

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -63,13 +63,8 @@ static inline mp_uint_t mp_hal_ticks_cpu(void) {
6363
#define mp_hal_pin_input(p) mp_hal_pin_config((p), MP_HAL_PIN_MODE_INPUT, MP_HAL_PIN_PULL_NONE, 0)
6464
#define mp_hal_pin_output(p) mp_hal_pin_config((p), MP_HAL_PIN_MODE_OUTPUT, MP_HAL_PIN_PULL_NONE, 0)
6565
#define mp_hal_pin_open_drain(p) mp_hal_pin_config((p), MP_HAL_PIN_MODE_OPEN_DRAIN, MP_HAL_PIN_PULL_NONE, 0)
66-
#if defined(STM32H7)
67-
#define mp_hal_pin_high(p) (((p)->gpio->BSRRL) = (p)->pin_mask)
68-
#define mp_hal_pin_low(p) (((p)->gpio->BSRRH) = (p)->pin_mask)
69-
#else
7066
#define mp_hal_pin_high(p) (((p)->gpio->BSRR) = (p)->pin_mask)
7167
#define mp_hal_pin_low(p) (((p)->gpio->BSRR) = ((p)->pin_mask << 16))
72-
#endif
7368
#define mp_hal_pin_od_low(p) mp_hal_pin_low(p)
7469
#define mp_hal_pin_od_high(p) mp_hal_pin_high(p)
7570
#define mp_hal_pin_read(p) (((p)->gpio->IDR >> (p)->pin) & 1)

ports/stm32/stm32_it.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -378,8 +378,10 @@ void OTG_FS_WKUP_IRQHandler(void) {
378378

379379
OTG_CMD_WKUP_Handler(&pcd_fs_handle);
380380

381+
#if !defined(STM32H7)
381382
/* Clear EXTI pending Bit*/
382383
__HAL_USB_FS_EXTI_CLEAR_FLAG();
384+
#endif
383385

384386
IRQ_EXIT(OTG_FS_WKUP_IRQn);
385387
}

ports/stm32/uart.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,8 @@
4040

4141
#if defined(STM32F4)
4242
#define UART_RXNE_IS_SET(uart) ((uart)->SR & USART_SR_RXNE)
43+
#elif defined(STM32H7)
44+
#define UART_RXNE_IS_SET(uart) ((uart)->ISR & USART_ISR_RXNE_RXFNE)
4345
#else
4446
#define UART_RXNE_IS_SET(uart) ((uart)->ISR & USART_ISR_RXNE)
4547
#endif

ports/stm32/uart.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -88,6 +88,8 @@ void uart_tx_strn(pyb_uart_obj_t *uart_obj, const char *str, uint len);
8888
static inline bool uart_tx_avail(pyb_uart_obj_t *self) {
8989
#if defined(STM32F4)
9090
return self->uartx->SR & USART_SR_TXE;
91+
#elif defined(STM32H7)
92+
return self->uartx->ISR & USART_ISR_TXE_TXFNF;
9193
#else
9294
return self->uartx->ISR & USART_ISR_TXE;
9395
#endif

ports/stm32/usbdev/class/src/usbd_cdc_msc_hid.c

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1129,6 +1129,9 @@ uint8_t USBD_HID_SetNAK(usbd_hid_state_t *hid) {
11291129
// get USBx object from pdev (needed for USBx_OUTEP macro below)
11301130
PCD_HandleTypeDef *hpcd = hid->usbd->pdev->pData;
11311131
USB_OTG_GlobalTypeDef *USBx = hpcd->Instance;
1132+
#if defined(STM32H7)
1133+
uint32_t USBx_BASE = (uint32_t)USBx;
1134+
#endif
11321135
// set NAK on HID OUT endpoint
11331136
USBx_OUTEP(HID_OUT_EP_WITH_CDC)->DOEPCTL |= USB_OTG_DOEPCTL_SNAK;
11341137
return USBD_OK;
@@ -1138,6 +1141,9 @@ uint8_t USBD_HID_ClearNAK(usbd_hid_state_t *hid) {
11381141
// get USBx object from pdev (needed for USBx_OUTEP macro below)
11391142
PCD_HandleTypeDef *hpcd = hid->usbd->pdev->pData;
11401143
USB_OTG_GlobalTypeDef *USBx = hpcd->Instance;
1144+
#if defined(STM32H7)
1145+
uint32_t USBx_BASE = (uint32_t)USBx;
1146+
#endif
11411147
// clear NAK on HID OUT endpoint
11421148
USBx_OUTEP(HID_OUT_EP_WITH_CDC)->DOEPCTL |= USB_OTG_DOEPCTL_CNAK;
11431149
return USBD_OK;

0 commit comments

Comments
 (0)