; generated by Component: ARM Compiler 5.05 update 2 (build 169) Tool: ArmCC [4d0f38]
; commandline ArmCC [--c99 --list --split_sections --debug -c --asm --interleave -o..\..\..\..\build\bootloader\mico-fire_f429\obj_rvmdk\platform_i2c.o --asm_dir=..\..\..\..\Build\Bootloader\MICO-Fire_F429\list_RVMDK\ --list_dir=..\..\..\..\Build\Bootloader\MICO-Fire_F429\list_RVMDK\ --depend=..\..\..\..\build\bootloader\mico-fire_f429\obj_rvmdk\platform_i2c.d --cpu=Cortex-M4.fp --apcs=interwork --diag_suppress=9931,1,1293 -I..\..\..\..\Bootloader -I..\..\..\..\Board\fire_F429 -I..\..\..\..\include -I..\..\..\..\libraries\utilities -I..\..\..\..\libraries\utilities\json_c -I..\..\..\..\MICO\core -I..\..\..\..\MICO\security -I..\..\..\..\MICO\system -I..\..\..\..\MICO\system\command_console -I..\..\..\..\Platform\include -I..\..\..\..\Platform\Cortex-M4 -I..\..\..\..\Platform\Cortex-M4\CMSIS -I..\..\..\..\Platform\MCU\STM32F4xx\peripherals -I..\..\..\..\Platform\MCU\STM32F4xx\peripherals\Libraries\STM32F4xx_StdPeriph_Driver\inc -I..\..\..\..\Platform\MCU\STM32F4xx\peripherals\Libraries -I..\..\..\..\Platform\MCU\STM32F4xx\wlan_bus_driver -I..\..\..\..\Platform\Drivers\spi_flash -I..\..\..\..\Platform\Drivers -IG:\GIT_OSC\F429_OV2640_MICO_SDRAM\Projects\STM32F429\bootloader\RVMDK\RTE -ID:\work\keil5\ARM\PACK\Keil\STM32F4xx_DFP\2.5.0\Drivers\CMSIS\Device\ST\STM32F4xx\Include -ID:\work\keil5\ARM\CMSIS\Include -ID:\work\keil5\ARM\PACK\Keil\STM32F4xx_DFP\2.5.0 -D__MICROLIB -D__UVISION_VERSION=516 -DSTM32F429xx -DUSE_STDPERIPH_DRIVER -DBOOTLOADER -DNO_MICO_RTOS -DHSE_VALUE=25000000 --omf_browse=..\..\..\..\build\bootloader\mico-fire_f429\obj_rvmdk\platform_i2c.crf ..\..\..\..\Platform\MCU\STM32F4xx\peripherals\platform_i2c.c]
                          THUMB

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

                  i2c_address_device PROC
