CCS7.3中PIN_init()函数与PIN_open()函数有什么区别?
为什么已经在PIN_init()函数中对IO口已经初始化过了,但在PIN_open()函数还要执行ledPinHandle = PIN_open()?
是否可以只在初始化做一次,ledPinHandle句柄有啥意义?
YiKai Chen:
請參考程序的註解
/** @briefPIN module initialization**Must be called early in the boot sequence to ensure that I/O pins have safe*configurations. This initialization sets up pins as GPIO as defined in an*array (possibly user-generated) that typically resides in a board file. All*pins not mentioned in aPinCfg[] are configured to be input/output/pull*disabled.**@note Function *cannot* be called more than once.**@param aPinCfg[]Pointer to array of PIN_Config entries, one per pin*that needs configuration. List terminates when a*#PIN_TERMINATE entry is encountered.*@return #PIN_SUCCESS if successful, else an error code.*/
extern PIN_Status PIN_init(const PIN_Config aPinCfg[]);/** @briefAllocate one or more pins for a driver or an application**Allows a PIN client (driver or application) to allocate a set of pins, thus*ensuring that they cannot be reconfigured/controlled by anyone else. The*pins are identified by and reconfigured according to the #PIN_Config*entries in pinList.**@param statePointer to a PIN_State object that will hold the state for*this IO client. The object must be in persistent memory*@param pinList[] Pointer to array of #PIN_Config entries, one per pin to*allocate. List terminates when #PIN_TERMINATE entry is*encountered.*@return A handle for further PIN driver calls or NULL if an error occurred*(already allocated pin in pinList or non-existent pin in pinList)*/
extern PIN_Handle PIN_open(PIN_State *state, const PIN_Config pinList[]);
Viki Shi:
两者不同。
PIN_init()是初始化IO口,确保安全配置
PIN_open()是为应用或者驱动分配端口,保证不被其他功能占用