00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011 #define VBUS_SENSE_PORT PORTC // PORTx
00012 #define VBUS_SENSE_PIN PINC // PINx
00013 #define VBUS_SENSE_DDR DDRC // DDRx
00014 #define VBUS_SENSE_IO 4 // 0...7
00015
00016
00017
00018
00019 #define Leds_init() (DDRD |= 0x33, PORTD &= ~0x33)
00020
00021 #define Led0_on() (PORTD |= 0x01) // PD0
00022 #define Led0_off() (PORTD &= ~0x01)
00023 #define Led0_toggle() (PORTD ^= 0x01)
00024 #define Led1_on() (PORTD |= 0x02) // PD1
00025 #define Led1_off() (PORTD &= ~0x02)
00026 #define Led1_toggle() (PORTD ^= 0x02)
00027 #define Led2_on() (PORTD |= 0x10) // PD4
00028 #define Led2_off() (PORTD &= ~0x10)
00029 #define Led2_toggle() (PORTD ^= 0x10)
00030 #define Led3_on() (PORTD |= 0x20) // PD5
00031 #define Led3_off() (PORTD &= ~0x20)
00032 #define Led3_toggle() (PORTD ^= 0x20)
00033
00034 #define Leds_set_val(c) (Leds_off(),PORTD |= (c&0x03)+((c&0x0C)<<2))
00035 #define Leds_get_val() ((PORTD&0x30)>>2+(PORTD&0x03))
00036 #define Leds_off() (PORTD &= ~0x33)
00037
00038
00039
00040
00041 #define Joy_init() (DDRB &= ~0xF1, PORTB |= 0xF1)
00042 #define Push_button_init() Joy_init()
00043
00044 #define Is_joy_left() (((PINB&0x10) == 0) ? TRUE : FALSE) // PB4
00045 #define Is_joy_not_left() (((PINB&0x10) == 0) ? FALSE : TRUE)
00046 #define Is_button_left() Is_joy_left()
00047 #define Is_button_not_left() Is_joy_not_left()
00048
00049 #define Is_joy_middle() (((PINB&0x01) == 0) ? TRUE : FALSE) // PB0
00050 #define Is_joy_not_middle() (((PINB&0x01) == 0) ? FALSE : TRUE)
00051 #define Is_joy_select() Is_joy_middle()
00052 #define Is_joy_not_select() Is_joy_not_middle()
00053 #define Is_button_middle() Is_joy_middle()
00054 #define Is_button_not_middle() Is_joy_not_middle()
00055
00056 #define Is_joy_right() (((PINB&0x40) == 0) ? TRUE : FALSE) // PB6
00057 #define Is_joy_not_right() (((PINB&0x40) == 0) ? FALSE : TRUE)
00058 #define Is_button_right() Is_joy_right()
00059 #define Is_button_not_right() Is_joy_not_right()
00060
00061 #define Is_joy_down() (((PINB&0x80) == 0) ? TRUE : FALSE) // PB7
00062 #define Is_joy_not_down() (((PINB&0x80) == 0) ? FALSE : TRUE)
00063 #define Is_button_down() Is_joy_down()
00064 #define Is_button_not_down() Is_joy_not_down()
00065
00066 #define Is_joy_up() (((PINB&0x20) == 0) ? TRUE : FALSE) // PB5
00067 #define Is_joy_not_up() (((PINB&0x20) == 0) ? FALSE : TRUE)
00068 #define Is_button_up() Is_joy_up()
00069 #define Is_button_not_up() Is_joy_not_up()
00070
00071
00072 #define Hwb_button_init() (DDRD &= ~0x80)
00073 #define Is_hwb() (((PIND&0x80) == 0) ? TRUE : FALSE) // PD7
00074
00078
00079 #define DF_8_MB // Type of DF implemented.
00080
00081
00082 #define DF_SELECT_MEM 0
00083 #define DF_UNSELECT_MEM 1
00084 #define DF_NB_MEM 1
00085
00086 #ifndef AVRGCC
00087
00088
00089
00090
00091
00092
00093
00094
00095 #define Init_df_stk526() (DDRC_Bit2=1,PORTC_Bit2=1,DDRB_Bit0=1)
00096 #define DF_CS_PIN PORTC_Bit2
00097 #define DF_CS0 DF_CS_PIN
00098 #define DF_CS1 DF_CS0
00099 #define DF_CS2 DF_CS0
00100 #define DF_CS3 DF_CS0
00101 #define Df_select_df(i, val) (DF_CS##i = val)
00102 #define Df_desel_all() (DF_CS0=DF_UNSELECT_MEM) // set CS# dataflash memories
00103 #else
00104 #define Init_df_stk526() (DDRC |=(1<<DF_CS0), PORTC|=(1<<DF_CS0), PORTB |= (1<<0))
00105 #define DF_CS_PORT PORTC
00106 #define DF_CS0 2
00107 #define DF_CS1 DF_CS0
00108 #define DF_CS2 DF_CS0
00109 #define DF_CS3 DF_CS0
00110 #define Df_desel_all() (DF_CS_PORT|=(1<<DF_CS0)) // set CS# dataflash memories (unselect).
00111 #endif
00112 #define df_init_spi() Init_df_stk526()
00114
00115