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

📄 lld_gpio.h

📁 本程序为ST公司开发的源代码
💻 H
字号:
/*____________________________________________________________________________| FILE:         lld_gpio.h| PROJECT:      OS20_ACCORDO+| SW-COMPONENT: |_____________________________________________________________________________| DESCRIPTION:  Low level driver for General Purpose I/O Ports          |_____________________________________________________________________________| COPYRIGHT:    (c) 2005 STMicroelectronics, Arzano (ITALY)| HISTORY:| Date      | Modification               						| Author|_____________________________________________________________________________| 05.10.27  | Initial revision        							| M. De Martino|____________________________________________________________________________*/#include "macro.h"#include "types.h"#ifndef _LLD_GPIO_H_#define _LLD_GPIO_H_#ifdef __cplusplusextern "C" {#endif/************************************************************************| defines|-----------------------------------------------------------------------*/#define GPIO_PORT_NUM			2#define GPIO_PIN_NUM			15/************************************************************************| typedefs |-----------------------------------------------------------------------*/ /* gpio identificator */typedef enum{	GPIO_A,	GPIO_B} GPIO_ID;typedef enum GPIO_pinTy{	GPIO_PIN_00 = 0x0001,	GPIO_PIN_01 = 0x0002,	GPIO_PIN_02 = 0x0004,	GPIO_PIN_03 = 0x0008,	GPIO_PIN_04 = 0x0010,	GPIO_PIN_05 = 0x0020,	GPIO_PIN_06 = 0x0040,	GPIO_PIN_07 = 0x0080,	GPIO_PIN_08 = 0x0100,	GPIO_PIN_09 = 0x0200,	GPIO_PIN_10 = 0x0400,	GPIO_PIN_11 = 0x0800,	GPIO_PIN_12 = 0x1000,	GPIO_PIN_13 = 0x2000,	GPIO_PIN_14 = 0x4000,	GPIO_PIN_15 = 0x8000	} GPIO_pinTy;typedef enum GPIO_portTy{	GPIO_PORT_A = 0,	GPIO_PORT_B = 1} GPIO_portTy;	/* Following structure has HALFWORD(16) access */typedef struct rGpio{    struct   {                                           tU16 C00:1;      tU16 C01:1;      tU16 C02:1;      tU16 C03:1;      tU16 C04:1;      tU16 C05:1;      tU16 C06:1;      tU16 C07:1;      tU16 C08:1;      tU16 C09:1;      tU16 C010:1;      tU16 C011:1;      tU16 C012:1;      tU16 C013:1;      tU16 C014:1;      tU16 C015:1;   } Pc0;						/* addr offset = 0x00 */      intra16;   struct   {                                           tU16 C10:1;      tU16 C11:1;      tU16 C12:1;      tU16 C13:1;      tU16 C14:1;      tU16 C15:1;      tU16 C16:1;      tU16 C17:1;      tU16 C18:1;      tU16 C19:1;      tU16 C110:1;      tU16 C111:1;      tU16 C112:1;      tU16 C113:1;      tU16 C114:1;      tU16 C115:1;   } Pc1;						/* addr offset = 0x04 */      intra16;   struct   {                                           tU16 C20:1;      tU16 C21:1;      tU16 C22:1;      tU16 C23:1;      tU16 C24:1;      tU16 C25:1;      tU16 C26:1;      tU16 C27:1;      tU16 C28:1;      tU16 C29:1;      tU16 C210:1;      tU16 C211:1;      tU16 C212:1;      tU16 C213:1;      tU16 C214:1;      tU16 C215:1;   } Pc2;						/* addr offset = 0x08 */      intra16;   struct   {                                           tU16 D0:1;      tU16 D1:1;      tU16 D2:1;      tU16 D3:1;      tU16 D4:1;      tU16 D5:1;      tU16 D6:1;      tU16 D7:1;      tU16 D8:1;      tU16 D9:1;      tU16 D10:1;      tU16 D11:1;      tU16 D12:1;      tU16 D13:1;      tU16 D14:1;      tU16 D15:1;   } Pd;						/* addr offset = 0x0C */} rGpio;	/************************************************************************| variable definitions (from .c)|-----------------------------------------------------------------------*/extern volatile rGpio GpioA;extern volatile rGpio GpioB;/************************************************************************ | function prototypes|-----------------------------------------------------------------------*/__inline static tVoid LLD_GPIO_PortAToggle (GPIO_pinTy pin){   wr16_reg (GpioA, Pd, (rd16_reg (GpioA, Pd) ^ pin));}__inline static tVoid LLD_GPIO_PortBToggle (GPIO_pinTy pin){   wr16_reg (GpioB, Pd, (rd16_reg (GpioB, Pd) ^ pin));}__inline static tU16 LLD_GPIO_PortADirectRead (tVoid){	return rd16_reg (GpioA, Pd);}__inline static tU16 LLD_GPIO_PortBDirectRead (tVoid){	return rd16_reg (GpioB, Pd);}__inline static tVoid LLD_GPIO_PortADirectWrite (tU16 data){	 wr16_reg (GpioA, Pd, data);}__inline static tVoid LLD_GPIO_PortBDirectWrite (tU16 data){	 wr16_reg (GpioB, Pd, data);}extern tVoid LLD_GPIO_SetPPOutput(GPIO_ID id, tU8 u8Pin);extern tVoid LLD_GPIO_SetODOutput(GPIO_ID id, tU8 u8Pin);extern tVoid LLD_GPIO_SetAFPPOutput(GPIO_ID id, tU8 u8Pin);extern tVoid LLD_GPIO_SetAFODOutput(GPIO_ID id, tU8 u8Pin);extern tVoid LLD_GPIO_SetInput(GPIO_ID id, tU8 u8Pin);extern tVoid LLD_GPIO_SetInput2(GPIO_ID id, tU8 u8Pin);extern tVoid LLD_GPIO_SetBiDirect(GPIO_ID id, tU8 u8Pin);extern tVoid LLD_GPIO_SetHiZ(GPIO_ID id, tU8 u8Pin);extern tU8   LLD_GPIO_GetState(GPIO_ID id, tU8 u8Pin);extern tVoid LLD_GPIO_SetStateHigh(GPIO_ID id, tU8 u8Pin);extern tVoid LLD_GPIO_SetStateLow(GPIO_ID id, tU8 u8Pin);extern tVoid LLD_GPIO_SetStateToggle(GPIO_ID id, tU8 u8Pin);extern tVoid LLD_GPIO_AFToGpioSwitch(tU8 u8Pin);extern tVoid LLD_GPIO_GpioToAFSwitch(tU8 u8Pin);#ifdef __cplusplus}#endif#endif  /* _LLD_GPIO_H_ *//* End of file */

⌨️ 快捷键说明

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