Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit82cdead

Browse files
authored
Merge pull request#1291 from fpistm/WB_fix
WB enhancements
2 parentsa12e123 +89e2f09 commit82cdead

File tree

18 files changed

+387
-445
lines changed

18 files changed

+387
-445
lines changed

‎cores/arduino/board.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
#include"digital_io.h"
1313
#include"dwt.h"
1414
#include"hw_config.h"
15+
#include"otp.h"
1516
#include"timer.h"
1617
#include"uart.h"
1718

‎cores/arduino/stm32/clock.h

Lines changed: 14 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -1,39 +1,15 @@
1-
/**
2-
******************************************************************************
3-
* @file clock.h
4-
* @author WI6LABS
5-
* @version V1.0.0
6-
* @date 01-August-2016
7-
* @brief Header for clock.c module
8-
******************************************************************************
9-
* @attention
10-
*
11-
* <h2><center>&copy; COPYRIGHT(c) 2016 STMicroelectronics</center></h2>
12-
*
13-
* Redistribution and use in source and binary forms, with or without modification,
14-
* are permitted provided that the following conditions are met:
15-
* 1. Redistributions of source code must retain the above copyright notice,
16-
* this list of conditions and the following disclaimer.
17-
* 2. Redistributions in binary form must reproduce the above copyright notice,
18-
* this list of conditions and the following disclaimer in the documentation
19-
* and/or other materials provided with the distribution.
20-
* 3. Neither the name of STMicroelectronics nor the names of its contributors
21-
* may be used to endorse or promote products derived from this software
22-
* without specific prior written permission.
23-
*
24-
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
25-
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
26-
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
27-
* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
28-
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
29-
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
30-
* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
31-
* CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
32-
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
33-
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
34-
*
35-
******************************************************************************
36-
*/
1+
/*
2+
*******************************************************************************
3+
* Copyright (c) 2016-2021, STMicroelectronics
4+
* All rights reserved.
5+
*
6+
* This software component is licensed by ST under BSD 3-Clause license,
7+
* the "License"; You may not use this file except in compliance with the
8+
* License. You may obtain a copy of the License at:
9+
* opensource.org/licenses/BSD-3-Clause
10+
*
11+
*******************************************************************************
12+
*/
3713

3814
/* Define to prevent recursive inclusion -------------------------------------*/
3915
#ifndef__CLOCK_H
@@ -62,6 +38,8 @@ uint32_t getCurrentMillis(void);
6238
uint32_tgetCurrentMicros(void);
6339

6440
voidenableClock(sourceClock_tsource);
41+
voidconfigHSECapacitorTuning(void);
42+
6543
#ifdef__cplusplus
6644
}
6745
#endif

‎cores/arduino/stm32/lock_resource.h

Lines changed: 168 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -1,27 +1,22 @@
1-
/**
2-
******************************************************************************
3-
* @file lock_resource.h
4-
* @author MCD Application Team
5-
* @brief Header for lock_resource.c
6-
******************************************************************************
7-
* @attention
8-
*
9-
* <h2><center>&copy; Copyright (c) 2019 STMicroelectronics.
10-
* All rights reserved.</center></h2>
11-
*
12-
* This software component is licensed by ST under BSD 3-Clause license,
13-
* the "License"; You may not use this file except in compliance with the
14-
* License. You may obtain a copy of the License at:
15-
* opensource.org/licenses/BSD-3-Clause
16-
*
17-
******************************************************************************
18-
*/
1+
/*
2+
*******************************************************************************
3+
* Copyright (c) 2019-2021, STMicroelectronics
4+
* All rights reserved.
5+
*
6+
* This software component is licensed by ST under BSD 3-Clause license,
7+
* the "License"; You may not use this file except in compliance with the
8+
* License. You may obtain a copy of the License at:
9+
* opensource.org/licenses/BSD-3-Clause
10+
*
11+
*******************************************************************************
12+
*/
1913
/* Define to prevent recursive inclusion -------------------------------------*/
2014
#ifndef_LOCK_RESOURCE_H
2115
#define_LOCK_RESOURCE_H
2216

