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_526_H
00045 #define STK_526_H
00046
00051
00055
00056 #define VBUS_SENSE_PORT PORTC // PORTx
00057 #define VBUS_SENSE_PIN PINC // PINx
00058 #define VBUS_SENSE_DDR DDRC // DDRx
00059 #define VBUS_SENSE_IO 4 // 0...7
00061
00065 #define LED_PORT PORTD
00066 #define LED_DDR DDRD
00067 #define LED_PIN PIND
00068
00069 #define LED0_BIT PIND0
00070 #define LED1_BIT PIND1
00071 #define LED2_BIT PIND4
00072 #define LED3_BIT PIND5
00073
00074 #define Leds_init() (LED_DDR |= (1<<LED0_BIT)|(1<<LED1_BIT)|(1<<LED2_BIT)|(1<<LED3_BIT), Leds_off())
00075 #define Leds_on() (LED_PORT |= (1<<LED0_BIT)|(1<<LED1_BIT)|(1<<LED2_BIT)|(1<<LED3_BIT))
00076 #define Leds_off() (LED_PORT &= ~((1<<LED0_BIT)|(1<<LED1_BIT)|(1<<LED2_BIT)|(1<<LED3_BIT)))
00077 #define Leds_set_val(c) (Leds_off(),LED_PORT |= (c<<4)&((1<<LED0_BIT) | (1<<LED1_BIT) | (1<<LED2_BIT) | (1<<LED3_BIT)))
00078 #define Leds_get_val() (LED_PORT>>4)
00079
00080 #define Led0_on() (LED_PORT |= (1<<LED0_BIT))
00081 #define Led1_on() (LED_PORT |= (1<<LED1_BIT))
00082 #define Led2_on() (LED_PORT |= (1<<LED2_BIT))
00083 #define Led3_on() (LED_PORT |= (1<<LED3_BIT))
00084 #define Led0_off() (LED_PORT &= ~(1<<LED0_BIT))
00085 #define Led1_off() (LED_PORT &= ~(1<<LED1_BIT))
00086 #define Led2_off() (LED_PORT &= ~(1<<LED2_BIT))
00087 #define Led3_off() (LED_PORT &= ~(1<<LED3_BIT))
00088 #define Led0_toggle() (LED_PIN |= (1<<LED0_BIT))
00089 #define Led1_toggle() (LED_PIN |= (1<<LED1_BIT))
00090 #define Led2_toggle() (LED_PIN |= (1<<LED2_BIT))
00091 #define Led3_toggle() (LED_PIN |= (1<<LED3_BIT))
00092 #define Is_led0_on() (LED_PIN & (1<<LED0_BIT) ? TRUE : FALSE)
00093 #define Is_led1_on() (LED_PIN & (1<<LED1_BIT) ? TRUE : FALSE)
00094 #define Is_led2_on() (LED_PIN & (1<<LED2_BIT) ? TRUE : FALSE)
00095 #define Is_led3_on() (LED_PIN & (1<<LED3_BIT) ? TRUE : FALSE)
00097
00101 #define Joy_init() (DDRB &= ~((1<<PINB7)|(1<<PINB6)|(1<<PINB5)|(1<<PINB4)|(1<<PINB0)), PORTB |= ((1<<PINB7)|(1<<PINB6)|(1<<PINB5)|(1<<PINB4)|(1<<PINB0)))
00102 #define Push_button_init() Joy_init()
00103
00104 #define Is_btn_left() Is_hwb()
00105 #define Is_btn_middle() ((PINB & (1<<PINB0)) ? FALSE : TRUE)
00106 #define Is_btn_right() FALSE
00107
00108 #define Is_joy_down() ((PINB & (1<<PINB7)) ? FALSE : TRUE)
00109 #define Is_joy_right() ((PINB & (1<<PINB6)) ? FALSE : TRUE)
00110 #define Is_joy_up() ((PINB & (1<<PINB5)) ? FALSE : TRUE)
00111 #define Is_joy_left() ((PINB & (1<<PINB4)) ? FALSE : TRUE)
00112
00113 #define Is_btn_not_left() Is_not_hwb()
00114 #define Is_btn_not_middle() ((PINB & (1<<PINB0)) ? TRUE : FALSE)
00115 #define Is_btn_not_right() TRUE
00116
00117 #define Is_joy_not_down() ((PINB & (1<<PINB7)) ? TRUE : FALSE)
00118 #define Is_joy_not_right() ((PINB & (1<<PINB6)) ? TRUE : FALSE)
00119 #define Is_joy_not_up() ((PINB & (1<<PINB5)) ? TRUE : FALSE)
00120 #define Is_joy_not_left() ((PINB & (1<<PINB4)) ? TRUE : FALSE)
00121
00122
00127 #define Switches_enable_it() { \
00128 PCMSK0 |= (1<<PCINT0)|(1<<PCINT4)|(1<<PCINT5)|(1<<PCINT6)|(1<<PCINT7);\
00129 PCIFR |= (1<<PCIF0); \
00130 PCICR |= (1<<PCIE0);}
00131
00136 #define Switches_disable_it() { \
00137 PCICR &= ~(1<<PCIE0); \
00138 PCIFR |= (1<<PCIF0); \
00139 PCMSK0 &= ~((1<<PCINT0)|(1<<PCINT4)|(1<<PCINT5)|(1<<PCINT6)|(1<<PCINT7));}
00141
00142
00147 #define Hwb_button_init() (DDRD &= ~(1<<PIND7))
00148 #define Is_hwb() ((PIND & (1<<PIND7)) ? FALSE : TRUE)
00149 #define Is_not_hwb() ((PIND & (1<<PIND7)) ? TRUE : FALSE)
00151
00152
00156
00157
00158 #define DF_8_MB
00159 #define DF_NB_MEM 1
00160
00161
00162
00163
00164
00165
00166
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 DDRC |= ((1<<PINC2)), \
00171 PORTC |= ((1<<PINC2)) )
00172 #define Df_select_0() (PORTC &= ~(1<<PINC2))
00173 #define Df_desel_all() (PORTC |= (1<<PINC2))
00175
00177
00178 #endif // STK_526
00179
00180