⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 car_prevent.lss

📁 基于AT Mega16的多功能小车
💻 LSS
📖 第 1 页 / 共 3 页
字号:

	car_ahead();					// 小车启动
 2f0:	0e 94 85 01 	call	0x30a	; 0x30a <car_ahead>
	while(1)
	{
		car_prevent();
 2f4:	0e 94 71 00 	call	0xe2	; 0xe2 <car_prevent>
 2f8:	fd cf       	rjmp	.-6      	; 0x2f4 <main+0x1a>

000002fa <car_init>:
#include "avr/io.h"
#include "util/delay.h"

void car_init(void)
{
	DDRD |= _BV(PD2) | _BV(PD3) | _BV(PD4) | _BV(PD5);
 2fa:	81 b3       	in	r24, 0x11	; 17
 2fc:	8c 63       	ori	r24, 0x3C	; 60
 2fe:	81 bb       	out	0x11, r24	; 17
}
 300:	08 95       	ret

00000302 <car_stop>:

void car_stop(void)					// 刹车
{
	PORTD |= _BV(PD2) | _BV(PD3) | _BV(PD4) | _BV(PD5);
 302:	82 b3       	in	r24, 0x12	; 18
 304:	8c 63       	ori	r24, 0x3C	; 60
 306:	82 bb       	out	0x12, r24	; 18
}
 308:	08 95       	ret

0000030a <car_ahead>:

void car_ahead(void)				// 前进
{
	PORTD &= ~(_BV(PD2) | _BV(PD3) | _BV(PD4) | _BV(PD5));
 30a:	82 b3       	in	r24, 0x12	; 18
 30c:	83 7c       	andi	r24, 0xC3	; 195
 30e:	82 bb       	out	0x12, r24	; 18
 310:	80 e0       	ldi	r24, 0x00	; 0
 312:	94 e2       	ldi	r25, 0x24	; 36
 314:	01 97       	sbiw	r24, 0x01	; 1
 316:	f1 f7       	brne	.-4      	; 0x314 <car_ahead+0xa>
	_delay_ms(5);
	PORTD |= _BV(PD2) | _BV(PD4);
 318:	82 b3       	in	r24, 0x12	; 18
 31a:	84 61       	ori	r24, 0x14	; 20
 31c:	82 bb       	out	0x12, r24	; 18
}
 31e:	08 95       	ret

00000320 <car_backward>:

void car_backward(void)				// 后退
{
	PORTD &= ~(_BV(PD2) | _BV(PD3) | _BV(PD4) | _BV(PD5));
 320:	82 b3       	in	r24, 0x12	; 18
 322:	83 7c       	andi	r24, 0xC3	; 195
 324:	82 bb       	out	0x12, r24	; 18
 326:	80 e0       	ldi	r24, 0x00	; 0
 328:	94 e2       	ldi	r25, 0x24	; 36
 32a:	01 97       	sbiw	r24, 0x01	; 1
 32c:	f1 f7       	brne	.-4      	; 0x32a <car_backward+0xa>
	_delay_ms(5);
	PORTD |= _BV(PD3) | _BV(PD5);
 32e:	82 b3       	in	r24, 0x12	; 18
 330:	88 62       	ori	r24, 0x28	; 40
 332:	82 bb       	out	0x12, r24	; 18
}
 334:	08 95       	ret

00000336 <car_left_Circle>:

void car_left_Circle(void)			// 原地左转
{
	PORTD &= ~(_BV(PD2) | _BV(PD3) | _BV(PD4) | _BV(PD5));
 336:	82 b3       	in	r24, 0x12	; 18
 338:	83 7c       	andi	r24, 0xC3	; 195
 33a:	82 bb       	out	0x12, r24	; 18
 33c:	80 e0       	ldi	r24, 0x00	; 0
 33e:	94 e2       	ldi	r25, 0x24	; 36
 340:	01 97       	sbiw	r24, 0x01	; 1
 342:	f1 f7       	brne	.-4      	; 0x340 <car_left_Circle+0xa>
	_delay_ms(5);
	PORTD |= _BV(PD3) | _BV(PD4);
 344:	82 b3       	in	r24, 0x12	; 18
 346:	88 61       	ori	r24, 0x18	; 24
 348:	82 bb       	out	0x12, r24	; 18
}
 34a:	08 95       	ret

0000034c <car_right_Circle>:

void car_right_Circle(void)			// 原地右转
{
	PORTD &= ~(_BV(PD2) | _BV(PD3) | _BV(PD4) | _BV(PD5));
 34c:	82 b3       	in	r24, 0x12	; 18
 34e:	83 7c       	andi	r24, 0xC3	; 195
 350:	82 bb       	out	0x12, r24	; 18
 352:	80 e0       	ldi	r24, 0x00	; 0
 354:	94 e2       	ldi	r25, 0x24	; 36
 356:	01 97       	sbiw	r24, 0x01	; 1
 358:	f1 f7       	brne	.-4      	; 0x356 <car_right_Circle+0xa>
	_delay_ms(5);
	PORTD |= _BV(PD2) | _BV(PD5);
 35a:	82 b3       	in	r24, 0x12	; 18
 35c:	84 62       	ori	r24, 0x24	; 36
 35e:	82 bb       	out	0x12, r24	; 18
}
 360:	08 95       	ret

00000362 <car_left_stop>:

void car_left_stop(void)			// 左转,左轮不动
{
	PORTD &= ~(_BV(PD2) | _BV(PD3) | _BV(PD4) | _BV(PD5));
 362:	82 b3       	in	r24, 0x12	; 18
 364:	83 7c       	andi	r24, 0xC3	; 195
 366:	82 bb       	out	0x12, r24	; 18
 368:	80 e0       	ldi	r24, 0x00	; 0
 36a:	94 e2       	ldi	r25, 0x24	; 36
 36c:	01 97       	sbiw	r24, 0x01	; 1
 36e:	f1 f7       	brne	.-4      	; 0x36c <car_left_stop+0xa>
	_delay_ms(5);
	PORTD |= _BV(PD2) | _BV(PD3) | _BV(PD4);
 370:	82 b3       	in	r24, 0x12	; 18
 372:	8c 61       	ori	r24, 0x1C	; 28
 374:	82 bb       	out	0x12, r24	; 18
}
 376:	08 95       	ret

00000378 <car_right_stop>:

void car_right_stop(void)			// 右转,右轮不动
{
	PORTD &= ~(_BV(PD2) | _BV(PD3) | _BV(PD4) | _BV(PD5));
 378:	82 b3       	in	r24, 0x12	; 18
 37a:	83 7c       	andi	r24, 0xC3	; 195
 37c:	82 bb       	out	0x12, r24	; 18
 37e:	80 e0       	ldi	r24, 0x00	; 0
 380:	94 e2       	ldi	r25, 0x24	; 36
 382:	01 97       	sbiw	r24, 0x01	; 1
 384:	f1 f7       	brne	.-4      	; 0x382 <car_right_stop+0xa>
	_delay_ms(5);
	PORTD |= _BV(PD2) | _BV(PD4) | _BV(PD5);
 386:	82 b3       	in	r24, 0x12	; 18
 388:	84 63       	ori	r24, 0x34	; 52
 38a:	82 bb       	out	0x12, r24	; 18
}
 38c:	08 95       	ret

0000038e <car_left>:

void car_left(void)					// 左转
{
	PORTD &= ~(_BV(PD2) | _BV(PD3) | _BV(PD4) | _BV(PD5));
 38e:	82 b3       	in	r24, 0x12	; 18
 390:	83 7c       	andi	r24, 0xC3	; 195
 392:	82 bb       	out	0x12, r24	; 18
 394:	80 e0       	ldi	r24, 0x00	; 0
 396:	94 e2       	ldi	r25, 0x24	; 36
 398:	01 97       	sbiw	r24, 0x01	; 1
 39a:	f1 f7       	brne	.-4      	; 0x398 <car_left+0xa>
	_delay_ms(5);
	PORTD |= _BV(PD4);
 39c:	94 9a       	sbi	0x12, 4	; 18
}
 39e:	08 95       	ret

000003a0 <car_right>:

void car_right(void)				// 右转
{
	PORTD &= ~(_BV(PD2) | _BV(PD3) | _BV(PD4) | _BV(PD5));
 3a0:	82 b3       	in	r24, 0x12	; 18
 3a2:	83 7c       	andi	r24, 0xC3	; 195
 3a4:	82 bb       	out	0x12, r24	; 18
 3a6:	80 e0       	ldi	r24, 0x00	; 0
 3a8:	94 e2       	ldi	r25, 0x24	; 36
 3aa:	01 97       	sbiw	r24, 0x01	; 1
 3ac:	f1 f7       	brne	.-4      	; 0x3aa <car_right+0xa>
	_delay_ms(5);
	PORTD |= _BV(PD2);
 3ae:	92 9a       	sbi	0x12, 2	; 18
}
 3b0:	08 95       	ret

000003b2 <Key_Init>:
//	入口参数:	无
//	返回  值:	无
//======================================================================
void Key_Init(void)
{
	P_Key_Dir &= ~(/*_BV(0) | _BV(1) | _BV(2) | */_BV(3));
 3b2:	d3 98       	cbi	0x1a, 3	; 26
	P_Key_Port |= /*_BV(0) | _BV(1) | _BV(2) | */_BV(3);		// 设置按键为上拉电阻
 3b4:	db 9a       	sbi	0x1b, 3	; 27
	
	ScanCnt = 0;			// 初始化变量
 3b6:	10 92 62 00 	sts	0x0062, r1
	KeyCode = 0;
 3ba:	10 92 61 00 	sts	0x0061, r1
	KeyUp = 1;
 3be:	81 e0       	ldi	r24, 0x01	; 1
 3c0:	80 93 63 00 	sts	0x0063, r24

	TCNT0 = 0;
 3c4:	12 be       	out	0x32, r1	; 50
	TCCR0 = _BV(CS02) | _BV(CS00);		// 预分频256
 3c6:	85 e0       	ldi	r24, 0x05	; 5
 3c8:	83 bf       	out	0x33, r24	; 51
	TIMSK |= _BV(TOIE0);
 3ca:	89 b7       	in	r24, 0x39	; 57
 3cc:	81 60       	ori	r24, 0x01	; 1
 3ce:	89 bf       	out	0x39, r24	; 57
	sei();								// 使能中断
 3d0:	78 94       	sei
}
 3d2:	08 95       	ret

000003d4 <Key_Scan>:
void Key_Scan(void)
{
	uint8_t key_t;

//	PORTB^=_BV(1);				// 调试时用来指示
	key_t = ~P_Key_Data;		// 获取IO端口状态
 3d4:	89 b3       	in	r24, 0x19	; 25
 3d6:	80 95       	com	r24
	key_t &= Key_ALL;			// 判断当前是否有键按下
	if(key_t != 0)
 3d8:	98 2f       	mov	r25, r24
 3da:	98 70       	andi	r25, 0x08	; 8
 3dc:	83 ff       	sbrs	r24, 3
 3de:	11 c0       	rjmp	.+34     	; 0x402 <Key_Scan+0x2e>
	{
		KeyUp = 0;				// 按键没抬起
 3e0:	10 92 63 00 	sts	0x0063, r1
		if(key_t == KeyCode)
 3e4:	80 91 61 00 	lds	r24, 0x0061
 3e8:	98 17       	cp	r25, r24
 3ea:	31 f4       	brne	.+12     	; 0x3f8 <Key_Scan+0x24>
		{
			ScanCnt++;
 3ec:	80 91 62 00 	lds	r24, 0x0062
 3f0:	8f 5f       	subi	r24, 0xFF	; 255
 3f2:	80 93 62 00 	sts	0x0062, r24
 3f6:	08 95       	ret
		}
		else
		{
			ScanCnt = 0;
 3f8:	10 92 62 00 	sts	0x0062, r1
			KeyCode = key_t;
 3fc:	90 93 61 00 	sts	0x0061, r25
 400:	08 95       	ret
		}
	}
	else
	{
		KeyUp = 1;				// 按键抬起
 402:	81 e0       	ldi	r24, 0x01	; 1
 404:	80 93 63 00 	sts	0x0063, r24
 408:	08 95       	ret

0000040a <Key_Get>:
//======================================================================
uint8_t Key_Get(void)
{
	uint8_t key_G;

	cli();		// 关中断
 40a:	f8 94       	cli
	if((ScanCnt >= Key_Debounce) && (KeyUp == 1))
 40c:	80 91 62 00 	lds	r24, 0x0062
 410:	88 23       	and	r24, r24
 412:	61 f0       	breq	.+24     	; 0x42c <Key_Get+0x22>
 414:	80 91 63 00 	lds	r24, 0x0063
 418:	81 30       	cpi	r24, 0x01	; 1
 41a:	41 f4       	brne	.+16     	; 0x42c <Key_Get+0x22>
	{
		key_G = KeyCode;
 41c:	90 91 61 00 	lds	r25, 0x0061
		KeyCode = 0;
 420:	10 92 61 00 	sts	0x0061, r1
		ScanCnt = 0;
 424:	10 92 62 00 	sts	0x0062, r1

		sei();	// 开中断
 428:	78 94       	sei
 42a:	15 c0       	rjmp	.+42     	; 0x456 <Key_Get+0x4c>
		return key_G;
	}
	if((ScanCnt >= Key_TimeOut) && (KeyUp==0))
 42c:	80 91 62 00 	lds	r24, 0x0062
 430:	80 31       	cpi	r24, 0x10	; 16
 432:	78 f0       	brcs	.+30     	; 0x452 <Key_Get+0x48>
 434:	80 91 63 00 	lds	r24, 0x0063
 438:	88 23       	and	r24, r24
 43a:	59 f4       	brne	.+22     	; 0x452 <Key_Get+0x48>
	{
		key_G = KeyCode;
 43c:	90 91 61 00 	lds	r25, 0x0061
		KeyCode = 0;
 440:	10 92 61 00 	sts	0x0061, r1
		ScanCnt = 0;
 444:	10 92 62 00 	sts	0x0062, r1
		KeyUp = 1;
 448:	81 e0       	ldi	r24, 0x01	; 1
 44a:	80 93 63 00 	sts	0x0063, r24

		sei();	// 开中断
 44e:	78 94       	sei
 450:	02 c0       	rjmp	.+4      	; 0x456 <Key_Get+0x4c>
		return key_G;
	}

	sei();
 452:	78 94       	sei
 454:	90 e0       	ldi	r25, 0x00	; 0
	return 0;	// 没有按键

}
 456:	89 2f       	mov	r24, r25
 458:	08 95       	ret

0000045a <_exit>:
 45a:	f8 94       	cli

0000045c <__stop_program>:
 45c:	ff cf       	rjmp	.-2      	; 0x45c <__stop_program>

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -