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

📄 serial_sa.c

📁 Intrisyc 公司的PXA255-bootloader,源码易懂
💻 C
字号:
//////////////////////////////////////////////////////////////////////////////////// Copyright(c) 2001 Intrinsyc Software Inc. All rights reserved.//// Module name:////      serial_sa.c//// Description:////      Interfaces with the StrongArm SA1110 serial hardware.//// Author:////      Mike Kirkland//// Created:////      October 2001//////////////////////////////////////////////////////////////////////////////////#include <serial.h>#include <timer.h>////////////////////////////////////////////////////////////////////////////////// init_serial// PURPOSE: Initializes the debug serial port.// PARAMS:  None.// RETURNS: Nothing////////////////////////////////////////////////////////////////////////////////voidinit_serial(u32 baud){   //wait for the fifo to clear   while(SERIAL_UTSR1 & UTSR1_TX_BSY);   //turn everything off   SERIAL_UTCR3 = 0;   SERIAL_UTCR0 = 0xFF;   SERIAL_UTCR0 = (UTCR0_1_SBIT | UTCR0_8_DBIT);   //set the speed we want   SERIAL_UTCR1 = 0;   SERIAL_UTCR2 = baud; //SERIAL_BAUD_38400;   //Turn everything back on   SERIAL_UTCR3 = (UTCR3_RX_ON | UTCR3_TX_ON);}////////////////////////////////////////////////////////////////////////////////// output_byte_serial// PURPOSE: Prints a byte to the serial port.// PARAMS:  (IN) char byte - byte to print.// RETURNS: Nothing.////////////////////////////////////////////////////////////////////////////////voidoutput_byte_serial(char byte){   //wait for room in the fifo.   while((SERIAL_UTSR0 & UTSR0_TX_HALF_EMPTY) == 0);   SERIAL_UTDR = byte;}////////////////////////////////////////////////////////////////////////////////// input_byte_serial// PURPOSE: Reads a byte from the serial port.// PARAMS:  (OUT) char *byte - byte read.// RETURNS: 1 for success, 0 for failure.////////////////////////////////////////////////////////////////////////////////intinput_byte_serial(char *byte){   int error = 0;   if(SERIAL_UTSR1 & UTSR1_RX_NOT_EMPTY)   {      error = (SERIAL_UTSR1 &               (UTSR1_RX_PARITY_ERROR |                UTSR1_RX_FRAMING_ERROR |                UTSR1_RX_OVERFLOW));      if(error)      {         SERIAL_UTCR3 = 0;         SERIAL_UTCR3 = (UTCR3_RX_ON | UTCR3_TX_ON);         return 0;      }      *byte = (char)SERIAL_UTDR;      return 1;   }   else   {      return 0;   }}

⌨️ 快捷键说明

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