Nothing important, just cleaning comments.
[goodfet] / firmware / apps / usb / maxusb.c
1 /*! \file max3421.c
2   \author Travis Goodspeed
3   \brief SPI Driver for MAX342x USB Controllers
4 */
5
6
7 #include "command.h"
8
9 #ifdef __MSPGCC__
10 #include <msp430.h>
11 #else
12 #include <signal.h>
13 #include <msp430.h>
14 #include <iomacros.h>
15 #endif
16
17 #include "maxusb.h"
18
19 #define MAXUSBAPPLICATION
20
21 #include "platform.h"
22
23
24 // define for the app list.
25 app_t const maxusb_app = {
26         /* app number */
27         MAXUSB,
28
29         /* handle fn */
30         maxusb_handle_fn,
31
32         /* name */
33         "MAXUSB",
34
35         /* desc */
36         "\tThis allows you to write USB Host or USB Device drivers for\n"
37         "\t the MAX3421 and MAX3420 chips.\n"
38 };
39
40 //! Set up the pins for SPI mode.
41 void maxusb_setup(){
42   SETSS;
43   SPIDIR|=MOSI+SCK+BIT0; //BIT0 might be SS
44   SPIDIR&=~MISO;
45   P4DIR&=~TST; //TST line becomes interrupt input.
46   P2DIR|=RST;
47   DIRSS;
48   
49   
50   //Setup the configuration pins.
51   //This might need some delays.
52   CLRRST; //Put the chip into RESET.
53   SETSS;  //Deselect the chip, end any existing transation.
54   SETRST; //Bring the chip out of RESET.
55 }
56
57
58
59 //! Handles a MAXUSB monitor command.
60 void maxusb_handle_fn( uint8_t const app,
61                        uint8_t const verb,
62                        uint32_t const len){
63   unsigned long i;
64
65   //Raise !SS to end transaction, just in case we forgot.
66   SETSS;
67
68   switch(verb){
69   case READ:
70   case WRITE:
71     CLRSS; //Drop !SS to begin transaction.
72     for(i=0;i<len;i++)
73       cmddata[i]=spitrans8(cmddata[i]);
74     SETSS;  //Raise !SS to end transaction.
75     txdata(app,verb,len);
76     break;
77
78   case PEEK://TODO peek a register.
79     debugstr("PEEK isn't implemented in MAXUSB");
80     txdata(app,verb,0);
81     break;
82
83   case POKE://TODO poke a register.
84     debugstr("POKE isn't implemented in MAXUSB");
85     txdata(app,verb,0);
86     break;
87     
88   case SETUP:
89     maxusb_setup();
90     txdata(app,verb,0);
91     break;
92   }
93         
94   //Raise !SS to end transaction, in case we forgot.
95   SETSS;
96 }