Skip to content

Commit a03985e

Browse files
committed
[M2351] Refine wait_ns(...) code
1. Add missing header file for mbed_mpu_manager_lock_ram_execution()/ mbed_mpu_manager_unlock_ram_execution() to avoid compile warning. 2. Locate delay_loop_code() on 16-byte boundary (sync to common version). 3. Optimize delay_loop macro (sync to common version).
1 parent 492d10c commit a03985e

File tree

1 file changed

+3
-2
lines changed
  • targets/TARGET_NUVOTON/TARGET_M2351/TARGET_M23_NS

1 file changed

+3
-2
lines changed

targets/TARGET_NUVOTON/TARGET_M2351/TARGET_M23_NS/wait_ns.c

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717
*/
1818

1919
#include "cmsis.h"
20+
#include "platform/mbed_mpu_mgmt.h"
2021
#include "platform/mbed_toolchain.h"
2122
#include "platform/mbed_wait_api.h"
2223

@@ -36,7 +37,7 @@
3637
// Cortex-M0+, M3, M4 and M23 take 5 cycles per iteration - SUBS = 1, 2xNOP = 2, BCS = 2
3738
#define LOOP_SCALER 5000
3839

39-
MBED_ALIGN(8)
40+
MBED_ALIGN(16)
4041
static uint16_t delay_loop_code[] = {
4142
0x1E40, // SUBS R0,R0,#1
4243
0xBF00, // NOP
@@ -46,7 +47,7 @@ static uint16_t delay_loop_code[] = {
4647
};
4748

4849
/* Take the address of the code, set LSB to indicate Thumb, and cast to void() function pointer */
49-
#define delay_loop ((void(*)()) ((uintptr_t) delay_loop_code | 1))
50+
#define delay_loop ((void(*)()) ((uintptr_t) delay_loop_code + 1))
5051

5152
void wait_ns(unsigned int ns)
5253
{

0 commit comments

Comments
 (0)