📄 sdhal.lis
字号:
.module sdhal.c
.area text(rom, con, rel)
0000 .dbfile D:\new_sd\SD\SD\sdhal.c
0000 .dbfunc e SPI_INIT _SPI_INIT fV
.even
0000 _SPI_INIT::
0000 .dbline -1
0000 .dbline 22
0000 ; /*****************************************************************************************************
0000 ; ** Descriptions:sd 卡驱动软件包: 硬件抽象层 ---- SPI操作函数
0000 ; ********************************************************************************************************/
0000 ; #include "D:\new_sd\define.h"
0000 ;
0000 ;
0000 ;
0000 ; /**************************************************************
0000 ;
0000 ; 读写SD卡的SPI接口函数: SPI接口设置,发送/接收字节函数
0000 ;
0000 ; **************************************************************/
0000 ; /*
0000 ; *********************************************************************************************************
0000 ; ** 函数名称:SSP_Init()
0000 ; ** 函数功能:将SSP控制器设置为主机SPI。
0000 ; ** 入口参数:无
0000 ; ** 出口参数:无
0000 ; *********************************************************************************************************
0000 ; */
0000 ; void SPI_INIT(void)
0000 ; {
0000 .dbline -2
0000 L1:
0000 .dbline 0 ; func end
0000 0895 ret
0002 .dbend
0002 .dbfunc e SD_HardWareInit _SD_HardWareInit fV
.even
0002 _SD_HardWareInit::
0002 .dbline -1
0002 .dbline 46
0002 ; /* SSPCR1 = 0x00;
0002 ;
0002 ; PINSEL1 |= (0x02 << 2) | //连接SSP模块
0002 ; (0x02 << 4) |
0002 ; (0x02 << 6);
0002 ; SPI_CS_OUT(); //片选脚设置为输出
0002 ; SPI_CS_SET(); //设置片选脚为高电平
0002 ;
0002 ; SSPCR0 = 0x0707; //8位数据长度,CPOL = 0, CPHA = 0,SCR=15,SPI模式
0002 ;
0002 ; SSPCPSR = 0x2; //时钟分频器
0002 ;
0002 ; SSPCR1 = 0x02; //SSP使能
0002 ; */
0002 ; }
0002 ;
0002 ; /*******************************************************************************************************************
0002 ; ** 函数名称: void SD_HardWareInit() Name: void SD_HardWareInit()
0002 ; ** 功能描述: 初始化访问SD卡的硬件条件 Function: initialize the hardware condiction that access sd card
0002 ; ** 输 入: 无 Input: NULL
0002 ; ** 输 出: 无 Output: NULL
0002 ; ********************************************************************************************************************/
0002 ; void SD_HardWareInit(void)
0002 ; { /*
0002 .dbline -2
0002 L2:
0002 .dbline 0 ; func end
0002 0895 ret
0004 .dbend
0004 .dbfunc e SPI_Clk400k _SPI_Clk400k fV
.even
0004 _SPI_Clk400k::
0004 .dbline -1
0004 .dbline 61
0004 ; SPI_INIT(); /// 初始化SPI接口
0004 ;
0004 ; SPI_CS_SET(); /// CS置高
0004 ; */
0004 ; }
0004 ;
0004 ;
0004 ; /*******************************************************************************************************************
0004 ; ** 函数名称: void SPI_Clk400k() Name: void SPI_Clk400k()
0004 ; ** 功能描述: 设置SPI的时钟小于400kHZ Function: set the clock of SPI less than 400kHZ
0004 ; ** 输 入: 无 Input: NULL
0004 ; ** 输 出: 无 Output: NULL
0004 ; ********************************************************************************************************************/
0004 ; void SPI_Clk400k(void)
0004 ; {
0004 .dbline -2
0004 L3:
0004 .dbline 0 ; func end
0004 0895 ret
0006 .dbend
0006 .dbfunc e SPI_ClkToMax _SPI_ClkToMax fV
.even
0006 _SPI_ClkToMax::
0006 .dbline -1
0006 .dbline 73
0006 ; //SSPCPSR = 128; // 设置SPI时钟分频值为128 Set the value of dividing frequency to 128
0006 ; }
0006 ;
0006 ;
0006 ; /*******************************************************************************************************************
0006 ; ** 函数名称: void SPI_ClkToMax() Name: void SPI_ClkToMax()
0006 ; ** 功能描述: 设置SPI的clock到最大值 Function: set the clock of SPI to maximum
0006 ; ** 输 入: 无 Input: NULL
0006 ; ** 输 出: 无 Output: NULL
0006 ; ********************************************************************************************************************/
0006 ; void SPI_ClkToMax(void)
0006 ; {
0006 .dbline -2
0006 L4:
0006 .dbline 0 ; func end
0006 0895 ret
0008 .dbend
0008 .dbfunc e SPI_SendByte _SPI_SendByte fV
0008 ; byte -> R0
.even
0008 _SPI_SendByte::
0008 .dbline -1
0008 .dbline 85
0008 ; //SSPCPSR = 8; // 设置SPI时钟分频值为8 Set the value of dividing frequency to 8
0008 ; }
0008 ;
0008 ;
0008 ; /*******************************************************************************************************************
0008 ; ** 函数名称: void SPI_SendByte() Name: void SPI_SendByte()
0008 ; ** 功能描述: 通过SPI接口发送一个字节 Function: send a byte by SPI interface
0008 ; ** 输 入: INT8U byte: 发送的字节 Input: INT8U byte: the byte that will be send
0008 ; ** 输 出: 无 Output: NULL
0008 ; ********************************************************************************************************************/
0008 ; void SPI_SendByte(uint8 byte)
0008 ; {/*
0008 .dbline -2
0008 L5:
0008 .dbline 0 ; func end
0008 0895 ret
000A .dbsym l byte 0 c
000A .dbend
000A .dbfunc e SPI_RecByte _SPI_RecByte fc
.even
000A _SPI_RecByte::
000A .dbline -1
000A .dbline 101
000A ; uint8 temp;
000A ; SSPDR = byte;
000A ; while ( (SSPSR & 0x01) == 0 );
000A ; temp = SSPDR; // 刷新 RxFIFO
000A ; */
000A ; }
000A ;
000A ;
000A ; /*******************************************************************************************************************
000A ; ** 函数名称: INT8U SPI_RecByte() Name: INT8U SPI_RecByte()
000A ; ** 功能描述: 从SPI接口接收一个字节 Function: receive a byte from SPI interface
000A ; ** 输 入: 无 Input: NULL
000A ; ** 输 出: 收到的字节 Output: the byte that be received
000A ; ********************************************************************************************************************/
000A ; uint8 SPI_RecByte(void)
000A ; {
000A .dbline -2
000A L6:
000A .dbline 0 ; func end
000A 0895 ret
000C .dbend
000C .dbfunc e SPI_CS_Assert _SPI_CS_Assert fV
.even
000C _SPI_CS_Assert::
000C .dbline -1
000C .dbline 119
000C ; /*
000C ; SSPDR = 0xFF;
000C ;
000C ; while(SSPSR & 0x10); // 等待SPIF置位,即等待收到数据
000C ; // wait for SPIF being set, that is, wait for being received data
000C ; return(SSPDR); // 读取收到的字节 read the byte received
000C ; */
000C ; }
000C ;
000C ;
000C ; /*******************************************************************************************************************
000C ; ** 函数名称: void SPI_CS_Assert() Name: void SPI_CS_Assert()
000C ; ** 功能描述: 片选SPI从机 Function: select the SPI slave
000C ; ** 输 入: 无 Input: NULL
000C ; ** 输 出: 无 Output: NULL
000C ; ********************************************************************************************************************/
000C ; void SPI_CS_Assert(void)
000C ; {
000C .dbline -2
000C L7:
000C .dbline 0 ; func end
000C 0895 ret
000E .dbend
000E .dbfunc e SPI_CS_Deassert _SPI_CS_Deassert fV
.even
000E _SPI_CS_Deassert::
000E .dbline -1
000E .dbline 131
000E ; //SPI_CS_CLR(); // 片选SPI从机 select the SPI slave
000E ; }
000E ;
000E ;
000E ; /*******************************************************************************************************************
000E ; ** 函数名称: void SPI_CS_Deassert() Name: void SPI_CS_Deassert()
000E ; ** 功能描述: 不片选SPI从机 Function: not select the SPI slave
000E ; ** 输 入: 无 Input: NULL
000E ; ** 输 出: 无 Output: NULL
000E ; ********************************************************************************************************************/
000E ; void SPI_CS_Deassert(void)
000E ; {
000E .dbline -2
000E L8:
000E .dbline 0 ; func end
000E 0895 ret
0010 .dbend
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -