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

Commita36188b

Browse files
committed
fix(usb): disable ICACHE
When USB is used on STM32H5 and ICACHE enable it does notwork so disable it.Signed-off-by: Frederic Pillon <frederic.pillon@st.com>
1 parent757e359 commita36188b

File tree

2 files changed

+36
-0
lines changed

2 files changed

+36
-0
lines changed

‎cores/arduino/stm32/usb/cdc/usbd_cdc_if.c

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,7 @@ USBD_HandleTypeDef hUSBD_Device_CDC;
4848

4949
staticboolCDC_initialized= false;
5050
staticboolCDC_DTR_enabled= true;
51+
staticboolicache_enabled= false;
5152

5253
/* Received Data over USB are stored in this buffer */
5354
CDC_TransmitQueue_TypeDefTransmitQueue;
@@ -270,6 +271,15 @@ static int8_t USBD_CDC_TransmitCplt(uint8_t *Buf, uint32_t *Len, uint8_t epnum)
270271

271272
voidCDC_init(void)
272273
{
274+
#if defined(ICACHE)&& defined (HAL_ICACHE_MODULE_ENABLED)&& !defined(HAL_ICACHE_MODULE_DISABLED)
275+
if (HAL_ICACHE_IsEnabled()==1) {
276+
icache_enabled= true;
277+
/* Disable instruction cache prior to internal cacheable memory update */
278+
if (HAL_ICACHE_Disable()!=HAL_OK) {
279+
Error_Handler();
280+
}
281+
}
282+
#endif/* ICACHE && HAL_ICACHE_MODULE_ENABLED && !HAL_ICACHE_MODULE_DISABLED */
273283
if (!CDC_initialized) {
274284
/* Init Device Library */
275285
if (USBD_Init(&hUSBD_Device_CDC,&USBD_Desc,0)==USBD_OK) {
@@ -294,6 +304,14 @@ void CDC_deInit(void)
294304
USBD_DeInit(&hUSBD_Device_CDC);
295305
CDC_initialized= false;
296306
}
307+
#if defined(ICACHE)&& defined (HAL_ICACHE_MODULE_ENABLED)&& !defined(HAL_ICACHE_MODULE_DISABLED)
308+
if (icache_enabled) {
309+
/* Re-enable instruction cache */
310+
if (HAL_ICACHE_Enable()!=HAL_OK) {
311+
Error_Handler();
312+
}
313+
}
314+
#endif/* ICACHE && HAL_ICACHE_MODULE_ENABLED && !HAL_ICACHE_MODULE_DISABLED */
297315
}
298316

299317
boolCDC_connected()

‎cores/arduino/stm32/usb/hid/usbd_hid_composite_if.c

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@ USBD_HandleTypeDef hUSBD_Device_HID;
2828

2929
staticboolHID_keyboard_initialized= false;
3030
staticboolHID_mouse_initialized= false;
31+
staticboolicache_enabled= false;
3132

3233
/**
3334
* @brief Initialize USB devices
@@ -36,6 +37,15 @@ static bool HID_mouse_initialized = false;
3637
*/
3738
voidHID_Composite_Init(HID_Interfacedevice)
3839
{
40+
#if defined(ICACHE)&& defined (HAL_ICACHE_MODULE_ENABLED)&& !defined(HAL_ICACHE_MODULE_DISABLED)
41+
if (HAL_ICACHE_IsEnabled()==1) {
42+
icache_enabled= true;
43+
/* Disable instruction cache prior to internal cacheable memory update */
44+
if (HAL_ICACHE_Disable()!=HAL_OK) {
45+
Error_Handler();
46+
}
47+
}
48+
#endif/* ICACHE && HAL_ICACHE_MODULE_ENABLED && !HAL_ICACHE_MODULE_DISABLED */
3949
if (IS_HID_INTERFACE(device)&&
4050
!HID_keyboard_initialized&& !HID_mouse_initialized) {
4151
/* Init Device Library */
@@ -72,6 +82,14 @@ void HID_Composite_DeInit(HID_Interface device)
7282
/* DeInit Device Library */
7383
USBD_DeInit(&hUSBD_Device_HID);
7484
}
85+
#if defined(ICACHE)&& defined (HAL_ICACHE_MODULE_ENABLED)&& !defined(HAL_ICACHE_MODULE_DISABLED)
86+
if (icache_enabled) {
87+
/* Re-enable instruction cache */
88+
if (HAL_ICACHE_Enable()!=HAL_OK) {
89+
Error_Handler();
90+
}
91+
}
92+
#endif/* ICACHE && HAL_ICACHE_MODULE_ENABLED && !HAL_ICACHE_MODULE_DISABLED */
7593
if (device==HID_KEYBOARD) {
7694
HID_keyboard_initialized= false;
7795
}

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp