📄 d12config.h
字号:
/****************************************Copyright (c)**************************************************
** 广州周立功单片机发展有限公司
** 研 究 所
** 产品一部
**
** http://www.zlgmcu.com
**
** 文 件 名: D12Config.h
** 最后修改日期: 2006年3月12日
** 描 述: PDIUSBD12 设备端驱动程序 硬件配置头文件
** 版 本: V1.0
** 最后修改 :Zhou Shuwu 移植到NiosII上
**********************************************************************************************************/
/******================= modified by Zhou Shuwu ==================================***********/
#include "altera_avalon_pio_regs.h"
#include "system.h"
/*
* User should modify these Macro definitions according to the real SOPC system
*/
//For USB D12
#ifndef D12_BASE //这是USB核的基地址
#define D12_BASE 0xffffffff //user's definition here
#endif
#if D12_BASE == 0xffffffff
#error "No definition of D12 core.\n"
#endif
//For reset usb
#ifndef USB_NRST_BASE //这是USB_nRST PIO核的基地址
#define USB_NRST_BASE 0xffffffff //user's definition here
#endif
#if USB_NRST_BASE == 0xffffffff
#error "No definition of USB_NRST PIO core.\n"
#endif
//For detecting the interrupt
#ifndef USB_NINT_BASE //USB_NINT PIO核的基地址
#define USB_NINT_BASE 0xffffffff //user's definition here
#endif
#if USB_NINT_BASE == 0xffffffff
#error "No definition of USB_NINT PIO core.\n"
#endif
#ifndef USB_SUSPD_BASE //这是SD_WP_PIO核的基地址
#define USB_SUSPD_BASE 0xfffffff0 //user's definition here
#endif
#if USB_SUSPD_BASE == 0xffffffff
#error "No definition of USB_SUSPD PIO core.\n"
#endif
/******================= modified by Zhou Shuwu ==================================***********/
typedef unsigned char INT8U; /* defined for unsigned 8-bits integer variable 无符号8位整型变量 */
typedef signed char INT8; /* defined for signed 8-bits integer variable 有符号8位整型变量 */
typedef unsigned short INT16U; /* defined for unsigned 16-bits integer variable 无符号16位整型变量 */
typedef signed short INT16; /* defined for signed 16-bits integer variable 有符号16位整型变量 */
typedef unsigned int INT32U; /* 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位长度) */
/******================= modified by Zhou Shuwu ==================================***********/
/*
__swi(0x00) void SwiHandle1(int Handle);
#define ENABLE() SwiHandle1(1); // 使能EINT0中断
#define DISABLE() SwiHandle1(0); // 禁止EINT0中断
*/
#define ENABLE() IOWR_ALTERA_AVALON_PIO_IRQ_MASK(USB_NINT_BASE, 0xff) //enable interrupts
#define DISABLE() IOWR_ALTERA_AVALON_PIO_IRQ_MASK(USB_NINT_BASE, 0x00) //enable interrupts
/*
//PDIUSBD12命令与数据地址
#define D12_COM (*((volatile INT8U *) 0x83200001)) //命令地址
#define D12_DAT (*((volatile INT8U *) 0x83200000)) //数据地址
#define D12_NOP (*((volatile INT8U *) 0x80000000)) //总线空操作地址,只能读
*/
#define D12_COM (*((volatile INT8U *) (D12_BASE+4))) //命令地址
#define D12_DAT (*((volatile INT8U *) (D12_BASE))) //数据地址
//#define D12_NOP (*((volatile INT8U *) (D12_BASE+8))) //总线空操作地址,只能读
/*设定 PDIUSBD12 各端口的功能*/
//#define USBRST_GPIO() //PINSEL2 &= ~(1 << 3) //初始化USBRST为GPIO
//#define SUSP_GPIO() //PINSEL2 &= ~(3 << 4) //初始化SUSP 为GPIO
/*设定 PDIUSBD12 各端口的方向*/
//#define USBRST_OUT() IO1DIR |= (1 << 16) //设定USBRST引脚为输出口
//#define SUSP_OUT() IO3DIR |= (1 << 28) //设定SUSP引脚为输出口
/*置 PDIUSBD12 各端口为高电平或低电平 */
/*
#define SET_USBRST() IO1SET = (1 << 16) //置USBRST为高电平
#define SET_SUSP() IO3SET = (1 << 28) //置SUSP 为高电平
#define CLR_USBRST() IO1CLR = (1 << 16) //置USBRST为低电平
#define CLR_SUSP() IO3CLR = (1 << 28) //置SUSP 为低电平
*/
#define SET_USBRST() IOWR_ALTERA_AVALON_PIO_DATA(USB_NRST_BASE, 1)//置USBRST为高电平
#define SET_SUSP() IOWR_ALTERA_AVALON_PIO_DATA(USB_SUSPD_BASE, 1)//置SUSP 为高电平
#define CLR_USBRST() IOWR_ALTERA_AVALON_PIO_DATA(USB_NRST_BASE, 0) //置USBRST为低电平
#define CLR_SUSP() IOWR_ALTERA_AVALON_PIO_DATA(USB_SUSPD_BASE, 0) //置SUSP 为低电平
/* 配置 PDIUSBD12 的中断引脚 */
/*
#define INIT_INTD12() PINSEL1 &= 0xCFFFFFFF;PINSEL1 |= 0x20000000 // 初始化INT_USB为中断输入口
#define CLR_INTD12() EXTINT |= 1<<3 // 清除EINT3中断标志
#define CLR_INT() VICVectAddr = 0x00 // 通知中断结束
*/
/* 配置 PDIUSBD12 的中断引脚 */
#define CLR_INTD12() IOWR_ALTERA_AVALON_PIO_EDGE_CAP(USB_NINT_BASE, 0);//清除中断标志
/******================= modified by Zhou Shuwu ==================================***********/
//下面的函数较少用,如需要,可将其值改为1即可
#define D12_SendResume_EN 0
#define D12_ReadCurrentFrameNumber_EN 0
#define D12_ClearBuff_EN 0
#define D12_ReadEndpointStatus_EN 1
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -