📄 csl_pwmopen.c
字号:
/* ============================================================================
* Copyright (c) Texas Instruments Inc 2002, 2003, 2004, 2005
*
* Use of this software is controlled by the terms and conditions found in the
* license agreement under which this software has been supplied.
* ===========================================================================
*/
/** @file csl_pwmOpen.c
*
* @brief File for functional layer of CSL API @a CSL_pwmOpen()
*
* Path: \\(CSLPATH)\\ipmodules\\pwm\\src
*
* Description
* - The @a CSL_pwmOpen() function definition & it's associated functions
*
* @date 27 April, 2004
* @author Pratheesh Gangadhar
*/
/* =============================================================================
* Revision History
* ===============
* 03-Oct-2004 brn Updated for the new CSL architecture.
* 11-Oct_2004 brn File updated with the review comments
* =============================================================================
*/
#include <csl_pwm.h>
/** ============================================================================
* @n@b CSL_pwmOpen
*
* @b Description
* @n This function populates the peripheral dpwm object for the instance
* and returns a handle to the instance.
* The open call sets up the dpwm structures for the particular instance
* of PWM device. The device can be re-opened anytime after it has been
* normally closed if so required. PWM Hardware setup will be performed
* at the end of the open call only if the HwSetup Pointer supplied was
* non- NULL. The handle returned by this call is input as an essential
* argument for rest of the APIs described for this module.
*
* @b Arguments
* @verbatim
pPwmObj Pointer to the PWM instance object
pwmNum Instance of the PWM to be opened
pPwmParam Pointer to module specific parameters
pStatus pointer for returning status of the function call
@endverbatim
*
* <b> Return Value </b> CSL_PwmHandle
* @n Valid PWM instance handle will be returned if status
value is equal to CSL_SOK.
*
* <b> Pre Condition </b>
* @n None
*
* <b> Post Condition </b>
* @n 1. PWM object structure is populated
* @n 2. The status is returned in the status variable. If status
* returned is
* @li CSL_SOK Valid pwm handle is returned
* @li CSL_ESYS_FAIL The pwm instance is invalid
* @li CSL_ESYS_INVPARAMS Invalid parameter
*
* @b Modifies
* @n 1. The status variable
* @n 2. PWM object structure
*
* @b Example
* @verbatim
CSL_status status;
CSL_PwmObj pwmObj;
CSL_PwmHandle hPwm;
...
hPwm = CSL_pwmOpen (&pwmObj, CSL_PWM_PER_CNT, NULL, &status);
...
@endverbatim
* =============================================================================
*/
#pragma CODE_SECTION (CSL_pwmOpen, ".text:csl_section:pwm");
CSL_PwmHandle CSL_pwmOpen (
CSL_PwmObj *pPwmObj,
CSL_InstNum pwmNum,
CSL_PwmParam *pPwmParam,
CSL_Status *pStatus
)
{
CSL_Status status;
CSL_PwmHandle hPwm;
CSL_PwmBaseAddress baseAddress;
/* Mistral: BRN updated the code according to the code review*/
*pPwmParam = *pPwmParam;
/* Added the following code according to the code review comments*/
if (pPwmObj == NULL) {
*pStatus = CSL_ESYS_INVPARAMS;
return NULL;
}
status = CSL_pwmGetBaseAddress(pwmNum, pPwmParam, &baseAddress);
if (status == CSL_SOK) {
pPwmObj->regs = baseAddress.regs;
pPwmObj->perNum = (CSL_InstNum)pwmNum;
hPwm = (CSL_PwmHandle)pPwmObj;
}
else {
pPwmObj->regs = (CSL_PwmRegsOvly)NULL;
pPwmObj->perNum = (CSL_InstNum)-1;
hPwm = (CSL_PwmHandle)NULL;
}
if (pStatus) {
*pStatus = status;
}
return hPwm;
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -