stk_600.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 STK_600_H
00045 #define STK_600_H
00046 
00047 //_____ I N C L U D E S ____________________________________________________
00048 #include "config.h"
00049 
00050 #if (TARGET_BOARD==STK600)
00051 
00052 //_____ M A C R O S ________________________________________________________
00053 
00070 
00071 
00075 #define  LED_PORT             PORTD
00076 #define  LED_DDR              DDRD
00077 #define  LED_PIN              PIND
00078 
00079 #define  LED0_BIT             PIND0
00080 #define  LED1_BIT             PIND1
00081 #define  LED2_BIT             PIND2
00082 #define  LED3_BIT             PIND3
00083 #define  LED4_BIT             PIND4
00084 #define  LED5_BIT             PIND5
00085 #define  LED6_BIT             PIND6
00086 #define  LED7_BIT             PIND7                      
00087 
00088 #define  Leds_init()          (LED_DDR  |=  (1<<LED0_BIT) | (1<<LED1_BIT) | (1<<LED2_BIT) | (1<<LED3_BIT) | (1<<LED4_BIT) | (1<<LED5_BIT) | (1<<LED6_BIT) | (1<<LED7_BIT),Leds_off())
00089 #define  Leds_on()            (LED_PORT &= ~((1<<LED0_BIT) | (1<<LED1_BIT) | (1<<LED2_BIT) | (1<<LED3_BIT) | (1<<LED4_BIT) | (1<<LED5_BIT) | (1<<LED6_BIT) | (1<<LED7_BIT)))
00090 #define  Leds_off()           (LED_PORT |=  (1<<LED0_BIT) | (1<<LED1_BIT) | (1<<LED2_BIT) | (1<<LED3_BIT) | (1<<LED4_BIT) | (1<<LED5_BIT) | (1<<LED6_BIT) | (1<<LED7_BIT))
00091 #define  Leds_set_val(val)    (Leds_off(),LED_PORT |= val&((1<<LED0_BIT) | (1<<LED1_BIT) | (1<<LED2_BIT) | (1<<LED3_BIT) | (1<<LED4_BIT) | (1<<LED5_BIT) | (1<<LED6_BIT) | (1<<LED7_BIT)))
00092 #define  Leds_get_val()       (LED_PORT)
00093 
00094 #define  Led0_on()            (LED_PORT &= ~(1<<LED0_BIT))
00095 #define  Led1_on()            (LED_PORT &= ~(1<<LED1_BIT))
00096 #define  Led2_on()            (LED_PORT &= ~(1<<LED2_BIT))
00097 #define  Led3_on()            (LED_PORT &= ~(1<<LED3_BIT))
00098 #define  Led4_on()            (LED_PORT &= ~(1<<LED4_BIT))
00099 #define  Led5_on()            (LED_PORT &= ~(1<<LED5_BIT))
00100 #define  Led6_on()            (LED_PORT &= ~(1<<LED6_BIT))
00101 #define  Led7_on()            (LED_PORT &= ~(1<<LED7_BIT))
00102 #define  Led0_off()           (LED_PORT |=  (1<<LED0_BIT))
00103 #define  Led1_off()           (LED_PORT |=  (1<<LED1_BIT))
00104 #define  Led2_off()           (LED_PORT |=  (1<<LED2_BIT))
00105 #define  Led3_off()           (LED_PORT |=  (1<<LED3_BIT))
00106 #define  Led4_off()           (LED_PORT |=  (1<<LED4_BIT))
00107 #define  Led5_off()           (LED_PORT |=  (1<<LED5_BIT))
00108 #define  Led6_off()           (LED_PORT |=  (1<<LED6_BIT))
00109 #define  Led7_off()           (LED_PORT |=  (1<<LED7_BIT))
00110 #define  Led0_toggle()        (LED_PIN  |=  (1<<LED0_BIT))
00111 #define  Led1_toggle()        (LED_PIN  |=  (1<<LED1_BIT))
00112 #define  Led2_toggle()        (LED_PIN  |=  (1<<LED2_BIT))
00113 #define  Led3_toggle()        (LED_PIN  |=  (1<<LED3_BIT))
00114 #define  Led4_toggle()        (LED_PIN  |=  (1<<LED4_BIT))
00115 #define  Led5_toggle()        (LED_PIN  |=  (1<<LED5_BIT))
00116 #define  Led6_toggle()        (LED_PIN  |=  (1<<LED6_BIT))
00117 #define  Led7_toggle()        (LED_PIN  |=  (1<<LED7_BIT))
00118 #define  Is_led0_on()         (LED_PIN  &   (1<<LED0_BIT) ? FALSE : TRUE)
00119 #define  Is_led1_on()         (LED_PIN  &   (1<<LED1_BIT) ? FALSE : TRUE)
00120 #define  Is_led2_on()         (LED_PIN  &   (1<<LED2_BIT) ? FALSE : TRUE)
00121 #define  Is_led3_on()         (LED_PIN  &   (1<<LED3_BIT) ? FALSE : TRUE)
00122 #define  Is_led4_on()         (LED_PIN  &   (1<<LED4_BIT) ? FALSE : TRUE)
00123 #define  Is_led5_on()         (LED_PIN  &   (1<<LED5_BIT) ? FALSE : TRUE)
00124 #define  Is_led6_on()         (LED_PIN  &   (1<<LED6_BIT) ? FALSE : TRUE)
00125 #define  Is_led7_on()         (LED_PIN  &   (1<<LED7_BIT) ? FALSE : TRUE)
00126 
00128 
00141 #define  Switches_init()      (DDRB &= ~0xFF, PORTB |= 0xFF)
00142 #define  Is_switch_7()        ((PINB & (1<<PINB7)) ?  FALSE : TRUE)
00143 #define  Is_switch_6()        ((PINB & (1<<PINB6)) ?  FALSE : TRUE)
00144 #define  Is_switch_5()        ((PINB & (1<<PINB5)) ?  FALSE : TRUE)
00145 #define  Is_switch_4()        ((PINB & (1<<PINB4)) ?  FALSE : TRUE)
00146 #define  Is_switch_3()        ((PINB & (1<<PINB3)) ?  FALSE : TRUE)
00147 #define  Is_switch_2()        ((PINB & (1<<PINB2)) ?  FALSE : TRUE)
00148 #define  Is_switch_1()        ((PINB & (1<<PINB1)) ?  FALSE : TRUE)
00149 #define  Is_switch_0()        ((PINB & (1<<PINB0)) ?  FALSE : TRUE)
00150 #define  Is_not_switch_7()    ((PINB & (1<<PINB7)) ?  TRUE : FALSE)
00151 #define  Is_not_switch_6()    ((PINB & (1<<PINB6)) ?  TRUE : FALSE)
00152 #define  Is_not_switch_5()    ((PINB & (1<<PINB5)) ?  TRUE : FALSE)
00153 #define  Is_not_switch_4()    ((PINB & (1<<PINB4)) ?  TRUE : FALSE)
00154 #define  Is_not_switch_3()    ((PINB & (1<<PINB3)) ?  TRUE : FALSE)
00155 #define  Is_not_switch_2()    ((PINB & (1<<PINB2)) ?  TRUE : FALSE)
00156 #define  Is_not_switch_1()    ((PINB & (1<<PINB1)) ?  TRUE : FALSE)
00157 #define  Is_not_switch_0()    ((PINB & (1<<PINB0)) ?  TRUE : FALSE)
00158 
00159 #define  Joy_init()           Switches_init()
00160 #define  Is_btn_left()        Is_switch_6()
00161 #define  Is_btn_middle()      Is_switch_5()
00162 #define  Is_btn_right()       Is_switch_4()
00163 #define  Is_joy_left()        Is_switch_3()
00164 #define  Is_joy_right()       Is_switch_2()
00165 #define  Is_joy_up()          Is_switch_1()
00166 #define  Is_joy_down()        Is_switch_0()
00167 
00168 
00169 #define  Is_btn_not_left()    Is_not_switch_6()
00170 #define  Is_btn_not_middle()  Is_not_switch_5()
00171 #define  Is_btn_not_right()   Is_not_switch_4()
00172 #define  Is_joy_not_left()    Is_not_switch_3()
00173 #define  Is_joy_not_right()   Is_not_switch_2()
00174 #define  Is_joy_not_up()      Is_not_switch_1()
00175 #define  Is_joy_not_down()    Is_not_switch_0()
00176 
00177 
00182 #define  Switches_enable_it() {  \
00183       PCMSK0 |= (1<<PCINT0)|(1<<PCINT1)|(1<<PCINT2)|(1<<PCINT3)|(1<<PCINT4)|(1<<PCINT5)|(1<<PCINT6)|(1<<PCINT7);\
00184       PCIFR |= (1<<PCIF0);       \
00185       PCICR |= (1<<PCIE0);}
00186 
00191 #define  Switches_disable_it() { \
00192       PCICR  &= ~(1<<PCIE0);     \
00193       PCIFR  |= (1<<PCIF0);      \
00194       PCMSK0 &= ~((1<<PCINT0)|(1<<PCINT1)|(1<<PCINT2)|(1<<PCINT3)|(1<<PCINT4)|(1<<PCINT5)|(1<<PCINT6)|(1<<PCINT7));}
00196 
00197 
00201 #define  Hwb_button_init()
00202 #define  Is_hwb()             FALSE
00203 #define  Is_not_hwb()         TRUE
00205 
00207 
00208 #endif   // TARGET_BOARD==STK600
00209 
00210 #endif  // STK_600_H

Generated on Mon Sep 14 13:21:27 2009 for ATMEL by  doxygen 1.5.3