📄 uart1.h
字号:
/////////////////////////////////////
// Generated Initialization File //
/////////////////////////////////////
#include "c8051F120.h"
// Peripheral specific initialization functions,
// Called from the Init_Device() function
//------------------------------------------------------------------------------------
// Timer1_Init
//------------------------------------------------------------------------------------
//
// Configure Timer1 to auto-reload and generate an interrupt at interval
// specified by <counts> using SYSCLK as its time base.
//
//
void Timer_Init ()
{
char SFRPAGE_SAVE = SFRPAGE; // Save Current SFR page
SFRPAGE = TIMER01_PAGE;
TCON = 0x40;
TMOD = 0x20;
CKCON = 0x10;
TH1 = 0xF3;
SFRPAGE = SFRPAGE_SAVE; // Restore SFR page
}
//------------------------------------------------------------------------------------
// PORT_Init
//------------------------------------------------------------------------------------
//
// Configure the Crossbar and GPIO ports
//
void Port_Init (void)
{
char SFRPAGE_SAVE = SFRPAGE; // Save Current SFR page
SFRPAGE = CONFIG_PAGE;
P1MDOUT = 0x40;
XBR2 = 0x44;
SFRPAGE = SFRPAGE_SAVE; // Restore SFR page
}
//------------------------------------------------------------------------------------
// UART1_Init
//------------------------------------------------------------------------------------
//
// Configure the UART1 using Timer1, for <baudrate> and 8-N-1.
//
void UART1_Init(void)
{
char SFRPAGE_SAVE = SFRPAGE; // Save Current SFR page
SFRPAGE = UART1_PAGE;
SCON1 = 0x50; // UART1 enable & can read and write
TI1 = 1; // Indicate TX1 ready
RI1 = 0;
SFRPAGE = SFRPAGE_SAVE; // Restore SFR page
}
void Interrupts_Init()
{
IE = 0x80;
EIE2 = 0x40;
}
// Initialization function for device,
// Call Init_Device() from your main program
void Init_Device(void)
{
Timer_Init();
UART1_Init();
Port_Init();
Interrupts_Init();
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -