usb_key.h

Go to the documentation of this file.
00001 
00002 
00003 
00004 
00005 
00006 
00007 
00008 
00009 
00010 
00011 
00012 
00013 
00014 #ifndef USB_KEY_H
00015 #define USB_KEY_H
00016 
00017 //_____ I N C L U D E S ____________________________________________________
00018 
00019 
00020 #include "config.h"
00021 
00022 
00023 //_____ M A C R O S ________________________________________________________
00024 
00025 
00030 
00034 #define Leds_init()     (DDRD |= 0xF0)
00035 #define Leds_on()       (PORTD |= 0xF0)   // Orange
00036 #define Leds_off()      (PORTD &= 0x0F)
00037 #define Led0_on()       (PORTD |= 0x10)   // Red
00038 #define Led1_on()       (PORTD |= 0x20)   // Green
00039 #define Led2_on()       (PORTD |= 0x40)   // Green
00040 #define Led3_on()       (PORTD |= 0x80)   // Red
00041 #define Led0_off()      (PORTD &= 0xEF)
00042 #define Led1_off()      (PORTD &= 0xDF)
00043 #define Led2_off()      (PORTD &= 0xBF)
00044 #define Led3_off()      (PORTD &= 0x7F)
00045 #define Led0_toggle()   (PIND |= 0x10)
00046 #define Led1_toggle()   (PIND |= 0x20)
00047 #define Led2_toggle()   (PIND |= 0x40)
00048 #define Led3_toggle()   (PIND |= 0x80)
00049 #define Leds_set_val(c) (Leds_off(),PORTD |= (c<<4)&0xF0)
00050 #define Leds_get_val()  (PORTD>>4)
00051 #define Is_led0_on()    (PIND & 0x10 ? TRUE : FALSE)
00052 
00053 
00057 #define Joy_init()            (DDRB &= 0x1F, PORTB |= 0xE0, DDRE &= 0xE7, PORTE |= 0x30)
00058 #define Is_joy_up()           ((PINB & 0x80) ?  FALSE : TRUE)
00059 #define Is_joy_not_up()       ((PINB & 0x80) ?  TRUE  : FALSE)
00060 #define Is_joy_left()         ((PINB & 0x40) ?  FALSE : TRUE)
00061 #define Is_joy_not_left()     ((PINB & 0x40) ?  TRUE : FALSE)
00062 #define Is_joy_select()       ((PINB & 0x20) ?  FALSE : TRUE)
00063 #define Is_joy_not_select()   ((PINB & 0x20) ?  TRUE : FALSE)
00064 #define Is_joy_right()        ((PINE & 0x10) ?  FALSE : TRUE)
00065 #define Is_joy_not_right()    ((PINE & 0x10) ?  TRUE : FALSE)
00066 #define Is_joy_down()         ((PINE & 0x20) ?  FALSE : TRUE)
00067 #define Is_joy_not_down()     ((PINE & 0x20) ?  TRUE : FALSE)
00068 
00069 
00074 #define Hwb_button_init()      (DDRE &= 0xFB, PORTE |= 0x04)
00075 #define Is_hwb()               ((PINE & 0x04) ?  FALSE : TRUE)
00076 #define Is_not_hwb()           ((PINE & 0x04) ?  TRUE : FALSE)
00077 
00078 
00079 // USB KEY ADC Channel Definition
00080 #define ADC_TEMP_CH  0x00
00081 
00082 #ifdef USE_ADC       
00083 
00084 
00085 
00095    U16 Get_adc_temp_val(void);
00096 
00097 
00107    S16  Read_temperature(void);
00108 
00109 #endif  //USE_ADC
00110 
00115 #ifdef USBKEY_HAS_321_DF
00116    #define DF_4_MB   // First prototypes version have AT90DB321C memories
00117 #else
00118    #define DF_8_MB   // AT45DB642D
00119 #endif
00120 
00121 #define DF_SELECT_MEM        0
00122 #define DF_UNSELECT_MEM      1
00123 
00124 #define DF_NB_MEM          2
00125 
00126 
00127 #ifndef AVRGCC
00128    // PORTB_Bit0=1,DDRB_Bit0=0: SPI Slave Select Input. The data direction of the
00129    //    NOT(SS) is INPUT and the pull-up resistor is activated.
00130    // DDRB_Bit1=1: the SCK signal direction is OUTPUT.
00131    // DDRB_Bit2=1: the SI signal direction is OUTPUT.
00132    // DDRB_Bit3=0: the SO signal direction is INPUT.
00133    // PORTE_Bit0=1,DDRE_Bit0=1,PORTE_Bit1=1,DDRE_Bit1=1: both CS are driven high
00134    //    and both CS are OUTPUT.
00135    #define Init_df_usb_key()  (PORTB_Bit0=1,DDRB_Bit0=0,DDRB_Bit1=1,DDRB_Bit2=1,\
00136                               DDRB_Bit3=0,DDRE_Bit0=1,DDRE_Bit1=1,Df_desel_all())
00137    #define DF_CS0             PORTE_Bit0
00138    #define DF_CS1             PORTE_Bit1
00139    #define DF_CS2             DF_CS0
00140    #define DF_CS3             DF_CS0
00141    #define Df_select_df(i, val) (DF_CS##i = val)
00142 
00143    #define Df_desel_all()     (DF_CS0=DF_UNSELECT_MEM,DF_CS1=DF_UNSELECT_MEM) // set CS# dataflash memories (unselect).
00144 #else 
00145    #define Init_df_usb_key()  (PORTB|=0x01,DDRB &= 0xFE,DDRB|=0x01,DDRB|=0x04,\
00146                               DDRB|=0x04,DDRE|=0x01,DDRE|=0x02,Df_desel_all())
00147    #define DF_CS_PORT         PORTE
00148    #define DF_CS0             0
00149    #define DF_CS1             1
00150    #define DF_CS2             DF_CS0
00151    #define DF_CS3             DF_CS0
00152 
00153    #define Df_desel_all()     (DF_CS_PORT|=0x03) // set CS# dataflash memories (unselect).   
00154 
00155 #endif
00156 
00157 #define df_init_spi()      Init_df_usb_key()
00158 
00159 
00161 
00162 #endif  // USB_KEY_H

Generated on Fri Mar 17 16:02:03 2006 for Atmel by  doxygen 1.4.6-NO