2317
/* Includes ------------------------------------------------------------------*/
2418
#include"stm32_def.h"
19+
#include"stm32yyxx_ll_hsem.h"
2520

2621
#ifdef__cplusplus
2722
extern"C" {
@@ -35,15 +30,163 @@ typedef enum {
3530
}LockResource_Status_t;
3631

3732
/* Exported constants --------------------------------------------------------*/
38-
#defineLOCK_RESOURCE_TIMEOUT 100U/* timeout in ms */
33+
#if defined(STM32WBxx)
34+
/*
35+
* HW semaphore Complement ID list defined in hw_conf.h from STM32WB.
36+
* They could be used also for H7 dualcore targets.
37+
*/
38+
/*
39+
* Index of the semaphore used by CPU2 to prevent the CPU1 to either write or
40+
* erase data in flash. The CPU1 shall not either write or erase in flash when
41+
* this semaphore is taken by the CPU2. When the CPU1 needs to either write or
42+
* erase in flash, it shall first get the semaphore and release it just
43+
* after writing a raw (64bits data) or erasing one sector.
44+
* On v1.4.0 and older CPU2 wireless firmware, this semaphore is unused and
45+
* CPU2 is using PES bit. By default, CPU2 is using the PES bit to protect its
46+
* timing. The CPU1 may request the CPU2 to use the semaphore instead of the
47+
* PES bit by sending the system command SHCI_C2_SetFlashActivityControl()
48+
*/
49+
#defineCFG_HW_BLOCK_FLASH_REQ_BY_CPU2_SEMID 7U
3950

40-
/* Exported macro ------------------------------------------------------------*/
41-
#definePERIPH_LOCK(__Periph__) Periph_Lock(__Periph__, LOCK_RESOURCE_TIMEOUT)
42-
#definePERIPH_UNLOCK(__Periph__) Periph_Unlock(__Periph__)
51+
/*
52+
* Index of the semaphore used by CPU1 to prevent the CPU2 to either write or
53+
* erase data in flash. In order to protect its timing, the CPU1 may get this
54+
* semaphore to prevent the CPU2 to either write or erase in flash
55+
* (as this will stall both CPUs)
56+
* The PES bit shall not be used as this may stall the CPU2 in some cases.
57+
*/
58+
#defineCFG_HW_BLOCK_FLASH_REQ_BY_CPU1_SEMID 6U
4359

44-
/* Exported functions ------------------------------------------------------- */
45-
LockResource_Status_tPeriph_Lock(void*Peripheral,uint32_tTimeout);
46-
voidPeriph_Unlock(void*Peripheral);
60+
/*
61+
* Index of the semaphore used to manage the CLK48 clock configuration
62+
* When the USB is required, this semaphore shall be taken before configuring
63+
* the CLK48 for USB and should be released after the application switch OFF
64+
* the clock when the USB is not used anymore. When using the RNG, it is good
65+
* enough to use CFG_HW_RNG_SEMID to control CLK48.
66+
* More details in AN5289
67+
*/
68+
#defineCFG_HW_CLK48_CONFIG_SEMID 5U
69+
#defineCFG_HW_RCC_CRRCR_CCIPR_SEMID CFG_HW_CLK48_CONFIG_SEMID
70+
71+
/* Index of the semaphore used to manage the entry Stop Mode procedure */
72+
#defineCFG_HW_ENTRY_STOP_MODE_SEMID 4U
73+
#defineCFG_HW_ENTRY_STOP_MODE_MASK_SEMID (1U << CFG_HW_ENTRY_STOP_MODE_SEMID)
74+
75+
/* Index of the semaphore used to access the RCC */
76+
#defineCFG_HW_RCC_SEMID 3U
77+
78+
/* Index of the semaphore used to access the FLASH */
79+
#defineCFG_HW_FLASH_SEMID 2U
80+
81+
/* Index of the semaphore used to access the PKA */
82+
#defineCFG_HW_PKA_SEMID 1U
83+
84+
/* Index of the semaphore used to access the RNG */
85+
#defineCFG_HW_RNG_SEMID 0U
86+
87+
/* Index of the semaphore used to access GPIO */
88+
#defineCFG_HW_GPIO_SEMID 8U
89+
90+
/* Index of the semaphore used to access the EXTI */
91+
#defineCFG_HW_EXTI_SEMID 9U
92+
93+
#elif defined(STM32MP1xx)
94+
/*
95+
* HW semaphore from STM32MP1
96+
* EXTI and GPIO are inherited from STM32MP1 Linux.
97+
* Other SEMID are not used by linux and must not be used here,
98+
* but reserved for MPU.
99+
*/
100+
/* Index of the semaphore used to access GPIO */
101+
#defineCFG_HW_GPIO_SEMID 0U
102+
103+
/* Index of the semaphore used to access the EXTI */
104+
#defineCFG_HW_EXTI_SEMID 1U
105+
#endif/* STM32WBxx */
106+
107+
/* Fake semaphore ID definition for compilation purpose only */
108+
#ifndefHSEM_SEMID_MAX
109+
#defineHSEM_SEMID_MAX 0U
110+
#endif
111+
#ifndefCFG_HW_BLOCK_FLASH_REQ_BY_CPU2_SEMID
112+
#defineCFG_HW_BLOCK_FLASH_REQ_BY_CPU2_SEMID (HSEM_SEMID_MAX +1)
113+
#endif
114+
#ifndefCFG_HW_BLOCK_FLASH_REQ_BY_CPU1_SEMID
115+
#defineCFG_HW_BLOCK_FLASH_REQ_BY_CPU1_SEMID (HSEM_SEMID_MAX +1)
116+
#endif
117+
#ifndefCFG_HW_CLK48_CONFIG_SEMID
118+
#defineCFG_HW_CLK48_CONFIG_SEMID (HSEM_SEMID_MAX +1)
119+
#endif
120+
#ifndefCFG_HW_RCC_CRRCR_CCIPR_SEMID
121+
#defineCFG_HW_RCC_CRRCR_CCIPR_SEMID (HSEM_SEMID_MAX +1)
122+
#endif
123+
#ifndefCFG_HW_ENTRY_STOP_MODE_SEMID
124+
#defineCFG_HW_ENTRY_STOP_MODE_SEMID (HSEM_SEMID_MAX +1)
125+
#endif
126+
#ifndefCFG_HW_RCC_SEMID
127+
#defineCFG_HW_RCC_SEMID (HSEM_SEMID_MAX +1)
128+
#endif
129+
#ifndefCFG_HW_FLASH_SEMID
130+
#defineCFG_HW_FLASH_SEMID (HSEM_SEMID_MAX +1)
131+
#endif
132+
#ifndefCFG_HW_PKA_SEMID
133+
#defineCFG_HW_PKA_SEMID (HSEM_SEMID_MAX +1)
134+
#endif
135+
#ifndefCFG_HW_RNG_SEMID
136+
#defineCFG_HW_RNG_SEMID (HSEM_SEMID_MAX +1)
137+
#endif
138+
#ifndefCFG_HW_GPIO_SEMID
139+
#defineCFG_HW_GPIO_SEMID (HSEM_SEMID_MAX +1)
140+
#endif
141+
#ifndefCFG_HW_EXTI_SEMID
142+
#defineCFG_HW_EXTI_SEMID (HSEM_SEMID_MAX +1)
143+
#endif
144+
145+
/* Hardware Semaphore wait forever value */
146+
#defineHSEM_LOCK_WAIT_FOREVER 0xFFFFFFFFU
147+
/* Hardware Semaphore default retry value */
148+
#ifndefHSEM_LOCK_DEFAULT_RETRY
149+
#defineHSEM_LOCK_DEFAULT_RETRY 0xFFFFU
150+
#endif
151+
152+
/*
153+
* @brief hsem_lock function is used for register protection of shared Peripheral
154+
* and shall be called before accessing registers of this shared Peripheral
155+
* If Semaphore id is already taken, the function will busy loop waiting for it to
156+
* be released, but give up after @retry downcounter have elapsed
157+
* @param semID: Semaphore id used to identify which peripheral to protect
158+
* @param retry: number of retry
159+
* @retval None
160+
*/
161+
staticinlinevoidhsem_lock(uint32_tsemID,uint32_tretry)
162+
{
163+
#if defined(STM32MP1xx)|| defined(STM32WBxx)
164+
if ((semID) <=HSEM_SEMID_MAX) {
165+
while (LL_HSEM_1StepLock(HSEM,semID)) {
166+
if (retry!=HSEM_LOCK_WAIT_FOREVER) {
167+
retry--;
168+
if (retry==0) {
169+
Error_Handler();
170+
}
171+
}
172+
}
173+
}
174+
#endif/* STM32MP1xx || STM32WBxx */
175+
}
176+
177+
/*
178+
* @brief hsem_unlock released a previously-acquired semaphore
179+
* @param semID Semaphore id used to identify which peripheral to release
180+
* @retval None
181+
*/
182+
staticinlinevoidhsem_unlock(uint32_tsemID)
183+
{
184+
#if defined(STM32MP1xx)|| defined(STM32WBxx)
185+
if ((semID) <=HSEM_SEMID_MAX) {
186+
LL_HSEM_ReleaseLock(HSEM,semID,0);
187+
}
188+
#endif/* STM32MP1xx || STM32WBxx */
189+
}
47190

48191
#ifdef__cplusplus
49192
}// extern "C"

