busvoodoo: add method to set voltage
This commit is contained in:
parent
e064cce4f0
commit
4f0a09f717
|
@ -136,7 +136,7 @@ void busvoodoo_safe_state(void)
|
|||
gpio_set_mode(GPIO(BUSVOODOO_CAN_S_PORT), GPIO_MODE_INPUT, GPIO_CNF_INPUT_FLOAT, GPIO(BUSVOODOO_CAN_S_PIN));
|
||||
}
|
||||
|
||||
float busvoodoo_rail_voltage(uint8_t channel)
|
||||
float busvoodoo_vreg_get(uint8_t channel)
|
||||
{
|
||||
if (channel!=BUSVOODOO_5V_CHANNEL && channel!=BUSVOODOO_3V3_CHANNEL && channel!=BUSVOODOO_XV_CHANNEL && channel!=BUSVOODOO_12V_CHANNEL) { // check channel
|
||||
return NAN;
|
||||
|
@ -171,3 +171,59 @@ float busvoodoo_rail_voltage(uint8_t channel)
|
|||
return to_return;
|
||||
}
|
||||
|
||||
float busvoodoo_vreg_set(uint8_t channel, float voltage)
|
||||
{
|
||||
if (channel!=BUSVOODOO_XV_CHANNEL && channel!=BUSVOODOO_12V_CHANNEL) { // check channel
|
||||
return NAN;
|
||||
}
|
||||
if (BUSVOODOO_12V_CHANNEL==channel && !busvoodoo_full) { // the 12V voltage regulator is only present on the full version
|
||||
return NAN;
|
||||
}
|
||||
|
||||
float volt = NAN; // common variable for voltages
|
||||
if (BUSVOODOO_XV_CHANNEL==channel) { // set voltage on xV low drop-out voltage regulator
|
||||
if (voltage<=0.0) { // disable voltage regulator
|
||||
gpio_clear(GPIO(BUSVOODOO_XVEN_PORT), GPIO(BUSVOODOO_XVEN_PIN)); // disable xV voltage regulator
|
||||
dac_disable(BUSVOODOO_XVCTL_CHANNEL); // disable xV control
|
||||
} else { // enable voltage regulator
|
||||
if (voltage>4.5) { // enforce upper voltage limit (5.0V rail minus LDO and diodes)
|
||||
voltage = 4.5;
|
||||
}
|
||||
volt = busvoodoo_vreg_get(BUSVOODOO_3V3_CHANNEL); // get reference voltage
|
||||
if (isnan(voltage)) {
|
||||
return NAN;
|
||||
}
|
||||
uint16_t dac_set = BUSVOODOO_XV_SET(voltage)/volt*4095; // DAC value corresponding to the voltage
|
||||
dac_load_data_buffer_single(dac_set, RIGHT12, BUSVOODOO_XVCTL_CHANNEL); // set output so the voltage regulator is set to 2.5V
|
||||
dac_software_trigger(BUSVOODOO_XVCTL_CHANNEL); // transfer the value to the DAC
|
||||
dac_enable(BUSVOODOO_XVCTL_CHANNEL); // enable DAC
|
||||
gpio_set(GPIO(BUSVOODOO_XVEN_PORT), GPIO(BUSVOODOO_XVEN_PIN)); // enable xV voltage regulator
|
||||
}
|
||||
sleep_ms(5); // let voltage settle
|
||||
volt = busvoodoo_vreg_get(BUSVOODOO_XV_CHANNEL); // get xV voltage to return
|
||||
} else if (BUSVOODOO_12V_CHANNEL==channel && busvoodoo_full) {// set voltage on 12V boost voltage regulator
|
||||
if (voltage<=0.0) { // disable voltage regulator
|
||||
gpio_set(GPIO(BUSVOODOO_12VEN_PORT), GPIO(BUSVOODOO_12VEN_PIN)); // disable 12V voltage regulator
|
||||
dac_disable(BUSVOODOO_12VCTL_CHANNEL); // disable 12V control
|
||||
} else {
|
||||
if (voltage>24.0) { // enforce upper voltage limit (diodes limit is 30V, ADC input limit is 25V)
|
||||
voltage = 24.0;
|
||||
}
|
||||
volt = busvoodoo_vreg_get(BUSVOODOO_3V3_CHANNEL); // get reference voltage
|
||||
if (isnan(voltage)) {
|
||||
return NAN;
|
||||
}
|
||||
uint16_t dac_set = BUSVOODOO_12V_SET(voltage)/volt*4095; // DAC value corresponding to the voltage
|
||||
dac_load_data_buffer_single(dac_set, RIGHT12, BUSVOODOO_12VCTL_CHANNEL); // set output so the voltage regulator is set to desired output voltage
|
||||
dac_software_trigger(BUSVOODOO_12VCTL_CHANNEL); // transfer the value to the DAC
|
||||
dac_enable(BUSVOODOO_12VCTL_CHANNEL); // enable DAC
|
||||
gpio_clear(GPIO(BUSVOODOO_12VEN_PORT), GPIO(BUSVOODOO_12VEN_PIN)); // enable 12V voltage regulator
|
||||
}
|
||||
sleep_ms(10); // let the voltage regulator start and voltage settle
|
||||
volt = busvoodoo_vreg_get(BUSVOODOO_12V_CHANNEL); // get 12V voltage
|
||||
} else { // don't know about other voltage regulators
|
||||
volt = NAN;
|
||||
}
|
||||
|
||||
return volt; // return measured voltage
|
||||
}
|
||||
|
|
|
@ -106,9 +106,14 @@ extern bool busvoodoo_full;
|
|||
void busvoodoo_setup(void);
|
||||
/** set safe state by disabling all outputs */
|
||||
void busvoodoo_safe_state(void);
|
||||
/** read power rail voltage
|
||||
* @param[in] channel which ADC channel to read voltage from
|
||||
* @return voltage of NaN if channel is invalid
|
||||
/** read voltage from power rail
|
||||
* @param[in] channel which power rail to read voltage from @ref busvoodoo_adc
|
||||
* @return voltage, or NaN if channel is invalid (or error happened)
|
||||
*/
|
||||
float busvoodoo_rail_voltage(uint8_t channel);
|
||||
|
||||
float busvoodoo_vreg_get(uint8_t channel);
|
||||
/** set voltage on adjustable voltage regulator
|
||||
* @note only vV and 12V are adjustable voltage regulators
|
||||
* @param[in] channel which voltage regulator to set voltage on @ref busvoodoo_adc
|
||||
* @return voltage output, or NaN if channel is invalid (or error happened)
|
||||
*/
|
||||
float busvoodoo_vreg_set(uint8_t channel, float voltage);
|
||||
|
|
|
@ -57,7 +57,7 @@ bool busvoodoo_hiz_test_self(void)
|
|||
}
|
||||
|
||||
// check 5V power rail
|
||||
float voltage = busvoodoo_rail_voltage(BUSVOODOO_5V_CHANNEL); // get 5V power rail voltage
|
||||
float voltage = busvoodoo_vreg_get(BUSVOODOO_5V_CHANNEL); // get 5V power rail voltage
|
||||
if (voltage<4.0) {
|
||||
printf("5V power rail voltage is too low: %.2fV\n", voltage);
|
||||
#if DEBUG
|
||||
|
@ -75,7 +75,7 @@ bool busvoodoo_hiz_test_self(void)
|
|||
}
|
||||
|
||||
// check 3.3V power rail
|
||||
voltage = busvoodoo_rail_voltage(BUSVOODOO_3V3_CHANNEL); // get 3.3V power rail voltage
|
||||
voltage = busvoodoo_vreg_get(BUSVOODOO_3V3_CHANNEL); // get 3.3V power rail voltage
|
||||
if (voltage<3.0) {
|
||||
printf("3.3V power rail voltage is too low: %.2fV\n", voltage);
|
||||
#if DEBUG
|
||||
|
@ -95,7 +95,7 @@ bool busvoodoo_hiz_test_self(void)
|
|||
// test 5V and 3.3V outputs
|
||||
gpio_clear(GPIO(BUSVOODOO_VOUTEN_PORT), GPIO(BUSVOODOO_VOUTEN_PIN)); // enable Vout
|
||||
sleep_ms(1); // wait a bit for voltage to settle
|
||||
voltage = busvoodoo_rail_voltage(BUSVOODOO_5V_CHANNEL); // get 5V power rail voltage
|
||||
voltage = busvoodoo_vreg_get(BUSVOODOO_5V_CHANNEL); // get 5V power rail voltage
|
||||
if (voltage<4.0) {
|
||||
printf("5V power rail voltage is too low when 5V output is enabled: %.2fV\n", voltage);
|
||||
#if DEBUG
|
||||
|
@ -111,7 +111,7 @@ bool busvoodoo_hiz_test_self(void)
|
|||
goto error;
|
||||
#endif
|
||||
}
|
||||
voltage = busvoodoo_rail_voltage(BUSVOODOO_3V3_CHANNEL); // get 3.3V power rail voltage
|
||||
voltage = busvoodoo_vreg_get(BUSVOODOO_3V3_CHANNEL); // get 3.3V power rail voltage
|
||||
if (voltage<3.0) {
|
||||
printf("3.3V power rail voltage is too low when 3V3 output is enabled: %.2fV\n", voltage);
|
||||
#if DEBUG
|
||||
|
@ -130,9 +130,7 @@ bool busvoodoo_hiz_test_self(void)
|
|||
gpio_set(GPIO(BUSVOODOO_VOUTEN_PORT), GPIO(BUSVOODOO_VOUTEN_PIN)); // disable Vout
|
||||
|
||||
// check xV voltage regulator
|
||||
gpio_clear(GPIO(BUSVOODOO_XVEN_PORT), GPIO(BUSVOODOO_XVEN_PIN)); // disable xV voltage regulator
|
||||
sleep_ms(1); // let voltage settle
|
||||
voltage = busvoodoo_rail_voltage(BUSVOODOO_XV_CHANNEL); // get xV voltage
|
||||
voltage = busvoodoo_vreg_set(BUSVOODOO_XV_CHANNEL, 0); // disable xV voltage regulator
|
||||
if (voltage>0.2) { // ensure the output is at 0V when the regulator is not enabled
|
||||
printf("xV voltage is %.2fV instead of 0V when the regulator is disabled\n", voltage);
|
||||
#if DEBUG
|
||||
|
@ -143,7 +141,7 @@ bool busvoodoo_hiz_test_self(void)
|
|||
}
|
||||
gpio_set(GPIO(BUSVOODOO_XVEN_PORT), GPIO(BUSVOODOO_XVEN_PIN)); // enable xV voltage regulator
|
||||
sleep_ms(5); // let the voltage regulator start and voltage settle
|
||||
voltage = busvoodoo_rail_voltage(BUSVOODOO_XV_CHANNEL); // get xV voltage
|
||||
voltage = busvoodoo_vreg_get(BUSVOODOO_XV_CHANNEL); // get xV voltage
|
||||
// without being driven it should be around the default voltage
|
||||
if (voltage<BUSVOODOO_XV_DEFAULT-0.2) {
|
||||
printf("xV voltage is lower (%.2fV) than expected (%.2fV) when the regulator is enabled\n", voltage, BUSVOODOO_XV_DEFAULT);
|
||||
|
@ -162,17 +160,7 @@ bool busvoodoo_hiz_test_self(void)
|
|||
}
|
||||
|
||||
// check if we can control xV
|
||||
voltage = busvoodoo_rail_voltage(BUSVOODOO_3V3_CHANNEL); // get reference voltage
|
||||
if (isnan(voltage)) {
|
||||
printf("can get 3V3 rail voltage");
|
||||
goto error;
|
||||
}
|
||||
uint16_t dac_set = BUSVOODOO_XV_SET(BUSVOODOO_XV_TEST)/voltage*4095; // DAC value corresponding to the voltage
|
||||
dac_load_data_buffer_single(dac_set, RIGHT12, BUSVOODOO_XVCTL_CHANNEL); // set output so the voltage regulator is set to 2.5V
|
||||
dac_software_trigger(BUSVOODOO_XVCTL_CHANNEL); // transfer the value to the DAC
|
||||
dac_enable(BUSVOODOO_XVCTL_CHANNEL); // enable DAC
|
||||
sleep_ms(5); // let voltage settle
|
||||
voltage = busvoodoo_rail_voltage(BUSVOODOO_XV_CHANNEL); // get xV voltage
|
||||
voltage = busvoodoo_vreg_set(BUSVOODOO_XV_CHANNEL, BUSVOODOO_XV_TEST); // get xV voltage
|
||||
// check if it matched desired voltage
|
||||
if (voltage<BUSVOODOO_XV_TEST-0.2) {
|
||||
printf("xV voltage is lower (%.2fV) than set (%.2fV)\n", voltage, BUSVOODOO_XV_TEST);
|
||||
|
@ -189,15 +177,11 @@ bool busvoodoo_hiz_test_self(void)
|
|||
goto error;
|
||||
#endif
|
||||
}
|
||||
dac_disable(BUSVOODOO_XVCTL_CHANNEL); // disable xV control
|
||||
gpio_clear(GPIO(BUSVOODOO_XVEN_PORT), GPIO(BUSVOODOO_XVEN_PIN)); // disable xV voltage regulator
|
||||
sleep_ms(1); // let voltage settle
|
||||
busvoodoo_vreg_set(BUSVOODOO_XV_CHANNEL, 0); // disable xV voltage regulator
|
||||
|
||||
// check 12V voltage regulator
|
||||
if (busvoodoo_full) {
|
||||
gpio_set(GPIO(BUSVOODOO_12VEN_PORT), GPIO(BUSVOODOO_12VEN_PIN)); // disable 12V voltage regulator
|
||||
sleep_ms(1); // let voltage settle
|
||||
voltage = busvoodoo_rail_voltage(BUSVOODOO_12V_CHANNEL); // get 12V voltage
|
||||
voltage = busvoodoo_vreg_set(BUSVOODOO_12V_CHANNEL, 0); // disable 12V voltage regulator
|
||||
if (voltage>0.2) { // ensure the output is at 0V when the regulator is not enabled
|
||||
printf("12V voltage is %.2fV instead of 0V when the regulator is disabled\n", voltage);
|
||||
#if DEBUG
|
||||
|
@ -208,7 +192,7 @@ bool busvoodoo_hiz_test_self(void)
|
|||
}
|
||||
gpio_clear(GPIO(BUSVOODOO_12VEN_PORT), GPIO(BUSVOODOO_12VEN_PIN)); // enable 12V voltage regulator
|
||||
sleep_ms(10); // let the voltage regulator start and voltage settle
|
||||
voltage = busvoodoo_rail_voltage(BUSVOODOO_12V_CHANNEL); // get 12V voltage
|
||||
voltage = busvoodoo_vreg_get(BUSVOODOO_12V_CHANNEL); // get 12V voltage
|
||||
// without being driven it should be around the default voltage
|
||||
if (voltage<BUSVOODOO_12V_DEFAULT-0.3) {
|
||||
printf("12V voltage is lower (%.2fV) than expected (%.2fV) when regulator is enabled\n", voltage, BUSVOODOO_12V_DEFAULT);
|
||||
|
@ -227,17 +211,7 @@ bool busvoodoo_hiz_test_self(void)
|
|||
}
|
||||
|
||||
// check if we can control 12V voltage regulator
|
||||
voltage = busvoodoo_rail_voltage(BUSVOODOO_3V3_CHANNEL); // get reference voltage
|
||||
if (isnan(voltage)) {
|
||||
printf("can get 3V3 rail voltage");
|
||||
goto error;
|
||||
}
|
||||
dac_set = BUSVOODOO_12V_SET(BUSVOODOO_12V_TEST)/voltage*4095; // DAC value corresponding to the voltage
|
||||
dac_load_data_buffer_single(dac_set, RIGHT12, BUSVOODOO_12VCTL_CHANNEL); // set output so the voltage regulator is set to desired output voltage
|
||||
dac_software_trigger(BUSVOODOO_12VCTL_CHANNEL); // transfer the value to the DAC
|
||||
dac_enable(BUSVOODOO_12VCTL_CHANNEL); // enable DAC
|
||||
sleep_ms(10); // let voltage settle
|
||||
voltage = busvoodoo_rail_voltage(BUSVOODOO_12V_CHANNEL); // get 12V voltage
|
||||
voltage = busvoodoo_vreg_set(BUSVOODOO_12V_CHANNEL, BUSVOODOO_12V_TEST); // set voltage on 12V voltage regulator
|
||||
if (voltage<BUSVOODOO_12V_TEST-0.3) {
|
||||
printf("12V voltage is lower (%.2fV) than set (%.2fV)\n", voltage, BUSVOODOO_12V_TEST);
|
||||
#if DEBUG
|
||||
|
@ -253,9 +227,7 @@ bool busvoodoo_hiz_test_self(void)
|
|||
goto error;
|
||||
#endif
|
||||
}
|
||||
dac_disable(BUSVOODOO_12VCTL_CHANNEL); // disable 12V control
|
||||
gpio_set(GPIO(BUSVOODOO_12VEN_PORT), GPIO(BUSVOODOO_12VEN_PIN)); // disable 12V voltage regulator
|
||||
sleep_ms(1); // let voltage settle
|
||||
voltage = busvoodoo_vreg_set(BUSVOODOO_12V_CHANNEL, 0); // disable 12V voltage regulator
|
||||
}
|
||||
|
||||
// pull all pins down and ensure they are low
|
||||
|
@ -354,7 +326,7 @@ bool busvoodoo_hiz_test_self(void)
|
|||
gpio_clear(GPIO(BUSVOODOO_5VPULLUP_PORT), GPIO(BUSVOODOO_5VPULLUP_PIN)); // enable 5V pull-up
|
||||
gpio_clear(GPIO(BUSVOODOO_OEPULLUP_PORT), GPIO(BUSVOODOO_OEPULLUP_PIN)); // switch on embedded pull-ups
|
||||
sleep_ms(1); // wait a bit for voltage to settle
|
||||
voltage = busvoodoo_rail_voltage(BUSVOODOO_5V_CHANNEL); // get 5V power rail voltage
|
||||
voltage = busvoodoo_vreg_get(BUSVOODOO_5V_CHANNEL); // get 5V power rail voltage
|
||||
if (voltage<4.0) {
|
||||
printf("5V power rail voltage is too low when used to pull up: %.2fV\n", voltage);
|
||||
#if DEBUG
|
||||
|
@ -391,7 +363,7 @@ bool busvoodoo_hiz_test_self(void)
|
|||
gpio_set(GPIO(BUSVOODOO_XVEN_PORT), GPIO(BUSVOODOO_XVEN_PIN)); // enable xV voltage regulator
|
||||
gpio_clear(GPIO(BUSVOODOO_OEPULLUP_PORT), GPIO(BUSVOODOO_OEPULLUP_PIN)); // switch in embedded pull-up
|
||||
sleep_ms(5); // let the voltage regulator start and voltage settle
|
||||
voltage = busvoodoo_rail_voltage(BUSVOODOO_XV_CHANNEL); // get xV voltage (without being driven it should be around 3.2V)
|
||||
voltage = busvoodoo_vreg_get(BUSVOODOO_XV_CHANNEL); // get xV voltage (without being driven it should be around 3.2V)
|
||||
if (voltage<BUSVOODOO_XV_DEFAULT-0.2) {
|
||||
printf("xV voltage is lower (%.2fV) than expected (%.2fV) when used to pull up\n", voltage, BUSVOODOO_XV_DEFAULT);
|
||||
#if DEBUG
|
||||
|
@ -421,7 +393,10 @@ bool busvoodoo_hiz_test_self(void)
|
|||
gpio_clear(GPIO(BUSVOODOO_XVEN_PORT), GPIO(BUSVOODOO_XVEN_PIN)); // disable xV voltage regulator
|
||||
|
||||
to_return = true; // all tests are successful
|
||||
#if DEBUG
|
||||
#else
|
||||
error:
|
||||
#endif
|
||||
busvoodoo_safe_state(); // set back to safe state
|
||||
if (!to_return) {
|
||||
printf("the test procedure has been aborted for safety reasons\n");
|
||||
|
@ -442,14 +417,14 @@ bool busvoodoo_hiz_test_pins(void)
|
|||
gpio_set(GPIO(BUSVOODOO_XVCTL_PORT), GPIO(BUSVOODOO_XVCTL_PIN)); // set pin high
|
||||
gpio_set_mode(GPIO(BUSVOODOO_XVCTL_PORT), GPIO_MODE_OUTPUT_2_MHZ, GPIO_CNF_OUTPUT_PUSHPULL, GPIO(BUSVOODOO_XVCTL_PIN)); // set xV control pin as output
|
||||
printf("%sI/O pin 1\n", xv_to);
|
||||
while (busvoodoo_rail_voltage(BUSVOODOO_XV_CHANNEL)>0.2) { // wait until pin is shorted to ground
|
||||
while (busvoodoo_vreg_get(BUSVOODOO_XV_CHANNEL)>0.2) { // wait until pin is shorted to ground
|
||||
sleep_ms(200); // wait for user to make connection
|
||||
}
|
||||
gpio_clear(GPIO(BUSVOODOO_XVCTL_PORT), GPIO(BUSVOODOO_XVCTL_PIN)); // set pin low
|
||||
gpio_set_mode(GPIO(BUSVOODOO_XVCTL_PORT), GPIO_MODE_OUTPUT_2_MHZ, GPIO_CNF_OUTPUT_PUSHPULL, GPIO(BUSVOODOO_XVCTL_PIN)); // set xV control pin as output
|
||||
led_toggle(); // notify user test is almost almost
|
||||
sleep_ms(200); // wait for voltage to settle an debounce
|
||||
if (busvoodoo_rail_voltage(BUSVOODOO_XV_CHANNEL)>0.2) {
|
||||
if (busvoodoo_vreg_get(BUSVOODOO_XV_CHANNEL)>0.2) {
|
||||
printf(xv_high);
|
||||
#if DEBUG
|
||||
while (true);
|
||||
|
@ -463,13 +438,13 @@ bool busvoodoo_hiz_test_pins(void)
|
|||
// test 5V output on pin 2
|
||||
gpio_clear(GPIO(BUSVOODOO_VOUTEN_PORT), GPIO(BUSVOODOO_VOUTEN_PIN)); // enable Vout
|
||||
printf("%sI/O pin 2\n", xv_to);
|
||||
while (busvoodoo_rail_voltage(BUSVOODOO_XV_CHANNEL)<0.2) { // wait until pin is connected
|
||||
while (busvoodoo_vreg_get(BUSVOODOO_XV_CHANNEL)<0.2) { // wait until pin is connected
|
||||
sleep_ms(200); // wait for user to make connection
|
||||
}
|
||||
gpio_set(GPIO(BUSVOODOO_VOUTEN_PORT), GPIO(BUSVOODOO_VOUTEN_PIN)); // disable Vout
|
||||
led_toggle(); // notify user test is almost complete
|
||||
sleep_ms(200); // wait for voltage to settle and debounce
|
||||
if (busvoodoo_rail_voltage(BUSVOODOO_XV_CHANNEL)>0.2) {
|
||||
if (busvoodoo_vreg_get(BUSVOODOO_XV_CHANNEL)>0.2) {
|
||||
printf(xv_high);
|
||||
#if DEBUG
|
||||
while (true);
|
||||
|
@ -482,13 +457,13 @@ bool busvoodoo_hiz_test_pins(void)
|
|||
// test 3.3V output on pin 3
|
||||
gpio_clear(GPIO(BUSVOODOO_VOUTEN_PORT), GPIO(BUSVOODOO_VOUTEN_PIN)); // enable Vout
|
||||
printf("%sI/O pin 3\n", xv_to);
|
||||
while (busvoodoo_rail_voltage(BUSVOODOO_XV_CHANNEL)<0.2 || busvoodoo_rail_voltage(BUSVOODOO_XV_CHANNEL)>3.5) { // wait until pin is connected
|
||||
while (busvoodoo_vreg_get(BUSVOODOO_XV_CHANNEL)<0.2 || busvoodoo_vreg_get(BUSVOODOO_XV_CHANNEL)>3.5) { // wait until pin is connected
|
||||
sleep_ms(200); // wait for user to make connection
|
||||
}
|
||||
gpio_set(GPIO(BUSVOODOO_VOUTEN_PORT), GPIO(BUSVOODOO_VOUTEN_PIN)); // disable Vout
|
||||
led_toggle(); // notify user test is almost complete
|
||||
sleep_ms(200); // wait for voltage to settle and debounce
|
||||
if (busvoodoo_rail_voltage(BUSVOODOO_XV_CHANNEL)>0.2) {
|
||||
if (busvoodoo_vreg_get(BUSVOODOO_XV_CHANNEL)>0.2) {
|
||||
printf(xv_high);
|
||||
#if DEBUG
|
||||
while (true);
|
||||
|
@ -505,13 +480,13 @@ bool busvoodoo_hiz_test_pins(void)
|
|||
gpio_set(busvoodoo_io_ports[pin], busvoodoo_io_pins[pin]); // set pin high
|
||||
gpio_set_mode(busvoodoo_io_ports[pin], GPIO_MODE_OUTPUT_2_MHZ, GPIO_CNF_OUTPUT_PUSHPULL, busvoodoo_io_pins[pin]); // set pin to output
|
||||
printf("%sI/O pin %u\n", xv_to, io+4);
|
||||
while (busvoodoo_rail_voltage(BUSVOODOO_XV_CHANNEL)<0.2) { // wait until pin is connected
|
||||
while (busvoodoo_vreg_get(BUSVOODOO_XV_CHANNEL)<0.2) { // wait until pin is connected
|
||||
sleep_ms(200); // wait for user to make connection
|
||||
}
|
||||
gpio_clear(busvoodoo_io_ports[pin], busvoodoo_io_pins[pin]); // set pin low
|
||||
led_toggle(); // notify user test is almost complete
|
||||
sleep_ms(200); // wait for voltage to settle and debounce
|
||||
if (busvoodoo_rail_voltage(BUSVOODOO_XV_CHANNEL)>0.2) {
|
||||
if (busvoodoo_vreg_get(BUSVOODOO_XV_CHANNEL)>0.2) {
|
||||
printf(xv_high);
|
||||
#if DEBUG
|
||||
while (true);
|
||||
|
@ -528,21 +503,21 @@ bool busvoodoo_hiz_test_pins(void)
|
|||
|
||||
if (busvoodoo_full) {
|
||||
// test 12V output on RS/CAN pin 1
|
||||
double voltage = busvoodoo_rail_voltage(BUSVOODOO_3V3_CHANNEL); // get reference voltage
|
||||
double voltage = busvoodoo_vreg_get(BUSVOODOO_3V3_CHANNEL); // get reference voltage
|
||||
uint16_t dac_set = BUSVOODOO_12V_SET(5.0)/voltage*4095; // DAC value corresponding to the voltage
|
||||
dac_load_data_buffer_single(dac_set, RIGHT12, BUSVOODOO_12VCTL_CHANNEL); // set output so the voltage regulator is set to desired output voltage
|
||||
dac_software_trigger(BUSVOODOO_12VCTL_CHANNEL); // transfer the value to the DAC
|
||||
dac_enable(BUSVOODOO_12VCTL_CHANNEL); // enable DAC
|
||||
gpio_clear(GPIO(BUSVOODOO_12VEN_PORT), GPIO(BUSVOODOO_12VEN_PIN)); // enable 12V voltage regulator
|
||||
printf("%sRS/CAN pin 1\n", xv_to);
|
||||
while (busvoodoo_rail_voltage(BUSVOODOO_XV_CHANNEL)<0.2) { // wait until pin is connected
|
||||
while (busvoodoo_vreg_get(BUSVOODOO_XV_CHANNEL)<0.2) { // wait until pin is connected
|
||||
sleep_ms(200); // wait for user to make connection
|
||||
}
|
||||
gpio_set(GPIO(BUSVOODOO_12VEN_PORT), GPIO(BUSVOODOO_12VEN_PIN)); // disable 12V voltage regulator
|
||||
dac_disable(BUSVOODOO_12VCTL_CHANNEL); // disable 12V control
|
||||
led_toggle(); // notify user test is almost complete
|
||||
sleep_ms(200); // wait for voltage to settle (and debounce)
|
||||
if (busvoodoo_rail_voltage(BUSVOODOO_XV_CHANNEL)>0.2) {
|
||||
if (busvoodoo_vreg_get(BUSVOODOO_XV_CHANNEL)>0.2) {
|
||||
printf(xv_high);
|
||||
#if DEBUG
|
||||
while (true);
|
||||
|
|
Loading…
Reference in New Issue