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

📄 stm8s_adc2.ls

📁 STM8-触摸例程
💻 LS
📖 第 1 页 / 共 2 页
字号:
 972  00c8               L04:
 973  00c8 43            	cpl	a
 974  00c9 c45406        	and	a,21510
 976  00cc 2010          	jp	LC001
 977  00ce               L514:
 978                     ; 296       ADC2->TDRH |= (u8)((u8)0x01 << ((u8)ADC2_SchmittTriggerChannel - (u8)8));
 980  00ce a008          	sub	a,#8
 981  00d0 5f            	clrw	x
 982  00d1 97            	ld	xl,a
 983  00d2 a601          	ld	a,#1
 984  00d4 5d            	tnzw	x
 985  00d5 2704          	jreq	L44
 986  00d7               L64:
 987  00d7 48            	sll	a
 988  00d8 5a            	decw	x
 989  00d9 26fc          	jrne	L64
 990  00db               L44:
 991  00db ca5406        	or	a,21510
 992  00de               LC001:
 993  00de c75406        	ld	21510,a
 994  00e1               L304:
 995                     ; 300 }
 998  00e1 85            	popw	x
 999  00e2 81            	ret	
1056                     ; 322 void ADC2_ConversionConfig(ADC2_ConvMode_TypeDef ADC2_ConversionMode, ADC2_Channel_TypeDef ADC2_Channel, ADC2_Align_TypeDef ADC2_Align)
1056                     ; 323 {
1057                     	switch	.text
1058  00e3               _ADC2_ConversionConfig:
1060       00000000      OFST:	set	0
1063                     ; 326   assert_param(IS_ADC2_CONVERSIONMODE_OK(ADC2_ConversionMode));
1065                     ; 327   assert_param(IS_ADC2_CHANNEL_OK(ADC2_Channel));
1067                     ; 328   assert_param(IS_ADC2_ALIGN_OK(ADC2_Align));
1069                     ; 331   ADC2->CR2 &= (u8)(~ADC2_CR2_ALIGN);
1071  00e3 72175402      	bres	21506,#3
1072  00e7 89            	pushw	x
1073                     ; 333   ADC2->CR2 |= (u8)(ADC2_Align);
1075  00e8 c65402        	ld	a,21506
1076  00eb 1a05          	or	a,(OFST+5,sp)
1077  00ed c75402        	ld	21506,a
1078                     ; 335   if (ADC2_ConversionMode == ADC2_CONVERSIONMODE_CONTINUOUS)
1080  00f0 9e            	ld	a,xh
1081  00f1 4a            	dec	a
1082  00f2 2606          	jrne	L744
1083                     ; 338     ADC2->CR1 |= ADC2_CR1_CONT;
1085  00f4 72125401      	bset	21505,#1
1087  00f8 2004          	jra	L154
1088  00fa               L744:
1089                     ; 343     ADC2->CR1 &= (u8)(~ADC2_CR1_CONT);
1091  00fa 72135401      	bres	21505,#1
1092  00fe               L154:
1093                     ; 347   ADC2->CSR &= (u8)(~ADC2_CSR_CH);
1095  00fe c65400        	ld	a,21504
1096  0101 a4f0          	and	a,#240
1097  0103 c75400        	ld	21504,a
1098                     ; 349   ADC2->CSR |= (u8)(ADC2_Channel);
1100  0106 c65400        	ld	a,21504
1101  0109 1a02          	or	a,(OFST+2,sp)
1102  010b c75400        	ld	21504,a
1103                     ; 351 }
1106  010e 85            	popw	x
1107  010f 81            	ret	
1153                     ; 373 void ADC2_ExternalTriggerConfig(ADC2_ExtTrig_TypeDef ADC2_ExtTrigger, FunctionalState ADC2_ExtTrigState)
1153                     ; 374 {
1154                     	switch	.text
1155  0110               _ADC2_ExternalTriggerConfig:
1157  0110 89            	pushw	x
1158       00000000      OFST:	set	0
1161                     ; 377   assert_param(IS_ADC2_EXTTRIG_OK(ADC2_ExtTrigger));
1163                     ; 378   assert_param(IS_FUNCTIONALSTATE_OK(ADC2_ExtTrigState));
1165                     ; 381   ADC2->CR2 &= (u8)(~ADC2_CR2_EXTSEL);
1167  0111 c65402        	ld	a,21506
1168  0114 a4cf          	and	a,#207
1169  0116 c75402        	ld	21506,a
1170                     ; 383   if (ADC2_ExtTrigState != DISABLE)
1172  0119 9f            	ld	a,xl
1173  011a 4d            	tnz	a
1174  011b 2706          	jreq	L574
1175                     ; 386     ADC2->CR2 |= (u8)(ADC2_CR2_EXTTRIG);
1177  011d 721c5402      	bset	21506,#6
1179  0121 2004          	jra	L774
1180  0123               L574:
1181                     ; 391     ADC2->CR2 &= (u8)(~ADC2_CR2_EXTTRIG);
1183  0123 721d5402      	bres	21506,#6
1184  0127               L774:
1185                     ; 395   ADC2->CR2 |= (u8)(ADC2_ExtTrigger);
1187  0127 c65402        	ld	a,21506
1188  012a 1a01          	or	a,(OFST+1,sp)
1189  012c c75402        	ld	21506,a
1190                     ; 397 }
1193  012f 85            	popw	x
1194  0130 81            	ret	
1218                     ; 417 void ADC2_StartConversion(void)
1218                     ; 418 {
1219                     	switch	.text
1220  0131               _ADC2_StartConversion:
1224                     ; 419   ADC2->CR1 |= ADC2_CR1_ADON;
1226  0131 72105401      	bset	21505,#0
1227                     ; 420 }
1230  0135 81            	ret	
1274                     ; 438 u16 ADC2_GetConversionValue(void)
1274                     ; 439 {
1275                     	switch	.text
1276  0136               _ADC2_GetConversionValue:
1278  0136 5205          	subw	sp,#5
1279       00000005      OFST:	set	5
1282                     ; 441   u16 temph = 0;
1284                     ; 442   u8 templ = 0;
1286                     ; 444   if (ADC2->CR2 & ADC2_CR2_ALIGN) /* Right alignment */
1288  0138 720754020e    	btjf	21506,#3,L335
1289                     ; 447     templ = ADC2->DRL;
1291  013d c65405        	ld	a,21509
1292  0140 6b03          	ld	(OFST-2,sp),a
1293                     ; 449     temph = ADC2->DRH;
1295  0142 c65404        	ld	a,21508
1296  0145 97            	ld	xl,a
1297                     ; 451     temph = (u16)(templ | (u16)(temph << (u8)8));
1299  0146 7b03          	ld	a,(OFST-2,sp)
1300  0148 02            	rlwa	x,a
1302  0149 201a          	jra	L535
1303  014b               L335:
1304                     ; 456     temph = ADC2->DRH;
1306  014b c65404        	ld	a,21508
1307  014e 97            	ld	xl,a
1308                     ; 458     templ = ADC2->DRL;
1310  014f c65405        	ld	a,21509
1311  0152 6b03          	ld	(OFST-2,sp),a
1312                     ; 460     temph = (u16)((u16)(templ << (u8)6) | (u16)(temph << (u8)8));
1314  0154 4f            	clr	a
1315  0155 02            	rlwa	x,a
1316  0156 1f01          	ldw	(OFST-4,sp),x
1317  0158 7b03          	ld	a,(OFST-2,sp)
1318  015a 97            	ld	xl,a
1319  015b a640          	ld	a,#64
1320  015d 42            	mul	x,a
1321  015e 01            	rrwa	x,a
1322  015f 1a02          	or	a,(OFST-3,sp)
1323  0161 01            	rrwa	x,a
1324  0162 1a01          	or	a,(OFST-4,sp)
1325  0164 01            	rrwa	x,a
1326  0165               L535:
1327                     ; 463   return ((u16)temph);
1331  0165 5b05          	addw	sp,#5
1332  0167 81            	ret	
1376                     ; 483 FlagStatus ADC2_GetFlagStatus(void)
1376                     ; 484 {
1377                     	switch	.text
1378  0168               _ADC2_GetFlagStatus:
1382                     ; 486   return ((u8)(ADC2->CSR & ADC2_CSR_EOC));
1384  0168 c65400        	ld	a,21504
1385  016b a480          	and	a,#128
1388  016d 81            	ret	
1411                     ; 505 void ADC2_ClearFlag(void)
1411                     ; 506 {
1412                     	switch	.text
1413  016e               _ADC2_ClearFlag:
1417                     ; 507     ADC2->CSR &= (u8)(~ADC2_CSR_EOC);
1419  016e 721f5400      	bres	21504,#7
1420                     ; 508 }
1423  0172 81            	ret	
1447                     ; 526 ITStatus ADC2_GetITStatus(void)
1447                     ; 527 {
1448                     	switch	.text
1449  0173               _ADC2_GetITStatus:
1453                     ; 528   return ((u8)(ADC2->CSR & ADC2_CSR_EOC));
1455  0173 c65400        	ld	a,21504
1456  0176 a480          	and	a,#128
1459  0178 81            	ret	
1483                     ; 546 void ADC2_ClearITPendingBit(void)
1483                     ; 547 {
1484                     	switch	.text
1485  0179               _ADC2_ClearITPendingBit:
1489                     ; 548     ADC2->CSR &= (u8)(~ADC2_CSR_EOC);
1491  0179 721f5400      	bres	21504,#7
1492                     ; 549 }
1495  017d 81            	ret	
1508                     	xdef	_ADC2_ClearITPendingBit
1509                     	xdef	_ADC2_GetITStatus
1510                     	xdef	_ADC2_ClearFlag
1511                     	xdef	_ADC2_GetFlagStatus
1512                     	xdef	_ADC2_GetConversionValue
1513                     	xdef	_ADC2_StartConversion
1514                     	xdef	_ADC2_ExternalTriggerConfig
1515                     	xdef	_ADC2_ConversionConfig
1516                     	xdef	_ADC2_SchmittTriggerConfig
1517                     	xdef	_ADC2_PrescalerConfig
1518                     	xdef	_ADC2_ITConfig
1519                     	xdef	_ADC2_Cmd
1520                     	xdef	_ADC2_Init
1521                     	xdef	_ADC2_DeInit
1540                     	end

⌨️ 快捷键说明

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