⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 pwm.h

📁 嵌入式系统
💻 H
字号:
/*-----------------------------------------------------------------------------
@@
@@ Copyright (c) 2001 Sharp Corporation All rights reserved.
@@
@@ (Summary)    : PWM driver user include header file
@@
@@ (Comment)    :
@@
@@ (Author)     : Kazuko FUKUDA
@@
@@ (History)    : 2001/1/15
@@                2001/1/17 K.FUKUDA    reflect result code review version
@@                2001/2/13 K.FUKUDA    modified calculation of address
@@                2001/6/05 Tan WK      Version 2.0 with LH79532 support
@@                2001/8/31 Teo LL      Version 3.0 with LH79533 support
@@
@@ (RCS ID) :
@@
-----------------------------------------------------------------------------*/
#ifndef APD_PWM_H
#define APD_PWM_H

/*+include files*************************************************************/
/*                                                                          */
/*                                                                          */
/**************************************************************************-*/
#include "type_def.h"
#include "dev_def.h"
#include "pwm_ref.h"

/*+Public Macro definitions**************************************************/
/*                                                                          */
/*                                                                          */
/**************************************************************************-*/

/*+Public Type definitions***************************************************/
/*                                                                          */
/*                                                                          */
/**************************************************************************-*/

/*-----------------------------------------------------------------------------
@@
@@ {Name}   : APD_PWM_MODE
@@
@@ {Summary}: Indicate the PWM's mode.
@@
@@ {Desc}   : It is used to set PWMx as either normal or synchronous mode.
@@            It is referred as an argument of "apd_PWMInit".
@@
@@ {END}
-----------------------------------------------------------------------------*/
typedef enum {
    APD_PWM_NORMAL_MODE = 0,    /* Operate PWMx in normal mode */
    APD_PWM_SYNCHRO_MODE        /* Operate PWMx in synchronous mode */
} APD_PWM_MODE;

/*-----------------------------------------------------------------------------
@@
@@ {Name}   : APD_PWM_SELECT_CLK
@@
@@ {Summary}: Indicate APD_PWM's clock select.
@@
@@ {Desc}   : It is used to set the input signal of PMWx as either
@@            couter/timer0 or external.
@@
@@ {END}
-----------------------------------------------------------------------------*/
typedef enum {
    APD_PWM_SYNC_COUNTER0 = 0x00,   /* Use Counter/Timer0 */
    APD_PWM_SYNC_EXTERNAL = 0x02    /* Use External input signal */
} APD_PWM_SELECT_CLK;

/*-----------------------------------------------------------------------------
@@
@@ {Name}   : APD_PWM_OUTPUT
@@
@@ {Summary}: Indicated the output signal of APD_PWM.
@@
@@ {Desc}   : It is used to set the PWM's output as either normal or inverted.
@@
@@ {END}
-----------------------------------------------------------------------------*/
typedef enum {
    APD_PWM_NORMAL_OUTPUT = 0,  /* normal output */
    APD_PWM_INVERT_OUTPUT       /* inverted output */
} APD_PWM_OUTPUT;

/*-----------------------------------------------------------------------------
@@
@@ {Name}   : APD_PWM_CHANNEL
@@
@@ {Summary}: Indicate APD_PWM Channel
@@
@@ {Desc}   : It is used to set PWM Channel type as a constant.
@@
@@ {END}
-----------------------------------------------------------------------------*/
typedef enum {
    APD_PWM_CH0 = 0x00, /* channel 0 */
    APD_PWM_CH1,        /* channel 1 */
    APD_PWM_CH2,        /* channel 2 */
    APD_PWM_CH3         /* channel 3 */
} APD_PWM_CHANNEL;

/*-----------------------------------------------------------------------------
@@
@@ {Name}   : APD_PWMINIT
@@
@@ {Summary}: The setting of PWM initialize bits.
@@
@@ {Desc}   : A structure defining how each PWM should be initialized to.
@@            div   - Division values
@@            mode  - Synchronous/Normal mode
@@            sel   - counter/external clock
@@            tc    - PWM frequency
@@            dc    - PWM duty cycle
@@            inv   - Normal/Inverted output
@@            ch    - Channel
@@
@@ {END}
-----------------------------------------------------------------------------*/
typedef struct {
    APD_UCHAR           div;
    APD_PWM_MODE        mode;
    APD_PWM_SELECT_CLK  sel;
    APD_USHORT          tc;
    APD_USHORT          dc;
    APD_PWM_OUTPUT      inv;
    APD_PWM_CHANNEL     ch;
} APD_PWMINIT;


#ifdef APD_PWM_C

/*-------------------------- Local context - START -------------------------*/

/*+include files*************************************************************/
/*                                                                          */
/*                                                                          */
/**************************************************************************-*/

#define VISIBLE             /* Mark as LOCAL context */

/*+Local Type definitions****************************************************/
/*                                                                          */
/*                                                                          */
/**************************************************************************-*/

/*+Local Macro definitions***************************************************/
/*                                                                          */
/*                                                                          */
/**************************************************************************-*/

/*+Local function prototypes*************************************************/
/*                                                                          */
/* Name         Type    Abstract                                            */
/* --------     ------- -----------                                         */
/**************************************************************************-*/

/*+Local data declarations***************************************************/
/*                                                                          */
/* Name         Type    Abstract                                            */
/* --------     ------- -----------                                         */
/*                                                                          */
/**************************************************************************-*/

/*-------------------------------- Local context - END ---------------------------------*/

#else
#define VISIBLE extern      /* Mark as GLOBAL context */
#endif

/*---------------------------- Global context - START ---------------------------------*/

/*+Public data declarations**************************************************/
/*                                                                          */
/* Name         Type    Abstract                                            */
/* --------     ------- -----------                                         */
/*                                                                          */
/**************************************************************************-*/

/*+Public function prototypes************************************************/
/*                                                                          */
/* Name         Type    Abstract                                            */
/* --------     ------- -----------                                         */
/*                                                                          */
/**************************************************************************-*/
VISIBLE APD_VOID apd_PWMInit(APD_PWMINIT *);
VISIBLE APD_VOID apd_PWMEnable(APD_PWM_CHANNEL ch);
VISIBLE APD_VOID apd_PWMEnable(APD_PWM_CHANNEL ch);
VISIBLE APD_VOID apd_PWMSetTc(APD_USHORT tc, APD_PWM_CHANNEL ch);
VISIBLE APD_VOID apd_PWMSetDc(APD_USHORT dc, APD_PWM_CHANNEL ch);
VISIBLE APD_VOID apd_PWMSetDiv(APD_UCHAR div, APD_PWM_CHANNEL ch);
VISIBLE APD_VOID apd_PWMSetInv(APD_PWM_OUTPUT inv, APD_PWM_CHANNEL ch);


/*-------------------------- Global context - END --------------------------*/

#undef VISIBLE
#endif	/* APD_PWM */

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -