1 /* mbed Microcontroller Library 2 ******************************************************************************* 3 * Copyright (c) 2014, Realtek Semiconductor Corp. 4 * All rights reserved. 5 * 6 * This module is a confidential and proprietary property of RealTek and 7 * possession or use of this module requires written permission of RealTek. 8 ******************************************************************************* 9 */ 10 #include "objects.h" 11 #include "pinmap.h" 12 13 /** 14 * Configure pin enable and function 15 */ pin_function(PinName pin,int function)16void pin_function(PinName pin, int function) 17 { 18 u8 pin_index = 0; 19 u32 Temp = 0; 20 21 assert_param(pin != NC); 22 23 /* 32bit per one pad */ 24 /* get PADCTR index*/ 25 pin_index = (pin) & 0x3F; 26 27 /* get PADCTR */ 28 Temp = PINMUX->PADCTR[pin_index]; 29 30 /* set needs function */ 31 Temp &= ~PAD_BIT_MASK_FUNCTION_ID; 32 Temp |= (function & PAD_BIT_MASK_FUNCTION_ID); 33 Temp &= ~PAD_BIT_SHUT_DWON; /* close pad power down */ 34 35 /* set PADCTR register */ 36 PINMUX->PADCTR[pin_index] = Temp; 37 } 38 39 /** 40 * Configure pin pull-up/pull-down 41 */ pin_mode(PinName pin,PinMode mode)42void pin_mode(PinName pin, PinMode mode) 43 { 44 u8 pull_type; 45 46 switch (mode) { 47 case PullNone: 48 pull_type = GPIO_PuPd_NOPULL; 49 break; 50 51 case PullDown: 52 pull_type = GPIO_PuPd_DOWN; 53 break; 54 55 case PullUp: 56 pull_type = GPIO_PuPd_UP; 57 break; 58 59 default: 60 pull_type = GPIO_PuPd_NOPULL; 61 break; 62 } 63 64 PAD_PullCtrl((u32)pin, (u32)pull_type); 65 66 } 67