2 \author Travis Goodspeed
3 \brief SPI Driver for MAX342x USB Controllers
19 #define MAXUSBAPPLICATION
24 // define the spi app's app_t
25 app_t const maxusb_app = {
37 "\tThis allows you to write USB Host or USB Device drivers for\n"
38 "\t the MAX3421 and MAX3420 chips.\n"
41 //! Set up the pins for SPI mode.
44 SPIDIR|=MOSI+SCK+BIT0; //BIT0 might be SS
46 P4DIR&=~TST; //TST line becomes interrupt input.
51 //Setup the configuration pins.
52 //This might need some delays.
53 CLRRST; //Put the chip into RESET.
54 debugstr("MAXUSB is off.");
55 SETSS; //Deselect the chip, end any existing transation.
56 SETRST; //Bring the chip out of RESET.
57 debugstr("MAXUSB is on.");
62 //! Handles a MAXUSB monitor command.
63 void maxusb_handle_fn( uint8_t const app,
68 //Raise !SS to end transaction, just in case we forgot.
74 CLRSS; //Drop !SS to begin transaction.
76 cmddata[i]=spitrans8(cmddata[i]);
77 SETSS; //Raise !SS to end transaction.
81 case PEEK://TODO peek a register.
82 debugstr("PEEK isn't implemented in MAXUSB");
86 case POKE://TODO poke a register.
87 debugstr("POKE isn't implemented in MAXUSB");
97 //Raise !SS to end transaction, in case we forgot.