📄 uart.c
字号:
//*************************************************************************
//
// P H I L I P S P R O P R I E T A R Y
//
// COPYRIGHT (c) 2004 BY PHILIPS SEMICONDUCTORS
// -- ALL RIGHTS RESERVED --
//
// File Name: uart.c
// Created: April 16, 2004
// Modified: Handoko (Hans) Chendra
// Revision: 1.00
//
//*************************************************************************
#include <REG51RX.H> // special function register declarations
#include "uart.h"
void Uart_Write(unsigned char Reg, unsigned char val) // Reg = register to be written, val = value
{
// UART address
A0 = Reg & 0x01;
A1 = Reg & 0x02;
A2 = Reg & 0x04;
A3 = Reg & 0x08;
UART_CEN = 0; // enable the UART
// write data to the microcontroller data bus
AUXR = 0x02; // access external memory, emit/don't emit ALE --> emit when using emulator
*((unsigned char pdata *)MCU_COMMAND) = val;
AUXR = 0x00; // access internal memory, emit ALE when using emulator
UART_CEN = 1; // disable the UART
}
unsigned char Uart_Read(unsigned char Reg) // Reg = register to be written
{
unsigned char RegData;
int i;
// UART address
A0 = Reg & 0x01;
A1 = Reg & 0x02;
A2 = Reg & 0x04;
A3 = Reg & 0x08;
UART_CEN = 0; // enable the UART
// read data from the microcontroller data bus
AUXR = 0x02; // access external memory, emit ALE when using emulator
RegData = *((unsigned char pdata *)MCU_COMMAND);
AUXR = 0x00; // access internal memory, emit ALE when using emulator
UART_CEN = 1; // disable the UART
return RegData;
}
void Uart_Reset(void)
{
int i;
UART_Reset = 1; // enable UART reset
for (i=0;i<10;i++); // delay
UART_Reset = 0; // disable UART reset
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -