usb_key.h

Go to the documentation of this file.
00001 /*This file is prepared for Doxygen automatic documentation generation.*/
00013 
00014 /* Copyright (c) 2009 Atmel Corporation. All rights reserved.
00015  *
00016  * Redistribution and use in source and binary forms, with or without
00017  * modification, are permitted provided that the following conditions are met:
00018  *
00019  * 1. Redistributions of source code must retain the above copyright notice,
00020  * this list of conditions and the following disclaimer.
00021  *
00022  * 2. Redistributions in binary form must reproduce the above copyright notice,
00023  * this list of conditions and the following disclaimer in the documentation
00024  * and/or other materials provided with the distribution.
00025  *
00026  * 3. The name of Atmel may not be used to endorse or promote products derived
00027  * from this software without specific prior written permission.
00028  *
00029  * 4. This software may only be redistributed and used in connection with an Atmel
00030  * AVR product.
00031  *
00032  * THIS SOFTWARE IS PROVIDED BY ATMEL "AS IS" AND ANY EXPRESS OR IMPLIED
00033  * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
00034  * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT ARE EXPRESSLY AND
00035  * SPECIFICALLY DISCLAIMED. IN NO EVENT SHALL ATMEL BE LIABLE FOR ANY DIRECT,
00036  * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
00037  * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
00038  * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
00039  * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
00040  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
00041  * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
00042  */
00043 
00044 #ifndef USB_KEY_H
00045 #define USB_KEY_H
00046 
00047 //_____ I N C L U D E S ____________________________________________________
00048 
00049 #include "config.h"
00050 #if (TARGET_BOARD==USBKEY)
00051 
00052 //_____ M A C R O S ________________________________________________________
00053 
00054 
00059 
00067 #define  LED_PORT             PORTD
00068 #define  LED_DDR              DDRD
00069 #define  LED_PIN              PIND
00070 #define  LED0_BIT             PIND4
00071 #define  LED1_BIT             PIND5
00072 #define  LED2_BIT             PIND6
00073 #define  LED3_BIT             PIND7
00074                       
00075 #define  Leds_init()          (LED_DDR |= (1<<LED0_BIT) | (1<<LED1_BIT) | (1<<LED2_BIT) | (1<<LED3_BIT))
00076 #define  Leds_on()            (LED_PORT |= (1<<LED0_BIT) | (1<<LED1_BIT) | (1<<LED2_BIT) | (1<<LED3_BIT))
00077 #define  Leds_off()           (LED_PORT &= ~((1<<LED0_BIT) | (1<<LED1_BIT) | (1<<LED2_BIT) | (1<<LED3_BIT)))
00078 #define  Leds_set_val(c)      (Leds_off(),LED_PORT |= (c<<4)&((1<<LED0_BIT) | (1<<LED1_BIT) | (1<<LED2_BIT) | (1<<LED3_BIT)))
00079 #define  Leds_get_val()       (LED_PORT>>4)
00080 
00081 #define  Led0_on()            (LED_PORT |=  (1<<LED0_BIT))
00082 #define  Led1_on()            (LED_PORT |=  (1<<LED1_BIT))
00083 #define  Led2_on()            (LED_PORT |=  (1<<LED2_BIT))
00084 #define  Led3_on()            (LED_PORT |=  (1<<LED3_BIT))
00085 #define  Led0_off()           (LED_PORT &= ~(1<<LED0_BIT))
00086 #define  Led1_off()           (LED_PORT &= ~(1<<LED1_BIT))
00087 #define  Led2_off()           (LED_PORT &= ~(1<<LED2_BIT))
00088 #define  Led3_off()           (LED_PORT &= ~(1<<LED3_BIT))
00089 #define  Led0_toggle()        (LED_PIN  |=  (1<<LED0_BIT))
00090 #define  Led1_toggle()        (LED_PIN  |=  (1<<LED1_BIT))
00091 #define  Led2_toggle()        (LED_PIN  |=  (1<<LED2_BIT))
00092 #define  Led3_toggle()        (LED_PIN  |=  (1<<LED3_BIT))
00093 #define  Is_led0_on()         (LED_PIN  &   (1<<LED0_BIT) ? TRUE : FALSE)
00094 #define  Is_led1_on()         (LED_PIN  &   (1<<LED1_BIT) ? TRUE : FALSE)
00095 #define  Is_led2_on()         (LED_PIN  &   (1<<LED2_BIT) ? TRUE : FALSE)
00096 #define  Is_led3_on()         (LED_PIN  &   (1<<LED3_BIT) ? TRUE : FALSE)
00098 
00102 #define  Joy_init()           (DDRB &= ~((1<<PINB7)|(1<<PINB6)|(1<<PINB5)), PORTB |= ((1<<PINB7)|(1<<PINB6)|(1<<PINB5)), DDRE &= ~((1<<PINE5)|(1<<PINE4)), PORTE |= ((1<<PINE5)|(1<<PINE4)))
00103 
00104 #define  Is_btn_left()        Is_hwb()
00105 #define  Is_btn_middle()      ((PINB & (1<<PINB5)) ?  FALSE : TRUE)
00106 #define  Is_btn_right()       FALSE
00107 
00108 #define  Is_joy_up()          ((PINB & (1<<PINB7)) ?  FALSE : TRUE)
00109 #define  Is_joy_left()        ((PINB & (1<<PINB6)) ?  FALSE : TRUE)
00110 #define  Is_joy_down()        ((PINE & (1<<PINE5)) ?  FALSE : TRUE)
00111 #define  Is_joy_right()       ((PINE & (1<<PINE4)) ?  FALSE : TRUE)
00112 
00113 #define  Is_btn_not_left()    Is_not_hwb()
00114 #define  Is_btn_not_middle()  ((PINB & (1<<PINB5)) ?  TRUE : FALSE)
00115 #define  Is_btn_not_right()   TRUE
00116 
00117 #define  Is_joy_not_up()      ((PINB & (1<<PINB7)) ?  TRUE  : FALSE)
00118 #define  Is_joy_not_left()    ((PINB & (1<<PINB6)) ?  TRUE : FALSE)
00119 #define  Is_joy_not_down()    ((PINE & (1<<PINE5)) ?  TRUE : FALSE)
00120 #define  Is_joy_not_right()   ((PINE & (1<<PINE4)) ?  TRUE : FALSE)
00121 
00126 #define  Switches_enable_it() {  \
00127       PCMSK0 |= (1<<PCINT5)|(1<<PCINT6)|(1<<PCINT7);\
00128       PCIFR |= (1<<PCIF0);       \
00129       PCICR |= (1<<PCIE0);}
00130  
00135 #define  Switches_disable_it() { \
00136       PCICR  &= ~(1<<PCIE0);     \
00137       PCIFR  |= (1<<PCIF0);      \
00138       PCMSK0 &= ~((1<<PCINT5)|(1<<PCINT6)|(1<<PCINT7));}
00140 
00141 
00146 #define Hwb_button_init()      (DDRE  &= ~(1<<PINE2), PORTE |= (1<<PINE2))
00147 #define Is_hwb()               ((PINE &   (1<<PINE2)) ?  FALSE : TRUE)
00148 #define Is_not_hwb()           ((PINE &   (1<<PINE2)) ?  TRUE : FALSE)
00150 
00151 
00155 
00156 // One AT45DB642D
00157 #define DF_8_MB            
00158 #define DF_NB_MEM          2
00159 
00160 // PINB0 : SPI Slave Select pin, this pin must be disable (disable input mode) because it is used by joystick
00161 //         Note: the joystick can work fine in Output mode, because the pull-up resistor is activated and the level pin can be read.
00162 // PINB1 : the SCK signal direction is OUTPUT
00163 // PINB2 : the SI signal direction is OUTPUT
00164 // PINB3 : the SO signal direction is INPUT
00165 // PINE0 : the CS0 signal direction is OUTPUT
00166 // PINE1 : the CS1 signal direction is OUTPUT
00167 #define  Df_init_spi()     (DDRB  &= ~((1<<PINB3)), \
00168                             DDRB  |=  ((1<<PINB2)|(1<<PINB1)|(1<<PINB0)), \
00169                             PORTB |=  ((1<<PINB3)|(1<<PINB2)|(1<<PINB1)|(1<<PINB0)),\
00170                             DDRE  |=  ((1<<PINE1)|(1<<PINE0)), \
00171                             PORTE |=  ((1<<PINE1)|(1<<PINE0)) )
00172 #define  Df_select_0()     (PORTE &= ~(1<<PINE0))
00173 #define  Df_select_1()     (PORTE &= ~(1<<PINE1))
00174 #define  Df_desel_all()    (PORTE |=  ((1<<PINE1)|(1<<PINE0)))
00175 
00177 
00179 
00180 
00181 // USB KEY ADC Channel Definition
00182 #define ADC_TEMP_CH  0x00
00183 
00184 #ifdef USE_ADC       
00185 
00186 
00187 
00197    U16 Get_adc_temp_val(void);
00198 
00199 
00209    S16  Read_temperature(void);
00210 
00211 #endif   // USE_ADC
00212 
00213 #endif   // TARGET_BOARD==USBKEY
00214 
00215 #endif   // USB_KEY_H
00216 

Generated on Mon Sep 14 13:24:11 2009 for ATMEL by  doxygen 1.5.3