;;;644    
;;;645    static OSStatus i2c_address_device( const platform_i2c_t* i2c, const platform_i2c_config_t* config, int retries, uint8_t direction )
000000  e92d47f0          PUSH     {r4-r10,lr}
;;;646    {
;;;647      OSStatus err = kTimeoutErr;
;;;648      retries = 1000;
000004  f44f757a          MOV      r5,#0x3e8
;;;649    
;;;650      /* Some chips( authentication and security related chips ) has to be addressed several times before they acknowledge their address */
;;;651      for ( ; retries != 0 ; --retries )
;;;652      {
;;;653        /* Generate a start condition and address a i2c in write mode */
;;;654        I2C_GenerateSTART( i2c->port, ENABLE );
;;;655    
;;;656        /* wait till start condition is generated and the bus becomes free */
;;;657        err = i2c_wait_for_event( i2c->port, I2C_EVENT_MASTER_MODE_SELECT, I2C_FLAG_CHECK_TIMEOUT );
000008  f8df904c          LDR      r9,|L1.88|
00000c  461f              MOV      r7,r3                 ;646
00000e  460e              MOV      r6,r1                 ;646
000010  4604              MOV      r4,r0                 ;646
000012  46a8              MOV      r8,r5                 ;648
                  |L1.20|
000014  2101              MOVS     r1,#1                 ;654
000016  6820              LDR      r0,[r4,#0]            ;654
000018  f7fffffe          BL       I2C_GenerateSTART
00001c  4642              MOV      r2,r8
00001e  4649              MOV      r1,r9
000020  6820              LDR      r0,[r4,#0]
000022  f7fffffe          BL       i2c_wait_for_event
;;;658        if(err != kNoErr)
000026  b988              CBNZ     r0,|L1.76|
;;;659          continue;
;;;660    
;;;661        if ( config->address_width == I2C_ADDRESS_WIDTH_7BIT )
000028  78b1              LDRB     r1,[r6,#2]
00002a  b979              CBNZ     r1,|L1.76|
;;;662        {
;;;663          /* send the address and R/W bit set to write of the requested i2c, wait for an acknowledge */
;;;664          I2C_Send7bitAddress( i2c->port, (uint8_t) ( config->address << 1 ), direction );
00002c  7830              LDRB     r0,[r6,#0]
00002e  463a              MOV      r2,r7
000030  0640              LSLS     r0,r0,#25
000032  0e01              LSRS     r1,r0,#24
000034  6820              LDR      r0,[r4,#0]
000036  f7fffffe          BL       I2C_Send7bitAddress
;;;665    
;;;666          /* wait till address gets sent and the direction bit is sent and */
;;;667          err = i2c_wait_for_event( i2c->port, (direction == I2C_Direction_Transmitter) ? I2C_EVENT_MASTER_TRANSMITTER_MODE_SELECTED : I2C_EVENT_MASTER_RECEIVER_MODE_SELECTED, I2C_FLAG_CHECK_LONG_TIMEOUT );
00003a  b15f              CBZ      r7,|L1.84|
00003c  4906              LDR      r1,|L1.88|
00003e  1c49              ADDS     r1,r1,#1
                  |L1.64|
000040  4642              MOV      r2,r8
000042  6820              LDR      r0,[r4,#0]
000044  f7fffffe          BL       i2c_wait_for_event
;;;668          if ( err == kNoErr )
000048  2800              CMP      r0,#0
00004a  d001              BEQ      |L1.80|
                  |L1.76|
00004c  1e6d              SUBS     r5,r5,#1
00004e  d1e1              BNE      |L1.20|
                  |L1.80|
;;;669            goto exit;
;;;670        }
;;;671        /* TODO: Support other address widths */
;;;672      }
;;;673    
;;;674    exit:
;;;675        return err;
;;;676    }
000050  e8bd87f0          POP      {r4-r10,pc}
                  |L1.84|
000054  4901              LDR      r1,|L1.92|
000056  e7f3              B        |L1.64|
;;;677    
                          ENDP

                  |L1.88|
                          DCD      0x00030001
                  |L1.92|
                          DCD      0x00070082

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

                  i2c_rx_no_dma PROC
;;;699    
;;;700    static OSStatus i2c_rx_no_dma( const platform_i2c_t* i2c, const platform_i2c_config_t* config, platform_i2c_message_t* message )
000000  e92d41f0          PUSH     {r4-r8,lr}
;;;701    {
000004  4616              MOV      r6,r2
000006  4605              MOV      r5,r0
;;;702        OSStatus          err = kNoErr;
;;;703        int               i;
;;;704    
;;;705        err = i2c_address_device( i2c, config, message->retries, I2C_Direction_Receiver );
000008  8992              LDRH     r2,[r2,#0xc]
00000a  2301              MOVS     r3,#1
00000c  f7fffffe          BL       i2c_address_device
000010  0007              MOVS     r7,r0
;;;706        require_noerr(err, exit);
000012  d128              BNE      |L2.102|
;;;707    
;;;708        /* Disable acknowledgement if this is a single byte transmission */
;;;709        if ( message->rx_length == 1 )
000014  8970              LDRH     r0,[r6,#0xa]
000016  2801              CMP      r0,#1
000018  6828              LDR      r0,[r5,#0]
00001a  d004              BEQ      |L2.38|
;;;710        {
;;;711            I2C_AcknowledgeConfig( i2c->port, DISABLE );
;;;712        }
;;;713        else
;;;714        {
;;;715            I2C_AcknowledgeConfig( i2c->port, ENABLE );
00001c  2101              MOVS     r1,#1
                  |L2.30|
00001e  f7fffffe          BL       I2C_AcknowledgeConfig
;;;716        }
;;;717    
;;;718        /* Start reading bytes */
;;;719        for ( i = 0; i < message->rx_length; i++ )
000022  2400              MOVS     r4,#0
000024  e01c              B        |L2.96|
                  |L2.38|
000026  2100              MOVS     r1,#0                 ;711
000028  e7f9              B        |L2.30|
                  |L2.42|
;;;720        {
;;;721            /* wait till something is in the i2c data register */
;;;722            err = i2c_wait_for_event( i2c->port, I2C_EVENT_MASTER_BYTE_RECEIVED, I2C_FLAG_CHECK_TIMEOUT );
00002a  f44f727a          MOV      r2,#0x3e8
00002e  490f              LDR      r1,|L2.108|
000030  6828              LDR      r0,[r5,#0]
000032  f7fffffe          BL       i2c_wait_for_event
000036  0007              MOVS     r7,r0
;;;723            require_noerr(err, exit);
000038  d115              BNE      |L2.102|
;;;724    
;;;725            /* get data */
;;;726            ((uint8_t*)message->rx_buffer)[ i ] = I2C_ReceiveData( i2c->port );
00003a  6828              LDR      r0,[r5,#0]
00003c  f7fffffe          BL       I2C_ReceiveData
000040  6871              LDR      r1,[r6,#4]
000042  5508              STRB     r0,[r1,r4]
;;;727    
;;;728            /* Check if last byte has been received */
;;;729            if ( i == ( message->rx_length - 1 ) )
000044  8970              LDRH     r0,[r6,#0xa]
000046  1e41              SUBS     r1,r0,#1
000048  42a1              CMP      r1,r4
00004a  d008              BEQ      |L2.94|
00004c  1e80              SUBS     r0,r0,#2
;;;730            {
;;;731            }
;;;732            else /* Check if the second last byte has been received */
;;;733            if ( i == ( message->rx_length - 2 ) )
00004e  42a0              CMP      r0,r4
000050  6828              LDR      r0,[r5,#0]
000052  d101              BNE      |L2.88|
;;;734            {
;;;735                /* setup NACK for the last byte to be received */
;;;736                I2C_AcknowledgeConfig( i2c->port, DISABLE );
000054  2100              MOVS     r1,#0
000056  e000              B        |L2.90|
                  |L2.88|
;;;737            }
;;;738            else
;;;739            {
;;;740                /* setup an acknowledgement beforehand for every byte that is to be received */
;;;741                I2C_AcknowledgeConfig( i2c->port, ENABLE );
000058  2101              MOVS     r1,#1
                  |L2.90|
00005a  f7fffffe          BL       I2C_AcknowledgeConfig
                  |L2.94|
00005e  1c64              ADDS     r4,r4,#1
                  |L2.96|
000060  8970              LDRH     r0,[r6,#0xa]          ;719
000062  42a0              CMP      r0,r4                 ;719
000064  dce1              BGT      |L2.42|
                  |L2.102|
;;;742            }
;;;743        }
;;;744    
;;;745    exit:
;;;746        return err;
000066  4638              MOV      r0,r7
;;;747    }
000068  e8bd81f0          POP      {r4-r8,pc}
;;;748    
                          ENDP

                  |L2.108|
                          DCD      0x00030040

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

                  i2c_transfer_message_no_dma PROC
;;;504    
;;;505    static OSStatus i2c_transfer_message_no_dma( const platform_i2c_t* i2c, const platform_i2c_config_t* config, platform_i2c_message_t* message )
000000  e92d47f0          PUSH     {r4-r10,lr}
;;;506    {
000004  4606              MOV      r6,r0
000006  6810              LDR      r0,[r2,#0]
000008  4615              MOV      r5,r2
00000a  460f              MOV      r7,r1
00000c  b1e0              CBZ      r0,|L3.72|
00000e  89aa              LDRH     r2,[r5,#0xc]
000010  2300              MOVS     r3,#0
000012  4630              MOV      r0,r6
000014  f7fffffe          BL       i2c_address_device
;;;507        OSStatus err;
;;;508    
;;;509        if ( message->tx_buffer != NULL )
;;;510        {
;;;511            err = i2c_tx_no_dma( i2c, config, message );
000018  b9a0              CBNZ     r0,|L3.68|
00001a  2400              MOVS     r4,#0
00001c  f44f787a          MOV      r8,#0x3e8
000020  f8df9044          LDR      r9,|L3.104|
000024  e00b              B        |L3.62|
                  |L3.38|
000026  6828              LDR      r0,[r5,#0]
000028  5d01              LDRB     r1,[r0,r4]
00002a  6830              LDR      r0,[r6,#0]
00002c  f7fffffe          BL       I2C_SendData
000030  4642              MOV      r2,r8
000032  4649              MOV      r1,r9
000034  6830              LDR      r0,[r6,#0]
000036  f7fffffe          BL       i2c_wait_for_event
00003a  b918              CBNZ     r0,|L3.68|
00003c  1c64              ADDS     r4,r4,#1
                  |L3.62|
00003e  8929              LDRH     r1,[r5,#8]
000040  42a1              CMP      r1,r4
000042  dcf0              BGT      |L3.38|
                  |L3.68|
000044  0004              MOVS     r4,r0
;;;512            if ( err != kNoErr )
000046  d107              BNE      |L3.88|
                  |L3.72|
;;;513            {
;;;514                goto exit;
;;;515            }
;;;516        }
;;;517    
;;;518        if ( message->rx_buffer != NULL )
000048  6868              LDR      r0,[r5,#4]
00004a  b128              CBZ      r0,|L3.88|
;;;519        {
;;;520            err = i2c_rx_no_dma( i2c, config, message );
00004c  462a              MOV      r2,r5
00004e  4639              MOV      r1,r7
000050  4630              MOV      r0,r6
000052  f7fffffe          BL       i2c_rx_no_dma
000056  4604              MOV      r4,r0
                  |L3.88|
;;;521        }
;;;522    
;;;523    exit:
;;;524        /* generate a stop condition */
;;;525        I2C_GenerateSTOP( i2c->port, ENABLE );
000058  2101              MOVS     r1,#1
00005a  6830              LDR      r0,[r6,#0]
00005c  f7fffffe          BL       I2C_GenerateSTOP
;;;526    
;;;527        return err;
000060  4620              MOV      r0,r4
;;;528    }
000062  e8bd87f0          POP      {r4-r10,pc}
;;;529    
                          ENDP

000066  0000              DCW      0x0000
                  |L3.104|
                          DCD      0x00070084

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

                  i2c_wait_for_event PROC
;;;631    
;;;632    static OSStatus i2c_wait_for_event( I2C_TypeDef* i2c, uint32_t event_id, uint32_t number_of_waits )
000000  b570              PUSH     {r4-r6,lr}
;;;633    {
000002  4614              MOV      r4,r2
000004  460d              MOV      r5,r1
000006  4606              MOV      r6,r0
;;;634      while ( I2C_CheckEvent( i2c, event_id ) != SUCCESS )
;;;635      {
;;;636        number_of_waits--;
;;;637        if ( number_of_waits == 0 )
;;;638        {
;;;639          return kTimeoutErr;
000008  e001              B        |L4.14|
                  |L4.10|
00000a  1e64              SUBS     r4,r4,#1
00000c  d007              BEQ      |L4.30|
                  |L4.14|
00000e  4629              MOV      r1,r5                 ;634
000010  4630              MOV      r0,r6                 ;634
000012  f7fffffe          BL       I2C_CheckEvent
000016  2801              CMP      r0,#1                 ;634
000018  d1f7              BNE      |L4.10|
;;;640        }
;;;641      }
;;;642      return kNoErr;
00001a  2000              MOVS     r0,#0
;;;643    }
00001c  bd70              POP      {r4-r6,pc}
                  |L4.30|
00001e  4801              LDR      r0,|L4.36|
000020  bd70              POP      {r4-r6,pc}
;;;644    
                          ENDP

000022  0000              DCW      0x0000
                  |L4.36|
                          DCD      0xffffe5be

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

                  platform_i2c_deinit PROC
;;;606    
;;;607    OSStatus platform_i2c_deinit( const platform_i2c_t* i2c, const platform_i2c_config_t* config )
000000  b570              PUSH     {r4-r6,lr}
;;;608    {
000002  4605              MOV      r5,r0
;;;609      UNUSED_PARAMETER( config );
;;;610      OSStatus err = kNoErr;
000004  2400              MOVS     r4,#0
;;;611      
;;;612      platform_mcu_powersave_disable();
000006  f7fffffe          BL       platform_mcu_powersave_disable
;;;613    
;;;614      require_action_quiet( i2c != NULL, exit, err = kParamErr);
00000a  b13d              CBZ      r5,|L5.28|
;;;615    
;;;616      /* Disable I2C peripheral clocks */
;;;617      RCC_APB1PeriphClockCmd( i2c->peripheral_clock_reg, DISABLE );
00000c  2100              MOVS     r1,#0
00000e  68e8              LDR      r0,[r5,#0xc]
000010  f7fffffe          BL       RCC_APB1PeriphClockCmd
                  |L5.20|
;;;618      
;;;619      /* Disable DMA */
;;;620    #ifdef I2C_USE_DMA
;;;621      DMA_DeInit( i2c->rx_dma_stream );
;;;622      DMA_DeInit( i2c->tx_dma_stream );
;;;623      RCC_AHB1PeriphClockCmd( i2c->tx_dma_peripheral_clock, DISABLE );
;;;624    #endif
;;;625      
;;;626    exit:
;;;627      platform_mcu_powersave_enable();
000014  f7fffffe          BL       platform_mcu_powersave_enable
;;;628      return err;
000018  4620              MOV      r0,r4
;;;629    }
00001a  bd70              POP      {r4-r6,pc}
                  |L5.28|
00001c  4c00              LDR      r4,|L5.32|
00001e  e7f9              B        |L5.20|
;;;630    
                          ENDP

                  |L5.32|
                          DCD      0xffffe5cf

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

                  platform_i2c_init PROC
;;;82     
;;;83     OSStatus platform_i2c_init( const platform_i2c_t* i2c, const platform_i2c_config_t* config )
000000  b5f0              PUSH     {r4-r7,lr}
;;;84     {
000002  b085              SUB      sp,sp,#0x14
000004  460f              MOV      r7,r1
000006  4604              MOV      r4,r0
;;;85       OSStatus err = kNoErr;
;;;86       I2C_InitTypeDef  I2C_InitStructure;
;;;87     
;;;88       platform_mcu_powersave_disable( );
000008  f7fffffe          BL       platform_mcu_powersave_disable
;;;89       require_action_quiet( i2c != NULL, exit, err = kParamErr);
00000c  b14c              CBZ      r4,|L6.34|
;;;90       
;;;91       // Init I2C GPIO clocks
;;;92       RCC_APB1PeriphClockCmd( i2c->peripheral_clock_reg, ENABLE );
00000e  2101              MOVS     r1,#1
000010  68e0              LDR      r0,[r4,#0xc]
000012  f7fffffe          BL       RCC_APB1PeriphClockCmd
;;;93       err = platform_gpio_enable_clock( i2c->pin_scl );
000016  6860              LDR      r0,[r4,#4]
000018  f7fffffe          BL       platform_gpio_enable_clock
00001c  0005              MOVS     r5,r0
;;;94       require_noerr(err, exit);
00001e  d14d              BNE      |L6.188|
000020  e001              B        |L6.38|
                  |L6.34|
000022  4d29              LDR      r5,|L6.200|
000024  e04a              B        |L6.188|
                  |L6.38|
;;;95       err = platform_gpio_enable_clock( i2c->pin_sda );
000026  68a0              LDR      r0,[r4,#8]
000028  f7fffffe          BL       platform_gpio_enable_clock
00002c  0005              MOVS     r5,r0
;;;96       require_noerr(err, exit);
00002e  d145              BNE      |L6.188|
;;;97       RCC_APB2PeriphClockCmd( RCC_APB2Periph_SYSCFG, ENABLE );
000030  2101              MOVS     r1,#1
000032  038e              LSLS     r6,r1,#14
000034  4630              MOV      r0,r6
000036  f7fffffe          BL       RCC_APB2PeriphClockCmd
;;;98       
;;;99       // Reset the I2C clock
;;;100      RCC_APB1PeriphResetCmd( i2c->peripheral_clock_reg, ENABLE );
00003a  2101              MOVS     r1,#1
00003c  68e0              LDR      r0,[r4,#0xc]
00003e  f7fffffe          BL       RCC_APB1PeriphResetCmd
;;;101      RCC_APB1PeriphResetCmd( i2c->peripheral_clock_reg, DISABLE );
000042  2100              MOVS     r1,#0
000044  68e0              LDR      r0,[r4,#0xc]
000046  f7fffffe          BL       RCC_APB1PeriphResetCmd
;;;102      
;;;103      // GPIO Configuration
;;;104      platform_gpio_set_alternate_function( i2c->pin_scl->port, i2c->pin_scl->pin_number, GPIO_OType_OD, GPIO_PuPd_NOPULL, i2c->gpio_af_scl );
00004a  f8940030          LDRB     r0,[r4,#0x30]
00004e  9000              STR      r0,[sp,#0]
000050  6860              LDR      r0,[r4,#4]
000052  2300              MOVS     r3,#0
000054  2201              MOVS     r2,#1
000056  7901              LDRB     r1,[r0,#4]
000058  6800              LDR      r0,[r0,#0]
00005a  f7fffffe          BL       platform_gpio_set_alternate_function
;;;105      platform_gpio_set_alternate_function( i2c->pin_sda->port, i2c->pin_sda->pin_number, GPIO_OType_OD, GPIO_PuPd_NOPULL, i2c->gpio_af_sda );
00005e  f8940031          LDRB     r0,[r4,#0x31]
000062  9000              STR      r0,[sp,#0]
000064  68a0              LDR      r0,[r4,#8]
000066  2300              MOVS     r3,#0
000068  2201              MOVS     r2,#1
00006a  7901              LDRB     r1,[r0,#4]
00006c  6800              LDR      r0,[r0,#0]
00006e  f7fffffe          BL       platform_gpio_set_alternate_function
;;;106      
;;;107    #ifdef I2C_USE_DMA
;;;108      // Enable the DMA clock
;;;109      RCC_AHB1PeriphClockCmd( i2c_mapping[device->port].tx_dma_peripheral_clock, ENABLE );
;;;110      
;;;111      // Configure the DMA streams for operation with the CP
;;;112      i2c_dma_init.DMA_Channel            = i2c_mapping[device->port].tx_dma_channel;
;;;113      i2c_dma_init.DMA_PeripheralBaseAddr = (uint32_t)&i2c_mapping[device->port].i2c->DR;
;;;114      i2c_dma_init.DMA_PeripheralInc      = DMA_PeripheralInc_Disable;
;;;115      i2c_dma_init.DMA_MemoryInc          = DMA_MemoryInc_Enable;
;;;116      i2c_dma_init.DMA_PeripheralDataSize = DMA_PeripheralDataSize_Byte;
;;;117      i2c_dma_init.DMA_MemoryDataSize     = DMA_MemoryDataSize_Byte;
;;;118      i2c_dma_init.DMA_Mode               = DMA_Mode_Normal;
;;;119      i2c_dma_init.DMA_Priority           = DMA_Priority_VeryHigh;
;;;120      //dma_init.DMA_FIFOMode           = DMA_FIFOMode_Enable;
;;;121      //dma_init.DMA_FIFOThreshold      = DMA_FIFOThreshold_Full;
;;;122      i2c_dma_init.DMA_MemoryBurst        = DMA_MemoryBurst_Single;
;;;123      i2c_dma_init.DMA_PeripheralBurst    = DMA_PeripheralBurst_Single;
;;;124      i2c_dma_init.DMA_Memory0BaseAddr    = (uint32_t) 0;               // This parameter will be configured during communication
;;;125      i2c_dma_init.DMA_DIR                = DMA_DIR_MemoryToPeripheral; // This parameter will be configured during communication
;;;126      i2c_dma_init.DMA_BufferSize         = 0xFFFF;                     // This parameter will be configured during communication
;;;127      
;;;128      DMA_DeInit( i2c_mapping[device->port].rx_dma_stream );
;;;129      DMA_DeInit( i2c_mapping[device->port].tx_dma_stream );
;;;130      
;;;131      // Clear any pending flags, disable, and clear the Tx DMA channel
;;;132      //DMA_ClearFlag( i2c_mapping[device->port].tx_dma_stream, CP_TX_DMA_FLAG_FEIF | CP_TX_DMA_FLAG_DMEIF | CP_TX_DMA_FLAG_TEIF | CP_TX_DMA_FLAG_HTIF | CP_TX_DMA_FLAG_TCIF );
;;;133      DMA_Cmd( i2c_mapping[device->port].tx_dma_stream, DISABLE );
;;;134      DMA_Cmd( i2c_mapping[device->port].rx_dma_stream, DISABLE );
;;;135      
;;;136      // Clear any pending flags, disable, and clear the Rx DMA channel
;;;137      //DMA_ClearFlag( i2c_mapping[device->port].rx_dma_stream, CP_RX_DMA_FLAG_FEIF | CP_RX_DMA_FLAG_DMEIF | CP_RX_DMA_FLAG_TEIF | CP_RX_DMA_FLAG_HTIF | CP_RX_DMA_FLAG_TCIF );
;;;138    #endif
;;;139      
;;;140      // Initialize the InitStruct for the CP
;;;141      I2C_InitStructure.I2C_Mode                = I2C_Mode_I2C;
000072  2000              MOVS     r0,#0
000074  f8ad0008          STRH     r0,[sp,#8]
;;;142      I2C_InitStructure.I2C_DutyCycle           = I2C_DutyCycle_2;
000078  f64b70ff          MOV      r0,#0xbfff
00007c  f8ad000a          STRH     r0,[sp,#0xa]
;;;143      I2C_InitStructure.I2C_OwnAddress1         = 0xA0;
000080  20a0              MOVS     r0,#0xa0
000082  f8ad000c          STRH     r0,[sp,#0xc]
;;;144      I2C_InitStructure.I2C_Ack                 = I2C_Ack_Enable;
000086  1130              ASRS     r0,r6,#4
000088  f8ad000e          STRH     r0,[sp,#0xe]
;;;145      I2C_InitStructure.I2C_AcknowledgedAddress = I2C_AcknowledgedAddress_7bit;
00008c  f8ad6010          STRH     r6,[sp,#0x10]
;;;146      
;;;147      if ( config->speed_mode == I2C_LOW_SPEED_MODE )
000090  7938              LDRB     r0,[r7,#4]
000092  b120              CBZ      r0,|L6.158|
;;;148      {
;;;149        I2C_InitStructure.I2C_ClockSpeed = 10000;
;;;150      }
;;;151      else if ( config->speed_mode == I2C_STANDARD_SPEED_MODE )
000094  2801              CMP      r0,#1
000096  d005              BEQ      |L6.164|
;;;152      {
;;;153        I2C_InitStructure.I2C_ClockSpeed = 100000;
;;;154      }
;;;155      else if ( config->speed_mode == I2C_HIGH_SPEED_MODE )
000098  2802              CMP      r0,#2
00009a  d005              BEQ      |L6.168|
00009c  e006              B        |L6.172|
                  |L6.158|
00009e  f2427010          MOV      r0,#0x2710            ;149
0000a2  e002              B        |L6.170|
                  |L6.164|
0000a4  4809              LDR      r0,|L6.204|
0000a6  e000              B        |L6.170|
                  |L6.168|
;;;156      {
;;;157        I2C_InitStructure.I2C_ClockSpeed = 400000;
0000a8  4809              LDR      r0,|L6.208|
                  |L6.170|
0000aa  9001              STR      r0,[sp,#4]
                  |L6.172|
;;;158      }
;;;159      
;;;160      // Enable and initialize the I2C bus
;;;161      I2C_Cmd( i2c->port, ENABLE );
0000ac  2101              MOVS     r1,#1
0000ae  6820              LDR      r0,[r4,#0]
0000b0  f7fffffe          BL       I2C_Cmd
;;;162      I2C_Init( i2c->port, &I2C_InitStructure );
0000b4  a901              ADD      r1,sp,#4
0000b6  6820              LDR      r0,[r4,#0]
0000b8  f7fffffe          BL       I2C_Init
                  |L6.188|
;;;163      
;;;164    #ifdef I2C_USE_DMA
;;;165      // Enable DMA on the I2C bus
;;;166      I2C_DMACmd( i2c->port, ENABLE );
;;;167    #endif
;;;168    
;;;169    exit:
;;;170      platform_mcu_powersave_enable( );
0000bc  f7fffffe          BL       platform_mcu_powersave_enable
;;;171      return err;
;;;172    }
0000c0  b005              ADD      sp,sp,#0x14
0000c2  4628              MOV      r0,r5                 ;171
0000c4  bdf0              POP      {r4-r7,pc}
;;;173    
                          ENDP

0000c6  0000              DCW      0x0000
                  |L6.200|
                          DCD      0xffffe5cf
                  |L6.204|
                          DCD      0x000186a0
                  |L6.208|
                          DCD      0x00061a80

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

                  platform_i2c_init_combined_message PROC
;;;564    
;;;565    OSStatus platform_i2c_init_combined_message( platform_i2c_message_t* message, const void* tx_buffer, void* rx_buffer, uint16_t tx_buffer_length, uint16_t rx_buffer_length, uint16_t retries )
000000  b5f0              PUSH     {r4-r7,lr}
;;;566    {
;;;567      OSStatus err = kNoErr;
000002  2400              MOVS     r4,#0
000004  e9dd6705          LDRD     r6,r7,[sp,#0x14]      ;566
000008  b168              CBZ      r0,|L7.38|
;;;568    
;;;569      require_action_quiet( ( message != NULL ) && ( tx_buffer != NULL ) && ( tx_buffer_length != 0 ) && ( rx_buffer != NULL ) && ( rx_buffer_length != 0 ), exit, err = kParamErr);
00000a  b161              CBZ      r1,|L7.38|
00000c  b15b              CBZ      r3,|L7.38|
00000e  b152              CBZ      r2,|L7.38|
000010  b14e              CBZ      r6,|L7.38|
;;;570    
;;;571      memset(message, 0x00, sizeof(platform_i2c_message_t));
000012  2500              MOVS     r5,#0
000014  6085              STR      r5,[r0,#8]
000016  60c5              STR      r5,[r0,#0xc]
000018  e9c01200          STRD     r1,r2,[r0,#0]
;;;572      message->rx_buffer = rx_buffer;
;;;573      message->tx_buffer = tx_buffer;
;;;574      message->retries = retries;
00001c  8187              STRH     r7,[r0,#0xc]
;;;575      message->tx_length = tx_buffer_length;
00001e  8103              STRH     r3,[r0,#8]
;;;576      message->rx_length = rx_buffer_length;
000020  8146              STRH     r6,[r0,#0xa]
                  |L7.34|
;;;577      
;;;578    exit:
;;;579      return err;
000022  4620              MOV      r0,r4
;;;580    }
000024  bdf0              POP      {r4-r7,pc}
                  |L7.38|
000026  4c01              LDR      r4,|L7.44|
000028  e7fb              B        |L7.34|
;;;581    
                          ENDP

00002a  0000              DCW      0x0000
                  |L7.44|
                          DCD      0xffffe5cf

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

                  platform_i2c_init_rx_message PROC
;;;549    
;;;550    OSStatus platform_i2c_init_rx_message( platform_i2c_message_t* message, void* rx_buffer, uint16_t rx_buffer_length, uint16_t retries )
000000  b530              PUSH     {r4,r5,lr}
;;;551    {
;;;552      OSStatus err = kNoErr;
000002  2500              MOVS     r5,#0
000004  b150              CBZ      r0,|L8.28|
;;;553    
;;;554      require_action_quiet( ( message != NULL ) && ( rx_buffer != NULL ) && ( rx_buffer_length != 0 ), exit, err = kParamErr);
000006  b149              CBZ      r1,|L8.28|
000008  b142              CBZ      r2,|L8.28|
;;;555    
;;;556      memset(message, 0x00, sizeof(platform_i2c_message_t));
00000a  2400              MOVS     r4,#0
00000c  6004              STR      r4,[r0,#0]
00000e  6084              STR      r4,[r0,#8]
;;;557      message->rx_buffer = rx_buffer;
;;;558      message->retries = retries;
000010  60c4              STR      r4,[r0,#0xc]
000012  6041              STR      r1,[r0,#4]
000014  8183              STRH     r3,[r0,#0xc]
;;;559      message->rx_length = rx_buffer_length;
000016  8142              STRH     r2,[r0,#0xa]
                  |L8.24|
;;;560      
;;;561    exit:
;;;562      return err;
000018  4628              MOV      r0,r5
;;;563    }
00001a  bd30              POP      {r4,r5,pc}
                  |L8.28|
00001c  4d00              LDR      r5,|L8.32|
00001e  e7fb              B        |L8.24|
;;;564    
                          ENDP

                  |L8.32|
                          DCD      0xffffe5cf

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

                  platform_i2c_init_tx_message PROC
;;;534    
;;;535    OSStatus platform_i2c_init_tx_message( platform_i2c_message_t* message, const void* tx_buffer, uint16_t tx_buffer_length, uint16_t retries )
000000  b530              PUSH     {r4,r5,lr}
;;;536    {
;;;537      OSStatus err = kNoErr;
000002  2500              MOVS     r5,#0
000004  b150              CBZ      r0,|L9.28|
;;;538    
;;;539      require_action_quiet( ( message != NULL ) && ( tx_buffer != NULL ) && ( tx_buffer_length != 0 ), exit, err = kParamErr);
000006  b149              CBZ      r1,|L9.28|
000008  b142              CBZ      r2,|L9.28|
;;;540    
;;;541      memset(message, 0x00, sizeof(platform_i2c_message_t));
00000a  2400              MOVS     r4,#0
00000c  6044              STR      r4,[r0,#4]
00000e  6084              STR      r4,[r0,#8]
;;;542      message->tx_buffer = tx_buffer;
;;;543      message->retries = retries;
000010  60c4              STR      r4,[r0,#0xc]
000012  6001              STR      r1,[r0,#0]
000014  8183              STRH     r3,[r0,#0xc]
;;;544      message->tx_length = tx_buffer_length;
000016  8102              STRH     r2,[r0,#8]
                  |L9.24|
;;;545      
;;;546    exit:  
;;;547      return err;
000018  4628              MOV      r0,r5
;;;548    }
00001a  bd30              POP      {r4,r5,pc}
                  |L9.28|
00001c  4d00              LDR      r5,|L9.32|
00001e  e7fb              B        |L9.24|
;;;549    
                          ENDP

                  |L9.32|
                          DCD      0xffffe5cf

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

                  platform_i2c_probe_device PROC
;;;195    
;;;196    bool platform_i2c_probe_device( const platform_i2c_t* i2c, const platform_i2c_config_t* config, int retries )
000000  b570              PUSH     {r4-r6,lr}
;;;197    {
000002  4614              MOV      r4,r2
000004  460e              MOV      r6,r1
000006  4605              MOV      r5,r0
;;;198      OSStatus err = kNoErr;
;;;199    
;;;200      platform_mcu_powersave_disable();
000008  f7fffffe          BL       platform_mcu_powersave_disable
;;;201    
;;;202      require_action_quiet( i2c != NULL, exit, err = kParamErr);
00000c  b17d              CBZ      r5,|L10.46|
;;;203    
;;;204      err = i2c_address_device( i2c, config, retries, I2C_Direction_Transmitter );
00000e  2300              MOVS     r3,#0
000010  4622              MOV      r2,r4
000012  4631              MOV      r1,r6
000014  4628              MOV      r0,r5
000016  f7fffffe          BL       i2c_address_device
00001a  4604              MOV      r4,r0
;;;205    
;;;206      I2C_GenerateSTOP( i2c->port, ENABLE );
00001c  2101              MOVS     r1,#1
00001e  6828              LDR      r0,[r5,#0]
000020  f7fffffe          BL       I2C_GenerateSTOP
                  |L10.36|
;;;207    
;;;208    exit:
;;;209      platform_mcu_powersave_enable();
000024  f7fffffe          BL       platform_mcu_powersave_enable
;;;210      return ( err == kNoErr) ? true : false;
000028  b11c              CBZ      r4,|L10.50|
00002a  2000              MOVS     r0,#0
;;;211    }
00002c  bd70              POP      {r4-r6,pc}
                  |L10.46|
00002e  4c02              LDR      r4,|L10.56|
000030  e7f8              B        |L10.36|
                  |L10.50|
000032  2001              MOVS     r0,#1                 ;210
000034  bd70              POP      {r4-r6,pc}
;;;212    
                          ENDP

000036  0000              DCW      0x0000
                  |L10.56|
                          DCD      0xffffe5cf

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

                  platform_i2c_transfer PROC
;;;581    
;;;582    OSStatus platform_i2c_transfer( const platform_i2c_t* i2c, const platform_i2c_config_t* config, platform_i2c_message_t* messages, uint16_t number_of_messages )
000000  e92d47f0          PUSH     {r4-r10,lr}
;;;583    {
;;;584      OSStatus err = kNoErr;
000004  2500              MOVS     r5,#0
000006  461e              MOV      r6,r3                 ;583
000008  4617              MOV      r7,r2                 ;583
00000a  4689              MOV      r9,r1                 ;583
00000c  4680              MOV      r8,r0                 ;583
;;;585      int      i   = 0;
00000e  462c              MOV      r4,r5
;;;586    
;;;587      platform_mcu_powersave_disable();
000010  f7fffffe          BL       platform_mcu_powersave_disable
;;;588      
;;;589      require_action_quiet( i2c != NULL, exit, err = kParamErr);
000014  f1b80f00          CMP      r8,#0
000018  d10a              BNE      |L11.48|
00001a  4d09              LDR      r5,|L11.64|
00001c  e00a              B        |L11.52|
                  |L11.30|
;;;590      
;;;591      for( i=0; i < number_of_messages; i++ )
;;;592      {
;;;593    #ifdef I2C_USE_DMA
;;;594        err = i2c_dma_transfer(device, &messages[i]);
;;;595        require_noerr(err, exit);
;;;596    #else  
;;;597        err = i2c_transfer_message_no_dma( i2c, config, &messages[ i ] );
00001e  eb071204          ADD      r2,r7,r4,LSL #4
000022  4649              MOV      r1,r9
000024  4640              MOV      r0,r8
000026  f7fffffe          BL       i2c_transfer_message_no_dma
00002a  0005              MOVS     r5,r0
;;;598        require_noerr(err, exit);
00002c  d102              BNE      |L11.52|
00002e  1c64              ADDS     r4,r4,#1
                  |L11.48|
000030  42b4              CMP      r4,r6                 ;591
000032  dbf4              BLT      |L11.30|
                  |L11.52|
;;;599    #endif
;;;600      }
;;;601    
;;;602     exit: 
;;;603      platform_mcu_powersave_enable();
000034  f7fffffe          BL       platform_mcu_powersave_enable
;;;604      return err;
000038  4628              MOV      r0,r5
;;;605    }
00003a  e8bd87f0          POP      {r4-r10,pc}
;;;606    
                          ENDP

00003e  0000              DCW      0x0000
                  |L11.64|
                          DCD      0xffffe5cf

;*** Start embedded assembler ***

#line 1 "..\\..\\..\\..\\Platform\\MCU\\STM32F4xx\\peripherals\\platform_i2c.c"
	AREA ||.rev16_text||, CODE
	THUMB
	EXPORT |__asm___14_platform_i2c_c_c319ce16____REV16|
#line 114 "..\\..\\..\\..\\Platform\\Cortex-M4\\CMSIS\\core_cmInstr.h"
|__asm___14_platform_i2c_c_c319ce16____REV16| PROC
#line 115

 rev16 r0, r0
 bx lr
	ENDP
	AREA ||.revsh_text||, CODE
	THUMB
	EXPORT |__asm___14_platform_i2c_c_c319ce16____REVSH|
#line 128
|__asm___14_platform_i2c_c_c319ce16____REVSH| PROC
#line 129

 revsh r0, r0
 bx lr
	ENDP

;*** End   embedded assembler ***
