wince去掉串口0的DEBUG模式,改为普通模式

来自:http://herbertbt.blog.163.com/blog/static/57266582200911151580307/

这个方法也还可以:


本文转自 :http://blog.chinaunix.net/u1/49088/showart_1933553.html

目前wince的串口0是作为调试串口用的,但是因为我的案子需要3个串口,所以要把它改为普通串口,但是开机时候还是需要打印debug信息,鉴于此,我修改如下:
debug.c中加入一行:
int
DebugConsoleEnabled=1;
发送时候做判断:

//------------------------------------------------------------------------------

//

// Function:
OEMWriteDebugByte

//

// Transmits a character out the
debug serial port.

//

VOID OEMWriteDebugByte(UINT8 ch)

{

   if(DebugConsoleEnabled ==
0)

return;


   // Wait for transmit buffer
to be empty

   while
((INREG32(&g_pUARTReg->UTRSTAT) & 0x02) == 0);


   // Send
character

  
OUTREG32(&g_pUARTReg->UTXH, ch);

}



//------------------------------------------------------------------------------

//

// Function:
OEMReadDebugByte

//

// Reads a byte from the debug
serial port. Does not wait for a character.

// If a character is not
available function returns "OEM_DEBUG_READ_NODATA".

//


int OEMReadDebugByte()

{

   UINT32 status,
ch;


   if(DebugConsoleEnabled ==
0)

return 0;


   status =
INREG32(&g_pUARTReg->UTRSTAT);

   if ((status & 0x01) != 0)
{

   ch =
INREG32(&g_pUARTReg->URXH);

   // if ((status &
UART_LINESTAT_RF) != 0) ch = OEM_DEBUG_COM_ERROR;

   } else {

   ch =
OEM_DEBUG_READ_NODATA;

   }

   return
(int)ch;

}


然后在OemInit函数结束后把DebugConsoleEnabled = 0;就可以了。

不知道为何,我4.2的bsp生成的wince,用以前的串口测试程序来测试,就可以,但是我的5.0的wince,串口测试程序打开不了,无奈只能自己写了一个简单的c#的串口测试,串口0是ok的。
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值