void buck_shift(double r, double *p, double *f) { static double pot, grad, pot_cut, grad_cut; buck_init(r, &pot, &grad, p); buck_init(dp_cut, &pot_cut, &grad_cut, p); *f = pot - pot_cut - r * (r - dp_cut) * grad_cut; return; }
int main(void) { uart_init(UART_BAUD_SELECT(UART_BAUD_RATE,F_CPU)); i2c_init(); buck_init(); buckAdc_init(); sei(); //Turn off buck converter DDRB |= (1<<DDB0); PORTB |= (1<<PORTB0); while(1) { cell_numberCount(); cell_adcReadings(); cell_balance(); uart_out(); mean_readings(); if (PINB & (1<<PORTB1)) buck(ENABLE); else buck(DISABLE); } return 0; }