Currently, the serial port 0 of Wince is used for debugging the serial port. However, because my case requires three serial ports, I need to change it to a common serial port, but I still need to print the debug information when I start the system, in view of this, I modified the following: Debug. add a line in C: int debugconsoleenabled = 1; make a judgment when sending:
// Outputs //// function: oemwritedebugbyte // transmits a character out of the debug serial port. // void oemwritedebugbyte (uint8 ch) {If (debugconsoleenabled = 0) return; // wait for transmit buffer to be empty while (inreg32 (& g_puarregulatory-> utrstat) & 0x02) = 0); // send character outreg32 (& g_puarreg-> 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_puarreg-> utrstat ); if (Status & 0x01 )! = 0) {CH = inreg32 (& g_puarreg-> urxh); // If (Status & uart_linestat_rf )! = 0) CH = oem_debug_com_error;} else {CH = oem_debug_read_nodata;} return (INT) ch;} Then debugconsoleenabled = 0 after the oeminit function is complete. I don't know why. I can use the serial port test program to test the wince generated by my 4.2 BSP, but my 5.0 wince cannot be opened by the serial port test program, instead, you can only write a simple C # Serial Port test. Serial Port 0 is OK. The next step is Serial Port 1 and Serial Port 2. PS: C # Is really convenient. A person who has never touched C # can directly write a program that does not seem simple on the interface. It seems like Delphi's ease of use.