; generated by Component: ARM Compiler 5.06 update 7 (build 960) Tool: ArmCC [4d365d]
; commandline ArmCC [--c99 --list --split_sections --debug -c --asm --interleave -o..\output\spi_communication.o --asm_dir=..\List\ --list_dir=..\List\ --depend=..\output\spi_communication.d --cpu=Cortex-M0+ --apcs=interwork --diag_suppress=9931 -I..\FWLib\SC32F1XXX_Lib\inc -I..\User\HeadFiles -I..\User -I..\Drivers -I..\Apps -I..\CMSIS -IF:\Users\SOC\AppData\Local\Arm\Packs\ARM\CMSIS\5.8.0\Device\ARM\ARMCM0plus\Include -D__UVISION_VERSION=536 -DARMCM0P -DSC32f10xx --omf_browse=..\output\spi_communication.crf ..\Apps\SPI_Communication.c]
                          THUMB

                          AREA ||i.SPI_Communication_Function||, CODE, READONLY, ALIGN=2

                          REQUIRE _printf_percent
                          REQUIRE _printf_x
                          REQUIRE _printf_longlong_hex
                  SPI_Communication_Function PROC
;;;22     
;;;23     void SPI_Communication_Function(void)
000000  b08a              SUB      sp,sp,#0x28
;;;24     {
;;;25       SPI_InitTypeDef SPI_InitStruct; //定义SPI初始化结构体变量
;;;26      
;;;27     #if (SPI_Mode_ == 0)	
;;;28       volatile uint8_t Master_ReceiveData[8];
;;;29       volatile uint8_t SPI0_Data, SPI0_Num = 0;;
;;;30       GPIO_InitTypeDef GPIO_InitStruct; //定义GPIO初始化结构体变量
;;;31       /* 使能SPI0的时钟 */
;;;32       RCC_APB0Cmd(ENABLE);  //SPI0外设挂载在APB0时钟上
;;;33     #if defined(SC32f12xx)||defined(SC32f10xx)
;;;34       RCC_APB0PeriphClockCmd(RCC_APB0Periph_SPI0, ENABLE);
;;;35     #endif
;;;36     #if defined(SC32f12xx)
;;;37       GPIO_InitStruct.GPIO_Pin = GPIO_Pin_2;
;;;38       GPIO_InitStruct.GPIO_Mode = GPIO_Mode_OUT_PP;
;;;39       GPIO_Init(GPIOC, &GPIO_InitStruct);
;;;40     	PC_BIT(2) = 1;
;;;41     #elif defined(SC32f10xx)
;;;42       GPIO_InitStruct.GPIO_Pin = GPIO_Pin_1;
;;;43       GPIO_InitStruct.GPIO_Mode = GPIO_Mode_OUT_PP;
;;;44       GPIO_Init(GPIOB, &GPIO_InitStruct);
;;;45     	PB_BIT(1) = 1;
;;;46     
;;;47     #endif
;;;48     
;;;49       /*  配置SPI0为主机 */
;;;50       SPI_InitStruct.SPI_CPHA = SPI_CPHA_1Edge;	//SPI第一沿采集数据
;;;51       SPI_InitStruct.SPI_CPOL = SPI_CPOL_High;	//SPI空闲电平为高电平
;;;52       SPI_InitStruct.SPI_DataSize = SPI_DataSize_8B;	//数据长度为8位
;;;53       SPI_InitStruct.SPI_FirstBit = SPI_FirstBit_MSB;	//数值传输为高位在前
;;;54       SPI_InitStruct.SPI_Mode = SPI_Mode_Master;	//SPI工作在主机模式
;;;55       SPI_InitStruct.SPI_Prescaler = SPI_Prescaler_1024;	//SPI传输频率为APB0时钟1024分频
;;;56       SPI_Init(SPI0, &SPI_InitStruct);
;;;57     
;;;58     
;;;59     #if defined(SC32f12xx) ||defined(SC32f10xx)
;;;60       /* 使能SPI0中断 */
;;;61       SPI_ITConfig(SPI0, SPI_IT_INTEN, ENABLE);
;;;62       NVIC_EnableIRQ(SPI0_IRQn);
;;;63     #endif
;;;64       /* 使能SPI0 */
;;;65       SPI_Cmd(SPI0, ENABLE);
;;;66       
;;;67     #elif (SPI_Mode_ == 1)
;;;68       volatile uint8_t Slave_ReceiveData[8];
;;;69       volatile uint8_t SPI1_Data, SPI1_Num = 0;
000002  2500              MOVS     r5,#0
000004  4668              MOV      r0,sp
000006  7005              STRB     r5,[r0,#0]
;;;70     
;;;71       /* 使能SPI1的时钟 */
;;;72        RCC_APB1Cmd(ENABLE);//SPI1外设挂载在APB1时钟上 
000008  2001              MOVS     r0,#1
00000a  f7fffffe          BL       RCC_APB1Cmd
;;;73     #if defined(SC32f12xx)
;;;74       RCC_APB1PeriphClockCmd(RCC_APB1Periph_SPI1, ENABLE);
;;;75     #elif defined(SC32f10xx)
;;;76        RCC_APB1Cmd(ENABLE);//SPI1外设挂载在APB1时钟上
00000e  2001              MOVS     r0,#1
000010  f7fffffe          BL       RCC_APB1Cmd
;;;77     #endif
;;;78       /* 配置SPI1为从机 */
;;;79     
;;;80       SPI_InitStruct.SPI_CPHA = SPI_CPHA_1Edge;	//SPI第一沿采集数据
;;;81       SPI_InitStruct.SPI_CPOL = SPI_CPOL_High;	//SPI空闲电平为高电平
000014  2010              MOVS     r0,#0x10
;;;82       SPI_InitStruct.SPI_DataSize = SPI_DataSize_8B;	//数据长度为8位
;;;83       SPI_InitStruct.SPI_FirstBit = SPI_FirstBit_MSB;	//数值传输为高位在前
;;;84       SPI_InitStruct.SPI_Prescaler = SPI_Prescaler_1024;	//SPI传输频率为APB1时钟1024分频
000016  9004              STR      r0,[sp,#0x10]
000018  2005              MOVS     r0,#5
00001a  0240              LSLS     r0,r0,#9
;;;85       SPI_InitStruct.SPI_Mode = SPI_Mode_Slave;	//SPI工作在从机模式
;;;86       SPI_Init(SPI1, &SPI_InitStruct);
00001c  4c27              LDR      r4,|L1.188|
00001e  9501              STR      r5,[sp,#4]
000020  9006              STR      r0,[sp,#0x18]
000022  9503              STR      r5,[sp,#0xc]          ;82
000024  9502              STR      r5,[sp,#8]            ;83
000026  9505              STR      r5,[sp,#0x14]         ;84
000028  a901              ADD      r1,sp,#4
00002a  4620              MOV      r0,r4
00002c  f7fffffe          BL       SPI_Init
;;;87       
;;;88     
;;;89     #if defined(SC32f12xx)
;;;90       /* 使能SPI1中断 */
;;;91       SPI_ITConfig(SPI1, SPI_IT_INTEN, ENABLE);
;;;92       NVIC_EnableIRQ(SPI1_2_IRQn);
;;;93     #elif defined(SC32f10xx)
;;;94       /* 使能SPI1中断 */
;;;95       SPI_ITConfig(SPI1, SPI_IT_INTEN, ENABLE);
000030  2201              MOVS     r2,#1
000032  4611              MOV      r1,r2
000034  4620              MOV      r0,r4
000036  f7fffffe          BL       SPI_ITConfig
00003a  4a21              LDR      r2,|L1.192|
00003c  1521              ASRS     r1,r4,#20
00003e  6011              STR      r1,[r2,#0]
;;;96       NVIC_EnableIRQ(SPI1_IRQn);
;;;97     
;;;98     #endif
;;;99       /* 使能SPI1 */
;;;100      SPI_Cmd(SPI1, ENABLE);
000040  2101              MOVS     r1,#1
000042  4620              MOV      r0,r4
000044  f7fffffe          BL       SPI_Cmd
;;;101    #endif
;;;102      
;;;103      
;;;104      while(1)
;;;105      { 
;;;106    #if (SPI_Mode_ == 0)
;;;107        GPIO_SetBits( GPIOC, GPIO_Pin_2);
;;;108      //  SPI0发送第一个数据
;;;109        SPI_SendData(SPI0,Master_SendData[SPI0_Num]);
;;;110        
;;;111        while(SPI0_Num < 7)
;;;112        {
;;;113          
;;;114          while(SPI0_Flag == RESET);
;;;115          SPI0_Flag = RESET;
;;;116          Master_ReceiveData[SPI0_Num] = SPI_ReceiveData(SPI0);//主机SPI0接收数据
;;;117          SPI0_Num++;
;;;118          SPI_SendData(SPI0, Master_SendData[SPI0_Num]);	//主机SPI0发送		
;;;119          
;;;120        }
;;;121        
;;;122          while(SPI0_Flag == RESET);
;;;123        Master_ReceiveData[SPI0_Num] = SPI_ReceiveData(SPI0);	//SPI0接收最后一个数据
;;;124        for(int i=0 ;i <= 7 ;i++)	printf("SPI0主机接收到的数据为“0x%x”\r\n",Master_ReceiveData[i]);
;;;125       for(int time=1000;time>0;time--)
;;;126       {
;;;127          for(int time1 = 1000;time1>0;time1--);
;;;128       };
;;;129        /* 清除标志位，为下一次通信做准备 */
;;;130       
;;;131        SPI0_Flag = RESET;
;;;132         SPI0_Num = 0;
;;;133    
;;;134    #elif (SPI_Mode_ == 1)
;;;135       
;;;136        //SPI1发送第一个数据
;;;137        SPI_SendData(SPI1,Slave_SendData[SPI1_Num]);
;;;138        
;;;139        while(SPI1_Num < 7)
;;;140        {
;;;141          while(SPI1_Flag == RESET);	  
;;;142          SPI1_Flag = RESET;      
;;;143          Slave_ReceiveData[SPI1_Num] = SPI_ReceiveData(SPI1);//从机SPI1接收数据
000048  af07              ADD      r7,sp,#0x1c
                  |L1.74|
00004a  4668              MOV      r0,sp                 ;137
00004c  4c1d              LDR      r4,|L1.196|
00004e  7800              LDRB     r0,[r0,#0]            ;137
000050  4e1a              LDR      r6,|L1.188|
000052  5c21              LDRB     r1,[r4,r0]            ;137
000054  4630              MOV      r0,r6                 ;137
000056  f7fffffe          BL       SPI_SendData
00005a  4634              MOV      r4,r6                 ;86
00005c  4e1a              LDR      r6,|L1.200|
00005e  e013              B        |L1.136|
                  |L1.96|
000060  7830              LDRB     r0,[r6,#0]            ;141  ; SPI1_Flag
000062  2800              CMP      r0,#0                 ;141
000064  d0fc              BEQ      |L1.96|
000066  7035              STRB     r5,[r6,#0]            ;142
000068  4620              MOV      r0,r4
00006a  f7fffffe          BL       SPI_ReceiveData
00006e  4669              MOV      r1,sp
000070  7809              LDRB     r1,[r1,#0]
000072  5478              STRB     r0,[r7,r1]
;;;144          SPI1_Num ++;
000074  4669              MOV      r1,sp
000076  7808              LDRB     r0,[r1,#0]
000078  1c40              ADDS     r0,r0,#1
00007a  7008              STRB     r0,[r1,#0]
;;;145          SPI_SendData(SPI1, Slave_SendData[SPI1_Num]);	//从机SPI1发送数据
00007c  4811              LDR      r0,|L1.196|
00007e  7809              LDRB     r1,[r1,#0]
000080  5c41              LDRB     r1,[r0,r1]
000082  4620              MOV      r0,r4
000084  f7fffffe          BL       SPI_SendData
                  |L1.136|
000088  4668              MOV      r0,sp                 ;139
00008a  7800              LDRB     r0,[r0,#0]            ;139
00008c  2807              CMP      r0,#7                 ;139
00008e  d3e7              BCC      |L1.96|
                  |L1.144|
;;;146        }
;;;147        
;;;148        while(SPI1_Flag == RESET);
000090  7830              LDRB     r0,[r6,#0]  ; SPI1_Flag
000092  2800              CMP      r0,#0
000094  d0fc              BEQ      |L1.144|
;;;149        Slave_ReceiveData[SPI1_Num] = SPI_ReceiveData(SPI1);	//SPI1接收最后一个数据
000096  4620              MOV      r0,r4
000098  f7fffffe          BL       SPI_ReceiveData
00009c  4669              MOV      r1,sp
00009e  7809              LDRB     r1,[r1,#0]
0000a0  5478              STRB     r0,[r7,r1]
;;;150       for(int i=0 ;i <= 7 ;i++)	printf("SPI1从机接收到的数据为“0x%x”\r\n",Slave_ReceiveData[i]);
0000a2  2400              MOVS     r4,#0
                  |L1.164|
0000a4  5d39              LDRB     r1,[r7,r4]
0000a6  a009              ADR      r0,|L1.204|
0000a8  f7fffffe          BL       __2printf
0000ac  1c64              ADDS     r4,r4,#1
0000ae  2c07              CMP      r4,#7
0000b0  ddf8              BLE      |L1.164|
;;;151        
;;;152        /* 清除标志位，为下一次通信做准备 */
;;;153        SPI1_Num = 0;
0000b2  4668              MOV      r0,sp
0000b4  7005              STRB     r5,[r0,#0]
;;;154        SPI1_Flag = RESET;	
0000b6  7035              STRB     r5,[r6,#0]
0000b8  e7c7              B        |L1.74|
;;;155    #endif	
;;;156        
;;;157      }
;;;158    }
;;;159    #if defined(SC32f12xx) ||defined(SC32f10xx)
                          ENDP

0000ba  0000              DCW      0x0000
                  |L1.188|
                          DCD      0x40021040
                  |L1.192|
                          DCD      0xe000e100
                  |L1.196|
                          DCD      ||.constdata||
                  |L1.200|
                          DCD      ||.data||
                  |L1.204|
0000cc  53504931          DCB      "SPI1",180,211,187,250,189,211,202,213,181,189,181,196,202
0000d0  b4d3bbfa
0000d4  bdd3cad5
0000d8  b5bdb5c4
0000dc  ca      
0000dd  fdbeddce          DCB      253,190,221,206,170,161,176,"0x%x",161,177,"\r\n",0
0000e1  aaa1b030
0000e5  782578a1
0000e9  b10d0a00
0000ed  00                DCB      0
0000ee  00                DCB      0
0000ef  00                DCB      0

                          AREA ||i.SPI_Communication_SPI0Handler||, CODE, READONLY, ALIGN=1

                  SPI_Communication_SPI0Handler PROC
;;;159    #if defined(SC32f12xx) ||defined(SC32f10xx)
;;;160    void SPI_Communication_SPI0Handler(void)
000000  4770              BX       lr
;;;161    {
;;;162    #if (SPI_Mode_ == 0)
;;;163      if(SPI_GetFlagStatus(SPI0, SPI_Flag_SPIF))
;;;164      {
;;;165        
;;;166        SPI_ClearFlag(SPI0, SPI_Flag_SPIF);
;;;167        SPI0_Flag = SET;
;;;168      }
;;;169    #endif
;;;170    
;;;171    }
;;;172    
                          ENDP


                          AREA ||i.SPI_Communication_SPI1_Handler||, CODE, READONLY, ALIGN=2

                  SPI_Communication_SPI1_Handler PROC
;;;186    #elif defined(SC32f10xx)
;;;187    void SPI_Communication_SPI1_Handler(void)
000000  b510              PUSH     {r4,lr}
;;;188    {
;;;189     
;;;190    #if (SPI_Mode_ == 1)
;;;191      if(SPI_GetFlagStatus(SPI1, SPI_Flag_SPIF))
000002  4c07              LDR      r4,|L3.32|
000004  2101              MOVS     r1,#1
000006  4620              MOV      r0,r4
000008  f7fffffe          BL       SPI_GetFlagStatus
00000c  2800              CMP      r0,#0
00000e  d006              BEQ      |L3.30|
;;;192      {
;;;193        SPI_ClearFlag(SPI1, SPI_Flag_SPIF);
000010  2101              MOVS     r1,#1
000012  4620              MOV      r0,r4
000014  f7fffffe          BL       SPI_ClearFlag
;;;194        SPI1_Flag = SET;
000018  4902              LDR      r1,|L3.36|
00001a  2001              MOVS     r0,#1
00001c  7008              STRB     r0,[r1,#0]
                  |L3.30|
;;;195      }
;;;196    #endif
;;;197    }
00001e  bd10              POP      {r4,pc}
;;;198    
                          ENDP

                  |L3.32|
                          DCD      0x40021040
                  |L3.36|
                          DCD      ||.data||

                          AREA ||.constdata||, DATA, READONLY, ALIGN=0

                  Slave_SendData
000000  08091011          DCB      0x08,0x09,0x10,0x11
000004  12131415          DCB      0x12,0x13,0x14,0x15

                          AREA ||.data||, DATA, ALIGN=0

                  SPI1_Flag
000000  00                DCB      0x00

;*** Start embedded assembler ***

#line 1 "..\\Apps\\SPI_Communication.c"
	AREA ||.rev16_text||, CODE
	THUMB
	EXPORT |__asm___19_SPI_Communication_c_5133a6e1____REV16|
#line 463 "..\\CMSIS\\cmsis_armcc.h"
|__asm___19_SPI_Communication_c_5133a6e1____REV16| PROC
#line 464

 rev16 r0, r0
 bx lr
	ENDP
	AREA ||.revsh_text||, CODE
	THUMB
	EXPORT |__asm___19_SPI_Communication_c_5133a6e1____REVSH|
#line 478
|__asm___19_SPI_Communication_c_5133a6e1____REVSH| PROC
#line 479

 revsh r0, r0
 bx lr
	ENDP

;*** End   embedded assembler ***
