1 /*
2 * Copyright (c) 2020 - 2024 Renesas Electronics Corporation and/or its affiliates
3 *
4 * SPDX-License-Identifier: BSD-3-Clause
5 */
6
7 /***********************************************************************************************************************
8 * Includes <System Includes> , "Project Includes"
9 **********************************************************************************************************************/
10 #include "bsp_api.h"
11
12 /***********************************************************************************************************************
13 * Macro definitions
14 **********************************************************************************************************************/
15
16 /***********************************************************************************************************************
17 * Typedef definitions
18 **********************************************************************************************************************/
19
20 /***********************************************************************************************************************
21 * Exported global variables (to be accessed by other files)
22 **********************************************************************************************************************/
23
24 /***********************************************************************************************************************
25 * Private global variables and functions
26 **********************************************************************************************************************/
27
28 /*******************************************************************************************************************//**
29 * This assembly language routine takes roughly 4 cycles per loop. 2 additional cycles
30 * occur when the loop exits. The 'naked' attribute indicates that the specified function does not need
31 * prologue/epilogue sequences generated by the compiler.
32 * @param[in] loop_cnt The number of loops to iterate.
33 **********************************************************************************************************************/
r_bsp_software_delay_loop(uint32_t loop_cnt)34 BSP_ATTRIBUTE_STACKLESS void r_bsp_software_delay_loop (__attribute__((unused)) uint32_t loop_cnt)
35 {
36 __asm volatile ("sw_delay_loop: \n"
37
38 #if defined(__ICCARM__) || defined(__ARMCC_VERSION)
39 " subs r0, #1 \n" ///< 1 cycle
40 #elif defined(__GNUC__)
41 " sub r0, r0, #1 \n" ///< 1 cycle
42 #endif
43
44 " cmp r0, #0 \n" ///< 1 cycle
45
46 " bne sw_delay_loop \n" ///< 2 cycles
47
48 " bx lr \n"); ///< 2 cycles
49 }
50