📄 csl_pwm.h
字号:
CSL_PWM_QUERY_OUTPUT_STATUS = 1,
/**
* @brief Queries PWM operation status
* @param (Uint32*)
* @return CSL_SOK
* @sa CSL_PWM_OPERSTAT_DEFINE
*/
CSL_PWM_QUERY_OPER_STATUS = 2,
/**
* @brief Queries peripheral id register
* @param (Uint32*)
* @return CSL_SOK
*/
CSL_PWM_QUERY_PID = 3
} CSL_PwmHwStatusQuery;
/**
@} */
/**
* @addtogroup CSL_PWM_DATASTRUCT
* @{
*/
/**
* @brief Configuration parameters for one-shot mode of operation of PWM
* Used to configure one-shot mode parameters of PWM
*/
typedef struct {
/** Interrupt Enable */
CSL_PwmInterrupt intEn;
/** Inactive Output Level */
CSL_PwmInactOutLevel inactOut;
/** First Phase Output Level */
CSL_PwmP1OutLevel p1Out;
/** Repeat count
<br> PWM repeat count = Repeat count+1 clock cycles */
Uint32 rpt;
/** Event Trigger */
CSL_PwmEventTrigger evtTrig;
} CSL_PwmConfigOneShot;
/**
@} */
/**
\addtogroup CSL_PWM_DATASTRUCT
@{
*/
/**
* @brief Configuration parameters for continuous mode of operation of PWM
* Used to configure continuous mode parameters of PWM
*/
typedef struct {
/** Interrupt Enable */
CSL_PwmInterrupt intEn;
/** Inactive Output Level */
CSL_PwmInactOutLevel inactOut;
/** First Phase Output Level */
CSL_PwmP1OutLevel p1Out;
} CSL_PwmConfigContinuous;
/**
@} */
/**
* @addtogroup CSL_PWM_DATASTRUCT
* @{
*/
/**
* @brief Input parameters for setting up PWM
* Used to put PWM known useful state
*/
typedef struct {
/** PWM mode selection*/
CSL_PwmMode modeSelect;
/** (PWM output period - 1).*/
Uint32 outPeriod;
/** Phase1 Duration.*/
Uint32 phase1Duation;
/** Emulation control configuration.*/
CSL_PwmEmuCtrl emuConfig;
/** Since we use union*/
void* extendSetup;
/** Union to select one mode from oneshot and continuous*/
union {
/** Configure pwm for oneshot mode*/
CSL_PwmConfigOneShot oneShot;
/** Configure pwm for continuous mode*/
CSL_PwmConfigContinuous continuous;
} mode;
} CSL_PwmHwSetup;
/**
* @addtogroup CSL_PWM_DATASTRUCT
* @{
*/
/**
* @brief This object contains the reference to the instance of PWM
* opened using the @a CSL_pwmOpen()
* The pointer to this is passed to all PWM CSL APIs
* This structure has the fields required to configure PWM for any test
* case/application. It should be initialized as per requirements of a
* test case/application and passed on to the setup function
*/
typedef struct CSL_PwmObj {
/**
* @brief This is a pointer to the registers of the
* instance of PWM referred to by this object
*/
CSL_PwmRegsOvly regs;
/** @brief This is the instance of PWM being referred to
* by this object
*/
CSL_InstNum perNum;
} CSL_PwmObj;
/** @brief this is a pointer to @a CSL_PwmObj and is passed as the first
* parameter to all PWM CSL APIs
*/
typedef CSL_PwmObj *CSL_PwmHandle;
/**
@} */
/**
* @brief Config structure which is used in HwSetupRaw fuction
*/
typedef struct {
/** PWM peripheral conrtol register */
volatile Uint32 PCR;
/** PWM configuration register */
volatile Uint32 CFG;
/** PWM start register */
volatile Uint32 START;
/** PWM repeat count */
volatile Uint32 RPT;
/** PWM perid register */
volatile Uint32 PER;
/** PWM first-phase duration register */
volatile Uint32 PH1D;
} CSL_PwmConfig;
/**
* The default values for PWM hardware setup structure
*/
#define CSL_PWM_HWSETUP_DEFAULTS { \
CSL_PWM_ONESHOT, \
(Uint32)CSL_PWM_OUT_PERIOD, \
(Uint32)CSL_PWM_PH1_DURATION, \
CSL_PWM_EMU_RUN, \
NULL, \
{ CSL_PWM_INTR_ENABLE, \
CSL_PWM_INACTOUT_HIGH, \
CSL_PWM_P1OUT_HIGH, \
(Uint32)CSL_PWM_RPT_CNT, \
CSL_PWM_EVTTRIG_POSITIVE_EDGE \
} \
};
/**
* The default values for PWM config structure
*/
#define CSL_PWM_CONFIG_DEFAULTS { \
CSL_PWM_PCR_RESETVAL, \
CSL_PWM_CFG_RESETVAL, \
CSL_PWM_START_RESETVAL, \
CSL_PWM_RPT_RESETVAL, \
CSL_PWM_PER_RESETVAL, \
CSL_PWM_PH1D_RESETVAL \
};
/**
* @brief Pulse width modulation param structure containing module
* specific parameters
*/
typedef struct {
/**
*Bit mask to be used for module specific parameters
*/
CSL_BitMask16 flags;
} CSL_PwmParam;
/**
* @brief Pulse width modulation module specific context structure
*/
typedef struct {
/**
* Context information of Pulse width modulation
*/
Uint16 contextInfo;
} CSL_PwmContext;
/**
* @brief This will have the base-address information for the
* peripheralinstance
*/
typedef struct {
/**
*Base-address of the Configuration registers of the peripheral
*/
CSL_PwmRegsOvly regs;
} CSL_PwmBaseAddress;
/*****************************************************************************\
CSL3.x mandatory function prototype definitions
\*****************************************************************************/
/** ===========================================================================
* @n@b CSL_pwmInit
*
* @b Description
* @n This function is idempotent in that calling it many times is same as
* calling it once. This function initializes the PWM CSL data structures.
*
* @b Arguments
@verbatim
pContext Context information for the instance. Should be NULL
@endverbatim
*
* <b> Return Value </b> CSL_Status
* @li CSL_SOK - Always returns
*
* <b> Pre Condition </b>
* @n None
*
* <b> Post Condition </b>
* @n None
*
* @b Modifies
* @n None
*
* @b Example
* @verbatim
...
CSL_sysInit( NULL );
if (CSL_SOK != CSL_pwmInit( NULL )) {
return;
}
@endverbatim
* <b> Usage Constraints: </b>
* CSL system initialization must be successfully completed by invoking
* @a CSL_sysInit() before calling this function. This function should be
* called before using any of the CSL APIs
*
* @b Example:
* @verbatim
CSL_Status status;
...
status = CSL_pwmInit( NULL )
if (CSL_SOK != status) {
return;
}
@endverbatim
*
* @return returns the status of the operation
*
* ============================================================================
*/
CSL_Status CSL_pwmInit (
CSL_PwmContext *pContext
);
/**
@}
*/
/** ============================================================================
* @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
* =============================================================================
*/
CSL_PwmHandle CSL_pwmOpen (
CSL_PwmObj *hPwmObj,
CSL_InstNum pwmNum,
CSL_PwmParam *pPwmParam,
CSL_Status *status
);
/** ===========================================================================
* @n@b CSL_pwmClose
*
* @b Description
* @n The Close call releases the resource and appropriate shared pins.
*
* <b> Usage Constraints:
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -