📄 io.h
字号:
#ifndef __LF240XIO_H__
#define __LF240XIO_H__
#ifdef __cplusplus
extern "C" {
#endif
#include "regs240x.h"
/*
MCRA
*/
#define TCLKINA 0x8000
#define TDIRA 0x4000
#define T2PWM 0x2000
#define T1PWM 0x1000
#define PWM6 0x0800
#define PWM5 0x0400
#define PWM4 0x0200
#define PWM3 0x0100
#define PWM2 0x0080
#define PWM1 0x0040
#define CAP3 0x0020
#define CAP2 0x0010
#define CAP1 0x0008
#define XINT1 0x0004
#define SCIRXD 0x0002
#define SCITXD 0x0001
#define IOPB7_ENABLE 0x8000
#define IOPB6_ENABLE 0x4000
#define IOPB5_ENABLE 0x2000
#define IOPB4_ENABLE 0x1000
#define IOPB3_ENABLE 0x0800
#define IOPB2_ENABLE 0x0400
#define IOPB1_ENABLE 0x0200
#define IOPB0_ENABLE 0x0100
#define IOPA7_ENABLE 0x0080
#define IOPA6_ENABLE 0x0040
#define IOPA5_ENABLE 0x0020
#define IOPA4_ENABLE 0x0010
#define IOPA3_ENABLE 0x0008
#define IOPA2_ENABLE 0x0004
#define IOPA1_ENABLE 0x0002
#define IOPA0_ENABLE 0x0001
#define IOPB7_DISABLE 0x7FFF
#define IOPB6_DISABLE 0xBFFF
#define IOPB5_DISABLE 0xDFFF
#define IOPB4_DISABLE 0xEFFF
#define IOPB3_DISABLE 0xF7FF
#define IOPB2_DISABLE 0xFBFF
#define IOPB1_DISABLE 0xFDFF
#define IOPB0_DISABLE 0xFEFF
#define IOPA7_DISABLE 0xFF7F
#define IOPA6_DISABLE 0xFFBF
#define IOPA5_DISABLE 0xFFDF
#define IOPA4_DISABLE 0xFFEF
#define IOPA3_DISABLE 0xFFF7
#define IOPA2_DISABLE 0xFFFB
#define IOPA1_DISABLE 0xFFFD
#define IOPA0_DISABLE 0xFFFE
/*
MCRB
*/
#define TMS2 0x8000
#define TMS 0x4000
#define TDO 0x2000
#define TDI 0x1000
#define TCK 0x0800
#define EMU1 0x0400
#define EMU0 0x0200
#define XINT2 0x0100
#define CANRX 0x0080
#define CANTX 0x0040
#define SPISTE 0x0020
#define SPICLK 0x0010
#define SPISOMI 0x0008
#define SPISIMO 0x0004
#define BIO 0x0002
#define W_R 0x0001
#define IOPD0_ENABLE 0x0100
#define IOPC7_ENABLE 0x0080
#define IOPC6_ENABLE 0x0040
#define IOPC5_ENABLE 0x0020
#define IOPC4_ENABLE 0x0010
#define IOPC3_ENABLE 0x0008
#define IOPC2_ENABLE 0x0004
#define IOPC1_ENABLE 0x0002
#define IOPC0_ENABLE 0x0001
#define IOPD0_DISABLE 0xFEFF
#define IOPC7_DISABLE 0xFF7F
#define IOPC6_DISABLE 0xFFBF
#define IOPC5_DISABLE 0xFFDF
#define IOPC4_DISABLE 0xFFEF
#define IOPC3_DISABLE 0xFFF7
#define IOPC2_DISABLE 0xFFFB
#define IOPC1_DISABLE 0xFFFD
#define IOPC0_DISABLE 0xFFFE
/*
MCRC
*/
#define MCRC_RES0 0x8000
#define IOPF6 0x4000
#define TCLKINB 0x2000
#define TDIRB 0x1000
#define T4PWM 0x0800
#define T3PWM 0x0400
#define CAP6 0x0200
#define CAP5 0x0100
#define CAP4 0x0080
#define PWM12 0x0040
#define PWM11 0x0020
#define PWM10 0x0010
#define PWM9 0x0008
#define PWM8 0x0004
#define PWM7 0x0002
#define CLKOUT 0x0001
#define IOPF6_ENABLE 0x4000
#define IOPF5_ENABLE 0x2000
#define IOPF4_ENABLE 0x1000
#define IOPF3_ENABLE 0x0800
#define IOPF2_ENABLE 0x0400
#define IOPF1_ENABLE 0x0200
#define IOPF0_ENABLE 0x0100
#define IOPE7_ENABLE 0x0080
#define IOPE6_ENABLE 0x0040
#define IOPE5_ENABLE 0x0020
#define IOPE4_ENABLE 0x0010
#define IOPE3_ENABLE 0x0008
#define IOPE2_ENABLE 0x0004
#define IOPE1_ENABLE 0x0002
#define IOPE0_ENABLE 0x0001
#define IOPF6_DISABLE 0xBFFF
#define IOPF5_DISABLE 0xDFFF
#define IOPF4_DISABLE 0xEFFF
#define IOPF3_DISABLE 0xF7FF
#define IOPF2_DISABLE 0xFBFF
#define IOPF1_DISABLE 0xFDFF
#define IOPF0_DISABLE 0xFEFF
#define IOPE7_DISABLE 0xFF7F
#define IOPE6_DISABLE 0xFFBF
#define IOPE5_DISABLE 0xFFDF
#define IOPE4_DISABLE 0xFFEF
#define IOPE3_DISABLE 0xFFF7
#define IOPE2_DISABLE 0xFFFB
#define IOPE1_DISABLE 0xFFFD
#define IOPE0_DISABLE 0xFFFE
/*
PADATDIR
*/
#define IOA7OUT 0x8000
#define IOA6OUT 0x4000
#define IOA5OUT 0x2000
#define IOA4OUT 0x1000
#define IOA3OUT 0x0800
#define IOA2OUT 0x0400
#define IOA1OUT 0x0200
#define IOA0OUT 0x0100
#define IOA7_HIGH 0x0080
#define IOA6_HIGH 0x0040
#define IOA5_HIGH 0x0020
#define IOA4_HIGH 0x0010
#define IOA3_HIGH 0x0008
#define IOA2_HIGH 0x0004
#define IOA1_HIGH 0x0002
#define IOA0_HIGH 0x0001
/*
PBDATDIR
*/
#define IOB7OUT 0x8000
#define IOB6OUT 0x4000
#define IOB5OUT 0x2000
#define IOB4OUT 0x1000
#define IOB3OUT 0x0800
#define IOB2OUT 0x0400
#define IOB1OUT 0x0200
#define IOB0OUT 0x0100
#define IOB7_HIGH 0x0080
#define IOB6_HIGH 0x0040
#define IOB5_HIGH 0x0020
#define IOB4_HIGH 0x0010
#define IOB3_HIGH 0x0008
#define IOB2_HIGH 0x0004
#define IOB1_HIGH 0x0002
#define IOB0_HIGH 0x0001
/*
PCDATDIR
*/
#define IOC7OUT 0x8000
#define IOC6OUT 0x4000
#define IOC5OUT 0x2000
#define IOC4OUT 0x1000
#define IOC3OUT 0x0800
#define IOC2OUT 0x0400
#define IOC1OUT 0x0200
#define IOC0OUT 0x0100
#define IOC7_HIGH 0x0080
#define IOC6_HIGH 0x0040
#define IOC5_HIGH 0x0020
#define IOC4_HIGH 0x0010
#define IOC3_HIGH 0x0008
#define IOC2_HIGH 0x0004
#define IOC1_HIGH 0x0002
#define IOC0_HIGH 0x0001
/*
PDDATDIR
*/
#define IOD0OUT 0x0100
#define IOD0_HIGH 0x0001
/*
PEDATDIR
*/
#define IOE7OUT 0x8000
#define IOE6OUT 0x4000
#define IOE5OUT 0x2000
#define IOE4OUT 0x1000
#define IOE3OUT 0x0800
#define IOE2OUT 0x0400
#define IOE1OUT 0x0200
#define IOE0OUT 0x0100
#define IOE7_HIGH 0x0080
#define IOE6_HIGH 0x0040
#define IOE5_HIGH 0x0020
#define IOE4_HIGH 0x0010
#define IOE3_HIGH 0x0008
#define IOE2_HIGH 0x0004
#define IOE1_HIGH 0x0002
#define IOE0_HIGH 0x0001
/*
PFDATDIR
*/
#define IOF6OUT 0x4000
#define IOF5OUT 0x2000
#define IOF4OUT 0x1000
#define IOF3OUT 0x0800
#define IOF2OUT 0x0400
#define IOF1OUT 0x0200
#define IOF0OUT 0x0100
#define IOF6_HIGH 0x0040
#define IOF5_HIGH 0x0020
#define IOF4_HIGH 0x0010
#define IOF3_HIGH 0x0008
#define IOF2_HIGH 0x0004
#define IOF1_HIGH 0x0002
#define IOF0_HIGH 0x0001
#define OUT_HIGH 1
#define OUT_LOW 0
//定义输入与输出
#define IO_IN 0
#define IO_OUT 1
//定义为输出功能时的输出高低
#define IO_LOW 0
#define IO_HIGH 1
//具体的IO口参数设置
//#define NO1_MCR Val_MCRC
//#define NO1_DATDIR Val_PEDATDIR
//#define NO1_ENA IOPE7_ENABLE
//#define NO1_OUT IOE7OUT
//#define NO1_HIGH IOE7_HIGH
#define NO1_MCR Val_MCRA
#define NO1_DATDIR Val_PADATDIR
#define NO1_ENA IOPA2_ENABLE
#define NO1_OUT IOA2OUT
#define NO1_HIGH IOA2_HIGH
#define PNO1_MCR Val_MCRA
#define PNO1_DATDIR Val_PADATDIR
#define PNO1_ENA IOPA3_ENABLE
#define PNO1_OUT IOA3OUT
#define PNO1_HIGH IOA3_HIGH
#define PNO2_MCR Val_MCRA
#define PNO2_DATDIR Val_PADATDIR
#define PNO2_ENA IOPA4_ENABLE
#define PNO2_OUT IOA4OUT
#define PNO2_HIGH IOA4_HIGH
//2005.12.28 日添加
#define CAP1_MCR Val_MCRA
#define CAP1_DATDIR Val_PADATDIR
#define CAP1_ENA IOPA3_ENABLE
#define CAP1_OUT IOA3OUT
#define CAP1_HIGH IOA3_HIGH
#define CAP2_MCR Val_MCRA
#define CAP2_DATDIR Val_PADATDIR
#define CAP2_ENA IOPA4_ENABLE
#define CAP2_OUT IOA4OUT
#define CAP2_HIGH IOA4_HIGH
#define CAP3_MCR Val_MCRA
#define CAP3_DATDIR Val_PADATDIR
#define CAP3_ENA IOPA5_ENABLE
#define CAP3_OUT IOA5OUT
#define CAP3_HIGH IOA5_HIGH
#define CAP4_MCR Val_MCRC
#define CAP4_DATDIR Val_PEDATDIR
#define CAP4_ENA IOPA3_ENABLE
#define CAP4_OUT IOE7OUT
#define CAP4_HIGH IOE7_HIGH
//本函数配置IO口的功能,参数列表为1.IO口复用控制寄存器,2端口方向与数据控制寄存器
//3一般IO口似能值,4,端口为输入还是输出,5,如果为输出时的默认值6,输出寄存器值
void IO_Status_Init(volatile unsigned int * mcr,volatile unsigned int * datdir,unsigned int X_enable ,
unsigned int in_out,unsigned int X_io_out,unsigned int High_Low ,unsigned int X_high);
unsigned int IN_Status_Load(volatile unsigned int * datdir,unsigned int X_high);
void OUT_Status_Set(volatile unsigned int * datdir,unsigned High_Low,unsigned int X_high);
void IO_Init();
#ifdef __cplusplus
}
#endif /* extern "C" */
#endif
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -