本帖最后由 CC2530 于 2011-7-11 08:43 编辑
更新一下:IO口加入极性操作(On,off)
#define LED_1 IO_AVR_OBJECT_DEF(A,1) //LED_1:A1
#define LED_2 IO_AVR_OBJECT_POLARITY_DEF(B,5,0) //LED_2:B5,低电平表示ON
uint8 x;
int main(void)
{
LED_1.MakeOut().Set().Clr().Toggle().MakeInHighImpedance().Read(x);
LED_1.Write(!x);
LED_2.MakeOut().On().Off().Toggle().MakeInHighImpedance().ReadOnOff(x);
LED_2.WriteOnOff(!x);
while(1);
}
RSEG CODE:CODE:NOROOT(1)
// 9 int main(void)
main:
// 10 {
// 11
// 12 LED_1.MakeOut().Set().Clr().Toggle().MakeInHighImpedance().Read(x);
SBI 0x1A, 0x01
SBI 0x1B, 0x01
CBI 0x1B, 0x01
LDI R16, 2
IN R17, 0x1B
EOR R17, R16
OUT 0x1B, R17
CBI 0x1A, 0x01
CBI 0x1B, 0x01
SBIS 0x19, 0x01
RJMP ??main_0
CBI 0x1B, 0x01
RJMP ??main_1
??main_0:
SBI 0x1B, 0x01
// 13 LED_1.Write(!x);
// 14
// 15 LED_2.MakeOut().On().Off().Toggle().MakeInHighImpedance().ReadOnOff(x);
??main_1:
SBI 0x17, 0x05
CBI 0x18, 0x05
SBI 0x18, 0x05
LDI R16, 32
IN R17, 0x18
EOR R17, R16
OUT 0x18, R17
CBI 0x17, 0x05
CBI 0x18, 0x05
SBIS 0x18, 0x05
RJMP ??main_2
CBI 0x18, 0x05
RJMP ??main_3
??main_2:
SBI 0x18, 0x05
// 16 LED_2.WriteOnOff(!x);
// 17
// 18 while(1);
|