‎cores/arduino/stm32/otp.h

Lines changed: 61 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,61 @@
1+
/*
2+
*******************************************************************************
3+
* Copyright (c) 2021, STMicroelectronics
4+
* All rights reserved.
5+
*
6+
* This software component is licensed by ST under BSD 3-Clause license,
7+
* the "License"; You may not use this file except in compliance with the
8+
* License. You may obtain a copy of the License at:
9+
* opensource.org/licenses/BSD-3-Clause
10+
*
11+
*******************************************************************************
12+
*/
13+
14+
/* Define to prevent recursive inclusion -------------------------------------*/
15+
#ifndef__OTP_H
16+
#define__OTP_H
17+
18+
#include"stm32_def.h"
19+
20+
#ifdefOTP_AREA_BASE
21+
#ifdef__cplusplus
22+
extern"C" {
23+
#endif
24+
25+
#ifdefSTM32WBxx
26+
/*
27+
* See AN5042: Precise HSE frequency and startup time tuning
28+
* for STM32 wireless MCUs. Each OTP structure type is indicated
29+
* by its index (one byte).The index used for the BT structure is 0.
30+
*/
31+
typedefstruct__packed {
32+
uint8_tbd_address[6];
33+
uint8_thse_tuning;
34+
uint8_tid;
35+
}OTP_BT_t;
36+
#endif/* STM32WBxx */
37+
38+
/* Exported functions --------------------------------------------------------*/
39+
40+
/**
41+
* @brief This API return the address (64 bits aligned) of the ID parameter in the OTP
42+
* It returns the first ID declaration found from the higher address down to the base address
43+
* The user shall fill the OTP from the base address to the top of the OTP so that the more recent
44+
* declaration is returned by the API
45+
* The OTP manager handles only 64 bits parameter
46+
* | Id | Parameter |
47+
* | 8bits | 58bits |
48+
* | MSB | LSB |
49+
*
50+
* @param id: ID of the parameter to read from OTP
51+
* @retval Address of the ID in the OTP - returns 0 when no ID found
52+
*/
53+
uint8_t*OTP_Read(uint8_tid);
54+
55+
#ifdef__cplusplus
56+
}
57+
#endif
58+
#endif/* OTP_AREA_BASE */
59+
#endif/*__OTP_H */
60+
61+
/************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp