📄 stm32f10x_gpio.lst
字号:
\ 0000000C 0020 MOVS R0,#+0
260 }
261 return bitstatus;
\ 0000000E 00BD POP {PC} ;; return
262 }
263
264 /*******************************************************************************
265 * Function Name : GPIO_ReadInputData
266 * Description : Reads the specified GPIO input data port.
267 * Input : - GPIOx: where x can be (A..G) to select the GPIO peripheral.
268 * Output : None
269 * Return : GPIO input data port value.
270 *******************************************************************************/
\ In segment CODE, align 4, keep-with-next
271 u16 GPIO_ReadInputData(GPIO_TypeDef* GPIOx)
272 {
273 /* Check the parameters */
274 assert_param(IS_GPIO_ALL_PERIPH(GPIOx));
275
276 return ((u16)GPIOx->IDR);
\ GPIO_ReadInputData:
\ 00000000 8068 LDR R0,[R0, #+8]
\ 00000002 80B2 UXTH R0,R0
\ 00000004 7047 BX LR ;; return
277 }
278
279 /*******************************************************************************
280 * Function Name : GPIO_ReadOutputDataBit
281 * Description : Reads the specified output data port bit.
282 * Input : - GPIOx: where x can be (A..G) to select the GPIO peripheral.
283 * : - GPIO_Pin: specifies the port bit to read.
284 * This parameter can be GPIO_Pin_x where x can be (0..15).
285 * Output : None
286 * Return : The output port pin value.
287 *******************************************************************************/
\ In segment CODE, align 4, keep-with-next
288 u8 GPIO_ReadOutputDataBit(GPIO_TypeDef* GPIOx, u16 GPIO_Pin)
289 {
\ GPIO_ReadOutputDataBit:
\ 00000000 00B5 PUSH {LR}
290 u8 bitstatus = 0x00;
291
292 /* Check the parameters */
293 assert_param(IS_GPIO_ALL_PERIPH(GPIOx));
294 assert_param(IS_GET_GPIO_PIN(GPIO_Pin));
295
296 if ((GPIOx->ODR & GPIO_Pin) != (u32)Bit_RESET)
\ 00000002 C068 LDR R0,[R0, #+12]
\ 00000004 0842 TST R0,R1
\ 00000006 01D0 BEQ.N ??GPIO_ReadOutputDataBit_0
297 {
298 bitstatus = (u8)Bit_SET;
\ 00000008 0120 MOVS R0,#+1
\ 0000000A 00BD POP {PC}
299 }
300 else
301 {
302 bitstatus = (u8)Bit_RESET;
\ ??GPIO_ReadOutputDataBit_0:
\ 0000000C 0020 MOVS R0,#+0
303 }
304 return bitstatus;
\ 0000000E 00BD POP {PC} ;; return
305 }
306
307 /*******************************************************************************
308 * Function Name : GPIO_ReadOutputData
309 * Description : Reads the specified GPIO output data port.
310 * Input : - GPIOx: where x can be (A..G) to select the GPIO peripheral.
311 * Output : None
312 * Return : GPIO output data port value.
313 *******************************************************************************/
\ In segment CODE, align 4, keep-with-next
314 u16 GPIO_ReadOutputData(GPIO_TypeDef* GPIOx)
315 {
316 /* Check the parameters */
317 assert_param(IS_GPIO_ALL_PERIPH(GPIOx));
318
319 return ((u16)GPIOx->ODR);
\ GPIO_ReadOutputData:
\ 00000000 C068 LDR R0,[R0, #+12]
\ 00000002 80B2 UXTH R0,R0
\ 00000004 7047 BX LR ;; return
320 }
321
322 /*******************************************************************************
323 * Function Name : GPIO_SetBits
324 * Description : Sets the selected data port bits.
325 * Input : - GPIOx: where x can be (A..G) to select the GPIO peripheral.
326 * - GPIO_Pin: specifies the port bits to be written.
327 * This parameter can be any combination of GPIO_Pin_x where
328 * x can be (0..15).
329 * Output : None
330 * Return : None
331 *******************************************************************************/
\ In segment CODE, align 4, keep-with-next
332 void GPIO_SetBits(GPIO_TypeDef* GPIOx, u16 GPIO_Pin)
333 {
334 /* Check the parameters */
335 assert_param(IS_GPIO_ALL_PERIPH(GPIOx));
336 assert_param(IS_GPIO_PIN(GPIO_Pin));
337
338 GPIOx->BSRR = GPIO_Pin;
\ GPIO_SetBits:
\ 00000000 0161 STR R1,[R0, #+16]
339 }
\ 00000002 7047 BX LR ;; return
340
341 /*******************************************************************************
342 * Function Name : GPIO_ResetBits
343 * Description : Clears the selected data port bits.
344 * Input : - GPIOx: where x can be (A..G) to select the GPIO peripheral.
345 * - GPIO_Pin: specifies the port bits to be written.
346 * This parameter can be any combination of GPIO_Pin_x where
347 * x can be (0..15).
348 * Output : None
349 * Return : None
350 *******************************************************************************/
\ In segment CODE, align 4, keep-with-next
351 void GPIO_ResetBits(GPIO_TypeDef* GPIOx, u16 GPIO_Pin)
352 {
353 /* Check the parameters */
354 assert_param(IS_GPIO_ALL_PERIPH(GPIOx));
355 assert_param(IS_GPIO_PIN(GPIO_Pin));
356
357 GPIOx->BRR = GPIO_Pin;
\ GPIO_ResetBits:
\ 00000000 4161 STR R1,[R0, #+20]
358 }
\ 00000002 7047 BX LR ;; return
359
360 /*******************************************************************************
361 * Function Name : GPIO_WriteBit
362 * Description : Sets or clears the selected data port bit.
363 * Input : - GPIOx: where x can be (A..G) to select the GPIO peripheral.
364 * - GPIO_Pin: specifies the port bit to be written.
365 * This parameter can be one of GPIO_Pin_x where x can be (0..15).
366 * - BitVal: specifies the value to be written to the selected bit.
367 * This parameter can be one of the BitAction enum values:
368 * - Bit_RESET: to clear the port pin
369 * - Bit_SET: to set the port pin
370 * Output : None
371 * Return : None
372 *******************************************************************************/
\ In segment CODE, align 4, keep-with-next
373 void GPIO_WriteBit(GPIO_TypeDef* GPIOx, u16 GPIO_Pin, BitAction BitVal)
374 {
375 /* Check the parameters */
376 assert_param(IS_GPIO_ALL_PERIPH(GPIOx));
377 assert_param(IS_GET_GPIO_PIN(GPIO_Pin));
378 assert_param(IS_GPIO_BIT_ACTION(BitVal));
379
380 if (BitVal != Bit_RESET)
\ GPIO_WriteBit:
\ 00000000 002A CMP R2,#+0
\ 00000002 01D0 BEQ.N ??GPIO_WriteBit_0
381 {
382 GPIOx->BSRR = GPIO_Pin;
\ 00000004 0161 STR R1,[R0, #+16]
\ 00000006 7047 BX LR
383 }
384 else
385 {
386 GPIOx->BRR = GPIO_Pin;
\ ??GPIO_WriteBit_0:
\ 00000008 4161 STR R1,[R0, #+20]
387 }
388 }
\ 0000000A 7047 BX LR ;; return
389
390 /*******************************************************************************
391 * Function Name : GPIO_Write
392 * Description : Writes data to the specified GPIO data port.
393 * Input : - GPIOx: where x can be (A..G) to select the GPIO peripheral.
394 * - PortVal: specifies the value to be written to the port output
395 * data register.
396 * Output : None
397 * Return : None
398 *******************************************************************************/
\ In segment CODE, align 4, keep-with-next
399 void GPIO_Write(GPIO_TypeDef* GPIOx, u16 PortVal)
400 {
401 /* Check the parameters */
402 assert_param(IS_GPIO_ALL_PERIPH(GPIOx));
403
404 GPIOx->ODR = PortVal;
\ GPIO_Write:
\ 00000000 C160 STR R1,[R0, #+12]
405 }
\ 00000002 7047 BX LR ;; return
406
407 /*******************************************************************************
408 * Function Name : GPIO_PinLockConfig
409 * Description : Locks GPIO Pins configuration registers.
410 * Input : - GPIOx: where x can be (A..G) to select the GPIO peripheral.
411 * - GPIO_Pin: specifies the port bit to be written.
412 * This parameter can be any combination of GPIO_Pin_x where
413 * x can be (0..15).
414 * Output : None
415 * Return : None
416 *******************************************************************************/
\ In segment CODE, align 4, keep-with-next
417 void GPIO_PinLockConfig(GPIO_TypeDef* GPIOx, u16 GPIO_Pin)
418 {
419 u32 tmp = 0x00010000;
420
421 /* Check the parameters */
422 assert_param(IS_GPIO_ALL_PERIPH(GPIOx));
423 assert_param(IS_GPIO_PIN(GPIO_Pin));
424
425 tmp |= GPIO_Pin;
\ GPIO_PinLockConfig:
\ 00000000 51F48032 ORRS R2,R1,#0x10000
426 /* Set LCKK bit */
427 GPIOx->LCKR = tmp;
\ 00000004 8261 STR R2,[R0, #+24]
428 /* Reset LCKK bit */
429 GPIOx->LCKR = GPIO_Pin;
\ 00000006 8161 STR R1,[R0, #+24]
430 /* Set LCKK bit */
431 GPIOx->LCKR = tmp;
\ 00000008 8261 STR R2,[R0, #+24]
432 /* Read LCKK bit*/
433 tmp = GPIOx->LCKR;
\ 0000000A 8169 LDR R1,[R0, #+24]
434 /* Read LCKK bit*/
435 tmp = GPIOx->LCKR;
\ 0000000C 8069 LDR R0,[R0, #+24]
436 }
\ 0000000E 7047 BX LR ;; return
437
438 /*******************************************************************************
439 * Function Name : GPIO_EventOutputConfig
440 * Description : Selects the GPIO pin used as Event output.
441 * Input : - GPIO_PortSource: selects the GPIO port to be used as source
442 * for Event output.
443 * This parameter can be GPIO_PortSourceGPIOx where x can be
444 * (A..E).
445 * - GPIO_PinSource: specifies the pin for the Event output.
446 * This parameter can be GPIO_PinSourcex where x can be (0..15).
447 * Output : None
448 * Return : None
449 *******************************************************************************/
\ In segment CODE, align 4, keep-with-next
450 void GPIO_EventOutputConfig(u8 GPIO_PortSource, u8 GPIO_PinSource)
451 {
\ GPIO_EventOutputConfig:
\ 00000000 10B5 PUSH {R4,LR}
452 u32 tmpreg = 0x00;
453
454 /* Check the parameters */
455 assert_param(IS_GPIO_EVENTOUT_PORT_SOURCE(GPIO_PortSource));
456 assert_param(IS_GPIO_PIN_SOURCE(GPIO_PinSource));
457
458 tmpreg = AFIO->EVCR;
\ 00000002 044A LDR.N R2,??GPIO_EventOutputConfig_0 ;; 0x40010000
\ 00000004 1368 LDR R3,[R2, #+0]
459 /* Clear the PORT[6:4] and PIN[3:0] bits */
460 tmpreg &= EVCR_PORTPINCONFIG_MASK;
461 tmpreg |= (u32)GPIO_PortSource << 0x04;
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -