move timer inits to files where it is used

This commit is contained in:
2022-02-11 18:11:08 +01:00
parent 33b01ee2d8
commit e20bdb3e8a
4 changed files with 21 additions and 27 deletions

28
main.c
View File

@@ -39,12 +39,9 @@ void get_mcusr(void)
}
//***********Prologue for fast WDT disable & and save reason of reset/power-up: END
//FUNC headers
static void avr_init(void);
void modbus_master_init(void);
void timer0_init(void);
void timer2_init(void);
void timer3_init(void);
void print_network_information(void);
@@ -168,6 +165,8 @@ int main()
modbus_master_init();
printf("moin!\n\r");
timer3_init();
timer4_init();
ioHelperInitBuffer();
ioHelperIoConf();
@@ -270,25 +269,6 @@ int main()
return 0;
}
// Timer0
// 1ms IRQ
// Used for millis() timing
void timer0_init()
{
TCCR0A = (1<<WGM01); //TIMER0 SET-UP: CTC MODE
TCCR0B = (1<<CS01)|(1<<CS00); // PS 1:64
OCR0A = 249; // 1ms reach for clear (16mz:64=>250kHz:250-=>1kHz)
TIMSK0 |= 1<<OCIE0A; //IRQ on TIMER0 output compareA
}
void timer2_init()
{
TCCR2A = (1<<WGM21); //TIMER0 SET-UP: CTC MODE
TCCR2B|=(1<<CS21); //prescaler 8
OCR2A = 200; // 1ms reach for clear (16mz/8/200=>10kHz)
TIMSK2|=(1<<OCIE2A);
}
void print_network_information()
{
@@ -311,6 +291,4 @@ void print_network_information()
printf("DNS Server : %d.%d.%d.%d\n\r",gWIZNETINFO.dns[0],gWIZNETINFO.dns[1],gWIZNETINFO.dns[2],gWIZNETINFO.dns[3]);
}
ISR(TIMER2_COMPA_vect) { //this ISR is called 9765.625 times per second
modbusTickTimer();
}