26 lines
640 B
C
26 lines
640 B
C
#include "const.h"
|
|
#include "state.h"
|
|
#include <hardware/adc.h>
|
|
#include <pico/time.h>
|
|
#include <stdint.h>
|
|
#include <hardware/gpio.h>
|
|
|
|
void set_mux_addr(uint8_t addr) {
|
|
gpio_put(MUX_S0, addr & 1);
|
|
gpio_put(MUX_S1, (addr >> 1) & 1);
|
|
gpio_put(MUX_S2, (addr >> 2) & 1);
|
|
}
|
|
|
|
|
|
|
|
void update_inputs() {
|
|
for(uint8_t i = 0; i < 2; i++) {
|
|
adc_select_input(i);
|
|
for(uint8_t j = 0; j < 8;j++) {
|
|
set_mux_addr(j);
|
|
sleep_ms(1); // let multiplexor multiplex
|
|
state.array[(i+1)*j]= adc_read();
|
|
}
|
|
}
|
|
}
|