[应用方案] M0的串口问题

[复制链接]
3396|22
 楼主| Mancherstun 发表于 2015-12-16 20:41 | 显示全部楼层
  1. /*---------------------------------------------------------------------------------------------------------*/
  2. /* Function:     DrvUART_SetFnIRDA                                                                         */
  3. /*                                                                                                         */
  4. /* Parameter:                                                                                              */
  5. /*     u32Port          -[in]   UART Channel:  UART_PORT0 / UART_PORT1                       */
  6. /*               STR_IRCR_T       -[in]   Ther stucture of IRCR                                */
  7. /*                                            It includes of                                               */
  8. /*                                               u8cTXSelect: 1: Enable Irda transmit function.(TX mode)   */
  9. /*                                                            0: Disable Irda transmit function.(RX mode)  */
  10. /*                                               u8cInvTX: Inverse TX signal                               */
  11. /*                                               u8cInvRX: Inverse RX signal                               */
  12. /*                                                                                                         */
  13. /* Returns:                                                                                                */
  14. /*               None                                                                                    */
  15. /*                                                                                                         */
  16. /* Description:                                                                                            */
  17. /*               The function is used to configure IRDA relative settings.                                 */
  18. /*               It consists of TX or RX mode and Inverse TX or RX signals.                                */
  19. /*---------------------------------------------------------------------------------------------------------*/
  20. void DrvUART_SetFnIRDA(E_UART_PORT u32Port,STR_IRCR_T *str_IRCR )
  21. {
  22. UART_T * tUART;
  23. tUART = (UART_T *)((uint32_t)UART0 + u32Port);
  24. tUART->FUNSEL.FUN_SEL  = FUN_IRCR;           /* Enable IrDA function and configure */
  25. tUART->IRCR.TX_SELECT = (str_IRCR->u8cTXSelect) ?1:0;
  26. tUART->IRCR.INV_TX  = str_IRCR->u8cInvTX ;
  27. tUART->IRCR.INV_RX  = str_IRCR->u8cInvRX ;
  28. }
 楼主| Mancherstun 发表于 2015-12-16 20:41 | 显示全部楼层
  1. /*---------------------------------------------------------------------------------------------------------*/
  2. /* Function:     DrvUART_SetFnRS485                                                                        */
  3. /*                                                                                                         */
  4. /* Parameter:                                                                                              */
  5. /*     u32Port             -[in]   UART Channel:  UART_PORT0 / UART_PORT1                       */
  6. /*               STR_RS485_T       -[in]   Ther stucture of RS485                                */
  7. /*                                            It includes of                                               */
  8. /*                                               u8cModeSelect: MODE_RS485_AUD / MODE_RS485_AAD            */
  9. /*                                                              MODE_RS485_NMM                             */
  10. /*                                               u8cAddrEnable: Enable or Disable RS-485 Address Detection */
  11. /*                                               u8cAddrValue:  Match Address Value                        */
  12. /*                                               u8cDelayTime:  Set transmit delay time value              */
  13. /*                                               u8cRxDisable:  Enable or Disable receiver function        */
  14. /* Returns:                                                                                                */
  15. /*               None                                                                                   */
  16. /*                                                                                                         */
  17. /* Description:                                                                                            */
  18. /*               The function is to Set RS485 Control Register                                             */
  19. /*---------------------------------------------------------------------------------------------------------*/
  20. void DrvUART_SetFnRS485(E_UART_PORT u32Port,STR_RS485_T *str_RS485)
  21. {

  22. UART_T * tUART;
  23. tUART = (UART_T *)((uint32_t)UART0 + u32Port);
  24. tUART->FUNSEL.FUN_SEL    = FUN_RS485;     /* Enable RS485 function and configure */
  25. tUART->ALTCON.RS485_ADD_EN     =  str_RS485-> u8cAddrEnable ?1:0;
  26. tUART->ALTCON.ADDR_MATCH  =  str_RS485-> u8cAddrValue ;
  27. tUART->ALTCON.RS485_NMM      = (str_RS485-> u8cModeSelect & MODE_RS485_NMM)?1:0;
  28. tUART->ALTCON.RS485_AAD      = (str_RS485-> u8cModeSelect & MODE_RS485_AAD)?1:0;
  29. tUART->ALTCON.RS485_AUD      = (str_RS485-> u8cModeSelect & MODE_RS485_AUD)?1:0;
  30. tUART->TOR.DLY                  =  str_RS485-> u8cDelayTime;
  31. tUART->FCR.RX_DIS               =  str_RS485-> u8cRxDisable;
  32. tUART->MCR.LEV_RTS = 0;

  33. }
 楼主| Mancherstun 发表于 2015-12-16 20:42 | 显示全部楼层
  1. /*---------------------------------------------------------------------------------------------------------*/
  2. /* Function:     DrvUART_GetVersion                                                                        */
  3. /*                                                                                                         */
  4. /* Parameter:                                */
  5. /*              None                                                                                     */
  6. /* Returns:                                                                                                */
  7. /*               Version Number                                                                            */
  8. /* Side effects:                                                                                           */
  9. /*                                                                                                         */
  10. /* Description:                                                                                            */
  11. /*               The function is used to get  DrvUART Version Number                                       */
  12. /*---------------------------------------------------------------------------------------------------------*/
  13. int32_t DrvUART_GetVersion(void)
  14. {
  15. return DRVUART_VERSION_NUM;

  16. }
您需要登录后才可以回帖 登录 | 注册

本版积分规则

快速回复 在线客服 返回列表 返回顶部