00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014 #ifndef STK_525_H
00015 #define STK_525_H
00016
00017
00018 #include "config.h"
00019
00020
00021
00022
00027
00028
00032 #define Leds_init() (DDRD |= 0xF0)
00033 #define Leds_on() (PORTD |= 0xF0)
00034 #define Leds_off() (PORTD &= 0x0F)
00035 #define Led0_on() (PORTD |= 0x10)
00036 #define Led1_on() (PORTD |= 0x20)
00037 #define Led2_on() (PORTD |= 0x40)
00038 #define Led3_on() (PORTD |= 0x80)
00039 #define Led0_off() (PORTD &= 0xEF)
00040 #define Led1_off() (PORTD &= 0xDF)
00041 #define Led2_off() (PORTD &= 0xBF)
00042 #define Led3_off() (PORTD &= 0x7F)
00043 #define Led0_toggle() (PIND |= 0x10)
00044 #define Led1_toggle() (PIND |= 0x20)
00045 #define Led2_toggle() (PIND |= 0x40)
00046 #define Led3_toggle() (PIND |= 0x80)
00047 #define Leds_set_val(c) (Leds_off(),PORTD |= (c<<4)&0xF0)
00048 #define Leds_get_val() (PORTD>>4)
00049 #define Is_led0_on() (PIND & 0x10 ? TRUE : FALSE)
00051
00055 #define Joy_init() (DDRB &= 0x1F, PORTB |= 0xE0, DDRE &= 0xE7, PORTE |= 0x30)
00056 #define Is_joy_up() ((PINB & 0x80) ? FALSE : TRUE)
00057 #define Is_joy_not_up() ((PINB & 0x80) ? TRUE : FALSE)
00058 #define Is_joy_left() ((PINB & 0x40) ? FALSE : TRUE)
00059 #define Is_joy_not_left() ((PINB & 0x40) ? TRUE : FALSE)
00060 #define Is_joy_select() ((PINB & 0x20) ? FALSE : TRUE)
00061 #define Is_joy_not_select() ((PINB & 0x20) ? TRUE : FALSE)
00062 #define Is_joy_right() ((PINE & 0x10) ? FALSE : TRUE)
00063 #define Is_joy_not_right() ((PINE & 0x10) ? TRUE : FALSE)
00064 #define Is_joy_down() ((PINE & 0x20) ? FALSE : TRUE)
00065 #define Is_joy_not_down() ((PINE & 0x20) ? TRUE : FALSE)
00067
00072 #define Hwb_button_init() (DDRE &= 0xFB, PORTE |= 0x04)
00073 #define Is_hwb() ((PINE & 0x04) ? FALSE : TRUE)
00074 #define Is_not_hwb() ((PINE & 0x04) ? TRUE : FALSE)
00076
00078 #define ADC_POT_CH 0x01
00079 #define ADC_MIC_CH 0x02
00080 #define ADC_TEMP_CH 0x00
00081
00082 #ifdef USE_ADC
00083
00095 U16 Get_adc_mic_val(void);
00096
00108 U16 Get_adc_temp_val(void);
00109
00121 U16 Get_adc_pot_val(void);
00122
00134 S16 Read_temperature(void);
00135
00136 #endif
00137
00141
00142 #define DF_4_MB // Type of DF implemented on STK525.
00143
00144
00145 #define DF_SELECT_MEM 0
00146 #define DF_UNSELECT_MEM 1
00147 #define DF_NB_MEM 1
00148
00149 #ifndef AVRGCC
00150
00151
00152
00153
00154
00155
00156
00157
00158 #define Init_df_stk525() (DDRB_Bit4=1,PORTB_Bit3=1,PORTB_Bit4=1,PORTB_Bit0=1)
00159 #define DF_CS_PIN PORTB_Bit4
00160 #define DF_CS0 DF_CS_PIN
00161 #define DF_CS1 DF_CS0
00162 #define DF_CS2 DF_CS0
00163 #define DF_CS3 DF_CS0
00164 #define Df_select_df(i, val) (DF_CS##i = val)
00165 #define Df_desel_all() (DF_CS0=DF_UNSELECT_MEM) // set CS# dataflash memories
00166 #else
00167 #define Init_df_stk525() (DDRB |=0x10,PORTB|=0x10,PORTB|=0x01,DDRB &= 0xFE,\
00168 DDRB|=0x01,DDRB|=0x04,DDRB|=0x04)
00169 #define DF_CS_PORT PORTB
00170 #define DF_CS0 4
00171 #define DF_CS1 DF_CS0
00172 #define DF_CS2 DF_CS0
00173 #define DF_CS3 DF_CS0
00174 #define Df_desel_all() (DF_CS_PORT|=0x10) // set CS# dataflash memories (unselect).
00175 #endif
00176 #define df_init_spi() Init_df_stk525()
00178
00180
00181 #endif // STK_525_H