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
00050
00054 #define Joy_init() (DDRB &= 0x1F, PORTB |= 0xE0, DDRE &= 0xE7, PORTE |= 0x30)
00055 #define Is_joy_up() ((PINB & 0x80) ? FALSE : TRUE)
00056 #define Is_joy_not_up() ((PINB & 0x80) ? TRUE : FALSE)
00057 #define Is_joy_left() ((PINB & 0x40) ? FALSE : TRUE)
00058 #define Is_joy_not_left() ((PINB & 0x40) ? TRUE : FALSE)
00059 #define Is_joy_select() ((PINB & 0x20) ? FALSE : TRUE)
00060 #define Is_joy_not_select() ((PINB & 0x20) ? TRUE : FALSE)
00061 #define Is_joy_right() ((PINE & 0x10) ? FALSE : TRUE)
00062 #define Is_joy_not_right() ((PINE & 0x10) ? TRUE : FALSE)
00063 #define Is_joy_down() ((PINE & 0x20) ? FALSE : TRUE)
00064 #define Is_joy_not_down() ((PINE & 0x20) ? TRUE : FALSE)
00065
00066
00071 #define Hwb_button_init() (DDRE &= 0xFB, PORTE |= 0x04)
00072 #define Is_hwb() ((PINE & 0x04) ? FALSE : TRUE)
00073 #define Is_not_hwb() ((PINE & 0x04) ? TRUE : FALSE)
00074
00075
00077 #define ADC_POT_CH 0x01
00078 #define ADC_MIC_CH 0x02
00079 #define ADC_TEMP_CH 0x00
00080
00081 #ifdef USE_ADC
00082
00094 U16 Get_adc_mic_val(void);
00095
00107 U16 Get_adc_temp_val(void);
00108
00120 U16 Get_adc_pot_val(void);
00121
00133 S16 Read_temperature(void);
00134
00135 #endif
00136
00140
00141 #define DF_4_MB // Type of DF implemented on STK525.
00142
00143
00144 #define DF_SELECT_MEM 0
00145 #define DF_UNSELECT_MEM 1
00146 #define DF_NB_MEM 1
00147
00148 #ifndef AVRGCC
00149
00150
00151
00152
00153
00154
00155
00156
00157 #define Init_df_stk525() (DDRB_Bit4=1,PORTB_Bit3=1,PORTB_Bit4=1,PORTB_Bit0=1)
00158 #define DF_CS_PIN PORTB_Bit4
00159 #define DF_CS0 DF_CS_PIN
00160 #define DF_CS1 DF_CS0
00161 #define DF_CS2 DF_CS0
00162 #define DF_CS3 DF_CS0
00163 #define Df_select_df(i, val) (DF_CS##i = val)
00164 #define Df_desel_all() (DF_CS0=DF_UNSELECT_MEM) // set CS# dataflash memories
00165 #else
00166 #define Init_df_stk525() (DDRB |=0x10,PORTB|=0x10,PORTB|=0x01,DDRB &= 0xFE,\
00167 DDRB|=0x01,DDRB|=0x04,DDRB|=0x04)
00168 #define DF_CS_PORT PORTB
00169 #define DF_CS0 4
00170 #define DF_CS1 DF_CS0
00171 #define DF_CS2 DF_CS0
00172 #define DF_CS3 DF_CS0
00173 #define Df_desel_all() (DF_CS_PORT|=0x10) // set CS# dataflash memories (unselect).
00174 #endif
00175 #define df_init_spi() Init_df_stk525()
00176
00177
00179
00180 #endif // STK_525_H