于十天学会AVR单片机的教程头文件
时间:11-19
来源:互联网
点击:
液晶常量及操作/#define LCDb_CTRL PORTD //12864控制端口定义#define LCDb_CTRL_DDR DDRD //控制端口方向寄存器定义#define LCDb_RS PD4 //定义四个控制引脚#define LCDb_RW PD5#define LCDb_E PD6#define LCDb_RST PD7#define LCDb_L1 0x80 //第一行的地址#define LCDb_L2 0x90 //第二行的地址#define LCDb_L3 0x88 //第三行的地址#define LCDb_L4 0x98 //第四行的地址#define LCDb_CGRAM_ADDR 0x40 //CGRAM的开始地址#define LCDb_CGMAX 64 //CGRAM存储的最大字节数#define LCDb_SET_RS LCDb_CTRL|=BIT(LCDb_RS) //四个控制管脚的控制操作#define LCDb_SET_RW LCDb_CTRL|=BIT(LCDb_RW)#define LCDb_SET_E LCDb_CTRL|=BIT(LCDb_E)#define LCDb_SET_RST LCDb_CTRL|=BIT(LCDb_RST)#define LCDb_CLR_RS LCDb_CTRL&=~BIT(LCDb_RS)#define LCDb_CLR_RW LCDb_CTRL&=~BIT(LCDb_RW)#define LCDb_CLR_E LCDb_CTRL&=~BIT(LCDb_E)#define LCDb_CLR_RST LCDb_CTRL&=~BIT(LCDb_RST)#define LCDb_DO PORTB //输出数据总线端口定义#define LCDb_DI PINB //输入数据总线端口定义#define LCDb_DATA_DDR DDRB //数据总线方向寄存器定义#define LCDb_FUNCTION 0x38 // 液晶模式为8位#define LCDb_BASCMD 0x30 // 基本指令集#define LCDb_CLS 0x01 // 清屏#define LCDb_HOME 0x02 // 地址返回原点,不改变DDRAM内容#define LCDb_ENTRY 0x06 // 设定输入模式,光标加,屏幕不移动#define LCDb_C2L 0x10 // 光标左移#define LCDb_C2R 0x14 // 光标右移#define LCDb_D2L 0x18 // 屏幕左移#define LCDb_D2R 0x1C // 屏幕又移#define LCDb_ON 0x0C // 打开显示#define LCDb_OFF 0x08 // 关闭显示#define LCDb_EXTCMD1 0x34 // 扩充指令集,关闭绘图显示#define LCDb_EXTCMD2 0x36 // 扩充指令集,打开绘图显示#define LCDb_EXTCLS 0x01 // 清屏#define LCDb_REVL1 0x04 // 反显第1行#define LCDb_REVL2 0x05 // 反显第2行#define LCDb_REVL3 0x06 // 反显第3行#define LCDb_REVL4 0x07 // 反显第4行/按键常量/#define KEY_DDR DDRD //按键方向定义#define KEY_PORTO PORTD //按键断口输出定义#define KEY_PORTI PIND //按键断口输入定义#define OUT 0xFF //输出常量#define IN 0xF0 //输入常量/按键外部中断常量/#define GLOBAL 7 //全局中断位宏定义#define EXTINT1 7 //外部中断1位宏定义#define EXTINT0 6 //外部中断0位宏定义/串行DA常量/#define DA_DATA PB5 //串行数据线#define DA_CLK PB7 //串行时钟线#define DA_CS PA1 //片选线/DS18B20常量/#define DS18B20 PA5/TWI(IIC)常量/#define START 0x08 //START信号发送完毕状态#define MT_SLA_ACK 0x18 //从器件地址发送,返回ACK#define MT_SLA_NOACK 0x20 //从器件地址发送,但是返回NOACK#define MT_DATA_ACK 0x28 //数据已发送,返回ACK#define MT_DATA_NOACK 0x30 //数据已发送,返回NOACK#define Start() (TWCR=(1led(TCS<>1010 or DS=00 or RS=00)//RAM 命令#define C_RAMBASE 0xC0 //RAM0~RAM30<1 地址需左移一位 /USB常量/#define CSUSB PA7#define D12_INT PD3#define WR_N PD4#define RD_N PD5#define C_D PD6#define D12_CS PD7#define USBCTL_DDR DDRD#define USBCTL_PORT PORTD#define USBDAT_DDR DDRB#define USBDAT_PORT PORTB#define USBDAT_PIN PINB#define CMD 0x01#define DAT 0x00#define UEN_GINT() SREG&=~BIT(7)#define EN_GINT() SREG|=BIT(7)#define MSB(x) (((x) >> 8) & 0xFF)#define MAX_ENDPOINTS (uchar)0x3#define NOLAZYCLOCK 0x02#define CLOCKRUNNING 0x04#define INTERRUPTMODE 0x08#define SOFTCONNECT 0x10#define ENDP_NONISO 0x00#define ENDP_ISOOUT 0x40#define ENDP_ISOIN 0x80#define ENDP_ISOIO 0xC0#define CLOCK_12M 0x03#define CLOCK_4M 0x0b#define SETTOONE 0x40#define SOFONLY 0x80#define NORMALPLUSSOF 0x20#define ENDP4INTENABLE 0x40#define ENDP5INTENABLE 0x80#define INT_ENDP0OUT 0x01#define INT_ENDP0IN 0x02#define INT_ENDP1OUT 0x04#define INT_ENDP1IN 0x08#define INT_ENDP2OUT 0x10#define INT_ENDP2IN 0x20#define INT_BUSRESET 0x40#define INT_SUSPENDCHANGE 0x80#define SETUPPACKET 0x20#define BUFFER0FULL 0x20#define BUFFER1FULL 0x40#define FULLEMPTY 0x01#define STALL 0x02#define USB_IDLE 0#define USB_TRANSMIT 1#define USB_RECEIVE 2#define MAX_CTLDAT_SIZE 8#define USB_ENDPOINT_DIRECTION_MASK 0x80#define USB_REQUEST_MASK (uchar)0x0F#define USB_REQUEST_TYPE_MASK (uchar)0x60#define USB_STANDARD_REQUEST (uchar)0x00#define DEVICE_ADDRESS_MASK 0x7F#define USB_FEATURE_ENDPOINT_STALL (uint)0x0000#define USB_FEATURE_REMOTE_WAKEUP (uint)0x0001#define EP0_PACKET_SIZE 16#define EP1_PACKET_SIZE 16#define EP2_PACKET_SIZE 64#define USB_RECIPIENT (uchar)0x1F#define USB_RECIPIENT_DEVICE (uchar)0x00#define USB_RECIPIENT_INTERFACE (uchar)0x01#define USB_RECIPIENT_ENDPOINT (uchar)0x02#define USB_DEVICE_DESCRIPTOR_TYPE 0x01#define USB_CONFIGURATION_DESCRIPTOR_TYPE 0x02#define USB_STRING_DESCRIPTOR_TYPE 0x03#define USB_INTERFACE_DESCRIPTOR_TYPE 0x04#define USB_ENDPOINT_DESCRIPTOR_TYPE 0x05#define USB_POWER_DESCRIPTOR_TYPE 0x06/* 设备描述符: 测试设备类型 */#define USB_CLASS_CODE_TEST_CLASS_DEVICE 0xdc/* D12 配置描述符长度 /#define CONFIG_DESCRIPTOR_LENGTH sizeof(USB_CONFIGURATION_DESCRIPTOR) \+ sizeof(USB_INTERFACE_DESCRIPTOR) \+ (NUM_ENDPOINTS * sizeof(USB_ENDPOINT_DESCRIPTOR))/* D12 接口描述符中: 除端点0的端点索引数目 /#define NUM_ENDPOINTS 4/* 设备描述符: 测试设备类型 */#define USB_CLASS_CODE_TEST_CLASS_DEVICE 0xdc/* 接口描述符: 子类代码 */#define USB_SUBCLASS_CODE_TEST_CLASS_D12 0xA0/* 接口描述符: 协议代码 */#define USB_PROTOCOL_CODE_TEST_CLASS_D12 0xB0/*USB 端点描述符结构体: 端点属性/#define USB_ENDPOINT_TYPE_MASK 0x03#define USB_ENDPOINT_TYPE_CONTROL 0x00#define USB_ENDPOINT_TYPE_ISOCHRONOUS 0x01#define USB_ENDPOINT_TYPE_BULK 0x02#define USB_ENDPOINT_TYPE_INTERRUPT 0x03/通用子函数/void Delayms(uint MS);/LED子函数/void One_led(uchar number,uchar light);void All_led(uchar light);void Flow_LED(uchar MS);void Flash_LED(uchar number,uchar MS);/数码管子函数/void One_smg_display(uchar data,uchar number);void All_smg_display(uchar *pdata);void Cycle_smg_display(uchar *pdata);/1602液晶管子函数/void LCD1602_portini(void);uchar LCD1602_readbyte(uchar DatCmd);void LCD1602_sendbyte(uchar DatCmd, uchar dByte);void LCD1602_sendstr(uchar *ptString);void LCD1602_clear(void);uchar LCD1602_readBF(void);void LCD1602_gotoXY(uchar Row, uchar Col);void LCD1602_initial(void);/USB函数/void D12_init(void);void OutB(uchar cmd,uchar dat);uchar InB(void);void Set_addren(uchar addr, uchar enable);void Set_EPen(uchar enable);void Set_mode(uchar config,uchar clkdiv);void Set_DMA(uchar bMode);uint Read_IntR(void);uchar Sel_EP(uchar endp);uchar Read_EPsta(uchar endp);uchar Read_LttransSta(uchar endp);void Set_EPsta(uchar endp,uchar stall);void Set_Sresume(void);uchar Read_EP(uchar endp,uchar len,uchar * buf);uchar Write_EP(uchar endp,uchar len,uchar * buf);void Ack_EP(uchar endp);void Clear_buf(uchar endp);void Stall_ep0(void);void S_trans(uchar * buf, uchar len);void Ep0_rxdone(void);void Ep0_txdone(void);void Ep1_txdone(void);void Ep1_rxdone(void);void Ep2_txdone(void);void Ep2_rxdone(void);void Reserved(void);void Get_status(void);void Clr_feature(void);void Set_feature(void);void Set_addr(void);void Get_descriptor(void);void Get_config(void);void Set_config(void);void Get_interface(void);void Set_interface(void);void USB_reconnect(void);void Control_handler(void);void Uart_sendB(uchar sendB);
AVR单片机头文 相关文章:
- 嵌入式学习笔记17——AVR单片机之头文件简介和使用(11-19)
- Windows CE 进程、线程和内存管理(11-09)
- RedHatLinux新手入门教程(5)(11-12)
- uClinux介绍(11-09)
- openwebmailV1.60安装教学(11-12)
- Linux嵌入式系统开发平台选型探讨(11-09)