xref: /btstack/port/renesas-ek-ra6m4a-da14531/e2-project/ra/fsp/src/bsp/mcu/all/bsp_delay.h (revision c30869498fb8e98c1408c9db0e7624f02f483b73)
1 /***********************************************************************************************************************
2  * Copyright [2020-2022] Renesas Electronics Corporation and/or its affiliates.  All Rights Reserved.
3  *
4  * This software and documentation are supplied by Renesas Electronics America Inc. and may only be used with products
5  * of Renesas Electronics Corp. and its affiliates ("Renesas").  No other uses are authorized.  Renesas products are
6  * sold pursuant to Renesas terms and conditions of sale.  Purchasers are solely responsible for the selection and use
7  * of Renesas products and Renesas assumes no liability.  No license, express or implied, to any intellectual property
8  * right is granted by Renesas. This software is protected under all applicable laws, including copyright laws. Renesas
9  * reserves the right to change or discontinue this software and/or this documentation. THE SOFTWARE AND DOCUMENTATION
10  * IS DELIVERED TO YOU "AS IS," AND RENESAS MAKES NO REPRESENTATIONS OR WARRANTIES, AND TO THE FULLEST EXTENT
11  * PERMISSIBLE UNDER APPLICABLE LAW, DISCLAIMS ALL WARRANTIES, WHETHER EXPLICITLY OR IMPLICITLY, INCLUDING WARRANTIES
12  * OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, AND NONINFRINGEMENT, WITH RESPECT TO THE SOFTWARE OR
13  * DOCUMENTATION.  RENESAS SHALL HAVE NO LIABILITY ARISING OUT OF ANY SECURITY VULNERABILITY OR BREACH.  TO THE MAXIMUM
14  * EXTENT PERMITTED BY LAW, IN NO EVENT WILL RENESAS BE LIABLE TO YOU IN CONNECTION WITH THE SOFTWARE OR DOCUMENTATION
15  * (OR ANY PERSON OR ENTITY CLAIMING RIGHTS DERIVED FROM YOU) FOR ANY LOSS, DAMAGES, OR CLAIMS WHATSOEVER, INCLUDING,
16  * WITHOUT LIMITATION, ANY DIRECT, CONSEQUENTIAL, SPECIAL, INDIRECT, PUNITIVE, OR INCIDENTAL DAMAGES; ANY LOST PROFITS,
17  * OTHER ECONOMIC DAMAGE, PROPERTY DAMAGE, OR PERSONAL INJURY; AND EVEN IF RENESAS HAS BEEN ADVISED OF THE POSSIBILITY
18  * OF SUCH LOSS, DAMAGES, CLAIMS OR COSTS.
19  **********************************************************************************************************************/
20 
21 #ifndef BSP_DELAY_H
22 #define BSP_DELAY_H
23 
24 /***********************************************************************************************************************
25  * Includes   <System Includes> , "Project Includes"
26  **********************************************************************************************************************/
27 
28 /** Common macro for FSP header files. There is also a corresponding FSP_FOOTER macro at the end of this file. */
29 FSP_HEADER
30 
31 #include "bsp_compiler_support.h"
32 
33 /*******************************************************************************************************************//**
34  * @addtogroup BSP_MCU
35  * @{
36  **********************************************************************************************************************/
37 
38 /***********************************************************************************************************************
39  * Macro definitions
40  **********************************************************************************************************************/
41 
42 /* The number of cycles required per software delay loop. */
43 #ifndef BSP_DELAY_LOOP_CYCLES
44  #define BSP_DELAY_LOOP_CYCLES    (4)
45 #endif
46 
47 /* Calculates the number of delay loops to pass to bsp_prv_software_delay_loop to achieve at least the requested cycle
48  * count delay. This is 1 loop longer than optimal if cycles is a multiple of BSP_DELAY_LOOP_CYCLES, but it ensures
49  * the requested number of loops is at least 1 since bsp_prv_software_delay_loop cannot be called with a loop count
50  * of 0. */
51 #define BSP_DELAY_LOOPS_CALCULATE(cycles)    (((cycles) / BSP_DELAY_LOOP_CYCLES) + 1U)
52 
53 /** Available delay units for R_BSP_SoftwareDelay(). These are ultimately used to calculate a total # of microseconds */
54 typedef enum
55 {
56     BSP_DELAY_UNITS_SECONDS      = 1000000, ///< Requested delay amount is in seconds
57     BSP_DELAY_UNITS_MILLISECONDS = 1000,    ///< Requested delay amount is in milliseconds
58     BSP_DELAY_UNITS_MICROSECONDS = 1        ///< Requested delay amount is in microseconds
59 } bsp_delay_units_t;
60 
61 /** @} (end addtogroup BSP_MCU) */
62 
63 /***********************************************************************************************************************
64  * Exported global variables
65  **********************************************************************************************************************/
66 
67 /***********************************************************************************************************************
68  * Exported global functions (to be accessed by other files)
69  **********************************************************************************************************************/
70 BSP_ATTRIBUTE_STACKLESS void bsp_prv_software_delay_loop(uint32_t loop_cnt);
71 
72 /** Common macro for FSP header files. There is also a corresponding FSP_HEADER macro at the top of this file. */
73 FSP_FOOTER
74 
75 #endif
76