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