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

📄 uartinit.c

📁 手机底层驱动程序
💻 C
字号:
                                                                                                                                                                                                                                                                                                                                                 
//==================================================================================

#include "main_system.h"
#include "bspUsart.h"
#include "Uartinit.h"

#include "bspCconf.h"
#include "bspConf_tbb3100_Llif.h"
#include "bspConf_tbb3100_Map.h"



#define RXBUFSIZE                64                                  /* RX Buffer Length */
#define TXBUFSIZE                64                                  /* TX Buffer Length */  

#define RXTHRESH                 01                                  /* RX Thresh-Hold  */
#define TXTHRESH                 01                                  /* TX Thresh-Hold  */ 


static BspUsart_BufferData       Rx_buffer[RXBUFSIZE];
static BspUsart_BufferData       Tx_buffer[TXBUFSIZE]; 


/*--------------------------------------------------------------
 Name: Init_Serial_Flows     
 Description: config UART structure
 Parameter: None    
 Return: None          
//--------------------------------------------------------------*/
void Init_Serial_Flows (void) 
{
	*(unsigned short*)0xfffb101a |= 0x00c0;     //SOFT 	
    dev_Uart_init();
    bspUsart_init();
}

/*--------------------------------------------------------------
 Name: UA_Open    
 Description: set UART baudrate and enble UART
 Parameter:     
	    BspUsart_Baud uid: UART NO
	    baudrate: the baudrate set
 Return: None          
//--------------------------------------------------------------*/
Int32 UA_Open(BspUsart_Baud uid,BspUsart_Baud baudrate)
{

        BspUsart_BitsPerChar    bpc = BSP_USART_BITS_PER_CHAR_8;
        BspUsart_StopBits       sb = BSP_USART_STOP_BITS_1;
        BspUsart_Parity         parity = BSP_USART_PARITY_NONE;
        Int16                   RetCode= -10 , RetValue = -10 ;

         RetValue =   bspUsart_unreserve(uid) ;

         if ( RetValue == BSP_USART_RESULT_CODE_OK )
         {
                  RetCode =  BSP_USART_RESULT_CODE_OK;
         }
         else
         {
                 RetCode =  BSP_USART_RESULT_CODE_INTERNAL_ERR ;
         }
          if( bspUsart_reserve(uid) == BSP_USART_RESULT_CODE_OK )
           {
                      RetValue = bspUsart_enable( uid, FALSE );
                       if ( RetValue == BSP_USART_RESULT_CODE_OK )
                         {
                               RetCode =  BSP_USART_RESULT_CODE_OK;
                        }
                     else
                       {
                              RetCode =  BSP_USART_RESULT_CODE_INTERNAL_ERR ;
                       }
                      RetValue = bspUsart_setComPar( uid, baudrate,  bpc,  sb,  parity );
                        
                      if ( RetValue == BSP_USART_RESULT_CODE_OK )
                         {
                               RetCode =  BSP_USART_RESULT_CODE_OK;
                        }
                     else
                       {
                              RetCode =  BSP_USART_RESULT_CODE_INTERNAL_ERR ;
                       }

                        RetValue = bspUsart_setBuffer( uid, Rx_buffer,Tx_buffer, RXBUFSIZE, TXBUFSIZE, RXTHRESH, TXTHRESH);
                
                      if ( RetValue == BSP_USART_RESULT_CODE_OK )
                         {
                               RetCode =  BSP_USART_RESULT_CODE_OK;
                         }
                     else
                        { 
                              RetCode =  BSP_USART_RESULT_CODE_INTERNAL_ERR ;
                         }
                        RetValue = bspUsart_setFlowCtrl( uid, BSP_USART_FLOW_CONTROL_NONE, 0x0, 0x0);
                
                        if ( RetValue == BSP_USART_RESULT_CODE_OK )
                         {
                               RetCode =  BSP_USART_RESULT_CODE_OK;
                         }
                     else
                        { 
                              RetCode =  BSP_USART_RESULT_CODE_INTERNAL_ERR ;
                         }
                         
                       RetValue = bspUsart_enable( uid, TRUE );
                
                     if ( RetValue == BSP_USART_RESULT_CODE_OK )
                         {
                               RetCode =  BSP_USART_RESULT_CODE_OK;
                         }
                     else
                        { 
                              RetCode =  BSP_USART_RESULT_CODE_INTERNAL_ERR ;
                         }

             }
		return RetCode;
}


⌨️ 快捷键说明

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