; generated by ARM C/C++ Compiler with , RVCT4.0 [Build 524] for uVision
; commandline ArmCC [--debug -c --asm --interleave -o.\output\main.o --depend=.\output\main.d --device=DARMSTM --apcs=interwork -O0 -I.\ -Id:\Keil\ARM\INC\ST\STM32F10x --omf_browse=.\output\main.crf main.c]
                          THUMB

                          AREA ||.text||, CODE, READONLY, ALIGN=2

                  Buffercmp PROC
;;;240    *******************************************************************************/
;;;241    TestStatus Buffercmp(u8* pBuffer1, u8* pBuffer2, u16 BufferLength)
000000  b510              PUSH     {r4,lr}
;;;242    {
000002  4603              MOV      r3,r0
;;;243      while(BufferLength--)
000004  e007              B        |L1.22|
                  |L1.6|
;;;244      {
;;;245        if(*pBuffer1 != *pBuffer2)
000006  7818              LDRB     r0,[r3,#0]
000008  780c              LDRB     r4,[r1,#0]
00000a  42a0              CMP      r0,r4
00000c  d001              BEQ      |L1.18|
;;;246        {
;;;247          return FAILED;
00000e  2000              MOVS     r0,#0
                  |L1.16|
;;;248        }
;;;249        
;;;250        pBuffer1++;
;;;251        pBuffer2++;
;;;252      }
;;;253    
;;;254      return PASSED;  
;;;255    }
000010  bd10              POP      {r4,pc}
                  |L1.18|
000012  1c5b              ADDS     r3,r3,#1              ;250
000014  1c49              ADDS     r1,r1,#1              ;251
                  |L1.22|
000016  0010              MOVS     r0,r2                 ;243
000018  f1a20401          SUB      r4,r2,#1              ;243
00001c  b2a2              UXTH     r2,r4                 ;243
00001e  d1f2              BNE      |L1.6|
000020  2001              MOVS     r0,#1                 ;254
000022  e7f5              B        |L1.16|
;;;256    
                          ENDP

                  GPIO_Configuration PROC
;;;175    *******************************************************************************/
;;;176    void GPIO_Configuration(void)
000024  b508              PUSH     {r3,lr}
;;;177    {
;;;178      GPIO_InitTypeDef GPIO_InitStructure;
;;;179    
;;;180      /* Configure I2C1 pins: SCL and SDA ----------------------------------------*/
;;;181      GPIO_InitStructure.GPIO_Pin =  GPIO_Pin_6 | GPIO_Pin_7;
000026  20c0              MOVS     r0,#0xc0
000028  f8ad0000          STRH     r0,[sp,#0]
;;;182      GPIO_InitStructure.GPIO_Speed = GPIO_Speed_50MHz;
00002c  2003              MOVS     r0,#3
00002e  f88d0002          STRB     r0,[sp,#2]
;;;183      GPIO_InitStructure.GPIO_Mode = GPIO_Mode_AF_OD;
000032  201c              MOVS     r0,#0x1c
000034  f88d0003          STRB     r0,[sp,#3]
;;;184      GPIO_Init(GPIOB, &GPIO_InitStructure);
000038  4669              MOV      r1,sp
00003a  4864              LDR      r0,|L1.460|
00003c  f7fffffe          BL       GPIO_Init
;;;185    
;;;186      /* Configure I2C2 pins: SCL and SDA ----------------------------------------*/
;;;187      GPIO_InitStructure.GPIO_Pin = GPIO_Pin_10 | GPIO_Pin_11;
000040  f44f6040          MOV      r0,#0xc00
000044  f8ad0000          STRH     r0,[sp,#0]
;;;188      GPIO_Init(GPIOB, &GPIO_InitStructure);
000048  4669              MOV      r1,sp
00004a  4860              LDR      r0,|L1.460|
00004c  f7fffffe          BL       GPIO_Init
;;;189      
;;;190      /* Configure PC.06, PC.07 as Output push-pull */
;;;191      GPIO_InitStructure.GPIO_Pin = GPIO_Pin_6 | GPIO_Pin_7;
000050  20c0              MOVS     r0,#0xc0
000052  f8ad0000          STRH     r0,[sp,#0]
;;;192      GPIO_InitStructure.GPIO_Mode = GPIO_Mode_Out_PP;
000056  2010              MOVS     r0,#0x10
000058  f88d0003          STRB     r0,[sp,#3]
;;;193      GPIO_InitStructure.GPIO_Speed = GPIO_Speed_50MHz;
00005c  2003              MOVS     r0,#3
00005e  f88d0002          STRB     r0,[sp,#2]
;;;194      GPIO_Init(GPIOC, &GPIO_InitStructure);
000062  4669              MOV      r1,sp
000064  485a              LDR      r0,|L1.464|
000066  f7fffffe          BL       GPIO_Init
;;;195    }
00006a  bd08              POP      {r3,pc}
;;;196    
                          ENDP

                  NVIC_Configuration PROC
;;;203    *******************************************************************************/
;;;204    void NVIC_Configuration(void)
00006c  b508              PUSH     {r3,lr}
;;;205    {
;;;206      NVIC_InitTypeDef NVIC_InitStructure;
;;;207      
;;;208    #ifdef  VECT_TAB_RAM  
;;;209      /* Set the Vector Table base location at 0x20000000 */ 
;;;210      NVIC_SetVectorTable(NVIC_VectTab_RAM, 0x0); 
;;;211    #else  /* VECT_TAB_FLASH  */
;;;212      /* Set the Vector Table base location at 0x08000000 */ 
;;;213      NVIC_SetVectorTable(NVIC_VectTab_FLASH, 0x0);   
00006e  2100              MOVS     r1,#0
000070  f04f6000          MOV      r0,#0x8000000
000074  f7fffffe          BL       NVIC_SetVectorTable
;;;214    #endif
;;;215    
;;;216      /* 1 bit for pre-emption priority, 3 bits for subpriority */
;;;217      NVIC_PriorityGroupConfig(NVIC_PriorityGroup_1);
000078  f44f60c0          MOV      r0,#0x600
00007c  f7fffffe          BL       NVIC_PriorityGroupConfig
;;;218       
;;;219      /* Configure and enable I2C1 interrupt -------------------------------------*/
;;;220      NVIC_InitStructure.NVIC_IRQChannel = I2C1_EV_IRQChannel;
000080  201f              MOVS     r0,#0x1f
000082  f88d0000          STRB     r0,[sp,#0]
;;;221      NVIC_InitStructure.NVIC_IRQChannelPreemptionPriority = 1;
000086  2001              MOVS     r0,#1
000088  f88d0001          STRB     r0,[sp,#1]
;;;222      NVIC_InitStructure.NVIC_IRQChannelSubPriority = 0;
00008c  2000              MOVS     r0,#0
00008e  f88d0002          STRB     r0,[sp,#2]
;;;223      NVIC_InitStructure.NVIC_IRQChannelCmd = ENABLE;
000092  2001              MOVS     r0,#1
000094  f88d0003          STRB     r0,[sp,#3]
;;;224      NVIC_Init(&NVIC_InitStructure);
000098  4668              MOV      r0,sp
00009a  f7fffffe          BL       NVIC_Init
;;;225    
;;;226      /* Configure and enable I2C2 interrupt -------------------------------------*/  
;;;227      NVIC_InitStructure.NVIC_IRQChannel = I2C2_EV_IRQChannel;
00009e  2021              MOVS     r0,#0x21
0000a0  f88d0000          STRB     r0,[sp,#0]
;;;228      NVIC_InitStructure.NVIC_IRQChannelPreemptionPriority = 0;
0000a4  2000              MOVS     r0,#0
0000a6  f88d0001          STRB     r0,[sp,#1]
;;;229      NVIC_Init(&NVIC_InitStructure);
0000aa  4668              MOV      r0,sp
0000ac  f7fffffe          BL       NVIC_Init
;;;230    }
0000b0  bd08              POP      {r3,pc}
;;;231    
                          ENDP

                  RCC_Configuration PROC
;;;114    *******************************************************************************/
;;;115    void RCC_Configuration(void)
0000b2  b510              PUSH     {r4,lr}
;;;116    {
;;;117      /* RCC system reset(for debug purpose) */
;;;118      RCC_DeInit();
0000b4  f7fffffe          BL       RCC_DeInit
;;;119    
;;;120      /* Enable HSE */
;;;121      RCC_HSEConfig(RCC_HSE_ON);
0000b8  f44f3080          MOV      r0,#0x10000
0000bc  f7fffffe          BL       RCC_HSEConfig
;;;122    
;;;123      /* Wait till HSE is ready */
;;;124      HSEStartUpStatus = RCC_WaitForHSEStartUp();
0000c0  f7fffffe          BL       RCC_WaitForHSEStartUp
0000c4  4943              LDR      r1,|L1.468|
0000c6  7008              STRB     r0,[r1,#0]
;;;125    
;;;126      if(HSEStartUpStatus == SUCCESS)
0000c8  4608              MOV      r0,r1
0000ca  7800              LDRB     r0,[r0,#0]  ; HSEStartUpStatus
0000cc  2801              CMP      r0,#1
0000ce  d126              BNE      |L1.286|
;;;127      {
;;;128        /* HCLK = SYSCLK */
;;;129        RCC_HCLKConfig(RCC_SYSCLK_Div1); 
0000d0  2000              MOVS     r0,#0
0000d2  f7fffffe          BL       RCC_HCLKConfig
;;;130      
;;;131        /* PCLK2 = HCLK */
;;;132        RCC_PCLK2Config(RCC_HCLK_Div1); 
0000d6  2000              MOVS     r0,#0
0000d8  f7fffffe          BL       RCC_PCLK2Config
;;;133    
;;;134        /* PCLK1 = HCLK/2 */
;;;135        RCC_PCLK1Config(RCC_HCLK_Div2);
0000dc  f44f6080          MOV      r0,#0x400
0000e0  f7fffffe          BL       RCC_PCLK1Config
;;;136     
;;;137        /* Flash 2 wait state */
;;;138        FLASH_SetLatency(FLASH_Latency_2);
0000e4  2002              MOVS     r0,#2
0000e6  f7fffffe          BL       FLASH_SetLatency
;;;139        /* Enable Prefetch Buffer */
;;;140        FLASH_PrefetchBufferCmd(FLASH_PrefetchBuffer_Enable);
0000ea  2010              MOVS     r0,#0x10
0000ec  f7fffffe          BL       FLASH_PrefetchBufferCmd
;;;141    
;;;142        /* PLLCLK = 8MHz * 9 = 72 MHz */
;;;143        RCC_PLLConfig(RCC_PLLSource_HSE_Div1, RCC_PLLMul_9);
0000f0  f44f11e0          MOV      r1,#0x1c0000
0000f4  f44f3080          MOV      r0,#0x10000
0000f8  f7fffffe          BL       RCC_PLLConfig
;;;144    
;;;145        /* Enable PLL */ 
;;;146        RCC_PLLCmd(ENABLE);
0000fc  2001              MOVS     r0,#1
0000fe  f7fffffe          BL       RCC_PLLCmd
;;;147    
;;;148        /* Wait till PLL is ready */
;;;149        while(RCC_GetFlagStatus(RCC_FLAG_PLLRDY) == RESET)
000102  bf00              NOP      
                  |L1.260|
000104  2039              MOVS     r0,#0x39
000106  f7fffffe          BL       RCC_GetFlagStatus
00010a  2800              CMP      r0,#0
00010c  d0fa              BEQ      |L1.260|
;;;150        {
;;;151        }
;;;152    
;;;153        /* Select PLL as system clock source */
;;;154        RCC_SYSCLKConfig(RCC_SYSCLKSource_PLLCLK);
00010e  2002              MOVS     r0,#2
000110  f7fffffe          BL       RCC_SYSCLKConfig
;;;155    
;;;156        /* Wait till PLL is used as system clock source */
;;;157        while(RCC_GetSYSCLKSource() != 0x08)
000114  bf00              NOP      
                  |L1.278|
000116  f7fffffe          BL       RCC_GetSYSCLKSource
00011a  2808              CMP      r0,#8
00011c  d1fb              BNE      |L1.278|
                  |L1.286|
;;;158        {
;;;159        }
;;;160      }
;;;161    
;;;162    /* Enable peripheral clocks --------------------------------------------------*/
;;;163      /* Enable I2C1 and I2C2 clock */
;;;164      RCC_APB1PeriphClockCmd(RCC_APB1Periph_I2C1 | RCC_APB1Periph_I2C2, ENABLE);
00011e  2101              MOVS     r1,#1
000120  f44f00c0          MOV      r0,#0x600000
000124  f7fffffe          BL       RCC_APB1PeriphClockCmd
;;;165      /* Enable GPIOB clock */
;;;166      RCC_APB2PeriphClockCmd(RCC_APB2Periph_GPIOB, ENABLE);
000128  2101              MOVS     r1,#1
00012a  2008              MOVS     r0,#8
00012c  f7fffffe          BL       RCC_APB2PeriphClockCmd
;;;167    }
000130  bd10              POP      {r4,pc}
;;;168    
                          ENDP

                  main PROC
;;;41     *******************************************************************************/
;;;42     int main(void)
000132  b510              PUSH     {r4,lr}
;;;43     {
;;;44     #ifdef DEBUG
;;;45       debug();
;;;46     #endif
;;;47     
;;;48       /* System clocks configuration ---------------------------------------------*/
;;;49       RCC_Configuration();
000134  f7fffffe          BL       RCC_Configuration
;;;50     
;;;51       /* NVIC configuration ------------------------------------------------------*/
;;;52       NVIC_Configuration();
000138  f7fffffe          BL       NVIC_Configuration
;;;53     
;;;54       /* GPIO configuration ------------------------------------------------------*/
;;;55       GPIO_Configuration();
00013c  f7fffffe          BL       GPIO_Configuration
;;;56     
;;;57       /* Enable I2C1 and I2C2 ----------------------------------------------------*/
;;;58       I2C_Cmd(I2C1, ENABLE);
000140  2101              MOVS     r1,#1
000142  4825              LDR      r0,|L1.472|
000144  f7fffffe          BL       I2C_Cmd
;;;59       I2C_Cmd(I2C2, ENABLE);
000148  2101              MOVS     r1,#1
00014a  4824              LDR      r0,|L1.476|
00014c  f7fffffe          BL       I2C_Cmd
;;;60     
;;;61       /* Enable I2C1 and I2C2 event and buffer interrupt */
;;;62       I2C_ITConfig(I2C1, I2C_IT_EVT | I2C_IT_BUF, ENABLE);
000150  2201              MOVS     r2,#1
000152  f44f61c0          MOV      r1,#0x600
000156  4820              LDR      r0,|L1.472|
000158  f7fffffe          BL       I2C_ITConfig
;;;63       I2C_ITConfig(I2C2, I2C_IT_EVT | I2C_IT_BUF, ENABLE);
00015c  2201              MOVS     r2,#1
00015e  f44f61c0          MOV      r1,#0x600
000162  481e              LDR      r0,|L1.476|
000164  f7fffffe          BL       I2C_ITConfig
;;;64     
;;;65       /* I2C1 configuration ------------------------------------------------------*/
;;;66       I2C_InitStructure.I2C_Mode = I2C_Mode_I2C;
000168  2000              MOVS     r0,#0
00016a  491d              LDR      r1,|L1.480|
00016c  8008              STRH     r0,[r1,#0]
;;;67       I2C_InitStructure.I2C_DutyCycle = I2C_DutyCycle_2;
00016e  f64b70ff          MOV      r0,#0xbfff
000172  8048              STRH     r0,[r1,#2]
;;;68       I2C_InitStructure.I2C_OwnAddress1 = I2C1_SLAVE_ADDRESS7;
000174  2030              MOVS     r0,#0x30
000176  8088              STRH     r0,[r1,#4]
;;;69       I2C_InitStructure.I2C_Ack = I2C_Ack_Enable;
000178  f44f6080          MOV      r0,#0x400
00017c  80c8              STRH     r0,[r1,#6]
;;;70       I2C_InitStructure.I2C_AcknowledgedAddress = I2C_AcknowledgedAddress_7bit;
00017e  0100              LSLS     r0,r0,#4
000180  8108              STRH     r0,[r1,#8]
;;;71       I2C_InitStructure.I2C_ClockSpeed = ClockSpeed;
000182  4818              LDR      r0,|L1.484|
000184  60c8              STR      r0,[r1,#0xc]  ; I2C_InitStructure
;;;72       I2C_Init(I2C1, &I2C_InitStructure);
000186  4814              LDR      r0,|L1.472|
000188  f7fffffe          BL       I2C_Init
;;;73       /* I2C2 configuration ------------------------------------------------------*/
;;;74       I2C_InitStructure.I2C_OwnAddress1 = I2C2_SLAVE_ADDRESS7;
00018c  2030              MOVS     r0,#0x30
00018e  4914              LDR      r1,|L1.480|
000190  8088              STRH     r0,[r1,#4]
;;;75       I2C_Init(I2C2, &I2C_InitStructure);
000192  4812              LDR      r0,|L1.476|
000194  f7fffffe          BL       I2C_Init
;;;76        
;;;77       /*----- Transmission Phase -----*/
;;;78       /* Send I2C1 START condition */
;;;79       I2C_GenerateSTART(I2C1, ENABLE);
000198  2101              MOVS     r1,#1
00019a  480f              LDR      r0,|L1.472|
00019c  f7fffffe          BL       I2C_GenerateSTART
;;;80     
;;;81       /* Send data */
;;;82       while(Rx_Idx < (BufferSize+1))
0001a0  bf00              NOP      
                  |L1.418|
0001a2  4811              LDR      r0,|L1.488|
0001a4  7800              LDRB     r0,[r0,#0]  ; Rx_Idx
0001a6  2805              CMP      r0,#5
0001a8  dbfb              BLT      |L1.418|
;;;83       {
;;;84       }
;;;85     
;;;86       /* Check the corectness of written data */
;;;87       
;;;88       if (Buffercmp(I2C1_Buffer_Tx, I2C2_Buffer_Rx, BufferSize) == FAILED)
0001aa  2204              MOVS     r2,#4
0001ac  490f              LDR      r1,|L1.492|
0001ae  4810              LDR      r0,|L1.496|
0001b0  f7fffffe          BL       Buffercmp
0001b4  b920              CBNZ     r0,|L1.448|
;;;89       {
;;;90          /* TransferStatus = FAILED, if the transmitted and received data 
;;;91          are different */ 
;;;92     	 /* Turn on led connected to PC.06 pin (LD1) */
;;;93         GPIO_SetBits(GPIOC, GPIO_Pin_6); 
0001b6  2140              MOVS     r1,#0x40
0001b8  4805              LDR      r0,|L1.464|
0001ba  f7fffffe          BL       GPIO_SetBits
0001be  e003              B        |L1.456|
                  |L1.448|
;;;94       }
;;;95       else
;;;96       {  
;;;97         /* TransferStatus = PASSED, if the transmitted and received data
;;;98          are equal */  
;;;99         /* Turn on led connected to PC.07 pin (LD2) */
;;;100        GPIO_SetBits(GPIOC, GPIO_Pin_7);
0001c0  2180              MOVS     r1,#0x80
0001c2  4803              LDR      r0,|L1.464|
0001c4  f7fffffe          BL       GPIO_SetBits
                  |L1.456|
;;;101      }
;;;102      
;;;103      while(1)				   
0001c8  bf00              NOP      
                  |L1.458|
0001ca  e7fe              B        |L1.458|
;;;104      {
;;;105      }
;;;106    }
;;;107    
                          ENDP

                  |L1.460|
                          DCD      0x40010c00
                  |L1.464|
                          DCD      0x40011000
                  |L1.468|
                          DCD      HSEStartUpStatus
                  |L1.472|
                          DCD      0x40005400
                  |L1.476|
                          DCD      0x40005800
                  |L1.480|
                          DCD      I2C_InitStructure
                  |L1.484|
                          DCD      0x00030d40
                  |L1.488|
                          DCD      Rx_Idx
                  |L1.492|
                          DCD      I2C2_Buffer_Rx
                  |L1.496|
                          DCD      I2C1_Buffer_Tx

                          AREA ||.bss||, DATA, NOINIT, ALIGN=2

                  I2C_InitStructure
                          %        16

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

                  I2C1_Buffer_Tx
000000  01020304          DCB      0x01,0x02,0x03,0x04
                  Tx_Idx
000004  00                DCB      0x00
                  Rx_Idx
000005  00                DCB      0x00
                  PEC_Value
000006  00                DCB      0x00
                  TransferStatus
000007  00                DCB      0x00
                  I2C2_Buffer_Rx
                          DCDU     0x00000000
                  HSEStartUpStatus
00000c  00                DCB      0x00

                  __ARM_use_no_argv EQU 0
