📄 stm32f10x_usart.lst
字号:
409 * - NewState: new state of the USART mode.
410 * This parameter can be: ENABLE or DISABLE.
411 * Output : None
412 * Return : None
413 *******************************************************************************/
414 void USART_ReceiverWakeUpCmd(USART_TypeDef* USARTx, FunctionalState NewState)
415 {
416 /* Check the parameters */
417 assert(IS_FUNCTIONAL_STATE(NewState));
418
419 if (NewState != DISABLE)
420 {
421 /* Enable the mute mode USART by setting the RWU bit in the CR1 register */
422 USARTx->CR1 |= CR1_RWU_Set;
423 }
424 else
425 {
426 /* Disable the mute mode USART by clearing the RWU bit in the CR1 register */
427 USARTx->CR1 &= CR1_RWU_Reset;
428 }
429 }
430
431 /*******************************************************************************
432 * Function Name : USART_LINBreakDetectLengthConfig
433 * Description : Sets the USART LIN Break detection length.
434 * Input : - USARTx: where x can be 1, 2 or 3 to select the USART
435 * peripheral.
436 * - USART_LINBreakDetectLength: specifies the LIN break
437 * detection length.
438 * This parameter can be one of the following values:
439 * - USART_LINBreakDetectLength_10b
440 * - USART_LINBreakDetectLength_11b
441 * Output : None
442 * Return : None
443 *******************************************************************************/
444 void USART_LINBreakDetectLengthConfig(USART_TypeDef* USARTx, u16 USART_LINBreakDetectLength)
445 {
446 /* Check the parameters */
447 assert(IS_USART_LIN_BREAK_DETECT_LENGTH(USART_LINBreakDetectLength));
448
449 USARTx->CR2 &= CR3_LBDL_Mask;
450 USARTx->CR2 |= USART_LINBreakDetectLength;
451 }
452
453 /*******************************************************************************
454 * Function Name : USART_LINCmd
455 * Description : Enables or disables the USART抯 LIN mode.
456 * Input : - USARTx: where x can be 1, 2 or 3 to select the USART
457 * peripheral.
458 * - NewState: new state of the USART LIN mode.
459 * This parameter can be: ENABLE or DISABLE.
460 * Output : None
461 * Return : None
462 *******************************************************************************/
463 void USART_LINCmd(USART_TypeDef* USARTx, FunctionalState NewState)
464 {
465 /* Check the parameters */
466 assert(IS_FUNCTIONAL_STATE(NewState));
467
468 if (NewState != DISABLE)
469 {
470 /* Enable the LIN mode by setting the LINE bit in the CR2 register */
471 USARTx->CR2 |= CR2_LINE_Set;
472 }
473 else
474 {
475 /* Disable the LIN mode by clearing the LINE bit in the CR2 register */
476 USARTx->CR2 &= CR2_LINE_Reset;
477 }
478 }
479
480 /*******************************************************************************
481 * Function Name : USART_SendData
482 * Description : Transmits signle data through the USARTx peripheral.
483 * Input : - USARTx: where x can be 1, 2 or 3 to select the USART
484 * peripheral.
485 * - Data: the data to transmit.
486 * Output : None
487 * Return : None
488 *******************************************************************************/
489 void USART_SendData(USART_TypeDef* USARTx, u16 Data)
490 {
491 /* Check the parameters */
492 assert(IS_USART_DATA(Data));
493
494 /* Transmit Data */
495 USARTx->DR = (Data & (u16)0x01FF);
496 }
497
498 /*******************************************************************************
499 * Function Name : USART_ReceiveData
500 * Description : Returns the most recent received data by the USARTx peripheral.
501 * Input : - USARTx: where x can be 1, 2 or 3 to select the USART
502 * peripheral.
503 * Output : None
504 * Return : The received data.
505 *******************************************************************************/
506 u16 USART_ReceiveData(USART_TypeDef* USARTx)
507 {
508 /* Receive Data */
509 return (u16)(USARTx->DR & (u16)0x01FF);
510 }
511
512 /*******************************************************************************
513 * Function Name : USART_SendBreak
514 * Description : Transmits break characters.
515 * Input : - USARTx: where x can be 1, 2 or 3 to select the USART
516 * peripheral.
517 * Output : None
518 * Return : None
519 *******************************************************************************/
520 void USART_SendBreak(USART_TypeDef* USARTx)
521 {
522 /* Send break characters */
523 USARTx->CR1 |= CR1_SBK_Set;
524 }
525
526 /*******************************************************************************
527 * Function Name : USART_SetGuardTime
528 * Description : Sets the specified USART guard time.
529 * Input : - USARTx: where x can be 1, 2 or 3 to select the USART
530 * peripheral.
531 * - USART_GuardTime: specifies the guard time.
532 * Output : None
533 * Return : None
534 *******************************************************************************/
535 void USART_SetGuardTime(USART_TypeDef* USARTx, u8 USART_GuardTime)
536 {
537 /* Clear the USART Guard time */
538 USARTx->GTPR &= GTPR_LSB_Mask;
539 /* Set the USART guard time */
540 USARTx->GTPR |= (u16)((u16)USART_GuardTime << 0x08);
541 }
542
543 /*******************************************************************************
544 * Function Name : USART_SetPrescaler
545 * Description : Sets the system clock prescaler.
546 * Input : - USARTx: where x can be 1, 2 or 3 to select the USART
547 * peripheral.
548 * - USART_Prescaler: specifies the prescaler clock.
549 * Output : None
550 * Return : None
551 *******************************************************************************/
552 void USART_SetPrescaler(USART_TypeDef* USARTx, u8 USART_Prescaler)
553 {
554 /* Clear the USART prescaler */
555 USARTx->GTPR &= GTPR_MSB_Mask;
556 /* Set the USART prescaler */
557 USARTx->GTPR |= USART_Prescaler;
558 }
559
560 /*******************************************************************************
561 * Function Name : USART_SmartCardCmd
562 * Description : Enables or disables the USART抯 Smart Card mode.
563 * Input : - USARTx: where x can be 1, 2 or 3 to select the USART
564 * peripheral.
565 * - NewState: new state of the Smart Card mode.
566 * This parameter can be: ENABLE or DISABLE.
567 * Output : None
568 * Return : None
569 *******************************************************************************/
570 void USART_SmartCardCmd(USART_TypeDef* USARTx, FunctionalState NewState)
571 {
572 /* Check the parameters */
573 assert(IS_FUNCTIONAL_STATE(NewState));
574
575 if (NewState != DISABLE)
576 {
577 /* Enable the SC mode by setting the SCEN bit in the CR3 register */
578 USARTx->CR3 |= CR3_SCEN_Set;
579 }
580 else
581 {
582 /* Disable the SC mode by clearing the SCEN bit in the CR3 register */
583 USARTx->CR3 &= CR3_SCEN_Reset;
584 }
585 }
586
587 /*******************************************************************************
588 * Function Name : USART_SmartCardNACKCmd
589 * Description : Enables or disables NACK transmission.
590 * Input : - USARTx: where x can be 1, 2 or 3 to select the USART
591 * peripheral.
592 * - NewState: new state of the NACK transmission.
593 * This parameter can be: ENABLE or DISABLE.
594 * Output : None
595 * Return : None
596 *******************************************************************************/
597 void USART_SmartCardNACKCmd(USART_TypeDef* USARTx, FunctionalState NewState)
598 {
599 /* Check the parameters */
600 assert(IS_FUNCTIONAL_STATE(NewState));
601
602 if (NewState != DISABLE)
603 {
604 /* Enable the NACK transmission by setting the NACK bit in the CR3 register */
605 USARTx->CR3 |= CR3_NACK_Set;
606 }
607 else
608 {
609 /* Disable the NACK transmission by clearing the NACK bit in the CR3 register */
610 USARTx->CR3 &= CR3_NACK_Reset;
611 }
612
613 }
614
615 /*******************************************************************************
616 * Function Name : USART_HalfDuplexCmd
617 * Description : Enables or disables the USART抯 Half Duplex communication.
618 * Input : - USARTx: where x can be 1, 2 or 3 to select the USART
619 * peripheral.
620 * - NewState: new state of the USART Communication.
621 * This parameter can be: ENABLE or DISABLE.
622 * Output : None
623 * Return : None
624 *******************************************************************************/
625 void USART_HalfDuplexCmd(USART_TypeDef* USARTx, FunctionalState NewState)
626 {
627 /* Check the parameters */
628 assert(IS_FUNCTIONAL_STATE(NewState));
629
630 if (NewState != DISABLE)
631 {
632 /* Enable the Half-Duplex mode by setting the HDSEL bit in the CR3 register */
633 USARTx->CR3 |= CR3_HDSEL_Set;
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -