基于MCU的U盤源碼實現flash的windos文件系統(tǒng)
#include "d12ci.h"
#include "main.h"
//#include "44b.h"
extern EPPFLAGS bEPPflags;
void outportdata(unsigned char val)
{
DISABLE;
D12_DATA=val;
ENABLE;
}
void outportcmd(unsigned char val)
{
DISABLE;
D12_COMMAND=val;
ENABLE;
}
unsigned char inportb(void)
{
unsigned char c;
DISABLE;
c = D12_DATA;
ENABLE;
return c;
}
void D12_SetAddressEnable(unsigned char bAddress, unsigned char bEnable)
{
?if(bEPPflags.bits.in_isr == 0)
??DISABLE;
?outportcmd(0xD0);
?if(bEnable)
??bAddress |= 0x80;
?outportdata(bAddress);
?if(bEPPflags.bits.in_isr == 0)
??ENABLE;
//?Uart_Printf("E D12_SetAddressEnable\n");
}
void D12_SetEndpointEnable(unsigned char bEnable)
{
?if(bEPPflags.bits.in_isr == 0)
??DISABLE;
?outportcmd(0xD8);
?if(bEnable)
??outportdata(1);
?else
??outportdata(0);
?if(bEPPflags.bits.in_isr == 0)
??ENABLE;
//?Uart_Printf("E D12_SetEndpointEnable\n");
}
void D12_SetMode(unsigned char bConfig, unsigned char bClkDiv)
{
??if(bEPPflags.bits.in_isr == 0)
??DISABLE;
??outportcmd(0xF3);
??outportdata(bConfig);
??outportdata(bClkDiv);
??if(bEPPflags.bits.in_isr == 0)
???ENABLE;
//?Uart_Printf("E D12_SetMode\n");
}
void D12_SetDMA(unsigned char bMode)
{
??if(bEPPflags.bits.in_isr == 0)
?? ?DISABLE;
??outportcmd(0xFB);
??outportdata(bMode);
?if(bEPPflags.bits.in_isr == 0)
??ENABLE;
//?Uart_Printf("E D12_SetDMA\n");
}
/*
unsigned char D12_GetDMA(void)
{
?outportcmd(0xFB);
?return(inportb());
}
*/
/*
unsigned char D12_ReadEndpointStatus(unsigned char bEndp)
{
?unsigned char c;
?if(bEPPflags.bits.in_isr == 0)
??DISABLE;
?outportcmd(0x80 + bEndp);
?c = inportb();
?if(bEPPflags.bits.in_isr == 0)
??ENABLE;
?return c;
}
*/
void D12_SetEndpointStatus(unsigned char bEndp, unsigned char bStalled)
{
?if(bEPPflags.bits.in_isr == 0)
??DISABLE;
?outportcmd(0x40 + bEndp);
?outportdata(bStalled);
?if(bEPPflags.bits.in_isr == 0)
??ENABLE;
//?Uart_Printf("E D12_SetEndpointStatus\n");
}
/*
void D12_SendResume(void)
{
?outportcmd(0xF6);
}
*/
unsigned char D12_WriteEndpoint(unsigned char endp, unsigned char len, unsigned char * buf)
{
?unsigned char i;
?if(bEPPflags.bits.in_isr == 0)
??DISABLE;
?//---------------------
?outportcmd(endp);?//選擇端點
?inportb();??//讀入滿/空狀態(tài)
?outportcmd(0xF0);?//寫緩沖區(qū)命令
?outportdata(0);
?outportdata(len);
?for(i=0; i
?outportcmd(0xFA);?//駛購沖區(qū)有效
?
?//--------------------------------
?if(bEPPflags.bits.in_isr == 0)
??ENABLE;
//?Uart_Printf("E D12_WriteEndpoint\n");
?return len;
}
void D12_AcknowledgeEndpoint(unsigned char endp)
{
?outportcmd( endp);?//選擇端點
?outportcmd(0xF1);?//應答設置
?if(endp == 0)
??outportcmd(0xF2);?//緩沖區(qū)清零
//?Uart_Printf("E D12_AcknowledgeEndpoint%d\n",endp);
}
unsigned short D12_ReadInterruptRegister(void)
{
?unsigned char b1;
?unsigned int j;
?//outportb(D12_COMMAND, 0xF4);
?outportcmd(0xF4);
?b1 = inportb();
?j = inportb();
?j <<= 8;
?j += b1;
//?if(j) Uart_Printf("E D12_ReadInterruptRegister:%x\n",j);//printf the intterrupt number if it's not zero.
?return j;
}
unsigned char D12_ReadLastTransactionStatus(unsigned char bEndp)
{
?//outportb(D12_COMMAND, 0x40 + bEndp);
?outportcmd(0x40 + bEndp);
//?Uart_Printf("E D12_ReadLastTransactionStatus\n");
?return inportb();
}
unsigned char D12_ReadEndpoint(unsigned char endp, unsigned char len, unsigned char * buf)
{
?unsigned char i, j;
?if(bEPPflags.bits.in_isr == 0)
??DISABLE;
?//--------------------------------
?outportcmd(endp);???//選擇端點
?if((inportb() & D12_FULLEMPTY) == 0) {?//如果緩沖區(qū)為空,則返回
??if(bEPPflags.bits.in_isr == 0)
???ENABLE;
??return 0;
?}
?outportcmd(0xF0);???//讀緩沖區(qū)
?j = inportb();
?j = inportb();
?if(j > len)
??j = len;
?for(i=0; i
?outportcmd(0xF2);????//緩沖區(qū)清空
?//-------------------------------
?if(bEPPflags.bits.in_isr == 0)
??ENABLE;
//?Uart_Printf("E D12_ReadEndpoint:%d,%d character read\n",endp,j);
?return j;
}
unsigned char D12_SelectEndpoint(unsigned char bEndp)
{
?unsigned char c;
?if(bEPPflags.bits.in_isr == 0)
??DISABLE;
?outportcmd(bEndp);
?c = inportb();
?if(bEPPflags.bits.in_isr == 0)
??ENABLE;
//?Uart_Printf("E D12_SelectEndpoint\n");
?return c;
}
非常好我支持^.^
(0) 0%
不好我反對
(0) 0%
下載地址
基于MCU的U盤源碼實現flash的windos文件系統(tǒng)下載
相關電子資料下載
- 慶祝元旦|源碼起新程,萬物共互聯(lián) 310
- 【賽事宣講會】OpenHarmony源碼轉換器—多線程特性轉換 213
- 報名啟動|OpenHarmony源碼轉換器—多線程特性轉換賽題 62
- ELF 1技術貼|在NXP源碼基礎上適配ELF 1開發(fā)板的LED功能 186
- git commit代碼提交規(guī)范 91
- 獲取Linux內核源碼的方法 106
- SpringBoot項目Jar包加密防止反編譯方案 149
- 分享一套生產管理MES系統(tǒng)源碼,可以直接拿來搞錢的好項目 144
- 分析Autosar架構下的NVM源碼 209
- 探索AIGC未來:CPU源碼優(yōu)化、多GPU編程與中國算力瓶頸與發(fā)展 672