void setVoltages(void){
cli();
STCP_LOW();
- for (unsigned int i = 3; i >= 0; i-- ){
+ for (uint8_t i = 0; i < 4; i++ ){
for (unsigned int j = 0; j < 5; j++){// 5 times to fill also Q7S
SHCP_LOW();
SHIFT_DATA_LOW();
SHCP_HIGH(); // write
}
- for (unsigned int j = 3; j >= 0; j--){
+ for (unsigned int j = 0; j< 4; j++){
SHCP_LOW();
- if (dcdc_settings[i][j] == 1) {
+ if (dcdc_settings[3-i][3-j] == 1) {
SHIFT_DATA_HIGH();
} else {
SHIFT_DATA_LOW();
if (rxbuf[0] == 'W'){ //write
- // switch DCDC channel On/Off
- if (hex_to_int(rxbuf[5]) == 0) {
- switchDCDC(hex_to_int(rxbuf[4]),hex_to_int(rxbuf[9]));
- }
-
- // set voltage of DCDC-Converter
- if (hex_to_int(rxbuf[5]) == 1) {
- setDCDC(hex_to_int(rxbuf[4]),hex_to_int(rxbuf[9]));
- eeprom_update_byte((uint8_t*)(0x20+hex_to_int(rxbuf[4])),hex_to_int(rxbuf[9])&0xF);
- }
-
- // switch DCDC channel On
- if (hex_to_int(rxbuf[5]) == 5) {
- setInfo(hex_to_int(rxbuf[4]),/* hex_to_int(rxbuf[6])*4096
- +hex_to_int(rxbuf[7])*256
- +hex_to_int(rxbuf[8])*16
- +*/hex_to_int(rxbuf[9]));
+ switch (hex_to_int(rxbuf[5])) {
+ // switch DCDC channel On/Off
+ case 0: {switchDCDC(hex_to_int(rxbuf[4]),hex_to_int(rxbuf[9]));
+ uint8_t answer[] = "FFFFFF";
+ send_answer_hex(&answer[0],0xFFFF);
+ break;
+ }
+
+ // set voltage of DCDC-Converter
+ case 1: {setDCDC(hex_to_int(rxbuf[4]),hex_to_int(rxbuf[9]));
+ //eeprom_update_byte((uint8_t*)(0x20+hex_to_int(rxbuf[4])),hex_to_int(rxbuf[9])&0xF);
+ uint8_t answer[] = "FFFFFF";
+ send_answer_hex(&answer[0],0xFFFF);
+ break;}
+
+ // switch DCDC channel On
+ case 5: {//setInfo(hex_to_int(rxbuf[4]),/* hex_to_int(rxbuf[6])*4096
+ // +hex_to_int(rxbuf[7])*256
+ // +hex_to_int(rxbuf[8])*16
+ // +*/hex_to_int(rxbuf[9]));
+ uint8_t answer[] = "FFFFFF";
+ send_answer_hex(&answer[0],0xFFFF);
+ break;}
+
+ default: {
+ uint8_t answer[] = "FFFFFF";
+ send_answer_hex(&answer[0],0xFFFF);
+ break;
+ }
+
}
}
dcdc_settings[3][2] = (eeprom_value >> 2)& 0x1;
dcdc_settings[3][3] = (eeprom_value >> 3)& 0x1;
- //setVoltages();
- //SHIFT_EN_OUTPUT(); // Enable output of shift register to mosfet
+ setVoltages();
+ SHIFT_EN_OUTPUT(); // Enable output of shift register to mosfet
sei();
uint8_t ADC_State = 0; // 0: start of uC; 1: Volt; 2: Current; 3: Temp
uint16_t lasttime = 0;