You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@mynewt.apache.org by ut...@apache.org on 2018/03/15 16:58:21 UTC
[mynewt-core] 01/03: Add stm32f3 to stm32_common HAL
This is an automated email from the ASF dual-hosted git repository.
utzig pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/mynewt-core.git
commit 86c41078bf30ce1f14426bf392b384b16e84d03f
Author: Fabio Utzig <ut...@apache.org>
AuthorDate: Mon Mar 12 20:24:18 2018 -0300
Add stm32f3 to stm32_common HAL
Also update all models to use hw unique id macro from ext.
---
hw/mcu/stm/stm32_common/src/stm32_hw_id.c | 2 +-
hw/mcu/stm/stm32f1xx/include/mcu/stm32_hal.h | 7 ---
.../include/mcu/stm32_hal.h | 19 ++-----
hw/mcu/stm/stm32f3xx/pkg.yml | 2 +-
hw/mcu/stm/stm32f3xx/src/hal_os_tick.c | 55 --------------------
hw/mcu/stm/stm32f3xx/src/hal_system.c | 43 ----------------
hw/mcu/stm/stm32f3xx/src/hal_system_start.c | 55 --------------------
hw/mcu/stm/stm32f3xx/src/hal_watchdog.c | 60 ----------------------
hw/mcu/stm/stm32f3xx/src/stm32f3xx_hw_id.c | 49 ------------------
hw/mcu/stm/stm32f4xx/include/mcu/stm32_hal.h | 7 ---
hw/mcu/stm/stm32f7xx/include/mcu/stm32_hal.h | 7 ---
hw/mcu/stm/stm32l1xx/include/mcu/stm32_hal.h | 8 ---
12 files changed, 7 insertions(+), 307 deletions(-)
diff --git a/hw/mcu/stm/stm32_common/src/stm32_hw_id.c b/hw/mcu/stm/stm32_common/src/stm32_hw_id.c
index 4dad67a..333138b 100644
--- a/hw/mcu/stm/stm32_common/src/stm32_hw_id.c
+++ b/hw/mcu/stm/stm32_common/src/stm32_hw_id.c
@@ -33,7 +33,7 @@ hal_bsp_hw_id(uint8_t *id, int max_len)
int cnt;
cnt = min(12, max_len);
- memcpy(id, (void *)STM32_HW_ID_ADDR, cnt);
+ memcpy(id, (void *)UID_BASE, cnt);
return cnt;
}
diff --git a/hw/mcu/stm/stm32f1xx/include/mcu/stm32_hal.h b/hw/mcu/stm/stm32f1xx/include/mcu/stm32_hal.h
index 9dc7e87..3685e62 100644
--- a/hw/mcu/stm/stm32f1xx/include/mcu/stm32_hal.h
+++ b/hw/mcu/stm/stm32f1xx/include/mcu/stm32_hal.h
@@ -36,13 +36,6 @@ extern "C" {
/* hal_system_start */
#define STM32_HAL_FLASH_REMAP()
-/* stm32_hw_id
- *
- * STM32F1 has a unique 96-bit id at address 0x1FFFF7E8.
- * See ref manual chapter 30.2.
- */
-#define STM32_HW_ID_ADDR 0x1FFFF7E8
-
#ifdef __cplusplus
}
#endif
diff --git a/hw/mcu/stm/stm32f7xx/include/mcu/stm32_hal.h b/hw/mcu/stm/stm32f3xx/include/mcu/stm32_hal.h
similarity index 75%
copy from hw/mcu/stm/stm32f7xx/include/mcu/stm32_hal.h
copy to hw/mcu/stm/stm32f3xx/include/mcu/stm32_hal.h
index 9187517..63b9ca8 100644
--- a/hw/mcu/stm/stm32f7xx/include/mcu/stm32_hal.h
+++ b/hw/mcu/stm/stm32f3xx/include/mcu/stm32_hal.h
@@ -24,13 +24,13 @@
extern "C" {
#endif
-#include <mcu/cortex_m7.h>
+#include <mcu/cortex_m4.h>
-#include "stm32f7xx_hal.h"
-#include "stm32f7xx_hal_def.h"
+#include "stm32f3xx_hal.h"
+#include "stm32f3xx_hal_def.h"
/* hal_watchdog */
-#include "stm32f7xx_hal_iwdg.h"
+#include "stm32f3xx_hal_iwdg.h"
#define STM32_HAL_WATCHDOG_CUSTOM_INIT(x) \
do { \
(x)->Init.Window = IWDG_WINDOW_DISABLE; \
@@ -39,18 +39,9 @@ extern "C" {
/* hal_system_start */
#define STM32_HAL_FLASH_REMAP() \
do { \
- SYSCFG->MEMRMP = 0; \
- SCB_InvalidateICache(); \
- __DSB(); \
+ __HAL_SYSCFG_REMAPMEMORY_FLASH(); \
} while (0)
-/* stm32_hw_id
- *
- * STM32F7 has a unique 96-bit id at address 0x1FF0F420.
- * See ref manual chapter 45.1.
- */
-#define STM32_HW_ID_ADDR 0x1FF0F420
-
#ifdef __cplusplus
}
#endif
diff --git a/hw/mcu/stm/stm32f3xx/pkg.yml b/hw/mcu/stm/stm32f3xx/pkg.yml
index d470c3f..bb5fa98 100644
--- a/hw/mcu/stm/stm32f3xx/pkg.yml
+++ b/hw/mcu/stm/stm32f3xx/pkg.yml
@@ -29,5 +29,5 @@ pkg.type: sdk
pkg.deps:
- hw/hal
- - hw/mcu/stm/stm32f3xx
+ - hw/mcu/stm/stm32_common
- hw/cmsis-core
diff --git a/hw/mcu/stm/stm32f3xx/src/hal_os_tick.c b/hw/mcu/stm/stm32f3xx/src/hal_os_tick.c
deleted file mode 100644
index 46b935a..0000000
--- a/hw/mcu/stm/stm32f3xx/src/hal_os_tick.c
+++ /dev/null
@@ -1,55 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-#include <assert.h>
-#include <os/os.h>
-#include <hal/hal_os_tick.h>
-
-/*
- * XXX implement tickless mode.
- */
-void
-os_tick_idle(os_time_t ticks)
-{
- OS_ASSERT_CRITICAL();
- __DSB();
- __WFI();
-}
-
-void
-os_tick_init(uint32_t os_ticks_per_sec, int prio)
-{
- uint32_t reload_val;
-
- reload_val = ((uint64_t)SystemCoreClock / os_ticks_per_sec) - 1;
-
- /* Set the system time ticker up */
- SysTick->LOAD = reload_val;
- SysTick->VAL = 0;
- SysTick->CTRL = 0x0007;
-
- /* Set the system tick priority */
- NVIC_SetPriority(SysTick_IRQn, prio);
-
- /*
- * Keep clocking debug even when CPU is sleeping, stopped or in standby.
- */
- DBGMCU->CR |= (DBGMCU_CR_DBG_SLEEP | DBGMCU_CR_DBG_STOP |
- DBGMCU_CR_DBG_STANDBY);
-}
diff --git a/hw/mcu/stm/stm32f3xx/src/hal_system.c b/hw/mcu/stm/stm32f3xx/src/hal_system.c
deleted file mode 100644
index 6bcbc96..0000000
--- a/hw/mcu/stm/stm32f3xx/src/hal_system.c
+++ /dev/null
@@ -1,43 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-#include <mcu/cortex_m4.h>
-#include <os/os.h>
-#include "hal/hal_system.h"
-#include "stm32f3xx_hal_def.h"
-
-void
-hal_system_reset(void)
-{
- while (1) {
- if (hal_debugger_connected()) {
- /*
- * If debugger is attached, breakpoint here.
- */
- asm("bkpt");
- }
- NVIC_SystemReset();
- }
-}
-
-int
-hal_debugger_connected(void)
-{
- return CoreDebug->DHCSR & CoreDebug_DHCSR_C_DEBUGEN_Msk;
-}
diff --git a/hw/mcu/stm/stm32f3xx/src/hal_system_start.c b/hw/mcu/stm/stm32f3xx/src/hal_system_start.c
deleted file mode 100644
index 3dc2469..0000000
--- a/hw/mcu/stm/stm32f3xx/src/hal_system_start.c
+++ /dev/null
@@ -1,55 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-#include <assert.h>
-#include <stddef.h>
-#include <inttypes.h>
-#include <mcu/cortex_m4.h>
-#include "stm32f3xx_hal.h"
-
-/**
- * Boots the image described by the supplied image header.
- *
- * @param hdr The header for the image to boot.
- */
-void
-hal_system_start(void *img_start)
-{
- typedef void jump_fn(void);
-
- uint32_t base0entry;
- uint32_t jump_addr;
- jump_fn *fn;
-
- /* First word contains initial MSP value. */
- __set_MSP(*(uint32_t *)img_start);
-
- /* Second word contains address of entry point (Reset_Handler). */
- base0entry = *(uint32_t *)(img_start + 4);
- jump_addr = base0entry;
- fn = (jump_fn *)jump_addr;
-
- /* Remap memory such that flash gets mapped to the code region. */
- __HAL_SYSCFG_REMAPMEMORY_FLASH();
- __DSB();
-
- /* Jump to image. */
- fn();
-}
-
diff --git a/hw/mcu/stm/stm32f3xx/src/hal_watchdog.c b/hw/mcu/stm/stm32f3xx/src/hal_watchdog.c
deleted file mode 100644
index ab7394a..0000000
--- a/hw/mcu/stm/stm32f3xx/src/hal_watchdog.c
+++ /dev/null
@@ -1,60 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-#include "hal/hal_watchdog.h"
-#include "stm32f3xx_hal.h"
-#include "stm32f3xx_hal_iwdg.h"
-
-IWDG_HandleTypeDef g_wdt_cfg;
-
-int
-hal_watchdog_init(uint32_t expire_msecs)
-{
- uint32_t reload;
-
- /* Max prescaler is 256 */
- reload = 32768 / 256;
- reload = (reload * expire_msecs) / 1000;
-
- /* Check to make sure we are not trying a reload value that is too large */
- if (reload > IWDG_RLR_RL) {
- return -1;
- }
-
- g_wdt_cfg.Instance = IWDG;
- g_wdt_cfg.Init.Prescaler = IWDG_PRESCALER_256;
- g_wdt_cfg.Init.Reload = reload;
- g_wdt_cfg.Init.Window = IWDG_WINDOW_DISABLE;
-
- return 0;
-}
-
-void
-hal_watchdog_enable(void)
-{
- __HAL_DBGMCU_FREEZE_IWDG();
- HAL_IWDG_Init(&g_wdt_cfg);
-}
-
-void
-hal_watchdog_tickle(void)
-{
- HAL_IWDG_Refresh(&g_wdt_cfg);
-}
-
diff --git a/hw/mcu/stm/stm32f3xx/src/stm32f3xx_hw_id.c b/hw/mcu/stm/stm32f3xx/src/stm32f3xx_hw_id.c
deleted file mode 100644
index 9b0d508..0000000
--- a/hw/mcu/stm/stm32f3xx/src/stm32f3xx_hw_id.c
+++ /dev/null
@@ -1,49 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-#include "stm32f3xx_ll_utils.h"
-
-#include <inttypes.h>
-#include <string.h>
-#include <hal/hal_bsp.h>
-
-#ifndef min
-#define min(a, b) ((a)<(b)?(a):(b))
-#endif
-
-/*
- * hw id
- *
- * Answer UID of the mcu.
- *
- * @param *id
- * @param max_len
- *
- * @return int
- */
-int
-hal_bsp_hw_id(uint8_t *id, int max_len)
-{
- int cnt;
-
- cnt = min(12, max_len);
- memcpy(id, (void *)UID_BASE_ADDRESS, cnt);
-
- return cnt;
-}
diff --git a/hw/mcu/stm/stm32f4xx/include/mcu/stm32_hal.h b/hw/mcu/stm/stm32f4xx/include/mcu/stm32_hal.h
index ce4442f..b6e65fa 100644
--- a/hw/mcu/stm/stm32f4xx/include/mcu/stm32_hal.h
+++ b/hw/mcu/stm/stm32f4xx/include/mcu/stm32_hal.h
@@ -40,13 +40,6 @@ extern "C" {
__DSB(); \
} while (0)
-/* stm32_hw_id
- *
- * STM32F4 has a unique 96-bit id at address 0x1FFF7A10.
- * See ref manual chapter 39.1.
- */
-#define STM32_HW_ID_ADDR 0x1FFF7A10
-
#ifdef __cplusplus
}
#endif
diff --git a/hw/mcu/stm/stm32f7xx/include/mcu/stm32_hal.h b/hw/mcu/stm/stm32f7xx/include/mcu/stm32_hal.h
index 9187517..60d53f0 100644
--- a/hw/mcu/stm/stm32f7xx/include/mcu/stm32_hal.h
+++ b/hw/mcu/stm/stm32f7xx/include/mcu/stm32_hal.h
@@ -44,13 +44,6 @@ extern "C" {
__DSB(); \
} while (0)
-/* stm32_hw_id
- *
- * STM32F7 has a unique 96-bit id at address 0x1FF0F420.
- * See ref manual chapter 45.1.
- */
-#define STM32_HW_ID_ADDR 0x1FF0F420
-
#ifdef __cplusplus
}
#endif
diff --git a/hw/mcu/stm/stm32l1xx/include/mcu/stm32_hal.h b/hw/mcu/stm/stm32l1xx/include/mcu/stm32_hal.h
index 5cdcfd8..ebc5b3b 100644
--- a/hw/mcu/stm/stm32l1xx/include/mcu/stm32_hal.h
+++ b/hw/mcu/stm/stm32l1xx/include/mcu/stm32_hal.h
@@ -40,14 +40,6 @@ extern "C" {
__DSB(); \
} while (0)
-/* stm32_hw_id
- *
- * STM32L1 has a unique 96-bit id at address either address
- * 0x1FF80050 or 0x1FF800D0 depending on the specific device.
- * See ref manual chapter 31.2.
- */
-#define STM32_HW_ID_ADDR 0x1FF800D0
-
#ifdef __cplusplus
}
#endif
--
To stop receiving notification emails like this one, please contact
utzig@apache.org.