在线时间0 小时
UID388695
注册时间2012-9-13
NXP金币0
该用户从未签到
注册会员

- 积分
- 99
- 最后登录
- 1970-1-1
|

楼主 |
发表于 2014-3-10 16:00:10
|
显示全部楼层
回复:KL25Z128 引脚设置推挽输出怎么设置
好的谢谢,
麻烦你了,
下面的是中PE生成的代码,但是每个代码中都有LDD_TUserData *UserDataPtr ,请问这个是起什么作用的的,真没看明白
LDD_TDeviceData* POWER_CONTROL_Init(LDD_TUserData *UserDataPtr)
{
/* Allocate device structure */
POWER_CONTROL_TDeviceDataPtr DeviceDataPrv;
/* {MQXLite RTOS Adapter} Driver memory allocation: Dynamic allocation is simulated by a pointer to the static object */
DeviceDataPrv = &DeviceDataPrv__DEFAULT_RTOS_ALLOC;
DeviceDataPrv->UserDataPtr = UserDataPtr; /* Store the RTOS device structure */
/* Configure pin as output */
/* GPIOC_PDDR: PDD|=1 */
GPIOC_PDDR |= GPIO_PDDR_PDD(0x01);
/* Set initialization value */
/* GPIOC_PDOR: PDO|=1 */
GPIOC_PDOR |= GPIO_PDOR_PDO(0x01);
/* Initialization of Port Control register */
/* PORTC_PCR0: ISF=0,MUX=1 */
PORTC_PCR0 = (uint32_t)((PORTC_PCR0 & (uint32_t)~(uint32_t)(
PORT_PCR_ISF_MASK |
PORT_PCR_MUX(0x06)
)) | (uint32_t)(
PORT_PCR_MUX(0x01)
));
/* Registration of the device structure */
PE_LDD_RegisterDeviceStructure(PE_LDD_COMPONENT_POWER_CONTROL_ID,DeviceDataPrv);
return ((LDD_TDeviceData *)DeviceDataPrv);
}
/*
** ===================================================================
** Method : POWER_CONTROL_Deinit (component BitIO_LDD)
*/
/*!
** @brief
** Deinitializes the device. Switches off the device, frees
** the device data structure memory, interrupts vectors, etc.
** @param
** DeviceDataPtr - Device data structure
** pointer returned by method.
*/
/* ===================================================================*/
void POWER_CONTROL_Deinit(LDD_TDeviceData *DeviceDataPtr)
{
(void)DeviceDataPtr; /* Parameter is not used, suppress unused argument warning */
/* GPIOC_PDDR: PDD&=~1 */
GPIOC_PDDR &= (uint32_t)~(uint32_t)(GPIO_PDDR_PDD(0x01));
/* Unregistration of the device structure */
PE_LDD_UnregisterDeviceStructure(PE_LDD_COMPONENT_POWER_CONTROL_ID);
/* Deallocation of the device structure */
/* {MQXLite RTOS Adapter} Driver memory deallocation: Dynamic allocation is simulated, no deallocation code is generated */
}
/*
** ===================================================================
** Method : POWER_CONTROL_SetDir (component BitIO_LDD)
*/
/*!
** @brief
** Sets a pin direction (available only if the direction =
** _[input/output]_).
** @param
** DeviceDataPtr - Device data structure
** pointer returned by method.
** @param
** Dir - Direction to set. Possible values:
** - Input
**- Output
*/
/* ===================================================================*/
void POWER_CONTROL_SetDir(LDD_TDeviceData *DeviceDataPtr, bool Dir)
{
(void)DeviceDataPtr; /* Parameter is not used, suppress unused argument warning */
if (Dir) {
/* Output */
GPIO_PDD_SetPortOutputDirectionMask(POWER_CONTROL_MODULE_BASE_ADDRESS, POWER_CONTROL_PORT_MASK);
} else {
/* Input */
GPIO_PDD_SetPortInputDirectionMask(POWER_CONTROL_MODULE_BASE_ADDRESS, POWER_CONTROL_PORT_MASK);
}
}
/*
** ===================================================================
** Method : POWER_CONTROL_PutVal (component BitIO_LDD)
*/
/*!
** @brief
** The specified output value is set. If the direction is
** input, the component saves the value to a memory or a
** register and this value will be written to the pin after
** switching to the output mode (using SetDir(TRUE);
** see Safe mode
** property for limitations). If the direction is output,
** it writes the value to the pin. (Method is available only if
** the direction = output or
** input/output).
** @param
** DeviceDataPtr - Device data structure
** pointer returned by method.
** @param
** Val - Output value. Possible values:
** - logical "0" (Low level)
**- logical "1" (High level)
*/
/* ===================================================================*/
void POWER_CONTROL_PutVal(LDD_TDeviceData *DeviceDataPtr, bool Val)
{
(void)DeviceDataPtr; /* Parameter is not used, suppress unused argument warning */
if (Val) {
GPIO_PDD_SetPortDataOutputMask(POWER_CONTROL_MODULE_BASE_ADDRESS, POWER_CONTROL_PORT_MASK);
} else { /* !Val */
GPIO_PDD_ClearPortDataOutputMask(POWER_CONTROL_MODULE_BASE_ADDRESS, POWER_CONTROL_PORT_MASK);
} /* !Val */
}
/*
** ===================================================================
** Method : POWER_CONTROL_ClrVal (component BitIO_LDD)
*/
/*!
** @brief
** Clears (set to zero) the output value. It is equivalent to
** the [PutVal(FALSE)]. This method is available only if the
** direction = _[output]_ or _[input/output]_.
** @param
** DeviceDataPtr - Pointer to device data
** structure returned by method.
*/
/* ===================================================================*/
void POWER_CONTROL_ClrVal(LDD_TDeviceData *DeviceDataPtr)
{
(void)DeviceDataPtr; /* Parameter is not used, suppress unused argument warning */
GPIO_PDD_ClearPortDataOutputMask(POWER_CONTROL_MODULE_BASE_ADDRESS, POWER_CONTROL_PORT_MASK);
}
/*
** ===================================================================
** Method : POWER_CONTROL_SetVal (component BitIO_LDD)
*/
/*!
** @brief
** Sets (to one) the output value. It is equivalent to the
** [PutVal(TRUE)]. This method is available only if the
** direction = _[output]_ or _[input/output]_.
** @param
** DeviceDataPtr - Pointer to device data
** structure returned by method.
*/
/* ===================================================================*/
void POWER_CONTROL_SetVal(LDD_TDeviceData *DeviceDataPtr)
{
(void)DeviceDataPtr; /* Parameter is not used, suppress unused argument warning */
GPIO_PDD_SetPortDataOutputMask(POWER_CONTROL_MODULE_BASE_ADDRESS, POWER_CONTROL_PORT_MASK);
}
/*
** ===================================================================
** Method : POWER_CONTROL_NegVal (component BitIO_LDD)
*/
/*!
** @brief
** Negates (inverts) the output value. It is equivalent to the
** [PutVal(!GetVal())]. This method is available only if the
** direction = _[output]_ or _[input/output]_.
** @param
** DeviceDataPtr - Pointer to device data
** structure returned by method.
*/
/* ===================================================================*/
void POWER_CONTROL_NegVal(LDD_TDeviceData *DeviceDataPtr)
{
(void)DeviceDataPtr; /* Parameter is not used, suppress unused argument warning */
GPIO_PDD_TogglePortDataOutputMask(POWER_CONTROL_MODULE_BASE_ADDRESS, POWER_CONTROL_PORT_MASK);
} |
|