1 /**************************************************************************//**
2 * @file lpgpio.c
3 * @version V1.00
4 * @brief LPGPIO driver source file
5 *
6 * SPDX-License-Identifier: Apache-2.0
7 * @copyright (C) 2023 Nuvoton Technology Corp. All rights reserved.
8 *****************************************************************************/
9
10 #include "NuMicro.h"
11
12 /** @addtogroup Standard_Driver Standard Driver
13 @{
14 */
15
16 /** @addtogroup LPGPIO_Driver LPGPIO Driver
17 @{
18 */
19
20 /** @addtogroup LPGPIO_EXPORTED_FUNCTIONS LPGPIO Exported Functions
21 @{
22 */
23
24 /**
25 * @brief Set LPGPIO operation mode
26 *
27 * @param[in] port LPGPIO port. It could be \ref LPGPIO.
28 * @param[in] u32PinMask The single or multiple pins of specified LPGPIO port.
29 * It could be \ref BIT0 ~ \ref BIT7 for LPGPIO pin 0 ~ pin 7.
30 * @param[in] u32Mode Operation mode. It could be
31 * - \ref LPGPIO_MODE_INPUT
32 * - \ref LPGPIO_MODE_OUTPUT
33 *
34 * @return None
35 *
36 * @details This function is used to set specified LPGPIO operation mode.
37 */
LPGPIO_SetMode(LPGPIO_T * port,uint32_t u32PinMask,uint32_t u32Mode)38 void LPGPIO_SetMode(LPGPIO_T *port, uint32_t u32PinMask, uint32_t u32Mode)
39 {
40 uint32_t i;
41
42 for(i = 0ul; i < LPGPIO_PIN_MAX; i++)
43 {
44 if((u32PinMask & (BIT0 << i))==(BIT0 << i))
45 {
46 port->MODE = (port->MODE & ~(BIT0 << i)) | (u32Mode << i);
47 }
48 }
49 }
50
51 /*@}*/ /* end of group LPGPIO_EXPORTED_FUNCTIONS */
52
53 /*@}*/ /* end of group LPGPIO_Driver */
54
55 /*@}*/ /* end of group Standard_Driver */
56
57 /*** (C) COPYRIGHT 2023 Nuvoton Technology Corp. ***/
58