📄 stm32f10x_spi.lst
字号:
###############################################################################
# #
# 30/Jul/2008 14:37:40 #
# IAR ARM ANSI C/C++ Compiler V5.11.0.20622/W32 EVALUATION #
# Copyright 1999-2007 IAR Systems. All rights reserved. #
# #
# Cpu mode = thumb #
# Endian = little #
# Source file = E:\library\src\stm32f10x_spi.c #
# Command line = E:\library\src\stm32f10x_spi.c -D EMB_FLASH -lCN #
# E:\ELE\yten\pro\Debug\List\ -lb #
# E:\ELE\yten\pro\Debug\List\ -o #
# E:\ELE\yten\pro\Debug\Obj\ --no_cse --no_unroll #
# --no_inline --no_code_motion --no_tbaa --no_clustering #
# --no_scheduling --debug --endian little --cpu Cortex-M3 #
# -e --fpu None --dlib_config "C:\Program Files\IAR #
# Systems\Embedded Workbench 5.0 #
# Evaluation\ARM\INC\DLib_Config_Normal.h" -I #
# E:\ELE\yten\pro\ -I E:\ELE\yten\pro\..\LIBRARY\INC\ -I #
# "C:\Program Files\IAR Systems\Embedded Workbench 5.0 #
# Evaluation\ARM\INC\" --section .text=.XML -On #
# List file = E:\ELE\yten\pro\Debug\List\stm32f10x_spi.lst #
# Object file = E:\ELE\yten\pro\Debug\Obj\stm32f10x_spi.o #
# #
# #
###############################################################################
E:\library\src\stm32f10x_spi.c
1 /******************** (C) COPYRIGHT 2007 STMicroelectronics ********************
2 * File Name : stm32f10x_spi.c
3 * Author : MCD Application Team
4 * Version : V1.0
5 * Date : 10/08/2007
6 * Description : This file provides all the SPI firmware functions.
7 ********************************************************************************
8 * THE PRESENT SOFTWARE WHICH IS FOR GUIDANCE ONLY AIMS AT PROVIDING CUSTOMERS
9 * WITH CODING INFORMATION REGARDING THEIR PRODUCTS IN ORDER FOR THEM TO SAVE TIME.
10 * AS A RESULT, STMICROELECTRONICS SHALL NOT BE HELD LIABLE FOR ANY DIRECT,
11 * INDIRECT OR CONSEQUENTIAL DAMAGES WITH RESPECT TO ANY CLAIMS ARISING FROM THE
12 * CONTENT OF SUCH SOFTWARE AND/OR THE USE MADE BY CUSTOMERS OF THE CODING
13 * INFORMATION CONTAINED HEREIN IN CONNECTION WITH THEIR PRODUCTS.
14 *******************************************************************************/
15
16 /* Includes ------------------------------------------------------------------*/
17 #include "stm32f10x_spi.h"
18 #include "stm32f10x_rcc.h"
19
20 /* Private typedef -----------------------------------------------------------*/
21 /* Private define ------------------------------------------------------------*/
22 /* SPI SPE mask */
23 #define CR1_SPE_Set ((u16)0x0040)
24 #define CR1_SPE_Reset ((u16)0xFFBF)
25
26 /* SPI CRCNext mask */
27 #define CR1_CRCNext_Set ((u16)0x1000)
28
29 /* SPI CRCEN mask */
30 #define CR1_CRCEN_Set ((u16)0x2000)
31 #define CR1_CRCEN_Reset ((u16)0xDFFF)
32
33 /* SPI SSOE mask */
34 #define CR2_SSOE_Set ((u16)0x0004)
35 #define CR2_SSOE_Reset ((u16)0xFFFB)
36
37 /* SPI registers Masks */
38 #define CR1_CLEAR_Mask ((u16)0x3040)
39
40 /* Private macro -------------------------------------------------------------*/
41 /* Private variables ---------------------------------------------------------*/
42 /* Private function prototypes -----------------------------------------------*/
43 /* Private functions ---------------------------------------------------------*/
44
45 /*******************************************************************************
46 * Function Name : SPI_DeInit
47 * Description : Deinitializes the SPIx peripheral registers to their default
48 * reset values.
49 * Input : - SPIx: where x can be 1 or 2 to select the SPI peripheral.
50 * Output : None
51 * Return : None
52 *******************************************************************************/
\ In section .XML, align 4, keep-with-next
53 void SPI_DeInit(SPI_TypeDef* SPIx)
54 {
\ SPI_DeInit:
\ 00000000 10B5 PUSH {R4,LR}
\ 00000002 0400 MOVS R4,R0
55 switch (*(u32*)&SPIx)
\ 00000004 2000 MOVS R0,R4
\ 00000006 0E49 LDR.N R1,??SPI_DeInit_0 ;; 0x40003800
\ 00000008 401A SUBS R0,R0,R1
\ 0000000A 0ED0 BEQ.N ??SPI_DeInit_1
\ 0000000C 5FF47841 MOVS R1,#+63488
\ 00000010 401A SUBS R0,R0,R1
\ 00000012 14D1 BNE.N ??SPI_DeInit_2
56 {
57 case SPI1_BASE:
58 /* Enable SPI1 reset state */
59 RCC_APB2PeriphResetCmd(RCC_APB2Periph_SPI1, ENABLE);
\ ??SPI_DeInit_3:
\ 00000014 0121 MOVS R1,#+1
\ 00000016 5FF48050 MOVS R0,#+4096
\ 0000001A ........ BL RCC_APB2PeriphResetCmd
60 /* Release SPI1 from reset state */
61 RCC_APB2PeriphResetCmd(RCC_APB2Periph_SPI1, DISABLE);
\ 0000001E 0021 MOVS R1,#+0
\ 00000020 5FF48050 MOVS R0,#+4096
\ 00000024 ........ BL RCC_APB2PeriphResetCmd
\ 00000028 09E0 B.N ??SPI_DeInit_2
62 break;
63
64 case SPI2_BASE:
65 /* Enable SPI2 reset state */
66 RCC_APB1PeriphResetCmd(RCC_APB1Periph_SPI2, ENABLE);
\ ??SPI_DeInit_1:
\ 0000002A 0121 MOVS R1,#+1
\ 0000002C 5FF48040 MOVS R0,#+16384
\ 00000030 ........ BL RCC_APB1PeriphResetCmd
67 /* Release SPI2 from reset state */
68 RCC_APB1PeriphResetCmd(RCC_APB1Periph_SPI2, DISABLE);
\ 00000034 0021 MOVS R1,#+0
\ 00000036 5FF48040 MOVS R0,#+16384
\ 0000003A ........ BL RCC_APB1PeriphResetCmd
69 break;
70
71 default:
72 break;
73 }
74 }
\ ??SPI_DeInit_2:
\ 0000003E 10BD POP {R4,PC} ;; return
\ ??SPI_DeInit_0:
\ 00000040 00380040 DC32 0x40003800
75
76 /*******************************************************************************
77 * Function Name : SPI_Init
78 * Description : Initializes the SPIx peripheral according to the specified
79 * parameters in the SPI_InitStruct.
80 * Input : - SPIx: where x can be 1 or 2 to select the SPI peripheral.
81 * - SPI_InitStruct: pointer to a SPI_InitTypeDef structure that
82 * contains the configuration information for the specified
83 * SPI peripheral.
84 * Output : None
85 * Return : None
86 ******************************************************************************/
\ In section .XML, align 4, keep-with-next
87 void SPI_Init(SPI_TypeDef* SPIx, SPI_InitTypeDef* SPI_InitStruct)
88 {
\ SPI_Init:
\ 00000000 30B4 PUSH {R4,R5}
89 u16 tmpreg = 0;
\ 00000002 0022 MOVS R2,#+0
\ 00000004 1300 MOVS R3,R2
90
91 /* Check the parameters */
92 assert_param(IS_SPI_DIRECTION_MODE(SPI_InitStruct->SPI_Direction));
93 assert_param(IS_SPI_MODE(SPI_InitStruct->SPI_Mode));
94 assert_param(IS_SPI_DATASIZE(SPI_InitStruct->SPI_DataSize));
95 assert_param(IS_SPI_CPOL(SPI_InitStruct->SPI_CPOL));
96 assert_param(IS_SPI_CPHA(SPI_InitStruct->SPI_CPHA));
97 assert_param(IS_SPI_NSS(SPI_InitStruct->SPI_NSS));
98 assert_param(IS_SPI_BAUDRATE_PRESCALER(SPI_InitStruct->SPI_BaudRatePrescaler));
99 assert_param(IS_SPI_FIRST_BIT(SPI_InitStruct->SPI_FirstBit));
100 assert_param(IS_SPI_CRC_POLYNOMIAL(SPI_InitStruct->SPI_CRCPolynomial));
101
102 /*---------------------------- SPIx CR1 Configuration ------------------------*/
103 /* Get the SPIx CR1 value */
104 tmpreg = SPIx->CR1;
\ 00000006 0288 LDRH R2,[R0, #+0]
\ 00000008 1300 MOVS R3,R2
105 /* Clear BIDIMode, BIDIOE, RxONLY, SSM, SSI, LSBFirst, BR, MSTR, CPOL and CPHA bits */
106 tmpreg &= CR1_CLEAR_Mask;
\ 0000000A 13F44153 ANDS R3,R3,#0x3040
107 /* Configure SPIx: direction, NSS management, first transmitted bit, BaudRate prescaler
108 master/salve mode, CPOL and CPHA */
109 /* Set BIDImode, BIDIOE and RxONLY bits according to SPI_Direction value */
110 /* Set SSM, SSI and MSTR bits according to SPI_Mode and SPI_NSS values */
111 /* Set LSBFirst bit according to SPI_FirstBit value */
112 /* Set BR bits according to SPI_BaudRatePrescaler value */
113 /* Set CPOL bit according to SPI_CPOL value */
114 /* Set CPHA bit according to SPI_CPHA value */
115 tmpreg |= (u16)((u32)SPI_InitStruct->SPI_Direction | SPI_InitStruct->SPI_Mode |
116 SPI_InitStruct->SPI_DataSize | SPI_InitStruct->SPI_CPOL |
117 SPI_InitStruct->SPI_CPHA | SPI_InitStruct->SPI_NSS |
118 SPI_InitStruct->SPI_BaudRatePrescaler | SPI_InitStruct->SPI_FirstBit);
\ 0000000E 1A00 MOVS R2,R3
\ 00000010 0B88 LDRH R3,[R1, #+0]
\ 00000012 4C88 LDRH R4,[R1, #+2]
\ 00000014 1C43 ORRS R4,R4,R3
\ 00000016 8B88 LDRH R3,[R1, #+4]
\ 00000018 2343 ORRS R3,R3,R4
\ 0000001A CC88 LDRH R4,[R1, #+6]
\ 0000001C 1C43 ORRS R4,R4,R3
\ 0000001E 0B89 LDRH R3,[R1, #+8]
\ 00000020 2343 ORRS R3,R3,R4
\ 00000022 4C89 LDRH R4,[R1, #+10]
\ 00000024 1C43 ORRS R4,R4,R3
\ 00000026 8D89 LDRH R5,[R1, #+12]
\ 00000028 2543 ORRS R5,R5,R4
\ 0000002A CB89 LDRH R3,[R1, #+14]
\ 0000002C 2B43 ORRS R3,R3,R5
\ 0000002E 1343 ORRS R3,R3,R2
119 /* Write to SPIx CR1 */
120 SPIx->CR1 = tmpreg;
\ 00000030 0380 STRH R3,[R0, #+0]
121
122 /*---------------------------- SPIx CRCPOLY Configuration --------------------*/
123 /* Write to SPIx CRCPOLY */
124 SPIx->CRCPR = SPI_InitStruct->SPI_CRCPolynomial;
\ 00000032 0A8A LDRH R2,[R1, #+16]
\ 00000034 0282 STRH R2,[R0, #+16]
125 }
\ 00000036 30BC POP {R4,R5}
\ 00000038 7047 BX LR ;; return
126
127 /*******************************************************************************
128 * Function Name : SPI_StructInit
129 * Description : Fills each SPI_InitStruct member with its default value.
130 * Input : - SPI_InitStruct : pointer to a SPI_InitTypeDef structure
131 * which will be initialized.
132 * Output : None
133 * Return : None
134 *******************************************************************************/
\ In section .XML, align 4, keep-with-next
135 void SPI_StructInit(SPI_InitTypeDef* SPI_InitStruct)
136 {
137 /*--------------- Reset SPI init structure parameters values -----------------*/
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -