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

📄 main.lss

📁 基於MCU c51/8051 讀寫SD/MMC card 再以USB 傳回電腦的範例程序
💻 LSS
📖 第 1 页 / 共 5 页
字号:
	D12_DAT_WR_L();
	D12_DAT_WR_H();

	while(Count)
	{
		NOP6();
		D12_OUTPUT = *Buffer++;
		D12_DAT_WR_L();
		D12_DAT_WR_H();

		Count--;
	}
	NOP4();
	D12_Enable_Buffer();
}

void D12_Write_Endpoint_SD(U8 Endpoint)
{
	NOP4();
	while(D12_Select_Endpoint(Endpoint)&1)	//wait buffer empty
	
	D12_Read_Last_Transaction_Status(Endpoint);

	D12_OUTPUT_MODE();
	D12_OUTPUT = 0xf0;
	D12_CMD_WR_L();
	D12_CMD_WR_H();

	NOP7();
	
	D12_OUTPUT = 0;
	D12_DAT_WR_L();
	D12_DAT_WR_H();

	NOP6();

	D12_OUTPUT = 64;
	D12_DAT_WR_L();
	D12_DAT_WR_H();
	
	
	D12_OUTPUT = SPI_WriteByte(0xff);
	D12_DAT_WR_L();
	D12_DAT_WR_H();

	D12_OUTPUT = SPI_WriteByte(0xff);
	D12_DAT_WR_L();
	D12_DAT_WR_H();

	D12_OUTPUT = SPI_WriteByte(0xff);
	D12_DAT_WR_L();
	D12_DAT_WR_H();

	D12_OUTPUT = SPI_WriteByte(0xff);
	D12_DAT_WR_L();
	D12_DAT_WR_H();
	
	D12_OUTPUT = SPI_WriteByte(0xff);
	D12_DAT_WR_L();
	D12_DAT_WR_H();

	D12_OUTPUT = SPI_WriteByte(0xff);
	D12_DAT_WR_L();
	D12_DAT_WR_H();

	D12_OUTPUT = SPI_WriteByte(0xff);
	D12_DAT_WR_L();
	D12_DAT_WR_H();

	D12_OUTPUT = SPI_WriteByte(0xff);
	D12_DAT_WR_L();
	D12_DAT_WR_H();
	
	D12_OUTPUT = SPI_WriteByte(0xff);
	D12_DAT_WR_L();
	D12_DAT_WR_H();

	D12_OUTPUT = SPI_WriteByte(0xff);
	D12_DAT_WR_L();
	D12_DAT_WR_H();

	D12_OUTPUT = SPI_WriteByte(0xff);
	D12_DAT_WR_L();
	D12_DAT_WR_H();

	D12_OUTPUT = SPI_WriteByte(0xff);
	D12_DAT_WR_L();
	D12_DAT_WR_H();
	
	D12_OUTPUT = SPI_WriteByte(0xff);
	D12_DAT_WR_L();
	D12_DAT_WR_H();

	D12_OUTPUT = SPI_WriteByte(0xff);
	D12_DAT_WR_L();
	D12_DAT_WR_H();

	D12_OUTPUT = SPI_WriteByte(0xff);
	D12_DAT_WR_L();
	D12_DAT_WR_H();

	D12_OUTPUT = SPI_WriteByte(0xff);
	D12_DAT_WR_L();
	D12_DAT_WR_H();
	
	D12_OUTPUT = SPI_WriteByte(0xff);
	D12_DAT_WR_L();
	D12_DAT_WR_H();

	D12_OUTPUT = SPI_WriteByte(0xff);
	D12_DAT_WR_L();
	D12_DAT_WR_H();

	D12_OUTPUT = SPI_WriteByte(0xff);
	D12_DAT_WR_L();
	D12_DAT_WR_H();

	D12_OUTPUT = SPI_WriteByte(0xff);
	D12_DAT_WR_L();
	D12_DAT_WR_H();
	
	D12_OUTPUT = SPI_WriteByte(0xff);
	D12_DAT_WR_L();
	D12_DAT_WR_H();

	D12_OUTPUT = SPI_WriteByte(0xff);
	D12_DAT_WR_L();
	D12_DAT_WR_H();

	D12_OUTPUT = SPI_WriteByte(0xff);
	D12_DAT_WR_L();
	D12_DAT_WR_H();

	D12_OUTPUT = SPI_WriteByte(0xff);
	D12_DAT_WR_L();
	D12_DAT_WR_H();
	
	D12_OUTPUT = SPI_WriteByte(0xff);
	D12_DAT_WR_L();
	D12_DAT_WR_H();

	D12_OUTPUT = SPI_WriteByte(0xff);
	D12_DAT_WR_L();
	D12_DAT_WR_H();

	D12_OUTPUT = SPI_WriteByte(0xff);
	D12_DAT_WR_L();
	D12_DAT_WR_H();

	D12_OUTPUT = SPI_WriteByte(0xff);
	D12_DAT_WR_L();
	D12_DAT_WR_H();
	
	D12_OUTPUT = SPI_WriteByte(0xff);
	D12_DAT_WR_L();
	D12_DAT_WR_H();

	D12_OUTPUT = SPI_WriteByte(0xff);
	D12_DAT_WR_L();
	D12_DAT_WR_H();

	D12_OUTPUT = SPI_WriteByte(0xff);
	D12_DAT_WR_L();
	D12_DAT_WR_H();

	D12_OUTPUT = SPI_WriteByte(0xff);
	D12_DAT_WR_L();
	D12_DAT_WR_H();
	
	D12_OUTPUT = SPI_WriteByte(0xff);
	D12_DAT_WR_L();
	D12_DAT_WR_H();

	D12_OUTPUT = SPI_WriteByte(0xff);
	D12_DAT_WR_L();
	D12_DAT_WR_H();

	D12_OUTPUT = SPI_WriteByte(0xff);
	D12_DAT_WR_L();
	D12_DAT_WR_H();

	D12_OUTPUT = SPI_WriteByte(0xff);
	D12_DAT_WR_L();
	D12_DAT_WR_H();
	
	D12_OUTPUT = SPI_WriteByte(0xff);
	D12_DAT_WR_L();
	D12_DAT_WR_H();

	D12_OUTPUT = SPI_WriteByte(0xff);
	D12_DAT_WR_L();
	D12_DAT_WR_H();

	D12_OUTPUT = SPI_WriteByte(0xff);
	D12_DAT_WR_L();
	D12_DAT_WR_H();

	D12_OUTPUT = SPI_WriteByte(0xff);
	D12_DAT_WR_L();
	D12_DAT_WR_H();
	
	D12_OUTPUT = SPI_WriteByte(0xff);
	D12_DAT_WR_L();
	D12_DAT_WR_H();

	D12_OUTPUT = SPI_WriteByte(0xff);
	D12_DAT_WR_L();
	D12_DAT_WR_H();

	D12_OUTPUT = SPI_WriteByte(0xff);
	D12_DAT_WR_L();
	D12_DAT_WR_H();

	D12_OUTPUT = SPI_WriteByte(0xff);
	D12_DAT_WR_L();
	D12_DAT_WR_H();
	
	D12_OUTPUT = SPI_WriteByte(0xff);
	D12_DAT_WR_L();
	D12_DAT_WR_H();

	D12_OUTPUT = SPI_WriteByte(0xff);
	D12_DAT_WR_L();
	D12_DAT_WR_H();

	D12_OUTPUT = SPI_WriteByte(0xff);
	D12_DAT_WR_L();
	D12_DAT_WR_H();

	D12_OUTPUT = SPI_WriteByte(0xff);
	D12_DAT_WR_L();
	D12_DAT_WR_H();
	
	D12_OUTPUT = SPI_WriteByte(0xff);
	D12_DAT_WR_L();
	D12_DAT_WR_H();

	D12_OUTPUT = SPI_WriteByte(0xff);
	D12_DAT_WR_L();
	D12_DAT_WR_H();

	D12_OUTPUT = SPI_WriteByte(0xff);
	D12_DAT_WR_L();
	D12_DAT_WR_H();

	D12_OUTPUT = SPI_WriteByte(0xff);
	D12_DAT_WR_L();
	D12_DAT_WR_H();
	
	D12_OUTPUT = SPI_WriteByte(0xff);
	D12_DAT_WR_L();
	D12_DAT_WR_H();

	D12_OUTPUT = SPI_WriteByte(0xff);
	D12_DAT_WR_L();
	D12_DAT_WR_H();

	D12_OUTPUT = SPI_WriteByte(0xff);
	D12_DAT_WR_L();
	D12_DAT_WR_H();

	D12_OUTPUT = SPI_WriteByte(0xff);
	D12_DAT_WR_L();
	D12_DAT_WR_H();
	
	D12_OUTPUT = SPI_WriteByte(0xff);
	D12_DAT_WR_L();
	D12_DAT_WR_H();

	D12_OUTPUT = SPI_WriteByte(0xff);
	D12_DAT_WR_L();
	D12_DAT_WR_H();

	D12_OUTPUT = SPI_WriteByte(0xff);
	D12_DAT_WR_L();
	D12_DAT_WR_H();

	D12_OUTPUT = SPI_WriteByte(0xff);
	D12_DAT_WR_L();
	D12_DAT_WR_H();
	
	D12_OUTPUT = SPI_WriteByte(0xff);
	D12_DAT_WR_L();
	D12_DAT_WR_H();

	D12_OUTPUT = SPI_WriteByte(0xff);
	D12_DAT_WR_L();
	D12_DAT_WR_H();

	D12_OUTPUT = SPI_WriteByte(0xff);
	D12_DAT_WR_L();
	D12_DAT_WR_H();

	D12_OUTPUT = SPI_WriteByte(0xff);
	D12_DAT_WR_L();
	D12_DAT_WR_H();

	NOP4();
	D12_Enable_Buffer();
}

U16 D12_Read_Interrupt_Register(void)
{
	U16 temp;
	U8 temp2;
	NOP4();

	D12_OUTPUT_MODE();
     4b6:	8f ef       	ldi	r24, 0xFF	; 255
     4b8:	8a bb       	out	0x1a, r24	; 26
	D12_OUTPUT = 0xf4;
     4ba:	84 ef       	ldi	r24, 0xF4	; 244
     4bc:	8b bb       	out	0x1b, r24	; 27
	D12_CMD_WR_L();
     4be:	e5 e6       	ldi	r30, 0x65	; 101
     4c0:	f0 e0       	ldi	r31, 0x00	; 0
     4c2:	83 e1       	ldi	r24, 0x13	; 19
     4c4:	80 83       	st	Z, r24
	D12_CMD_WR_H();
     4c6:	9f e1       	ldi	r25, 0x1F	; 31
     4c8:	90 83       	st	Z, r25
	...

	NOP7();
     4d6:	00 00       	nop

	D12_INPUT_MODE();
     4d8:	1a ba       	out	0x1a, r1	; 26
	D12_CMD_RD_L();
     4da:	2b e0       	ldi	r18, 0x0B	; 11
     4dc:	20 83       	st	Z, r18
	NOP3();
     4de:	00 00       	nop
     4e0:	00 00       	nop
     4e2:	00 00       	nop
	temp = D12_INPUT;
     4e4:	89 b3       	in	r24, 0x19	; 25
	D12_CMD_RD_H();
     4e6:	90 83       	st	Z, r25
	...

	NOP6();

	D12_CMD_RD_L();
     4f4:	20 83       	st	Z, r18
	NOP3();
     4f6:	00 00       	nop
     4f8:	00 00       	nop
     4fa:	00 00       	nop
	temp2 = D12_INPUT;
     4fc:	29 b3       	in	r18, 0x19	; 25
	D12_CMD_RD_H();
     4fe:	90 83       	st	Z, r25
	...
	
	NOP4();

	return temp;
}
     508:	99 27       	eor	r25, r25
     50a:	08 95       	ret

0000050c <D12_Clear_Buffer>:
	...

void D12_Clear_Buffer(void)
{

	NOP4();

	D12_OUTPUT_MODE();
     514:	8f ef       	ldi	r24, 0xFF	; 255
     516:	8a bb       	out	0x1a, r24	; 26
	D12_OUTPUT = 0xf2;
     518:	82 ef       	ldi	r24, 0xF2	; 242
     51a:	8b bb       	out	0x1b, r24	; 27
	D12_CMD_WR_L();
     51c:	e5 e6       	ldi	r30, 0x65	; 101
     51e:	f0 e0       	ldi	r31, 0x00	; 0
     520:	83 e1       	ldi	r24, 0x13	; 19
     522:	80 83       	st	Z, r24
	D12_CMD_WR_H();
     524:	8f e1       	ldi	r24, 0x1F	; 31
     526:	80 83       	st	Z, r24
	...

	NOP4();
     530:	08 95       	ret

00000532 <D12_Ack_Endpoint>:
	...
     53a:	9f ef       	ldi	r25, 0xFF	; 255
     53c:	9a bb       	out	0x1a, r25	; 26
     53e:	8b bb       	out	0x1b, r24	; 27
     540:	33 e1       	ldi	r19, 0x13	; 19
     542:	30 93 65 00 	sts	0x0065, r19
     546:	2f e1       	ldi	r18, 0x1F	; 31
     548:	20 93 65 00 	sts	0x0065, r18
	...
     558:	00 00       	nop
     55a:	91 ef       	ldi	r25, 0xF1	; 241
     55c:	9b bb       	out	0x1b, r25	; 27
     55e:	30 93 65 00 	sts	0x0065, r19
     562:	20 93 65 00 	sts	0x0065, r18
	...
     56e:	88 23       	and	r24, r24
     570:	11 f4       	brne	.+4      	; 0x576 <D12_Ack_Endpoint+0x44>
     572:	0e 94 86 02 	call	0x50c	; 0x50c <D12_Clear_Buffer>
     576:	08 95       	ret

00000578 <D12_Enable_Buffer>:
	...
}

void D12_Enable_Buffer(void)
{

	NOP4();

	D12_OUTPUT_MODE();
     580:	8f ef       	ldi	r24, 0xFF	; 255
     582:	8a bb       	out	0x1a, r24	; 26
	D12_OUTPUT = 0xfa;
     584:	8a ef       	ldi	r24, 0xFA	; 250
     586:	8b bb       	out	0x1b, r24	; 27
	D12_CMD_WR_L();
     588:	e5 e6       	ldi	r30, 0x65	; 101
     58a:	f0 e0       	ldi	r31, 0x00	; 0
     58c:	83 e1       	ldi	r24, 0x13	; 19
     58e:	80 83       	st	Z, r24
	D12_CMD_WR_H();
     590:	8f e1       	ldi	r24, 0x1F	; 31
     592:	80 83       	st	Z, r24
	...

⌨️ 快捷键说明

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