00001
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032
00033
00034
00035
00036
00037
00038
00039
00040
00041
00042
00043
00044 #ifndef STK_600_H
00045 #define STK_600_H
00046
00047
00048 #include "config.h"
00049
00050 #if (TARGET_BOARD==STK600)
00051
00052
00053
00070
00075
00076
00077
00078
00079
00080
00082
00083
00087 #define LED_PORT PORTD
00088 #define LED_DDR DDRD
00089 #define LED_PIN PIND
00090
00091 #define LED0_BIT PIND0
00092 #define LED1_BIT PIND1
00093 #define LED2_BIT PIND2
00094 #define LED3_BIT PIND3
00095 #define LED4_BIT PIND4
00096 #define LED5_BIT PIND5
00097 #define LED6_BIT PIND6
00098
00099 #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),Leds_off())
00100 #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)))
00101 #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))
00102 #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)))
00103 #define Leds_get_val() (LED_PORT)
00104
00105 #define Led0_on() (LED_PORT &= ~(1<<LED0_BIT))
00106 #define Led1_on() (LED_PORT &= ~(1<<LED1_BIT))
00107 #define Led2_on() (LED_PORT &= ~(1<<LED2_BIT))
00108 #define Led3_on() (LED_PORT &= ~(1<<LED3_BIT))
00109 #define Led4_on() (LED_PORT &= ~(1<<LED4_BIT))
00110 #define Led5_on() (LED_PORT &= ~(1<<LED5_BIT))
00111 #define Led6_on() (LED_PORT &= ~(1<<LED6_BIT))
00112 #define Led0_off() (LED_PORT |= (1<<LED0_BIT))
00113 #define Led1_off() (LED_PORT |= (1<<LED1_BIT))
00114 #define Led2_off() (LED_PORT |= (1<<LED2_BIT))
00115 #define Led3_off() (LED_PORT |= (1<<LED3_BIT))
00116 #define Led4_off() (LED_PORT |= (1<<LED4_BIT))
00117 #define Led5_off() (LED_PORT |= (1<<LED5_BIT))
00118 #define Led6_off() (LED_PORT |= (1<<LED6_BIT))
00119 #define Led0_toggle() (LED_PIN |= (1<<LED0_BIT))
00120 #define Led1_toggle() (LED_PIN |= (1<<LED1_BIT))
00121 #define Led2_toggle() (LED_PIN |= (1<<LED2_BIT))
00122 #define Led3_toggle() (LED_PIN |= (1<<LED3_BIT))
00123 #define Led4_toggle() (LED_PIN |= (1<<LED4_BIT))
00124 #define Led5_toggle() (LED_PIN |= (1<<LED5_BIT))
00125 #define Led6_toggle() (LED_PIN |= (1<<LED6_BIT))
00126 #define Is_led0_on() (LED_PIN & (1<<LED0_BIT) ? FALSE : TRUE)
00127 #define Is_led1_on() (LED_PIN & (1<<LED1_BIT) ? FALSE : TRUE)
00128 #define Is_led2_on() (LED_PIN & (1<<LED2_BIT) ? FALSE : TRUE)
00129 #define Is_led3_on() (LED_PIN & (1<<LED3_BIT) ? FALSE : TRUE)
00130 #define Is_led4_on() (LED_PIN & (1<<LED4_BIT) ? FALSE : TRUE)
00131 #define Is_led5_on() (LED_PIN & (1<<LED5_BIT) ? FALSE : TRUE)
00132 #define Is_led6_on() (LED_PIN & (1<<LED6_BIT) ? FALSE : TRUE)
00134
00147 #define Switches_init() (DDRB &= ~0xFF, PORTB |= 0xFF)
00148 #define Is_switch_7() ((PINB & (1<<PINB7)) ? FALSE : TRUE)
00149 #define Is_switch_6() ((PINB & (1<<PINB6)) ? FALSE : TRUE)
00150 #define Is_switch_5() ((PINB & (1<<PINB5)) ? FALSE : TRUE)
00151 #define Is_switch_4() ((PINB & (1<<PINB4)) ? FALSE : TRUE)
00152 #define Is_switch_3() ((PINB & (1<<PINB3)) ? FALSE : TRUE)
00153 #define Is_switch_2() ((PINB & (1<<PINB2)) ? FALSE : TRUE)
00154 #define Is_switch_1() ((PINB & (1<<PINB1)) ? FALSE : TRUE)
00155 #define Is_switch_0() ((PINB & (1<<PINB0)) ? FALSE : TRUE)
00156 #define Is_not_switch_7() ((PINB & (1<<PINB7)) ? TRUE : FALSE)
00157 #define Is_not_switch_6() ((PINB & (1<<PINB6)) ? TRUE : FALSE)
00158 #define Is_not_switch_5() ((PINB & (1<<PINB5)) ? TRUE : FALSE)
00159 #define Is_not_switch_4() ((PINB & (1<<PINB4)) ? TRUE : FALSE)
00160 #define Is_not_switch_3() ((PINB & (1<<PINB3)) ? TRUE : FALSE)
00161 #define Is_not_switch_2() ((PINB & (1<<PINB2)) ? TRUE : FALSE)
00162 #define Is_not_switch_1() ((PINB & (1<<PINB1)) ? TRUE : FALSE)
00163 #define Is_not_switch_0() ((PINB & (1<<PINB0)) ? TRUE : FALSE)
00164
00165 #define Joy_init() Switches_init()
00166 #define Push_button_init() Joy_init()
00167
00168 #define Is_btn_left() Is_switch_6()
00169 #define Is_btn_middle() Is_switch_5()
00170 #define Is_btn_right() Is_switch_4()
00171
00172 #define Is_joy_left() Is_switch_3()
00173 #define Is_joy_right() Is_switch_2()
00174 #define Is_joy_up() Is_switch_1()
00175 #define Is_joy_down() Is_switch_0()
00176
00177 #define Is_btn_not_left() Is_not_switch_6()
00178 #define Is_btn_not_middle() Is_not_switch_5()
00179 #define Is_btn_not_right() Is_not_switch_4()
00180
00181 #define Is_joy_not_left() Is_not_switch_3()
00182 #define Is_joy_not_right() Is_not_switch_2()
00183 #define Is_joy_not_up() Is_not_switch_1()
00184 #define Is_joy_not_down() Is_not_switch_0()
00185
00186
00191 #define Switches_enable_it() { \
00192 PCMSK0 |= (1<<PCINT0)|(1<<PCINT1)|(1<<PCINT2)|(1<<PCINT3)|(1<<PCINT4)|(1<<PCINT5)|(1<<PCINT6)|(1<<PCINT7);\
00193 PCIFR |= (1<<PCIF0); \
00194 PCICR |= (1<<PCIE0);}
00195
00200 #define Switches_disable_it() { \
00201 PCICR &= ~(1<<PCIE0); \
00202 PCIFR |= (1<<PCIF0); \
00203 PCMSK0 &= ~((1<<PCINT0)|(1<<PCINT1)|(1<<PCINT2)|(1<<PCINT3)|(1<<PCINT4)|(1<<PCINT5)|(1<<PCINT6)|(1<<PCINT7));}
00205
00206
00210 #define Hwb_button_init()
00211 #define Is_hwb() FALSE
00212 #define Is_not_hwb() TRUE
00214
00216
00217 #endif // TARGET_BOARD==STK600
00218
00219 #endif // STK_600_H