📄 stm32f10x_usart.lst
字号:
450 * Description : Enables or disables the USART抯 LIN mode.
451 * Input : - USARTx: where x can be 1, 2 or 3 to select the USART
452 * peripheral.
453 * - NewState: new state of the USART LIN mode.
454 * This parameter can be: ENABLE or DISABLE.
455 * Output : None
456 * Return : None
457 *******************************************************************************/
458 void USART_LINCmd(USART_TypeDef* USARTx, FunctionalState NewState)
459 {
460 /* Check the parameters */
461 assert_param(IS_FUNCTIONAL_STATE(NewState));
462
463 if (NewState != DISABLE)
464 {
465 /* Enable the LIN mode by setting the LINE bit in the CR2 register */
466 USARTx->CR2 |= CR2_LINE_Set;
467 }
468 else
469 {
470 /* Disable the LIN mode by clearing the LINE bit in the CR2 register */
471 USARTx->CR2 &= CR2_LINE_Reset;
472 }
473 }
474
475 /*******************************************************************************
476 * Function Name : USART_SendData
477 * Description : Transmits signle data through the USARTx peripheral.
478 * Input : - USARTx: where x can be 1, 2 or 3 to select the USART
479 * peripheral.
480 * - Data: the data to transmit.
481 * Output : None
482 * Return : None
483 *******************************************************************************/
484 void USART_SendData(USART_TypeDef* USARTx, u16 Data)
485 {
486 /* Check the parameters */
487 assert_param(IS_USART_DATA(Data));
488
489 /* Transmit Data */
490 USARTx->DR = (Data & (u16)0x01FF);
491 }
492
493 /*******************************************************************************
494 * Function Name : USART_ReceiveData
495 * Description : Returns the most recent received data by the USARTx peripheral.
496 * Input : - USARTx: where x can be 1, 2 or 3 to select the USART
497 * peripheral.
498 * Output : None
499 * Return : The received data.
500 *******************************************************************************/
501 u16 USART_ReceiveData(USART_TypeDef* USARTx)
502 {
503 /* Receive Data */
504 return (u16)(USARTx->DR & (u16)0x01FF);
505 }
506
507 /*******************************************************************************
508 * Function Name : USART_SendBreak
509 * Description : Transmits break characters.
510 * Input : - USARTx: where x can be 1, 2 or 3 to select the USART
511 * peripheral.
512 * Output : None
513 * Return : None
514 *******************************************************************************/
515 void USART_SendBreak(USART_TypeDef* USARTx)
516 {
517 /* Send break characters */
518 USARTx->CR1 |= CR1_SBK_Set;
519 }
520
521 /*******************************************************************************
522 * Function Name : USART_SetGuardTime
523 * Description : Sets the specified USART guard time.
524 * Input : - USARTx: where x can be 1, 2 or 3 to select the USART
525 * peripheral.
526 * - USART_GuardTime: specifies the guard time.
527 * Output : None
528 * Return : None
529 *******************************************************************************/
530 void USART_SetGuardTime(USART_TypeDef* USARTx, u8 USART_GuardTime)
531 {
532 /* Clear the USART Guard time */
533 USARTx->GTPR &= GTPR_LSB_Mask;
534 /* Set the USART guard time */
535 USARTx->GTPR |= (u16)((u16)USART_GuardTime << 0x08);
536 }
537
538 /*******************************************************************************
539 * Function Name : USART_SetPrescaler
540 * Description : Sets the system clock prescaler.
541 * Input : - USARTx: where x can be 1, 2 or 3 to select the USART
542 * peripheral.
543 * - USART_Prescaler: specifies the prescaler clock.
544 * Output : None
545 * Return : None
546 *******************************************************************************/
547 void USART_SetPrescaler(USART_TypeDef* USARTx, u8 USART_Prescaler)
548 {
549 /* Clear the USART prescaler */
550 USARTx->GTPR &= GTPR_MSB_Mask;
551 /* Set the USART prescaler */
552 USARTx->GTPR |= USART_Prescaler;
553 }
554
555 /*******************************************************************************
556 * Function Name : USART_SmartCardCmd
557 * Description : Enables or disables the USART抯 Smart Card mode.
558 * Input : - USARTx: where x can be 1, 2 or 3 to select the USART
559 * peripheral.
560 * - NewState: new state of the Smart Card mode.
561 * This parameter can be: ENABLE or DISABLE.
562 * Output : None
563 * Return : None
564 *******************************************************************************/
565 void USART_SmartCardCmd(USART_TypeDef* USARTx, FunctionalState NewState)
566 {
567 /* Check the parameters */
568 assert_param(IS_FUNCTIONAL_STATE(NewState));
569
570 if (NewState != DISABLE)
571 {
572 /* Enable the SC mode by setting the SCEN bit in the CR3 register */
573 USARTx->CR3 |= CR3_SCEN_Set;
574 }
575 else
576 {
577 /* Disable the SC mode by clearing the SCEN bit in the CR3 register */
578 USARTx->CR3 &= CR3_SCEN_Reset;
579 }
580 }
581
582 /*******************************************************************************
583 * Function Name : USART_SmartCardNACKCmd
584 * Description : Enables or disables NACK transmission.
585 * Input : - USARTx: where x can be 1, 2 or 3 to select the USART
586 * peripheral.
587 * - NewState: new state of the NACK transmission.
588 * This parameter can be: ENABLE or DISABLE.
589 * Output : None
590 * Return : None
591 *******************************************************************************/
592 void USART_SmartCardNACKCmd(USART_TypeDef* USARTx, FunctionalState NewState)
593 {
594 /* Check the parameters */
595 assert_param(IS_FUNCTIONAL_STATE(NewState));
596
597 if (NewState != DISABLE)
598 {
599 /* Enable the NACK transmission by setting the NACK bit in the CR3 register */
600 USARTx->CR3 |= CR3_NACK_Set;
601 }
602 else
603 {
604 /* Disable the NACK transmission by clearing the NACK bit in the CR3 register */
605 USARTx->CR3 &= CR3_NACK_Reset;
606 }
607
608 }
609
610 /*******************************************************************************
611 * Function Name : USART_HalfDuplexCmd
612 * Description : Enables or disables the USART抯 Half Duplex communication.
613 * Input : - USARTx: where x can be 1, 2 or 3 to select the USART
614 * peripheral.
615 * - NewState: new state of the USART Communication.
616 * This parameter can be: ENABLE or DISABLE.
617 * Output : None
618 * Return : None
619 *******************************************************************************/
620 void USART_HalfDuplexCmd(USART_TypeDef* USARTx, FunctionalState NewState)
621 {
622 /* Check the parameters */
623 assert_param(IS_FUNCTIONAL_STATE(NewState));
624
625 if (NewState != DISABLE)
626 {
627 /* Enable the Half-Duplex mode by setting the HDSEL bit in the CR3 register */
628 USARTx->CR3 |= CR3_HDSEL_Set;
629 }
630 else
631 {
632 /* Disable the Half-Duplex mode by clearing the HDSEL bit in the CR3 register */
633 USARTx->CR3 &= CR3_HDSEL_Reset;
634 }
635 }
636
637 /*******************************************************************************
638 * Function Name : USART_IrDAConfig
639 * Description : Configures the USART抯 IrDA interface.
640 * Input : - USARTx: where x can be 1, 2 or 3 to select the USART
641 * peripheral.
642 * - USART_IrDAMode: specifies the IrDA mode.
643 * This parameter can be one of the following values:
644 * - USART_IrDAMode_LowPower
645 * - USART_IrDAMode_Normal
646 * Output : None
647 * Return : None
648 *******************************************************************************/
649 void USART_IrDAConfig(USART_TypeDef* USARTx, u16 USART_IrDAMode)
650 {
651 /* Check the parameters */
652 assert_param(IS_USART_IRDA_MODE(USART_IrDAMode));
653
654 USARTx->CR3 &= CR3_IRLP_Mask;
655 USARTx->CR3 |= USART_IrDAMode;
656 }
657
658 /*******************************************************************************
659 * Function Name : USART_IrDACmd
660 * Description : Enables or disables the USART抯 IrDA interface.
661 * Input : - USARTx: where x can be 1, 2 or 3 to select the USART
662 * peripheral.
663 * - NewState: new state of the IrDA mode.
664 * This parameter can be: ENABLE or DISABLE.
665 * Output : None
666 * Return : None
667 *******************************************************************************/
668 void USART_IrDACmd(USART_TypeDef* USARTx, FunctionalState NewState)
669 {
670 /* Check the parameters */
671 assert_param(IS_FUNCTIONAL_STATE(NewState));
672
673 if (NewState != DISABLE)
674 {
675 /* Enable the IrDA mode by setting the IREN bit in the CR3 register */
676 USARTx->CR3 |= CR3_IREN_Set;
677 }
678 else
679 {
680 /* Disable the IrDA mode by clearing the IREN bit in the CR3 register */
681 USARTx->CR3 &= CR3_IREN_Reset;
682 }
683 }
684
685 /*******************************************************************************
686 * Function Name : USART_GetFlagStatus
687 * Description : Checks whether the specified USART flag is set or not.
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -