📄 sys_init.c
字号:
VICVectAddr = 0; // 向量中断结束
}
//=================================================================================================
/**************************************************************************************************
Function: // void __irq IRQ_Eint2 (void)
Description: // for int2 interrupt
Calls: // none
Called By: // init ()
Table Accessed: // none
Table Updated: // none
Input: // void
Output: // none
Return: // void
Others: // none
***************************************************************************************************/
void __irq IRQ_Eint2 (void)
{
while ((EXTINT & 0x04) != 0)
{
EXTINT |= 0x04; // 清除EINT2中断标志
}
VICVectAddr = 0; // 向量中断结束
}
//=================================================================================================
/**************************************************************************************************
Function: // void init_io(void)
Description: // for init the io
Calls: // none
Called By: // init ()
Table Accessed: // none
Table Updated: // none
Input: // void
Output: // none
Return: // void
Others: // none
***************************************************************************************************/
void init_io(void)
{
//PINSEL0 = 0x80000000; //1000_0000_0000_0000_0000_0000_0000_0000
//PINSEL1 = 0x01000001; //0000_0001_0000_0100_0000_0000_0000_0001
//IO0DIR = 0xedfe7fff; //1110_1101_1111_1110_0111_1111_1111_1111
//IO1DIR = 0xffffffff; //1111_1111_1111_1111_1111_1111_1111_1111
PINSEL0 = UART0_EN|I2C_EN|UART1_EN; //enable uart0 uart1 i2c
PINSEL1 = 0;
//PINSEL2=0;
IO0DIR = LCD_RW|//0xffffffff;
LCD_E|
LCD_D0|
LCD_D2|
LCD_D3|
LCD_D5|
LCD_D7|
LCD_CS2|
LCD_CS1|
D1302_RST|
LCD_POWER|
M485_EN|
M4821_CS11|
M4821_SDI2|
M4821_CS12|
M4821_SDI1|
D1302_CLK;
IO1DIR =//0xffffffff;//
D1302_IO|
M4821_SCK1|
M4821_SCK2|
LED|
BEEP|
LCD_D6|
LCD_D4|
LCD_D1|
LCD_RS|
RY4;//|
// RY3|
// RY2|
// RY1;
IO1SET |=LED;
IO1SET |=BEEP;
IO0CLR |=M485_EN;//485始终置低,只在发送是置高.
IO0SET |=LCD_POWER;
IO1SET |=BEEP;
}
//=================================================================================================
/**************************************************************************************************
Function: // void init_clock(void)
Description: // for init clock
Calls: // none
Called By: // init ()
Table Accessed: // none
Table Updated: // none
Input: // void
Output: // none
Return: // void
Others: // none
***************************************************************************************************/
void init_clock (void)
{
}
//=================================================================================================
/**************************************************************************************************
Function: // void void init_timer0 (void)
Description: // for init timer0
Calls: // none
Called By: // init ()
Table Accessed: // none
Table Updated: // none
Input: // void
Output: // none
Return: // void
Others: // none
***************************************************************************************************/
void init_timer0 (void)
{
T0TC = 0; //定时器0初值设置为0
T0PR = 0; //时钟不分频
T0MCR = 0x03; //设置T0MR0匹配后复位T0TC,并产生中断标志
T0MR0 = Fpclk /4; //1/350秒钟定时,(1MS定时:T0MR0 = Fpclk / 1000)
T0TCR = 0x03; //启动定时器0和分频器0
T0TCR = 0x01; //启动定时器0和分频器0
//-----------------------------------------------
VICIntSelect &=~(1<<4); //设置timer0中断通道设置为IRQ中断
VICVectCntl2 = 0x20 | 4; //分配定时器0到向量中断2
VICVectAddr2 = (uint32)IRQ_Timer0; //设置中断服务程序地址
VICIntEnable |=(1<<4); //使能定时器0中断
}
//=================================================================================================
/**************************************************************************************************
Function: // void init_timer1 (void)
Description: // for init timer1
Calls: // none
Called By: // init ()
Table Accessed: // none
Table Updated: // none
Input: // void
Output: // none
Return: // void
Others: // none
***************************************************************************************************/
void init_timer1 (void)
{
T1TC = 0; //定时器1初值设置为0
T1PR = 0; //时钟不分频
T1MCR = 0x03; //设置T1MR0匹配后复位T1TC,并产生中断标志
T1MR0 = Fpclk /4; //1/350秒钟定时,(1MS定时:T1MR0 = Fpclk / 1000)
T1TCR = 0x03; //启动定时器1和分频器1
T1TCR = 0x01; //启动定时器1和分频器1
//-----------------------------------------------
VICIntSelect &=~(1<<5); //设置timer1中断通道设置为IRQ中断
VICVectCntl3 =0x20 | 5; //分配定时器1到向量中断3
VICVectAddr3 =(uint32)IRQ_Timer1; //设置中断服务程序地址
VICIntEnable |=(1<<5); //使能定时器1中断
}
//=================================================================================================
/**************************************************************************************************
Function: // void init_int0 (void)
Description: // for init int0
Calls: // none
Called By: // init ()
Table Accessed: // none
Table Updated: // none
Input: // void
Output: // none
Return: // void
Others: // none
***************************************************************************************************/
void init_int0 (void)
{
EXTMODE |=0x01; //int0 pulse trigle
EXTPOLAR |=0x01; //rise endge active
EXTINT |=0x01; //清除EINT0中断标志
VICIntSelect &=~(1<<14); //设置int0中断通道设置为IRQ中断
VICVectCntl0 =0x20 | 14; //分配外部中断0到向量中断0
VICVectAddr0 =(uint32)IRQ_Eint0; //设置中断服务程序地址
VICIntEnable |=(1<<14); //使能EINT0中断
}
//=================================================================================================
/**************************************************************************************************
Function: // void init_int2 (void)
Description: // for init int2
Calls: // none
Called By: // init ()
Table Accessed: // none
Table Updated: // none
Input: // void
Output: // none
Return: // void
Others: // none
***************************************************************************************************/
void init_int2 (void)
{
EXTMODE |=0x04; //int2 pulse trigle
EXTPOLAR |=0x04; //rise endge active
EXTINT |=0x04; //清除EINT2中断标志
VICIntSelect &=~(1<<16); //设置int2中断通道设置为IRQ中断
VICVectCntl1 =0x20 | 16; //分配外部中断2到向量中断1
VICVectAddr1 =(uint32)IRQ_Eint2; //设置中断服务程序地址
VICIntEnable |=(1<<16); //使能EINT2中断
}
//=================================================================================================
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -