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

📄 lib.h

📁 本人经过实验的可以再LPC2214上跑起来的ucos-ii。
💻 H
字号:


typedef unsigned char  uint8;                   /* defined for unsigned 8-bits integer variable 	无符号8位整型变量  */
typedef signed   char  int8;                    /* defined for signed 8-bits integer variable		有符号8位整型变量  */
typedef unsigned short uint16;                  /* defined for unsigned 16-bits integer variable 	无符号16位整型变量 */
typedef signed   short int16;                   /* defined for signed 16-bits integer variable 		有符号16位整型变量 */
typedef unsigned int   uint32;                  /* defined for unsigned 32-bits integer variable 	无符号32位整型变量 */
typedef signed   int   int32;                   /* defined for signed 32-bits integer variable 		有符号32位整型变量 */
typedef float          fp32;                    /* single precision floating point variable (32bits) 单精度浮点数(32位长度) */
typedef double         fp64;                    /* double precision floating point variable (64bits) 双精度浮点数(64位长度) */

#define NoInt 0x80
/*调试用宏定义*/
#define MAIN_DEBUG_MODE 0
#define ISR_DEBUG_MODE 0
#define STATE_MODE 1

/*GPIO设置相关宏定义macros related with */
#define GPIOPIN0		1<<0
#define GPIOPIN1		1<<1
#define GPIOPIN2		1<<2
#define GPIOPIN3		1<<3
#define GPIOPIN4		1<<4
#define GPIOPIN5		1<<5
#define GPIOPIN6		1<<6
#define GPIOPIN7		1<<7
#define GPIOPIN8		1<<8
#define GPIOPIN9		1<<9
#define GPIOPIN10	1<<10
#define GPIOPIN11	1<<11
#define GPIOPIN12	1<<12
#define GPIOPIN13	1<<13
#define GPIOPIN14	1<<14
#define GPIOPIN15	1<<15
#define GPIOPIN16	1<<16
#define GPIOPIN17	1<<17
#define GPIOPIN18	1<<18
#define GPIOPIN19	1<<19
#define GPIOPIN20	1<<20
#define GPIOPIN21	1<<21
#define GPIOPIN22	1<<22
#define GPIOPIN23	1<<23
#define GPIOPIN24	1<<24
#define GPIOPIN25	1<<25
#define GPIOPIN26	1<<26
#define GPIOPIN27	1<<27
#define GPIOPIN28	1<<28
#define GPIOPIN29	1<<29
#define GPIOPIN30	1<<30
#define GPIOPIN31	1<<31

#define LED17 GPIOPIN17
#define LED15 GPIOPIN15

#define LED21 GPIOPIN21
#define LED14 GPIOPIN14

#define LED30 GPIOPIN30
#define LED31 GPIOPIN31

#define CS0 GPIOPIN0

#define GPIO0  0
#define GPIO1  1
#define GPIO2  2
#define GPIO3  3

/*串行口相关宏定义marcos related with the usarts*/
#define UART0 		0
#define UART1		1

//串行口设置波特率
#define BPS_1024000 	1024000
#define BPS_512000 		512000
#define BPS_235000 		235000
#define BPS_115200 		115200
#define BPS_9600		9600
#define BPS_4800		4800
#define BPS_2400		2400
#define BPS_1200		1200

//串行口设置数据位的位数--U0LCR[1:0]
#define BITS_5			0x00
#define BITS_6			0x01
#define BITS_7			0x10
#define BITS_8			0x11
//停止位--U0LCR[2]
#define STOPBITS_1		0<<2	
#define STOPBITS_2		1<<2
//奇偶使能
#define PARITYDISABLE	0<<3
#define PARITYENABLE	1<<3
#define ODDPARITY		0<<4
#define EVENPARITY		0x01<<4
#define FORCEONE		0x10<<4
#define FORCEZERO		0x11<<4
//时能间隔发送--此位为1输出管脚TxD强制为逻辑0
#define SENDDISABLE		0<<6
#define SENDENABLE		1<<6
//出书锁存器访问位
#define DIVACCESSENABLE	1<<7
#define DIVACCESSDISABLE	0<<7
//UART0中断号
#define UART0IntID 6
#define UART1IntID 7
#define EXT0IntID 14
//中断向量号
#define CTRL0 0
#define CTRL1 1
#define CTRL2 2
#define CTRL3 3
#define CTRL4 4
#define CTRL5 5
#define CTRL6 6
#define CTRL7 7
#define CTRL8 8
#define CTRL9 9
#define CTRL10 10
#define CTRL11 11
#define CTRL12 12
#define CTRL13 13
#define CTRL14 14
#define CTRL15 15


//SPC3的起始地址【分配为Bank0块】
#define CS0BASEADDR 0x80000000
#define SPC3BASEADR CS0BASEADDR

#define WR GPIOPIN27
#define WR_PORT	GPIO3
#define RD GPIOPIN1
#define RD_PORT	GPIO1
#define RST GPIOPIN25
#define RST_PORT GPIO2
#define VPC3ADDR 0x7ff
#define VPC3ADDR_PORT GPIO3
#define VPC3DATA 0xff
#define VPC3DATA_PORT GPIO2
#define XREADY GPIOPIN22
#define XREADY_PORT GPIO2
//地址转换宏
#define GetAddr(addr) (volatile unsigned char*/*uint16 * 存储器的位数长度*/)(SPC3BASEADR | addr)

#ifndef _LIB_H
#define _LIB_H
/*定义串口模式设置数据结构*/
typedef struct UartMode
{
    uint8 datab; //字长度,5.6.7.8
    uint8 stopb; //停止位。1.2
    uint8 parity; //奇偶校验位,0为无校验,1为奇数校验,2为偶数校验
} UARTMODE;

/*declaretion of the public function*/
void GPIOOutputMode(uint8 GPIOx, uint32 GPIOPins);
void GPIOInputMode(uint8 GPIOx, uint32 GPIOPins);
void GPIOSetBits(uint8 GPIOx, uint32 GPIOPins);
void GPIOResetBits(uint8 GPIOx, uint32 GPIOPins);

void UARTxBaudSet(uint8 UARTx, uint32 BAUDRATE);
void UARTxBitsSet(uint8 UARTx, uint8 Bits);
void UARTxDefInit(uint8 UARTx);
void UARTxSendByte(uint8 UARTx, uint8 data);
void UARTxSendStr(uint8 UARTx, uint8 const *str);
void UARTxEnable(uint8 UARTx);
void UARTxDisable(uint8 UARTx);
void UARTxFIFOEnable(uint8 UARTx, uint8 BytesTrigger);
void UARTxINTEnable(uint8 UARTx, uint8 CTRLx, uint32 irq_addr);
void UARTxINTDisable(uint8 UARTx);
void UARTxDisable(uint8 UARTx);
void UARTxSendByte(uint8 UARTx, uint8 data);
void UARTxSendBufer(uint8 UARTx, uint8 data[8]);
void DataAddrBusEnable(void);
void writeSpc3(uint32 addr, uint8 data);
void SPC3Reset(void);
uint8 readSpc3(uint32 addr);
#endif

⌨️ 快捷键说明

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