⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 stm32f10x_usart.txt

📁 STM32手持式示波器源代码
💻 TXT
📖 第 1 页 / 共 4 页
字号:
000042  43b7              BICS     r7,r7,r6
000044  601f              STR      r7,[r3,#0]
                  |L11.70|
;;;398      }
;;;399    }
000046  bdf0              POP      {r4-r7,pc}
;;;400    
                          ENDP


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

                  USART_Init PROC
;;;164      */
;;;165    void USART_Init(USART_TypeDef* USARTx, USART_InitTypeDef* USART_InitStruct)
000000  e92d47f0          PUSH     {r4-r10,lr}
;;;166    {
000004  b086              SUB      sp,sp,#0x18
000006  4604              MOV      r4,r0
000008  460d              MOV      r5,r1
;;;167      uint32_t tmpreg = 0x00, apbclock = 0x00;
00000a  2600              MOVS     r6,#0
00000c  2700              MOVS     r7,#0
;;;168      uint32_t integerdivider = 0x00;
00000e  bf00              NOP      
;;;169      uint32_t fractionaldivider = 0x00;
000010  bf00              NOP      
;;;170      uint32_t usartxbase = 0;
000012  46b2              MOV      r10,r6
;;;171      RCC_ClocksTypeDef RCC_ClocksStatus;
;;;172      /* Check the parameters */
;;;173      assert_param(IS_USART_ALL_PERIPH(USARTx));
;;;174      assert_param(IS_USART_BAUDRATE(USART_InitStruct->USART_BaudRate));  
;;;175      assert_param(IS_USART_WORD_LENGTH(USART_InitStruct->USART_WordLength));
;;;176      assert_param(IS_USART_STOPBITS(USART_InitStruct->USART_StopBits));
;;;177      assert_param(IS_USART_PARITY(USART_InitStruct->USART_Parity));
;;;178      assert_param(IS_USART_MODE(USART_InitStruct->USART_Mode));
;;;179      assert_param(IS_USART_HARDWARE_FLOW_CONTROL(USART_InitStruct->USART_HardwareFlowControl));
;;;180      /* The hardware flow control is available only for USART1, USART2 and USART3 */
;;;181      if (USART_InitStruct->USART_HardwareFlowControl != USART_HardwareFlowControl_None)
000014  89a8              LDRH     r0,[r5,#0xc]
000016  b100              CBZ      r0,|L12.26|
;;;182      {
;;;183        assert_param(IS_USART_123_PERIPH(USARTx));
000018  bf00              NOP      
                  |L12.26|
;;;184      }
;;;185    
;;;186      usartxbase = (uint32_t)USARTx;
00001a  46a2              MOV      r10,r4
;;;187    
;;;188    /*---------------------------- USART CR2 Configuration -----------------------*/
;;;189      tmpreg = USARTx->CR2;
00001c  8a26              LDRH     r6,[r4,#0x10]
;;;190      /* Clear STOP[13:12] bits */
;;;191      tmpreg &= CR2_STOP_CLEAR_Mask;
00001e  f64c70ff          MOV      r0,#0xcfff
000022  4006              ANDS     r6,r6,r0
;;;192      /* Configure the USART Stop Bits, Clock, CPOL, CPHA and LastBit ------------*/
;;;193      /* Set STOP[13:12] bits according to USART_StopBits value */
;;;194      tmpreg |= (uint32_t)USART_InitStruct->USART_StopBits;
000024  88e8              LDRH     r0,[r5,#6]
000026  4306              ORRS     r6,r6,r0
;;;195      
;;;196      /* Write to USART CR2 */
;;;197      USARTx->CR2 = (uint16_t)tmpreg;
000028  8226              STRH     r6,[r4,#0x10]
;;;198    
;;;199    /*---------------------------- USART CR1 Configuration -----------------------*/
;;;200      tmpreg = USARTx->CR1;
00002a  89a6              LDRH     r6,[r4,#0xc]
;;;201      /* Clear M, PCE, PS, TE and RE bits */
;;;202      tmpreg &= CR1_CLEAR_Mask;
00002c  f64e10f3          MOV      r0,#0xe9f3
000030  4006              ANDS     r6,r6,r0
;;;203      /* Configure the USART Word Length, Parity and mode ----------------------- */
;;;204      /* Set the M bits according to USART_WordLength value */
;;;205      /* Set PCE and PS bits according to USART_Parity value */
;;;206      /* Set TE and RE bits according to USART_Mode value */
;;;207      tmpreg |= (uint32_t)USART_InitStruct->USART_WordLength | USART_InitStruct->USART_Parity |
000032  88a8              LDRH     r0,[r5,#4]
000034  8929              LDRH     r1,[r5,#8]
000036  4308              ORRS     r0,r0,r1
000038  8969              LDRH     r1,[r5,#0xa]
00003a  4308              ORRS     r0,r0,r1
00003c  4306              ORRS     r6,r6,r0
;;;208                USART_InitStruct->USART_Mode;
;;;209      /* Write to USART CR1 */
;;;210      USARTx->CR1 = (uint16_t)tmpreg;
00003e  81a6              STRH     r6,[r4,#0xc]
;;;211    
;;;212    /*---------------------------- USART CR3 Configuration -----------------------*/  
;;;213      tmpreg = USARTx->CR3;
000040  8aa6              LDRH     r6,[r4,#0x14]
;;;214      /* Clear CTSE and RTSE bits */
;;;215      tmpreg &= CR3_CLEAR_Mask;
000042  f64f40ff          MOV      r0,#0xfcff
000046  4006              ANDS     r6,r6,r0
;;;216      /* Configure the USART HFC -------------------------------------------------*/
;;;217      /* Set CTSE and RTSE bits according to USART_HardwareFlowControl value */
;;;218      tmpreg |= USART_InitStruct->USART_HardwareFlowControl;
000048  89a8              LDRH     r0,[r5,#0xc]
00004a  4306              ORRS     r6,r6,r0
;;;219      /* Write to USART CR3 */
;;;220      USARTx->CR3 = (uint16_t)tmpreg;
00004c  82a6              STRH     r6,[r4,#0x14]
;;;221    
;;;222    /*---------------------------- USART BRR Configuration -----------------------*/
;;;223      /* Configure the USART Baud Rate -------------------------------------------*/
;;;224      RCC_GetClocksFreq(&RCC_ClocksStatus);
00004e  a801              ADD      r0,sp,#4
000050  f7fffffe          BL       RCC_GetClocksFreq
;;;225      if (usartxbase == USART1_BASE)
000054  4654              MOV      r4,r10
000056  4811              LDR      r0,|L12.156|
000058  4582              CMP      r10,r0
00005a  d101              BNE      |L12.96|
;;;226      {
;;;227        apbclock = RCC_ClocksStatus.PCLK2_Frequency;
00005c  9f04              LDR      r7,[sp,#0x10]
00005e  e000              B        |L12.98|
                  |L12.96|
;;;228      }
;;;229      else
;;;230      {
;;;231        apbclock = RCC_ClocksStatus.PCLK1_Frequency;
000060  9f03              LDR      r7,[sp,#0xc]
                  |L12.98|
;;;232      }
;;;233      /* Determine the integer part */
;;;234      integerdivider = ((0x19 * apbclock) / (0x04 * (USART_InitStruct->USART_BaudRate)));
000062  eb0700c7          ADD      r0,r7,r7,LSL #3
000066  eb001007          ADD      r0,r0,r7,LSL #4
00006a  6829              LDR      r1,[r5,#0]
00006c  0089              LSLS     r1,r1,#2
00006e  fbb0f8f1          UDIV     r8,r0,r1
;;;235      tmpreg = (integerdivider / 0x64) << 0x04;
000072  2064              MOVS     r0,#0x64
000074  fbb8f0f0          UDIV     r0,r8,r0
000078  0106              LSLS     r6,r0,#4
;;;236      /* Determine the fractional part */
;;;237      fractionaldivider = integerdivider - (0x64 * (tmpreg >> 0x04));
00007a  0930              LSRS     r0,r6,#4
00007c  2164              MOVS     r1,#0x64
00007e  fb018910          MLS      r9,r1,r0,r8
;;;238      tmpreg |= ((((fractionaldivider * 0x10) + 0x32) / 0x64)) & ((uint8_t)0x0F);
000082  2132              MOVS     r1,#0x32
000084  eb011009          ADD      r0,r1,r9,LSL #4
000088  2164              MOVS     r1,#0x64
00008a  fbb0f0f1          UDIV     r0,r0,r1
00008e  f000000f          AND      r0,r0,#0xf
000092  4306              ORRS     r6,r6,r0
;;;239      /* Write to USART BRR */
;;;240      USARTx->BRR = (uint16_t)tmpreg;
000094  8126              STRH     r6,[r4,#8]
;;;241    }
000096  b006              ADD      sp,sp,#0x18
000098  e8bd87f0          POP      {r4-r10,pc}
;;;242    
                          ENDP

                  |L12.156|
                          DCD      0x40013800

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

                  USART_IrDACmd PROC
;;;745      */
;;;746    void USART_IrDACmd(USART_TypeDef* USARTx, FunctionalState NewState)
000000  b121              CBZ      r1,|L13.12|
;;;747    {
;;;748      /* Check the parameters */
;;;749      assert_param(IS_USART_ALL_PERIPH(USARTx));
;;;750      assert_param(IS_FUNCTIONAL_STATE(NewState));
;;;751        
;;;752      if (NewState != DISABLE)
;;;753      {
;;;754        /* Enable the IrDA mode by setting the IREN bit in the CR3 register */
;;;755        USARTx->CR3 |= CR3_IREN_Set;
000002  8a82              LDRH     r2,[r0,#0x14]
000004  f0420202          ORR      r2,r2,#2
000008  8282              STRH     r2,[r0,#0x14]
00000a  e004              B        |L13.22|
                  |L13.12|
;;;756      }
;;;757      else
;;;758      {
;;;759        /* Disable the IrDA mode by clearing the IREN bit in the CR3 register */
;;;760        USARTx->CR3 &= CR3_IREN_Reset;
00000c  8a82              LDRH     r2,[r0,#0x14]
00000e  f64f73fd          MOV      r3,#0xfffd
000012  401a              ANDS     r2,r2,r3
000014  8282              STRH     r2,[r0,#0x14]
                  |L13.22|
;;;761      }
;;;762    }
000016  4770              BX       lr
;;;763    
                          ENDP


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

                  USART_IrDAConfig PROC
;;;726      */
;;;727    void USART_IrDAConfig(USART_TypeDef* USARTx, uint16_t USART_IrDAMode)
000000  8a82              LDRH     r2,[r0,#0x14]
;;;728    {
;;;729      /* Check the parameters */
;;;730      assert_param(IS_USART_ALL_PERIPH(USARTx));
;;;731      assert_param(IS_USART_IRDA_MODE(USART_IrDAMode));
;;;732        
;;;733      USARTx->CR3 &= CR3_IRLP_Mask;
000002  f64f73fb          MOV      r3,#0xfffb
000006  401a              ANDS     r2,r2,r3
000008  8282              STRH     r2,[r0,#0x14]
;;;734      USARTx->CR3 |= USART_IrDAMode;
00000a  8a82              LDRH     r2,[r0,#0x14]
00000c  430a              ORRS     r2,r2,r1
00000e  8282              STRH     r2,[r0,#0x14]
;;;735    }
000010  4770              BX       lr
;;;736    
                          ENDP


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

                  USART_LINBreakDetectLengthConfig PROC
;;;513      */
;;;514    void USART_LINBreakDetectLengthConfig(USART_TypeDef* USARTx, uint16_t USART_LINBreakDetectLength)
000000  8a02              LDRH     r2,[r0,#0x10]
;;;515    {
;;;516      /* Check the parameters */
;;;517      assert_param(IS_USART_ALL_PERIPH(USARTx));
;;;518      assert_param(IS_USART_LIN_BREAK_DETECT_LENGTH(USART_LINBreakDetectLength));
;;;519      
;;;520      USARTx->CR2 &= CR2_LBDL_Mask;
000002  f64f73df          MOV      r3,#0xffdf
000006  401a              ANDS     r2,r2,r3
000008  8202              STRH     r2,[r0,#0x10]
;;;521      USARTx->CR2 |= USART_LINBreakDetectLength;  
00000a  8a02              LDRH     r2,[r0,#0x10]
00000c  430a              ORRS     r2,r2,r1
00000e  8202              STRH     r2,[r0,#0x10]
;;;522    }
000010  4770              BX       lr
;;;523    
                          ENDP


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

                  USART_LINCmd PROC
;;;532      */
;;;533    void USART_LINCmd(USART_TypeDef* USARTx, FunctionalState NewState)
000000  b121              CBZ      r1,|L16.12|
;;;534    {
;;;535      /* Check the parameters */
;;;536      assert_param(IS_USART_ALL_PERIPH(USARTx));
;;;537      assert_param(IS_FUNCTIONAL_STATE(NewState));
;;;538      
;;;539      if (NewState != DISABLE)
;;;540      {
;;;541        /* Enable the LIN mode by setting the LINEN bit in the CR2 register */
;;;542        USARTx->CR2 |= CR2_LINEN_Set;
000002  8a02              LDRH     r2,[r0,#0x10]
000004  f4424280          ORR      r2,r2,#0x4000
000008  8202              STRH     r2,[r0,#0x10]
00000a  e004              B        |L16.22|
                  |L16.12|
;;;543      }
;;;544      else
;;;545      {
;;;546        /* Disable the LIN mode by clearing the LINEN bit in the CR2 register */
;;;547        USARTx->CR2 &= CR2_LINEN_Reset;
00000c  8a02              LDRH     r2,[r0,#0x10]
00000e  f64b73ff          MOV      r3,#0xbfff
000012  401a              ANDS     r2,r2,r3
000014  8202              STRH     r2,[r0,#0x10]
                  |L16.22|
;;;548      }
;;;549    }
000016  4770              BX       lr
;;;550    
                          ENDP


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

                  USART_ReceiveData PROC
;;;575      */
;;;576    uint16_t USART_ReceiveData(USART_TypeDef* USARTx)
000000  4601              MOV      r1,r0

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -