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_525_H
00045 #define STK_525_H
00046
00047
00048 #include "config.h"
00049
00050 #if (TARGET_BOARD==STK525)
00051
00052
00053
00058
00059
00063 #define LED_PORT PORTD
00064 #define LED_DDR DDRD
00065 #define LED_PIN PIND
00066 #define LED0_BIT PIND4
00067 #define LED1_BIT PIND5
00068 #define LED2_BIT PIND6
00069 #define LED3_BIT PIND7
00070
00071 #define Leds_init() (LED_DDR |= (1<<LED0_BIT) | (1<<LED1_BIT) | (1<<LED2_BIT) | (1<<LED3_BIT))
00072 #define Leds_on() (LED_PORT |= (1<<LED0_BIT) | (1<<LED1_BIT) | (1<<LED2_BIT) | (1<<LED3_BIT))
00073 #define Leds_off() (LED_PORT &= ~((1<<LED0_BIT) | (1<<LED1_BIT) | (1<<LED2_BIT) | (1<<LED3_BIT)))
00074 #define Leds_set_val(c) (Leds_off(),LED_PORT |= (c<<4)&((1<<LED0_BIT) | (1<<LED1_BIT) | (1<<LED2_BIT) | (1<<LED3_BIT)))
00075 #define Leds_get_val() (LED_PORT>>4)
00076
00077 #define Led0_on() (LED_PORT |= (1<<LED0_BIT))
00078 #define Led1_on() (LED_PORT |= (1<<LED1_BIT))
00079 #define Led2_on() (LED_PORT |= (1<<LED2_BIT))
00080 #define Led3_on() (LED_PORT |= (1<<LED3_BIT))
00081 #define Led0_off() (LED_PORT &= ~(1<<LED0_BIT))
00082 #define Led1_off() (LED_PORT &= ~(1<<LED1_BIT))
00083 #define Led2_off() (LED_PORT &= ~(1<<LED2_BIT))
00084 #define Led3_off() (LED_PORT &= ~(1<<LED3_BIT))
00085 #define Led0_toggle() (LED_PIN |= (1<<LED0_BIT))
00086 #define Led1_toggle() (LED_PIN |= (1<<LED1_BIT))
00087 #define Led2_toggle() (LED_PIN |= (1<<LED2_BIT))
00088 #define Led3_toggle() (LED_PIN |= (1<<LED3_BIT))
00089 #define Is_led0_on() (LED_PIN & (1<<LED0_BIT) ? TRUE : FALSE)
00090 #define Is_led1_on() (LED_PIN & (1<<LED1_BIT) ? TRUE : FALSE)
00091 #define Is_led2_on() (LED_PIN & (1<<LED2_BIT) ? TRUE : FALSE)
00092 #define Is_led3_on() (LED_PIN & (1<<LED3_BIT) ? TRUE : FALSE)
00094
00098 #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)))
00099
00100 #define Is_btn_left() Is_hwb()
00101 #define Is_btn_middle() ((PINB & (1<<PINB5)) ? FALSE : TRUE)
00102 #define Is_btn_right() FALSE
00103
00104 #define Is_joy_left() ((PINB & (1<<PINB6)) ? FALSE : TRUE)
00105 #define Is_joy_up() ((PINB & (1<<PINB7)) ? FALSE : TRUE)
00106 #define Is_joy_down() ((PINE & (1<<PINE5)) ? FALSE : TRUE)
00107 #define Is_joy_right() ((PINE & (1<<PINE4)) ? FALSE : TRUE)
00108
00109 #define Is_btn_not_left() Is_not_hwb()
00110 #define Is_btn_not_middle() ((PINB & (1<<PINB5)) ? TRUE : FALSE)
00111 #define Is_btn_not_right() TRUE
00112
00113 #define Is_joy_not_up() ((PINB & (1<<PINB7)) ? TRUE : FALSE)
00114 #define Is_joy_not_left() ((PINB & (1<<PINB6)) ? TRUE : FALSE)
00115 #define Is_joy_not_down() ((PINE & (1<<PINE5)) ? TRUE : FALSE)
00116 #define Is_joy_not_right() ((PINE & (1<<PINE4)) ? TRUE : FALSE)
00117
00122 #define Switches_enable_it() { \
00123 PCMSK0 |= (1<<PCINT5)|(1<<PCINT6)|(1<<PCINT7);\
00124 PCIFR |= (1<<PCIF0); \
00125 PCICR |= (1<<PCIE0);}
00126
00131 #define Switches_disable_it() { \
00132 PCICR &= ~(1<<PCIE0); \
00133 PCIFR |= (1<<PCIF0); \
00134 PCMSK0 &= ~((1<<PCINT5)|(1<<PCINT6)|(1<<PCINT7));}
00136
00137
00142 #define Hwb_button_init() (DDRE &= ~(1<<PINE2), PORTE |= (1<<PINE2))
00143 #define Is_hwb() ((PINE & (1<<PINE2)) ? FALSE : TRUE)
00144 #define Is_not_hwb() ((PINE & (1<<PINE2)) ? TRUE : FALSE)
00146
00147
00151
00152
00153 #define DF_4_MB
00154 #define DF_NB_MEM 1
00155
00156
00157
00158
00159
00160
00161
00162 #define Df_init_spi() (DDRB &= ~((1<<PINB3)), \
00163 DDRB |= ((1<<PINB4)|(1<<PINB2)|(1<<PINB1)|(1<<PINB0)), \
00164 PORTB |= ((1<<PINB4)|(1<<PINB3)|(1<<PINB2)|(1<<PINB1)|(1<<PINB0)) )
00165 #define Df_select_0() (PORTB &= ~(1<<PINB4))
00166 #define Df_desel_all() (PORTB |= (1<<PINB4))
00169
00171
00172
00173
00175 #define ADC_POT_CH 0x01
00176 #define ADC_MIC_CH 0x02
00177 #define ADC_TEMP_CH 0x00
00178
00179 #ifdef USE_ADC
00180
00192 U16 Get_adc_mic_val(void);
00193
00205 U16 Get_adc_temp_val(void);
00206
00218 U16 Get_adc_pot_val(void);
00219
00231 S16 Read_temperature(void);
00232
00233 #endif // USE_ADC
00234
00235 #endif // TARGET_BOARD==STK525
00236
00237 #endif // STK_525_H