Skip to content

DISCO_H747I: add support of MBED_TICKLESS #11950

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 6 commits into from
Nov 29, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 1 addition & 2 deletions features/mbedtls/targets/TARGET_STM/TARGET_STM32L4/aes_alt.c
Original file line number Diff line number Diff line change
Expand Up @@ -93,8 +93,7 @@ void mbedtls_aes_free(mbedtls_aes_context *ctx)
return;
}
#if defined(DUAL_CORE)
uint32_t timeout = HSEM_TIMEOUT;
while (LL_HSEM_1StepLock(HSEM, CFG_HW_RCC_SEMID) && (--timeout != 0)) {
while (LL_HSEM_1StepLock(HSEM, CFG_HW_RCC_SEMID)) {
}
#endif /* DUAL_CORE */
/* Force the CRYP Periheral Clock Reset */
Expand Down
8 changes: 8 additions & 0 deletions targets/TARGET_STM/TARGET_STM32F0/common_objects.h
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@
#include "PinNames.h"
#include "stm32f0xx_ll_usart.h"
#include "stm32f0xx_ll_tim.h"
#include "stm32f0xx_ll_pwr.h"

#ifdef __cplusplus
extern "C" {
Expand Down Expand Up @@ -119,6 +120,13 @@ struct analogin_s {
uint8_t channel;
};


#ifdef CRC_PROG_POLYNOMIAL_SUPPORT
#define HAL_CRC_IS_SUPPORTED(polynomial, width) ((width) == 7 || (width) == 8 || (width) == 16 || (width) == 32)
#else
#define HAL_CRC_IS_SUPPORTED(polynomial, width) ((width) == 32 && (polynomial) == 0x04C11DB7)
#endif

#include "gpio_object.h"

#if DEVICE_ANALOGOUT
Expand Down
1 change: 1 addition & 0 deletions targets/TARGET_STM/TARGET_STM32F1/common_objects.h
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@
#include "PinNames.h"
#include "stm32f1xx_ll_usart.h"
#include "stm32f1xx_ll_tim.h"
#include "stm32f1xx_ll_pwr.h"

#ifdef __cplusplus
extern "C" {
Expand Down
1 change: 1 addition & 0 deletions targets/TARGET_STM/TARGET_STM32F2/objects.h
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@
#include "PinNames.h"
#include "stm32f2xx_ll_usart.h"
#include "stm32f2xx_ll_tim.h"
#include "stm32f2xx_ll_pwr.h"

#ifdef __cplusplus
extern "C" {
Expand Down
1 change: 1 addition & 0 deletions targets/TARGET_STM/TARGET_STM32F3/common_objects.h
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@
#include "PinNames.h"
#include "stm32f3xx_ll_usart.h"
#include "stm32f3xx_ll_tim.h"
#include "stm32f3xx_ll_pwr.h"

#ifdef __cplusplus
extern "C" {
Expand Down
1 change: 1 addition & 0 deletions targets/TARGET_STM/TARGET_STM32F4/common_objects.h
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@
#include "PinNames.h"
#include "stm32f4xx_ll_usart.h"
#include "stm32f4xx_ll_tim.h"
#include "stm32f4xx_ll_pwr.h"

#ifdef __cplusplus
extern "C" {
Expand Down
1 change: 1 addition & 0 deletions targets/TARGET_STM/TARGET_STM32F7/common_objects.h
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@
#include "stm32f7xx_ll_tim.h"
#include "stm32f7xx_ll_adc.h"
#include "stm32f7xx_ll_rtc.h"
#include "stm32f7xx_ll_pwr.h"

#ifdef __cplusplus
extern "C" {
Expand Down
23 changes: 0 additions & 23 deletions targets/TARGET_STM/TARGET_STM32H7/TARGET_STM32H747xI/h747i_sleep.c

This file was deleted.

3 changes: 1 addition & 2 deletions targets/TARGET_STM/TARGET_STM32H7/analogin_device.c
Original file line number Diff line number Diff line change
Expand Up @@ -89,8 +89,7 @@ void analogin_init(analogin_t *obj, PinName pin)
PeriphClkInitStruct.AdcClockSelection = RCC_ADCCLKSOURCE_CLKP;
PeriphClkInitStruct.PLL2.PLL2P = 4;
#if defined(DUAL_CORE)
uint32_t timeout = HSEM_TIMEOUT;
while (LL_HSEM_1StepLock(HSEM, CFG_HW_RCC_SEMID) && (--timeout != 0)) {
while (LL_HSEM_1StepLock(HSEM, CFG_HW_RCC_SEMID)) {
}
#endif /* DUAL_CORE */
HAL_RCCEx_PeriphCLKConfig(&PeriphClkInitStruct);
Expand Down
14 changes: 13 additions & 1 deletion targets/TARGET_STM/TARGET_STM32H7/device/stm32h7xx_hal_rcc.c
Original file line number Diff line number Diff line change
Expand Up @@ -803,7 +803,19 @@ __weak HAL_StatusTypeDef HAL_RCC_OscConfig(RCC_OscInitTypeDef *RCC_OscInitStruc
}
else
{
return HAL_ERROR;
/* Do not return HAL_ERROR if request repeats the current configuration */
uint32_t temp1_pllckcfg = RCC->PLLCKSELR;
uint32_t temp2_pllckcfg = RCC->PLL1DIVR;
if(((RCC_OscInitStruct->PLL.PLLState) == RCC_PLL_OFF) ||
(READ_BIT(temp1_pllckcfg, RCC_PLLCKSELR_PLLSRC) != RCC_OscInitStruct->PLL.PLLSource) ||
((READ_BIT(temp1_pllckcfg, RCC_PLLCKSELR_DIVM1) >> RCC_PLLCKSELR_DIVM1_Pos) != RCC_OscInitStruct->PLL.PLLM) ||
(READ_BIT(temp2_pllckcfg, RCC_PLL1DIVR_N1) != (RCC_OscInitStruct->PLL.PLLN - 1U)) ||
((READ_BIT(temp2_pllckcfg, RCC_PLL1DIVR_P1) >> RCC_PLL1DIVR_P1_Pos) != (RCC_OscInitStruct->PLL.PLLP - 1U)) ||
((READ_BIT(temp2_pllckcfg, RCC_PLL1DIVR_Q1) >> RCC_PLL1DIVR_Q1_Pos) != (RCC_OscInitStruct->PLL.PLLQ - 1U)) ||
((READ_BIT(temp2_pllckcfg, RCC_PLL1DIVR_R1) >> RCC_PLL1DIVR_R1_Pos) != (RCC_OscInitStruct->PLL.PLLR - 1U)))
{
return HAL_ERROR;
}
}
}
return HAL_OK;
Expand Down
9 changes: 3 additions & 6 deletions targets/TARGET_STM/TARGET_STM32H7/flash_api.c
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,7 @@ static uint32_t GetSectorBase(uint32_t SectorId, uint32_t BanksId);
int32_t flash_init(flash_t *obj)
{
#if defined(DUAL_CORE)
uint32_t timeout = HSEM_TIMEOUT;
while (LL_HSEM_1StepLock(HSEM, CFG_HW_FLASH_SEMID) && (--timeout != 0)) {
while (LL_HSEM_1StepLock(HSEM, CFG_HW_FLASH_SEMID)) {
}
#endif /* DUAL_CORE */
/* Clear pending flags (if any) */
Expand Down Expand Up @@ -58,8 +57,7 @@ int32_t flash_erase_sector(flash_t *obj, uint32_t address)
}

#if defined(DUAL_CORE)
uint32_t timeout = HSEM_TIMEOUT;
while (LL_HSEM_1StepLock(HSEM, CFG_HW_FLASH_SEMID) && (--timeout != 0)) {
while (LL_HSEM_1StepLock(HSEM, CFG_HW_FLASH_SEMID)) {
}
#endif /* DUAL_CORE */
if (HAL_FLASH_Unlock() != HAL_OK) {
Expand Down Expand Up @@ -121,8 +119,7 @@ int32_t flash_program_page(flash_t *obj, uint32_t address, const uint8_t *data,
}

#if defined(DUAL_CORE)
uint32_t timeout = HSEM_TIMEOUT;
while (LL_HSEM_1StepLock(HSEM, CFG_HW_FLASH_SEMID) && (--timeout != 0)) {
while (LL_HSEM_1StepLock(HSEM, CFG_HW_FLASH_SEMID)) {
}
#endif /* DUAL_CORE */
if (HAL_FLASH_Unlock() != HAL_OK) {
Expand Down
6 changes: 3 additions & 3 deletions targets/TARGET_STM/TARGET_STM32H7/objects.h
Original file line number Diff line number Diff line change
Expand Up @@ -40,9 +40,9 @@
#if defined(DUAL_CORE)
#include "stm32h7xx_ll_hsem.h"
#include "stm32h7xx_ll_rcc.h"
#include "stm32h7xx_ll_pwr.h"
#include "stm32h7xx_ll_cortex.h"
#endif /* CONFIG_STM32H7_DUAL_CORE */
#include "stm32h7xx_ll_pwr.h"

#ifdef __cplusplus
extern "C" {
Expand Down Expand Up @@ -151,8 +151,8 @@ struct analogin_s {
#if defined(DUAL_CORE)
/* HW semaphore Complement ID list defined in hw_conf.h from STM32WB */
/* Index of the semaphore used to manage the entry Stop Mode procedure */
#define CFG_HW_ENTRY_STOP_MODE_SEMID 4
#define CFG_HW_ENTRY_STOP_MODE_MASK_SEMID (1 << CFG_HW_ENTRY_STOP_MODE_SEMID)
#define CFG_HW_STOP_MODE_SEMID 4
#define CFG_HW_STOP_MODE_MASK_SEMID (1 << CFG_HW_STOP_MODE_SEMID)

/* Index of the semaphore used to access the RCC */
#define CFG_HW_RCC_SEMID 3
Expand Down
6 changes: 2 additions & 4 deletions targets/TARGET_STM/TARGET_STM32H7/pin_device.h
Original file line number Diff line number Diff line change
Expand Up @@ -45,8 +45,7 @@ static inline void stm_pin_DisconnectDebug(PinName pin)
static inline void stm_pin_PullConfig(GPIO_TypeDef *gpio, uint32_t ll_pin, uint32_t pull_config)
{
#if defined(DUAL_CORE)
uint32_t timeout = HSEM_TIMEOUT;
while (LL_HSEM_1StepLock(HSEM, CFG_HW_GPIO_SEMID) && (--timeout != 0)) {
while (LL_HSEM_1StepLock(HSEM, CFG_HW_GPIO_SEMID)) {
}
#endif /* DUAL_CORE */

Expand All @@ -72,8 +71,7 @@ static inline void stm_pin_SetAFPin(GPIO_TypeDef *gpio, PinName pin, uint32_t af
uint32_t ll_pin = ll_pin_defines[STM_PIN(pin)];

#if defined(DUAL_CORE)
uint32_t timeout = HSEM_TIMEOUT;
while (LL_HSEM_1StepLock(HSEM, CFG_HW_GPIO_SEMID) && (--timeout != 0)) {
while (LL_HSEM_1StepLock(HSEM, CFG_HW_GPIO_SEMID)) {
}
#endif /* DUAL_CORE */

Expand Down
1 change: 1 addition & 0 deletions targets/TARGET_STM/TARGET_STM32L0/common_objects.h
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@
#include "PinNames.h"
#include "stm32l0xx_ll_usart.h"
#include "stm32l0xx_ll_tim.h"
#include "stm32l0xx_ll_pwr.h"

#ifdef __cplusplus
extern "C" {
Expand Down
1 change: 1 addition & 0 deletions targets/TARGET_STM/TARGET_STM32L1/common_objects.h
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@
#include "PinNames.h"
#include "stm32l1xx_ll_usart.h"
#include "stm32l1xx_ll_tim.h"
#include "stm32l1xx_ll_pwr.h"

#ifdef __cplusplus
extern "C" {
Expand Down
1 change: 1 addition & 0 deletions targets/TARGET_STM/TARGET_STM32L4/common_objects.h
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@
#include "stm32l4xx_ll_lpuart.h"
#include "stm32l4xx_ll_tim.h"
#include "stm32l4xx_ll_rtc.h"
#include "stm32l4xx_ll_pwr.h"

#ifdef __cplusplus
extern "C" {
Expand Down
1 change: 1 addition & 0 deletions targets/TARGET_STM/TARGET_STM32WB/common_objects.h
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@
#include "PinNames.h"
#include "stm32wbxx_ll_usart.h"
#include "stm32wbxx_ll_tim.h"
#include "stm32wbxx_ll_pwr.h"

#ifdef __cplusplus
extern "C" {
Expand Down
9 changes: 3 additions & 6 deletions targets/TARGET_STM/can_api.c
Original file line number Diff line number Diff line change
Expand Up @@ -91,8 +91,7 @@ void can_init_freq(can_t *obj, PinName rd, PinName td, int hz)
RCC_PeriphClkInit.PeriphClockSelection = RCC_PERIPHCLK_FDCAN;
RCC_PeriphClkInit.FdcanClockSelection = RCC_FDCANCLKSOURCE_PLL; // 10 MHz (RCC_OscInitStruct.PLL.PLLQ = 80)
#if defined(DUAL_CORE)
uint32_t timeout = HSEM_TIMEOUT;
while (LL_HSEM_1StepLock(HSEM, CFG_HW_RCC_SEMID) && (--timeout != 0)) {
while (LL_HSEM_1StepLock(HSEM, CFG_HW_RCC_SEMID)) {
}
#endif /* DUAL_CORE */
if (HAL_RCCEx_PeriphCLKConfig(&RCC_PeriphClkInit) != HAL_OK) {
Expand Down Expand Up @@ -190,8 +189,7 @@ void can_irq_free(can_t *obj)
void can_free(can_t *obj)
{
#if defined(DUAL_CORE)
uint32_t timeout = HSEM_TIMEOUT;
while (LL_HSEM_1StepLock(HSEM, CFG_HW_RCC_SEMID) && (--timeout != 0)) {
while (LL_HSEM_1StepLock(HSEM, CFG_HW_RCC_SEMID)) {
}
#endif /* DUAL_CORE */
__HAL_RCC_FDCAN_FORCE_RESET();
Expand Down Expand Up @@ -638,8 +636,7 @@ void can_free(can_t *obj)
{
CANName can = (CANName) obj->CanHandle.Instance;
#if defined(DUAL_CORE)
uint32_t timeout = HSEM_TIMEOUT;
while (LL_HSEM_1StepLock(HSEM, CFG_HW_RCC_SEMID) && (--timeout != 0)) {
while (LL_HSEM_1StepLock(HSEM, CFG_HW_RCC_SEMID)) {
}
#endif /* DUAL_CORE */
// Reset CAN and disable clock
Expand Down
3 changes: 1 addition & 2 deletions targets/TARGET_STM/gpio_api.c
Original file line number Diff line number Diff line change
Expand Up @@ -156,8 +156,7 @@ void gpio_mode(gpio_t *obj, PinMode mode)
inline void gpio_dir(gpio_t *obj, PinDirection direction)
{
#if defined(DUAL_CORE)
uint32_t timeout = HSEM_TIMEOUT;
while (LL_HSEM_1StepLock(HSEM, CFG_HW_GPIO_SEMID) && (--timeout != 0)) {
while (LL_HSEM_1StepLock(HSEM, CFG_HW_GPIO_SEMID)) {
}
#endif /* DUAL_CORE */

Expand Down
3 changes: 1 addition & 2 deletions targets/TARGET_STM/gpio_object.h
Original file line number Diff line number Diff line change
Expand Up @@ -58,8 +58,7 @@ typedef struct {
static inline void gpio_write(gpio_t *obj, int value)
{
#if defined(DUAL_CORE)
uint32_t timeout = HSEM_TIMEOUT;
while (LL_HSEM_1StepLock(HSEM, CFG_HW_GPIO_SEMID) && (--timeout != 0)) {
while (LL_HSEM_1StepLock(HSEM, CFG_HW_GPIO_SEMID)) {
}
#endif /* DUAL_CORE */

Expand Down
6 changes: 2 additions & 4 deletions targets/TARGET_STM/i2c_api.c
Original file line number Diff line number Diff line change
Expand Up @@ -215,8 +215,7 @@ void i2c_hw_reset(i2c_t *obj)
timeout = BYTE_TIMEOUT;
while ((__HAL_I2C_GET_FLAG(handle, I2C_FLAG_BUSY)) && (--timeout != 0));
#if defined(DUAL_CORE)
timeout = HSEM_TIMEOUT;
while (LL_HSEM_1StepLock(HSEM, CFG_HW_RCC_SEMID) && (--timeout != 0)) {
while (LL_HSEM_1StepLock(HSEM, CFG_HW_RCC_SEMID)) {
}
#endif /* DUAL_CORE */
#if defined I2C1_BASE
Expand Down Expand Up @@ -422,8 +421,7 @@ void i2c_frequency(i2c_t *obj, int hz)

/*##-1- Configure the I2C clock source. The clock is derived from the SYSCLK #*/
#if defined(DUAL_CORE)
timeout = HSEM_TIMEOUT;
while (LL_HSEM_1StepLock(HSEM, CFG_HW_RCC_SEMID) && (--timeout != 0)) {
while (LL_HSEM_1StepLock(HSEM, CFG_HW_RCC_SEMID)) {
}
#endif /* DUAL_CORE */
#if defined(I2C1_BASE) && defined (__HAL_RCC_I2C1_CONFIG)
Expand Down
21 changes: 19 additions & 2 deletions targets/TARGET_STM/lp_ticker.c
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,13 @@
#define LPTIM_MST_IRQ LPTIM4_IRQn
#define LPTIM_MST_RCC __HAL_RCC_LPTIM4_CLK_ENABLE

#define LPTIM_MST_RCC_CLKAM __HAL_RCC_LPTIM4_CLKAM_ENABLE

/* Enable LPTIM wakeup source but only for current core, and disable it for the other core */
#define LPTIM_MST_EXTI_LPTIM_WAKEUP_CONFIG() {\
HAL_EXTI_D1_EventInputConfig(EXTI_LINE52, EXTI_MODE_IT, ENABLE);\
HAL_EXTI_D2_EventInputConfig(EXTI_LINE52, EXTI_MODE_IT, DISABLE);\
}
#define LPTIM_MST_RESET_ON __HAL_RCC_LPTIM4_FORCE_RESET
#define LPTIM_MST_RESET_OFF __HAL_RCC_LPTIM4_RELEASE_RESET

Expand All @@ -85,6 +92,13 @@
#define LPTIM_MST_IRQ LPTIM5_IRQn
#define LPTIM_MST_RCC __HAL_RCC_LPTIM5_CLK_ENABLE

#define LPTIM_MST_RCC_CLKAM __HAL_RCC_LPTIM5_CLKAM_ENABLE

/* Enable LPTIM wakeup source but only for current core, and disable it for the other core */
#define LPTIM_MST_EXTI_LPTIM_WAKEUP_CONFIG() {\
HAL_EXTI_D2_EventInputConfig(EXTI_LINE53, EXTI_MODE_IT, ENABLE);\
HAL_EXTI_D1_EventInputConfig(EXTI_LINE53, EXTI_MODE_IT, DISABLE);\
}
#define LPTIM_MST_RESET_ON __HAL_RCC_LPTIM5_FORCE_RESET
#define LPTIM_MST_RESET_OFF __HAL_RCC_LPTIM5_RELEASE_RESET
#else
Expand Down Expand Up @@ -191,8 +205,7 @@ void lp_ticker_init(void)

#endif /* MBED_CONF_TARGET_LSE_AVAILABLE */
#if defined(DUAL_CORE)
uint32_t timeout = HSEM_TIMEOUT;
while (LL_HSEM_1StepLock(HSEM, CFG_HW_RCC_SEMID) && (--timeout != 0)) {
while (LL_HSEM_1StepLock(HSEM, CFG_HW_RCC_SEMID)) {
}
#endif /* DUAL_CORE */
if (HAL_RCC_OscConfig(&RCC_OscInitStruct) != HAL_OK) {
Expand All @@ -209,6 +222,10 @@ void lp_ticker_init(void)
LPTIM_MST_RESET_ON();
LPTIM_MST_RESET_OFF();
#if defined(DUAL_CORE)
/* Configure EXTI wakeup and configure autonomous mode */
LPTIM_MST_RCC_CLKAM();
LPTIM_MST_EXTI_LPTIM_WAKEUP_CONFIG();

LL_HSEM_ReleaseLock(HSEM, CFG_HW_RCC_SEMID, HSEM_CR_COREID_CURRENT);
#endif /* DUAL_CORE */

Expand Down
9 changes: 5 additions & 4 deletions targets/TARGET_STM/mbed_overrides.c
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ void mbed_sdk_init()
/* CM4 boots at the same time than CM7. It is necessary to synchronize with CM7, by mean of HSEM, that CM7 finishes its initialization. */

/* Activate HSEM notification for Cortex-M4*/
LL_HSEM_EnableIT_C2IER(HSEM, CFG_HW_ENTRY_STOP_MODE_MASK_SEMID);
LL_HSEM_EnableIT_C2IER(HSEM, CFG_HW_STOP_MODE_MASK_SEMID);

/*
* Domain D2 goes to STOP mode (Cortex-M4 in deep-sleep) waiting for
Expand Down Expand Up @@ -89,7 +89,8 @@ void mbed_sdk_init()
LL_LPM_EnableSleep();

/* Clear HSEM flag */
LL_HSEM_ClearFlag_C2ICR(HSEM, CFG_HW_ENTRY_STOP_MODE_MASK_SEMID);
LL_HSEM_DisableIT_C2IER(HSEM, CFG_HW_STOP_MODE_MASK_SEMID);
LL_HSEM_ClearFlag_C2ICR(HSEM, CFG_HW_STOP_MODE_MASK_SEMID);
}

// Update the SystemCoreClock variable.
Expand All @@ -109,9 +110,9 @@ void mbed_sdk_init()
/* Check wether CM4 boot in parallel with CM7. If CM4 was gated but CM7 trigger the CM4 boot. No need to wait for synchronization.
otherwise CM7 should wakeup CM4 when system clocks initialization is done. */
if (READ_BIT(SYSCFG->UR1, SYSCFG_UR1_BCM4)) {
LL_HSEM_1StepLock(HSEM, CFG_HW_ENTRY_STOP_MODE_SEMID);
LL_HSEM_1StepLock(HSEM, CFG_HW_STOP_MODE_SEMID);
/*Release HSEM in order to notify the CPU2(CM4)*/
LL_HSEM_ReleaseLock(HSEM, CFG_HW_ENTRY_STOP_MODE_SEMID, 0);
LL_HSEM_ReleaseLock(HSEM, CFG_HW_STOP_MODE_SEMID, 0);
} else {
LL_RCC_ForceCM4Boot();
}
Expand Down
Loading