在线时间0 小时
UID2028068
注册时间2013-7-24
NXP金币0
该用户从未签到
新手上路

- 积分
- 92
- 最后登录
- 1970-1-1
|
通过PE添加组件运用Capture功能,捕获其下降沿。生成如下的函数(其中两个):
** ===================================================================
** Method : TU1_GetCounterValue (component TimerUnit_LDD)
**
** Description :
** Returns the content of counter register. This method can be
** used both if counter is enabled and if counter is disabled.
** The method is not available if HW doesn't allow reading of
** the counter.
** Parameters :
** NAME - DESCRIPTION
** * DeviceDataPtr - Device data structure
** pointer returned by method.
** Returns :
** --- - Counter value (number of counted ticks).
** ===================================================================
*/
TU1_TValueType TU1_GetCounterValue(LDD_TDeviceData *DeviceDataPtr)
{
(void)DeviceDataPtr; /* Parameter is not used, suppress unused argument warning */
return (TU1_TValueType)TPM_PDD_ReadCounterReg(TPM0_BASE_PTR);
}
** ===================================================================
** Method : TU1_GetCaptureValue (component TimerUnit_LDD)
**
** Description :
** Returns the content of capture register specified by the
** parameter ChannelIdx. This method is available when at least
** one channel is configured.
** Parameters :
** NAME - DESCRIPTION
** * DeviceDataPtr - Device data structure
** pointer returned by method.
** ChannelIdx - Index of the component
** channel.
** * ValuePtr - Pointer to return value of the
** capture register.
** Returns :
** --- - Error code, possible codes:
** ERR_OK - OK
** ERR_PARAM_INDEX - ChannelIdx parameter is
** out of possible range
** ERR_NOTAVAIL - The capture mode is not
** selected for selected channel.
** ERR_SPEED - The component does not work in
** the active clock configuration
** ===================================================================
*/
LDD_TError TU1_GetCaptureValue(LDD_TDeviceData *DeviceDataPtr, uint8_t ChannelIdx, TU1_TValueType *ValuePtr)
{
(void)DeviceDataPtr; /* Parameter is not used, suppress unused argument warning */
/* Parameter test - this test can be disabled by setting the "Ignore range checking"
property to the "yes" value in the "Configuration inspector" */
if (ChannelIdx > LAST_CHANNEL) { /* Is the channel index out of range? */
return ERR_PARAM_INDEX; /* If yes then error */
}
if ((ChannelMode[ChannelIdx]) != 1u) { /* Is the channel in capture mode? */
return ERR_NOTAVAIL; /* If not then error */
}
*ValuePtr = (TU1_TValueType)(TPM_PDD_ReadChannelValueReg(TPM0_BASE_PTR, ChannelDevice[ChannelIdx]));
return ERR_OK; /* OK */
}
若我需要计数在某一段时间内其下降沿,是用这个函数吗LDD_TError TU1_GetCaptureValue(LDD_TDeviceData *DeviceDataPtr, uint8_t ChannelIdx, TU1_TValueType *ValuePtr)
?
|
|