📄 nereid_usb.h
字号:
/* nereid_usb.h - header for Nereid USB (SL811HST) * Copyright (C) 2003 Tachibana Eriko * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */#ifndef nereid_usb_h#define nereid_usb_h#include "binary.h"/* Nereid 惂屼儗僕僗僞 */#define NEREID_CTRL_0 ((__volatile unsigned char*) 0xece3f1)#define NEREID_CTRL_1 ((__volatile unsigned char*) 0xecebf1)#define NEREID_CTRL NEREID_CTRL_0#define NEREID_USB_ENA 0x01#define NEREID_USB_POW 0x02#define NEREID_USB_INT 0x04#define NEREID_BM_ADDR 0x20#define NEREID_BM_SIZE 0x40#define NEREID_BM_ENA 0x80/* SL811HST 億乕僩傾僪儗僗 */#define SL811HST_ADDR_0 ((__volatile unsigned char*) 0xece381)#define SL811HST_DATA_0 ((__volatile unsigned char*) 0xece383)#define SL811HST_ADDR_1 ((__volatile unsigned char*) 0xeceb81)#define SL811HST_DATA_1 ((__volatile unsigned char*) 0xeceb83)#define SL811HST_ADDR SL811HST_ADDR_0#define SL811HST_DATA SL811HST_DATA_0/* SL811HST 儗僕僗僞 */#define SL811_A_HostControlRegister 0x00#define SL811_A_HostBaseAddress 0x01#define SL811_A_HostBaseLength 0x02#define SL811_A_HostPID_DeviceEndpoint 0x03 /* Write */#define SL811_A_USBStatus 0x03 /* Read */#define SL811_A_HostDeviceAddress 0x04 /* Write */#define SL811_A_HostTransferCountRegister 0x04 /* Read */#define SL811_ControlRegister1 0x05#define SL811_InterruptEnableRegister 0x06#define SL811_Reserved 0x07#define SL811_B_HostControlRegister 0x08#define SL811_B_HostBaseAddress 0x09#define SL811_B_HostBaseLength 0x0a#define SL811_B_HostPID_DeviceEndpoint 0x0b /* Write */#define SL811_B_USBStatus 0x0b /* Read */#define SL811_B_HostDeviceAddress 0x0c /* Write */#define SL811_B_HostTransferCountRegister 0x0c /* Read */#define SL811_InterruptStatusRegister 0x0d#define SL811_SOFCounterLow 0x0e /* Write */#define SL811_HWRevisionRegister 0x0e /* Read */#define SL811_SOFCounterHigh_ControlRegister2 0x0f#define SL811_BUF 0x10#define SL811_SIZE 0x100#define SL811_BUF_SIZE (SL811_SIZE - SL811_BUF)/* HostControlRegister 愝掕抣 */#define SL811_ARM b0000_0001 /* ARM */#define SL811_ISO b0001_0000 /* Isochronous */#define SL811_SOF b0010_0000 /* SYNC to SOF */#define SL811_SEQ b0100_0000 /* Data0/Data1 */#define SL811_READ_DATA0 b0000_0011 /* ARM, Enable, toHost, Data0 */#define SL811_READ_DATA1 b0100_0011 /* ARM, Enable, toHost, Data1 */#define SL811_WRITE_DATA0 b0000_0111 /* ARM, Enable, toDevice, Data0 */#define SL811_WRITE_DATA1 b0100_0111 /* ARM, Enable, toDevice, Data1 *//* A_USBStatus丄B_USBStatus 嶲徠抣 */#define SL811_ST_ACK b0000_0001 /* ACK */#define SL811_ST_ERR b0000_0010 /* Error */#define SL811_ST_TO b0000_0100 /* Time-Out */#define SL811_ST_SEQ b0000_1000 /* Sequence 0=Data0 1=Data1 */#define SL811_ST_SUP b0001_0000 /* Setup Packet */#define SL811_ST_OVFL b0010_0000 /* Overflow */#define SL811_ST_NAK b0100_0000 /* NAK */#define SL811_ST_STALL b1000_0000 /* STALL *//* ControlRegister1 愝掕抣 */#define SL811_C1_SOF b0000_0001 /* Hardware SOF Enable */#define SL811_C1_EOF2 b0000_0100 /* transfer in EOF2 Disable */#define SL811_C1_RESET b0000_1000 /* USB Engine Reset */#define SL811_C1_JKFS b0001_0000 /* J-K Force State */#define SL811_C1_SPEED b0010_0000 /* USB Speed */#define SL811_C1_SUSP b0100_0000 /* Suspend *//* InterruptEnableRegister 愝掕抣丄InterruptStatusRegister 嶲徠抣 */#define SL811_INT_A b0000_0001 /* USB-A */#define SL811_INT_B b0000_0010 /* USB-B */#define SL811_INT_BD b0000_0100 /* Babble Detection (攑巭) */#define SL811_INT_SOF b0001_0000 /* SOF Timer */#define SL811_INT_INS b0010_0000 /* Insert/Remove */#define SL811_INT_RESET b0100_0000 /* Reset/Resume */#define SL811_INT_D b1000_0000 /* D+ status *//* 妱傝崬傒嬛巭 */static __inline voidDI (void){ __asm __volatile ("move\tsr,-(sp)\n\tori\t#$700,sr"::);}/* 妱傝崬傒嫋壜 */static __inline voidEI (void){ __asm __volatile ("move\t(sp)+,sr"::);}/* 1僶僀僩撉傒崬傒 */static __inline unsigned charSL811Read (int addr){ unsigned char data; DI (); *SL811HST_ADDR = addr; data = *SL811HST_DATA; EI (); return data;}/* 擟堄僶僀僩撉傒崬傒 */static __inline voidSL811BufRead (int addr, unsigned char* buf, int size){ DI (); *SL811HST_ADDR = addr; while (--size >= 0) *buf++ = *SL811HST_DATA; EI ();}/* 1僶僀僩彂偒崬傒 */static __inline voidSL811Write (int addr, unsigned char data){ DI (); *SL811HST_ADDR = addr; *SL811HST_DATA = data; EI ();}/* 擟堄僶僀僩彂偒崬傒 */static __inline voidSL811BufWrite (int addr, const unsigned char* buf, int size){ DI (); *SL811HST_ADDR = addr; while (--size >= 0) *SL811HST_DATA = *buf++; EI ();}/* 僂僃僀僩 */#define DELAYMS(t) delay20ms ((t) * 20)static __inline voiddelay20ms (int time){ register int dummy; __asm __volatile ( "move.b (%2),%0\n" "@@: cmp.b (%2),%0\n" " beq @b\n" "@@: subq.b #1,%0\n" " bne @f\n" " moveq #$c8,%0\n" "@@: cmp.b (%2),%0\n" " beq @b\n" " subq.l #1,%3\n" " bgt @@b" : "=&d" (dummy), "=&d" (time) : "a" (0xe88023), "d" (time));}#endif /* !nereid_usb_h *//* EOF */
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -