void Setup() { debug_level = 2; //set clock to max for init 32MHz ClockSetSource(x32MHz); //disable 2MHZ osc OSC.CTRL = 0b00000010; //save power turnoff_subsystems(); EnableInterrupts(); //init basic peripherals led_init(); uart_init_buffers(); uart_init(); time_init(); buzzer_init(); battery_init(); buttons_init(); //basic power control mems_power_init(); io_init(); SD_EN_INIT; //load configuration cfg_load(); _delay_ms(100); }
void Setup() { //set clock to max for init 32MHz ClockSetSource(x32MHz); //disable 2MHZ osc OSC.CTRL = 0b00000010; //get RAM info free_ram_at_start = freeRam(); //get reset reason system_rst = RST.STATUS; RST.STATUS = 0b00111111; //save power - peripherals are turned on on demand by drivers turnoff_subsystems(); EnableInterrupts(); //load device id GetID(); //init basic peripherals led_init(); uart_init_buffers(); time_init(); buzzer_init(); battery_init(); buttons_init(); //basic power control mems_power_init(); io_init(); SD_EN_INIT; //load configuration from EE cfg_load(); uart_init(); _delay_ms(100); }