📄 stm32f10x_i2c.txt
字号:
|L21.176|
DCD 0x000f4240
|L21.180|
DCD 0x000186a0
AREA ||i.I2C_OwnAddress2Config||, CODE, READONLY, ALIGN=1
I2C_OwnAddress2Config PROC
;;;448 *******************************************************************************/
;;;449 void I2C_OwnAddress2Config(I2C_TypeDef* I2Cx, u8 Address)
000000 8982 LDRH r2,[r0,#0xc]
;;;450 {
;;;451 u16 tmpreg = 0;
;;;452
;;;453 /* Check the parameters */
;;;454 assert_param(IS_I2C_ALL_PERIPH(I2Cx));
;;;455
;;;456 /* Get the old register value */
;;;457 tmpreg = I2Cx->OAR2;
;;;458 /* Reset I2Cx Own address2 bit [7:1] */
;;;459 tmpreg &= OAR2_ADD2_Reset;
;;;460 /* Set I2Cx Own address2 */
;;;461 tmpreg |= (u16)(Address & (u16)0x00FE);
000002 f00101fe AND r1,r1,#0xfe
000006 f02202fe BIC r2,r2,#0xfe ;459
00000a 4311 ORRS r1,r1,r2
;;;462 /* Store the new register value */
;;;463 I2Cx->OAR2 = tmpreg;
00000c 8181 STRH r1,[r0,#0xc]
;;;464 }
00000e 4770 BX lr
;;;465
ENDP
AREA ||i.I2C_PECPositionConfig||, CODE, READONLY, ALIGN=1
I2C_PECPositionConfig PROC
;;;743 *******************************************************************************/
;;;744 void I2C_PECPositionConfig(I2C_TypeDef* I2Cx, u16 I2C_PECPosition)
000000 f5b16f00 CMP r1,#0x800
;;;745 {
;;;746 /* Check the parameters */
;;;747 assert_param(IS_I2C_ALL_PERIPH(I2Cx));
;;;748 assert_param(IS_I2C_PEC_POSITION(I2C_PECPosition));
;;;749
;;;750 if (I2C_PECPosition == I2C_PECPosition_Next)
;;;751 {
;;;752 /* Next byte in shift register is PEC */
;;;753 I2Cx->CR1 |= I2C_PECPosition_Next;
000004 8801 LDRH r1,[r0,#0]
000006 d102 BNE |L23.14|
000008 f4416100 ORR r1,r1,#0x800
00000c e001 B |L23.18|
|L23.14|
;;;754 }
;;;755 else
;;;756 {
;;;757 /* Current byte in shift register is PEC */
;;;758 I2Cx->CR1 &= I2C_PECPosition_Current;
00000e f4216100 BIC r1,r1,#0x800
|L23.18|
000012 8001 STRH r1,[r0,#0] ;753
;;;759 }
;;;760 }
000014 4770 BX lr
;;;761
ENDP
AREA ||i.I2C_ReadRegister||, CODE, READONLY, ALIGN=1
I2C_ReadRegister PROC
;;;637 *******************************************************************************/
;;;638 u16 I2C_ReadRegister(I2C_TypeDef* I2Cx, u8 I2C_Register)
000000 5a40 LDRH r0,[r0,r1]
;;;639 {
;;;640 /* Check the parameters */
;;;641 assert_param(IS_I2C_ALL_PERIPH(I2Cx));
;;;642 assert_param(IS_I2C_REGISTER(I2C_Register));
;;;643
;;;644 /* Return the selected register value */
;;;645 return (*(vu16 *)(*((vu32 *)&I2Cx) + I2C_Register));
;;;646 }
000002 4770 BX lr
;;;647
ENDP
AREA ||i.I2C_ReceiveData||, CODE, READONLY, ALIGN=1
I2C_ReceiveData PROC
;;;577 *******************************************************************************/
;;;578 u8 I2C_ReceiveData(I2C_TypeDef* I2Cx)
000000 8a00 LDRH r0,[r0,#0x10]
;;;579 {
;;;580 /* Check the parameters */
;;;581 assert_param(IS_I2C_ALL_PERIPH(I2Cx));
;;;582
;;;583 /* Return the data in the DR register */
;;;584 return (u8)I2Cx->DR;
000002 b2c0 UXTB r0,r0
;;;585 }
000004 4770 BX lr
;;;586
ENDP
AREA ||i.I2C_SMBusAlertConfig||, CODE, READONLY, ALIGN=1
I2C_SMBusAlertConfig PROC
;;;685 *******************************************************************************/
;;;686 void I2C_SMBusAlertConfig(I2C_TypeDef* I2Cx, u16 I2C_SMBusAlert)
000000 f5b15f00 CMP r1,#0x2000
;;;687 {
;;;688 /* Check the parameters */
;;;689 assert_param(IS_I2C_ALL_PERIPH(I2Cx));
;;;690 assert_param(IS_I2C_SMBUS_ALERT(I2C_SMBusAlert));
;;;691
;;;692 if (I2C_SMBusAlert == I2C_SMBusAlert_Low)
;;;693 {
;;;694 /* Drive the SMBusAlert pin Low */
;;;695 I2Cx->CR1 |= I2C_SMBusAlert_Low;
000004 8801 LDRH r1,[r0,#0]
000006 d102 BNE |L26.14|
000008 f4415100 ORR r1,r1,#0x2000
00000c e001 B |L26.18|
|L26.14|
;;;696 }
;;;697 else
;;;698 {
;;;699 /* Drive the SMBusAlert pin High */
;;;700 I2Cx->CR1 &= I2C_SMBusAlert_High;
00000e f4215100 BIC r1,r1,#0x2000
|L26.18|
000012 8001 STRH r1,[r0,#0] ;695
;;;701 }
;;;702 }
000014 4770 BX lr
;;;703
ENDP
AREA ||i.I2C_Send7bitAddress||, CODE, READONLY, ALIGN=1
I2C_Send7bitAddress PROC
;;;599 *******************************************************************************/
;;;600 void I2C_Send7bitAddress(I2C_TypeDef* I2Cx, u8 Address, u8 I2C_Direction)
000000 b112 CBZ r2,|L27.8|
;;;601 {
;;;602 /* Check the parameters */
;;;603 assert_param(IS_I2C_ALL_PERIPH(I2Cx));
;;;604 assert_param(IS_I2C_DIRECTION(I2C_Direction));
;;;605
;;;606 /* Test on the direction to set/reset the read/write bit */
;;;607 if (I2C_Direction != I2C_Direction_Transmitter)
;;;608 {
;;;609 /* Set the address bit0 for read */
;;;610 Address |= OAR1_ADD0_Set;
000002 f0410101 ORR r1,r1,#1
000006 e001 B |L27.12|
|L27.8|
;;;611 }
;;;612 else
;;;613 {
;;;614 /* Reset the address bit0 for write */
;;;615 Address &= OAR1_ADD0_Reset;
000008 f00101fe AND r1,r1,#0xfe
|L27.12|
;;;616 }
;;;617 /* Send the address */
;;;618 I2Cx->DR = Address;
00000c 8201 STRH r1,[r0,#0x10]
;;;619 }
00000e 4770 BX lr
;;;620
ENDP
AREA ||i.I2C_SendData||, CODE, READONLY, ALIGN=1
I2C_SendData PROC
;;;561 *******************************************************************************/
;;;562 void I2C_SendData(I2C_TypeDef* I2Cx, u8 Data)
000000 8201 STRH r1,[r0,#0x10]
;;;563 {
;;;564 /* Check the parameters */
;;;565 assert_param(IS_I2C_ALL_PERIPH(I2Cx));
;;;566
;;;567 /* Write in the DR register the data to be sent */
;;;568 I2Cx->DR = Data;
;;;569 }
000002 4770 BX lr
;;;570
ENDP
AREA ||i.I2C_SoftwareResetCmd||, CODE, READONLY, ALIGN=1
I2C_SoftwareResetCmd PROC
;;;656 *******************************************************************************/
;;;657 void I2C_SoftwareResetCmd(I2C_TypeDef* I2Cx, FunctionalState NewState)
000000 2900 CMP r1,#0
;;;658 {
;;;659 /* Check the parameters */
;;;660 assert_param(IS_I2C_ALL_PERIPH(I2Cx));
;;;661 assert_param(IS_FUNCTIONAL_STATE(NewState));
;;;662
;;;663 if (NewState != DISABLE)
;;;664 {
;;;665 /* Peripheral under reset */
;;;666 I2Cx->CR1 |= CR1_SWRST_Set;
000002 8801 LDRH r1,[r0,#0]
000004 d002 BEQ |L29.12|
000006 f4414100 ORR r1,r1,#0x8000
00000a e001 B |L29.16|
|L29.12|
;;;667 }
;;;668 else
;;;669 {
;;;670 /* Peripheral not under reset */
;;;671 I2Cx->CR1 &= CR1_SWRST_Reset;
00000c f3c1010e UBFX r1,r1,#0,#15
|L29.16|
000010 8001 STRH r1,[r0,#0] ;666
;;;672 }
;;;673 }
000012 4770 BX lr
;;;674
ENDP
AREA ||i.I2C_StretchClockCmd||, CODE, READONLY, ALIGN=1
I2C_StretchClockCmd PROC
;;;841 *******************************************************************************/
;;;842 void I2C_StretchClockCmd(I2C_TypeDef* I2Cx, FunctionalState NewState)
000000 2900 CMP r1,#0
;;;843 {
;;;844 /* Check the parameters */
;;;845 assert_param(IS_I2C_ALL_PERIPH(I2Cx));
;;;846 assert_param(IS_FUNCTIONAL_STATE(NewState));
;;;847
;;;848 if (NewState == DISABLE)
;;;849 {
;;;850 /* Enable the selected I2C Clock stretching */
;;;851 I2Cx->CR1 |= CR1_NOSTRETCH_Set;
000002 8801 LDRH r1,[r0,#0]
000004 d102 BNE |L30.12|
000006 f0410180 ORR r1,r1,#0x80
00000a e001 B |L30.16|
|L30.12|
;;;852 }
;;;853 else
;;;854 {
;;;855 /* Disable the selected I2C Clock stretching */
;;;856 I2Cx->CR1 &= CR1_NOSTRETCH_Reset;
00000c f0210180 BIC r1,r1,#0x80
|L30.16|
000010 8001 STRH r1,[r0,#0] ;851
;;;857 }
;;;858 }
000012 4770 BX lr
;;;859
ENDP
AREA ||i.I2C_StructInit||, CODE, READONLY, ALIGN=1
I2C_StructInit PROC
;;;256 *******************************************************************************/
;;;257 void I2C_StructInit(I2C_InitTypeDef* I2C_InitStruct)
000000 2100 MOVS r1,#0
;;;258 {
;;;259 /*---------------- Reset I2C init structure parameters values ----------------*/
;;;260 /* Initialize the I2C_Mode member */
;;;261 I2C_InitStruct->I2C_Mode = I2C_Mode_I2C;
000002 8001 STRH r1,[r0,#0]
;;;262
;;;263 /* Initialize the I2C_DutyCycle member */
;;;264 I2C_InitStruct->I2C_DutyCycle = I2C_DutyCycle_2;
000004 f64b72ff MOV r2,#0xbfff
000008 8042 STRH r2,[r0,#2]
;;;265
;;;266 /* Initialize the I2C_OwnAddress1 member */
;;;267 I2C_InitStruct->I2C_OwnAddress1 = 0;
00000a 8081 STRH r1,[r0,#4]
;;;268
;;;269 /* Initialize the I2C_Ack member */
;;;270 I2C_InitStruct->I2C_Ack = I2C_Ack_Disable;
00000c 80c1 STRH r1,[r0,#6]
;;;271
;;;272 /* Initialize the I2C_AcknowledgedAddress member */
;;;273 I2C_InitStruct->I2C_AcknowledgedAddress = I2C_AcknowledgedAddress_7bit;
00000e f44f4180 MOV r1,#0x4000
000012 8101 STRH r1,[r0,#8]
;;;274
;;;275 /* initialize the I2C_ClockSpeed member */
;;;276 I2C_InitStruct->I2C_ClockSpeed = 5000;
000014 f2413188 MOV r1,#0x1388
;;;277 }
000018 60c1 STR r1,[r0,#0xc]
00001a 4770 BX lr
;;;278
ENDP
AREA ||i.I2C_TransmitPEC||, CODE, READONLY, ALIGN=1
I2C_TransmitPEC PROC
;;;712 *******************************************************************************/
;;;713 void I2C_TransmitPEC(I2C_TypeDef* I2Cx, FunctionalState NewState)
000000 2900 CMP r1,#0
;;;714 {
;;;715 /* Check the parameters */
;;;716 assert_param(IS_I2C_ALL_PERIPH(I2Cx));
;;;717 assert_param(IS_FUNCTIONAL_STATE(NewState));
;;;718
;;;719 if (NewState != DISABLE)
;;;720 {
;;;721 /* Enable the selected I2C PEC transmission */
;;;722 I2Cx->CR1 |= CR1_PEC_Set;
000002 8801 LDRH r1,[r0,#0]
000004 d002 BEQ |L32.12|
000006 f4415180 ORR r1,r1,#0x1000
00000a e001 B |L32.16|
|L32.12|
;;;723 }
;;;724 else
;;;725 {
;;;726 /* Disable the selected I2C PEC transmission */
;;;727 I2Cx->CR1 &= CR1_PEC_Reset;
00000c f4215180 BIC r1,r1,#0x1000
|L32.16|
000010 8001 STRH r1,[r0,#0] ;722
;;;728 }
;;;729 }
000012 4770 BX lr
;;;730
ENDP
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -