starting with SDCC

  1. download and install sdcc from http://sdcc.sf.net (I'm using the CVS)
  2. now create a new folder und put the header files ezusb_reg.h and dtypes.h of the EZUSB - human interface project
  3. create a new subfolder called example and put the main.c, Makefile and getdevpath to it
  4. type
    make

    to compile and upload you first sdcc programm ;-)


Examples can be found here: EZ-USB - summary and examples

Files

Makefile

file: http://darcs.erazor-zone.de/ezusb/sdcc/blink_example/Makefile

CFLAGS=-I. -I../
DEVICE_PATH=$(shell ./getdevpath -v 0547 -p 2131)
 
all: main.ihx load
 
main.rel: main.c
	sdcc $(CFLAGS) -c main.c
 
main.ihx: main.rel
	sdcc $(CFLAGS) $(LFLAGS) main.rel;
 
load:
	fxload -D $(DEVICE_PATH) -I main.ihx
 
clean:
	rm -f *~ *.o *.ihx *.lnk *.lst *.mem *.map *.rel *.rst *.sym

main.c

file: http://darcs.erazor-zone.de/ezusb/sdcc/blink_example/main.c

#include <8051.h>
 
#include "ezusb_reg_rzr.h"
 
void main(void) {
  /* setup the io-ports */
  PORTBCFG=0x00;
  PORTCCFG=0x00;
  OEB=0xff;
  OEC=0xff;
  // output both to zero
  OUTB=0x00;
  OUTC=0x00;
 
  /* timer setup */
  // Timer 0 is in mode1 (16-bit counter)
  TMOD=0x01;
  // T0M cleared -> CLK24/12
  CKCON=0x00;
  // start Timer 0
  TCON=0x10;
 
  /* interrupts */
  // set EA and ET0
  IE=0x82;
 
  while ( 1 );
}
 
static void timer0_isr(void) interrupt 1 {
  OUTB=0xff-PINSB;
  OUTC=PINSC+1;
}

ezusb_reg.h

file: http://darcs.erazor-zone.de/ezusb/sdcc/ezusb_reg.h

/*
 *
 * $Id: ezusb_reg.h,v 1.6 2004/01/27 20:23:26 arniml Exp $
 *
 * Change History:
 *
 * $Log: ezusb_reg.h,v $
 * Revision 1.6  2004/01/27 20:23:26  arniml
 * add ISOCTL
 *
 * Revision 1.5  2004/01/26 18:36:24  arniml
 * add new SFRs (triggered by n64pad)
 *
 * Revision 1.4  2003/12/23 22:44:21  arniml
 * update with additional SFR etc.
 *
 * Revision 1.3  2002/03/03 23:35:32  arniml
 * add TOGCTL
 *
 * Revision 1.2  2001/08/15 18:24:03  arniml
 * added some register definitions for serial port 1 and IN2 endpoint
 *
 * Revision 1.1.1.1  2001/07/14 15:32:37  arniml
 * initial import
 *
 *
 */
 
#ifndef __EZUSB_REG_H__
#define __EZUSB_REG_H__
 
 
sbit  at 0xe8 EUSB;
sbit  at 0xac ES0;
sbit  at 0xae ES1;
sbit  at 0x98 RI_0;
sbit  at 0x99 TI_0;
sbit  at 0xc0 RI_1;
sbit  at 0xc1 TI_1;
sbit  at 0xca TR2;
sbit  at 0xcf TF2;
sbit  at 0xad ET2;
sbit  at 0xdf SMOD1;
 
sfr   at 0x86 DPS;
sfr   at 0x91 EXIF;
sfr   at 0x92 MPAGE;
sfr   at 0xe8 EIE;
sfr   at 0x98 SCON0;
sfr   at 0xc0 SCON1;
sfr   at 0x99 SBUF0;
sfr   at 0xc1 SBUF1;
sfr   at 0x8e CKCON;
sfr   at 0xc8 T2CON;
sfr   at 0xca RCAP2L;
sfr   at 0xcb RCAP2H;
sfr   at 0xcc TL2;
sfr   at 0xcd TH2;
sfr   at 0xd8 EICON;
sfr   at 0x82 DPL0;
sfr   at 0x83 DPH0;
sfr   at 0x84 DPL1;
sfr   at 0x85 DPH1;
 
 
xdata at 0x7fb4 unsigned char EP0CS;
xdata at 0x7f00 unsigned char IN0BUF;
xdata at 0x7fb5 unsigned char IN0BC;
xdata at 0x7ec0 unsigned char OUT0BUF;
xdata at 0x7fc5 unsigned char OUT0BC;
 
xdata at 0x7fb6 unsigned char IN1CS;
xdata at 0x7e80 unsigned char IN1BUF;
xdata at 0x7fb7 unsigned char IN1BC;
xdata at 0x7e40 unsigned char OUT1BUF;
xdata at 0x7fc6 unsigned char OUT1CS;
xdata at 0x7fc7 unsigned char OUT1BC;
 
xdata at 0x7e00 unsigned char IN2BUF;
xdata at 0x7fb9 unsigned char IN2BC;
xdata at 0x7fb8 unsigned char IN2CS;
xdata at 0x7fc9 unsigned char OUT2BC;
xdata at 0x7fc8 unsigned char OUT2CS;
xdata at 0x7dc0 unsigned char OUT2BUF;
 
xdata at 0x7d80 unsigned char IN3BUF;
xdata at 0x7d40 unsigned char OUT3BUF;
xdata at 0x7fba unsigned char IN3CS;
xdata at 0x7fbb unsigned char IN3BC;
xdata at 0x7fca unsigned char OUT3CS;
xdata at 0x7fcb unsigned char OUT3BC;
 
xdata at 0x7d00 unsigned char IN4BUF;
xdata at 0x7cc0 unsigned char OUT4BUF;
xdata at 0x7fbc unsigned char IN4CS;
xdata at 0x7fcc unsigned char OUT4CS;
xdata at 0x7fbd unsigned char IN4BC;
xdata at 0x7fcd unsigned char OUT4BC;
 
xdata at 0x7f9c unsigned char OEA;
xdata at 0x7f96 unsigned char OUTA;
xdata at 0x7f99 unsigned char PINSA;
xdata at 0x7f9d unsigned char OEB;
xdata at 0x7f97 unsigned char OUTB;
xdata at 0x7f9a unsigned char PINSB;
xdata at 0x7f9e unsigned char OEC;
xdata at 0x7f98 unsigned char OUTC;
xdata at 0x7f9b unsigned char PINSC;
xdata at 0x7f93 unsigned char PORTACFG;
xdata at 0x7f94 unsigned char PORTBCFG;
xdata at 0x7f95 unsigned char PORTCCFG;
 
xdata at 0x7fa1 unsigned char ISOCTL;
 
xdata at 0x7fa9 unsigned char IN07IRQ;
xdata at 0x7faa unsigned char OUT07IRQ;
xdata at 0x7fac unsigned char IN07IEN;
xdata at 0x7fad unsigned char OUT07IEN;
xdata at 0x7fab unsigned char USBIRQ;
xdata at 0x7fae unsigned char USBIEN;
 
xdata at 0x7fdd unsigned char USBPAIR;
xdata at 0x7faf unsigned char USBBAV;
xdata at 0x7fd6 unsigned char USBCS;
xdata at 0x7fd7 unsigned char TOGCTL;
xdata at 0x7fd4 unsigned char SUDPTRH;
xdata at 0x7fd5 unsigned char SUDPTRL;
xdata at 0x7fe8 unsigned char SETUPDAT;
xdata at 0x7fa5 unsigned char I2CS;
xdata at 0x7fa6 unsigned char I2DAT;
xdata at 0x7fde unsigned char IN07VAL;
xdata at 0x7fdf unsigned char OUT07VAL;
xdata at 0x7fe2 unsigned char FASTXFR;
xdata at 0x7fe3 unsigned char AUTOPTRH;
xdata at 0x7fe4 unsigned char AUTOPTRL;
xdata at 0x7fe5 unsigned char AUTODATA;
 
 
#endif /* __EZUSB_REG_H__ */

dtypes.h

file: http://darcs.erazor-zone.de/ezusb/sdcc/dtypes.h

/*
 *
 * $Id: dtypes.h,v 1.3 2004/01/27 20:22:31 arniml Exp $
 *
 *
 * Copyright (C) 2003, 2004 Arnim Laeuger
 *
 *  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. See also the file COPYING which
 *  came with this application.
 *
 *  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 __DTYPES_H__
#define __DTYPES_H__
 
 
#if !defined (TRUE)
#define TRUE (1==1)
#endif
#if !defined (FALSE)
#define FALSE (!TRUE)
#endif
 
#define in0buf(n)  (&IN0BUF)[n]
#define out0buf(n) (&OUT0BUF)[n]
#define in1buf(n)  (&IN1BUF)[n]
#define in2buf(n)  (&IN2BUF)[n]
#define in3buf(n)  (&IN3BUF)[n]
#define in4buf(n)  (&IN4BUF)[n]
 
 
/* our main data type */
typedef unsigned char Byte;
typedef signed   char SByte;
 
typedef          int  Int16;
typedef unsigned int  UInt16;
typedef          long Int32;
typedef unsigned long UInt32;
 
/* mapping for the setup packet */
struct setup_dat {
      Byte bmRequestType;
      Byte bRequest;
      Byte wValueL;
      Byte wValueH;
      Byte wIndexL;
      Byte wIndexH;
      Byte wLengthL;
      Byte wLengthH;
};
typedef struct setup_dat setup_dat;
 
#endif /* __DTYPES_H__ */

FAQ - Frequently Asked Questions

Copyright

 
wiki/projects/ez-usb/sdcc.txt · Last modified: 2005/08/24 16:08 (external edit)
 
Except where otherwise noted, content on this wiki is licensed under the following license:CC Attribution-Noncommercial-Share Alike 3.0 Unported
Recent changes RSS feed Donate Powered by PHP Valid XHTML 1.0 Valid CSS Driven by DokuWiki