]> git.sur5r.net Git - freertos/blob - FreeRTOS/Demo/CORTEX_MPU_M23_Nuvoton_NuMaker_PFM_M2351_IAR_GCC/Nuvoton_Code/StdDriver/inc/hdiv.h
Add Cortex M23 GCC and IAR ports. Add demo projects for Nuvoton NuMaker-PFM-2351.
[freertos] / FreeRTOS / Demo / CORTEX_MPU_M23_Nuvoton_NuMaker_PFM_M2351_IAR_GCC / Nuvoton_Code / StdDriver / inc / hdiv.h
1 /**************************************************************************//**\r
2  * @file     hdiv.h\r
3  * @version  V3.0\r
4  * $Revision: 1 $\r
5  * $Date: 16/07/07 7:50p $\r
6  * @brief    M0564 series Hardware Divider(HDIV) driver header file\r
7  *\r
8  * @note\r
9  * Copyright (C) 2016 Nuvoton Technology Corp. All rights reserved.\r
10  *\r
11  ******************************************************************************/\r
12 #ifndef __HDIV_H__\r
13 #define __HDIV_H__\r
14 \r
15 #ifdef __cplusplus\r
16 extern "C"\r
17 {\r
18 #endif\r
19 \r
20 \r
21 /** @addtogroup Standard_Driver Standard Driver\r
22   @{\r
23 */\r
24 \r
25 /** @addtogroup HDIV_Driver HDIV Driver\r
26   @{\r
27 */\r
28 \r
29 /** @addtogroup HDIV_EXPORTED_FUNCTIONS HDIV Exported Functions\r
30   @{\r
31 */\r
32 \r
33 /**\r
34  * @brief      Division function to calculate (x/y)\r
35  *\r
36  * @param[in]  x the dividend of the division\r
37  * @param[in]  y the divisor of the division\r
38  *\r
39  * @return     The result of (x/y)\r
40  *\r
41  * @details    This is a division function to calculate x/y\r
42  *\r
43  */\r
44 static __INLINE int32_t HDIV_Div(int32_t x, int16_t y)\r
45 {\r
46     uint32_t *p32;\r
47 \r
48     p32 = (uint32_t *)HDIV_BASE;\r
49     *p32++ = (uint32_t)x;\r
50     *p32++ = (uint32_t)y;\r
51     return (int32_t) * p32;\r
52 }\r
53 \r
54 \r
55 /**\r
56  * @brief      To calculate the remainder of x/y, i.e., the result of x mod y.\r
57  *\r
58  * @param[in]  x the dividend of the division\r
59  * @param[in]  y the divisor of the division\r
60  *\r
61  * @return     The remainder of (x/y)\r
62  *\r
63  * @details    This function is used to calculate the remainder of x/y.\r
64  */\r
65 static __INLINE int16_t HDIV_Mod(int32_t x, int16_t y)\r
66 {\r
67     uint32_t *p32;\r
68 \r
69     p32 = (uint32_t *)HDIV_BASE;\r
70     *p32++ = (uint32_t)x;\r
71     *p32++ = (uint32_t)y;\r
72     return (int16_t)p32[1];\r
73 }\r
74 \r
75 /*@}*/ /* end of group HDIV_EXPORTED_FUNCTIONS */\r
76 \r
77 /*@}*/ /* end of group HDIV_Driver */\r
78 \r
79 /*@}*/ /* end of group Standard_Driver */\r
80 \r
81 #ifdef __cplusplus\r
82 }\r
83 #endif\r
84 \r
85 #endif //__HDIV_H__\r
86 \r
87 /*** (C) COPYRIGHT 2016 Nuvoton Technology Corp. ***/\r
88 \r
89 \r