}
void switchLDO(uint8_t chan, uint8_t val) {
- if (chan == 2) {
+ if (chan == 1) {
shift_register &= ~(1<<4);
if (val ==0) {} //LDO CH1 off
else {shift_register |= (1<<4);} //LDO CH1 on
}
- if (chan == 1) {
+ if (chan == 0) {
shift_register &= ~(1<<3);
if (val ==0) {} //LDO CH0 off
else {shift_register |= (1<<3);} //LDO CH0 on
void setDCDC(uint8_t chan, uint8_t val) {
//DCDC CH0
if (chan == 2 & val<=7) {
- shift_register &= ~((1<<15)|(1<<14)|(1<<13)); //clear decbitpos15-13
- shift_register |= val<<13;
+ val = 7 - val;
+ shift_register &= ~((1<<15)|(1<<14)|(1<<13)); //clear decbitpos15-13
+ shift_register |= val<<13;
}
//DCDC CH1
if (chan == 3 & val<=7) {
- shift_register &= ~((1<<11)|(1<<10)|(1<<9));
- shift_register |= val<<9;
+ val = 7 - val;
+ shift_register &= ~((1<<11)|(1<<10)|(1<<9));
+ shift_register |= val<<9;
}
//LDO CH1
if (chan == 1 & val<=7) {
- shift_register &= ~((1<<7)|(1<<6)|(1<<5));
- shift_register |= val<<5;
+ val = 7 - val;
+ shift_register &= ~((1<<7)|(1<<6)|(1<<5));
+ shift_register |= val<<5;
}
//LDO CH0
if (chan == 0 & val<=7) {
- shift_register &= ~((1<<2)|(1<<1)|(1<<0));
- shift_register |= val<<0;
+ val = 7 - val;
+ shift_register &= ~((1<<2)|(1<<1)|(1<<0));
+ shift_register |= val<<0;
}
setVoltages();
}
send_answer_hex(&rxbuf[0],read_LDO_status);
}
- // get DCDC selection
+ // get voltage resistors selection
if (hex_to_int(rxbuf[5]) == 1) {
uint16_t read_setting = 0xFFFF;
//DCDC CH0
- if (hex_to_int(rxbuf[4]) == 2) {read_setting = (shift_register >> 13) & 7;
+ if (hex_to_int(rxbuf[4]) == 2) {read_setting = 7 - ((shift_register >> 13) & 7);
}
//DCDC CH1
- if (hex_to_int(rxbuf[4]) == 3) {read_setting = (shift_register >> 9) & 7;
+ if (hex_to_int(rxbuf[4]) == 3) {read_setting = 7 - ((shift_register >> 9) & 7);
}
//LDO CH1
- if (hex_to_int(rxbuf[4]) == 1) {read_setting = (shift_register >> 5) & 7;
+ if (hex_to_int(rxbuf[4]) == 1) {read_setting = 7 - ((shift_register >> 5) & 7);
}
//LDO CH0
- if (hex_to_int(rxbuf[4]) == 0) {read_setting = shift_register & 7;
+ if (hex_to_int(rxbuf[4]) == 0) {read_setting = 7 - (shift_register & 7);
}
send_answer_hex(&rxbuf[0],read_setting);
}
if (hex_to_int(rxbuf[5]) == 7) {
//DCDC CH0
if (hex_to_int(rxbuf[4]) == 2) {
- V_out = adc[0];
+ V_out = (5*adc[0])/2;
send_answer_hex(&rxbuf[0],V_out);
}
//DCDC CH1
if (hex_to_int(rxbuf[4]) == 3) {
- V_out = adc[7];
+ V_out = (5*adc[7])/2;
send_answer_hex(&rxbuf[0],V_out);
}
//LDO CH1
if (hex_to_int(rxbuf[4]) == 1) {
- V_out = adc[6];
+ V_out = (5*adc[6])/2;
send_answer_hex(&rxbuf[0],V_out);
}
//LDO CH0
if (hex_to_int(rxbuf[4]) == 0) {
- V_out = adc[1];
+ V_out = (5*adc[1])/2;
send_answer_hex(&rxbuf[0],V_out);
}