stk_525.h

Go to the documentation of this file.
00001 /*This file has been prepared for Doxygen automatic documentation generation.*/
00013 
00014 /* Copyright (c) 2007, 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  * THIS SOFTWARE IS PROVIDED BY ATMEL ``AS IS'' AND ANY EXPRESS OR IMPLIED
00030  * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
00031  * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE EXPRESSLY AND
00032  * SPECIFICALLY DISCLAIMED. IN NO EVENT SHALL ATMEL BE LIABLE FOR ANY DIRECT,
00033  * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
00034  * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
00035  * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
00036  * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
00037  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
00038  * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
00039  */
00040 
00041 #ifndef STK_525_H
00042 #define STK_525_H
00043 
00044 //_____ I N C L U D E S ____________________________________________________
00045 #include "config.h"
00046 
00047 #if (TARGET_BOARD==STK525)
00048 
00049 //_____ M A C R O S ________________________________________________________
00050 
00055 
00056 
00060 #define  LED_PORT             PORTD
00061 #define  LED_DDR              DDRD
00062 #define  LED_PIN              PIND
00063 #define  LED0_BIT             PIND4
00064 #define  LED1_BIT             PIND5
00065 #define  LED2_BIT             PIND6
00066 #define  LED3_BIT             PIND7
00067                       
00068 #define  Leds_init()          (LED_DDR  |=  (1<<LED0_BIT) | (1<<LED1_BIT) | (1<<LED2_BIT) | (1<<LED3_BIT))
00069 #define  Leds_on()            (LED_PORT |=  (1<<LED0_BIT) | (1<<LED1_BIT) | (1<<LED2_BIT) | (1<<LED3_BIT))
00070 #define  Leds_off()           (LED_PORT &= ~((1<<LED0_BIT) | (1<<LED1_BIT) | (1<<LED2_BIT) | (1<<LED3_BIT)))
00071 #define  Leds_set_val(c)      (Leds_off(),LED_PORT |= (c<<4)&((1<<LED0_BIT) | (1<<LED1_BIT) | (1<<LED2_BIT) | (1<<LED3_BIT)))
00072 #define  Leds_get_val()       (LED_PORT>>4)
00073 
00074 #define  Led0_on()            (LED_PORT |=  (1<<LED0_BIT))
00075 #define  Led1_on()            (LED_PORT |=  (1<<LED1_BIT))
00076 #define  Led2_on()            (LED_PORT |=  (1<<LED2_BIT))
00077 #define  Led3_on()            (LED_PORT |=  (1<<LED3_BIT))
00078 #define  Led0_off()           (LED_PORT &= ~(1<<LED0_BIT))
00079 #define  Led1_off()           (LED_PORT &= ~(1<<LED1_BIT))
00080 #define  Led2_off()           (LED_PORT &= ~(1<<LED2_BIT))
00081 #define  Led3_off()           (LED_PORT &= ~(1<<LED3_BIT))
00082 #define  Led0_toggle()        (LED_PIN  |=  (1<<LED0_BIT))
00083 #define  Led1_toggle()        (LED_PIN  |=  (1<<LED1_BIT))
00084 #define  Led2_toggle()        (LED_PIN  |=  (1<<LED2_BIT))
00085 #define  Led3_toggle()        (LED_PIN  |=  (1<<LED3_BIT))
00086 #define  Is_led0_on()         (LED_PIN  &   (1<<LED0_BIT) ? TRUE : FALSE)
00087 #define  Is_led1_on()         (LED_PIN  &   (1<<LED1_BIT) ? TRUE : FALSE)
00088 #define  Is_led2_on()         (LED_PIN  &   (1<<LED2_BIT) ? TRUE : FALSE)
00089 #define  Is_led3_on()         (LED_PIN  &   (1<<LED3_BIT) ? TRUE : FALSE)
00091 
00095 #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)))
00096 
00097 #define  Is_btn_left()        Is_hwb()
00098 #define  Is_btn_middle()      ((PINB & (1<<PINB5)) ?  FALSE : TRUE)
00099 #define  Is_btn_right()       FALSE
00100 
00101 #define  Is_joy_left()        ((PINB & (1<<PINB6)) ?  FALSE : TRUE)
00102 #define  Is_joy_up()          ((PINB & (1<<PINB7)) ?  FALSE : TRUE)
00103 #define  Is_joy_down()        ((PINE & (1<<PINE5)) ?  FALSE : TRUE)
00104 #define  Is_joy_right()       ((PINE & (1<<PINE4)) ?  FALSE : TRUE)
00105 
00106 #define  Is_btn_not_left()    Is_not_hwb()
00107 #define  Is_btn_not_middle()  ((PINB & (1<<PINB5)) ?  TRUE : FALSE)
00108 #define  Is_btn_not_right()   TRUE
00109 
00110 #define  Is_joy_not_up()      ((PINB & (1<<PINB7)) ?  TRUE : FALSE)
00111 #define  Is_joy_not_left()    ((PINB & (1<<PINB6)) ?  TRUE : FALSE)
00112 #define  Is_joy_not_down()    ((PINE & (1<<PINE5)) ?  TRUE : FALSE)
00113 #define  Is_joy_not_right()   ((PINE & (1<<PINE4)) ?  TRUE : FALSE)
00114 
00119 #define  Switches_enable_it() {  \
00120       PCMSK0 |= (1<<PCINT5)|(1<<PCINT6)|(1<<PCINT7);\
00121       PCIFR |= (1<<PCIF0);       \
00122       PCICR |= (1<<PCIE0);}
00123  
00128 #define  Switches_disable_it() { \
00129       PCICR  &= ~(1<<PCIE0);     \
00130       PCIFR  |= (1<<PCIF0);      \
00131       PCMSK0 &= ~((1<<PCINT5)|(1<<PCINT6)|(1<<PCINT7));}
00133 
00134 
00139 #define  Hwb_button_init()    (DDRE  &= ~(1<<PINE2), PORTE |= (1<<PINE2))
00140 #define  Is_hwb()             ((PINE &   (1<<PINE2)) ?  FALSE : TRUE)
00141 #define  Is_not_hwb()         ((PINE &   (1<<PINE2)) ?  TRUE : FALSE)
00143 
00144 
00148 
00149 // One AT45DB321C
00150 #define DF_4_MB            
00151 #define DF_NB_MEM          1
00152 
00153 // PINB0 : SPI Slave Select pin, this pin must be disable (disable input mode) because it is used by joystick
00154 //         Note: the joystick can work fine in Output mode, because the pull-up resistor is activated and the level pin can be read.
00155 // PINB1 : the SCK signal direction is OUTPUT
00156 // PINB2 : the SI signal direction is OUTPUT
00157 // PINB3 : the SO signal direction is INPUT
00158 // PINB4 : the CS signal direction is OUTPUT
00159 #define  Df_init_spi()     (DDRB  &= ~((1<<PINB3)), \
00160                             DDRB  |=  ((1<<PINB4)|(1<<PINB2)|(1<<PINB1)|(1<<PINB0)), \
00161                             PORTB |=  ((1<<PINB4)|(1<<PINB3)|(1<<PINB2)|(1<<PINB1)|(1<<PINB0)) )
00162 #define  Df_select_0()     (PORTB &= ~(1<<PINB4))
00163 #define  Df_desel_all()    (PORTB |=  (1<<PINB4))
00166 
00168 
00169 
00170 
00172 #define ADC_POT_CH   0x01
00173 #define ADC_MIC_CH   0x02
00174 #define ADC_TEMP_CH  0x00
00175 
00176 #ifdef USE_ADC       
00177 
00189    U16 Get_adc_mic_val(void);
00190 
00202    U16 Get_adc_temp_val(void);
00203 
00215    U16 Get_adc_pot_val(void);
00216 
00228    S16  Read_temperature(void);
00229 
00230 #endif   // USE_ADC
00231 
00232 #endif   // TARGET_BOARD==STK525
00233 
00234 #endif   // STK_525_H

Generated on Mon Nov 3 10:08:23 2008 for ATMEL by  doxygen 1.5.3