sysinit.c

来自「ATmega128和ads7864实现ATP闭环控制」· C语言 代码 · 共 66 行

C
66
字号
#include "public.h"






void port_init(void)
{
 PORTA = 0x00;
 DDRA  = 0xFF;
 PORTB = 0x00;
 DDRB  = 0xF7;
 PORTC = 0xFF; //m103 output only
 DDRC  = 0x00;
 PORTD = 0xFF;
 DDRD  = 0xFE;	//PD0 input
 PORTE = 0x00;
 DDRE  = 0xFE;	//PE0 input
 PORTF = 0x00;
 DDRF  = 0x00;
 PORTG = 0x1F;
 DDRG  = 0x1F;
}

//call this routine to initialize all peripherals
void init_devices(void)
{
	 XDIV  = 0x00; //xtal divider
	 XMCRA = 0x00; //external memory
	 port_init();
	 MCUCR = 0x00;
	 EICRA = 0x00; //extended ext ints
	 EICRB = 0x00; //extended ext ints
	 EIMSK = 0x00;
	 TIMSK = 0x00; //timer interrupt sources
	 ETIMSK = 0x00; //extended timer interrupt sources
 
}



void SysInit(void)
{
	//stop errant interrupts until set up
	 CLI(); //disable all interrupts
	init_devices();

	spi_init();


	AD_Init();
	


	


	



	
	//SEI(); //re-enable interrupts
 	//all peripherals are now initialized
}

⌨️ 快捷键说明

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