mutiplexors done

This commit is contained in:
PoliEcho 2026-04-24 15:22:37 +02:00
parent 946417b020
commit f4aa96104f
2 changed files with 15 additions and 4 deletions

14
mux.c
View File

@ -1,4 +1,7 @@
#include "const.h"
#include "state.h"
#include <hardware/adc.h>
#include <pico/time.h>
#include <stdint.h>
#include <hardware/gpio.h>
@ -8,12 +11,15 @@ void set_mux_addr(uint8_t addr) {
gpio_put(MUX_S2, (addr >> 2) & 1);
}
float read_value_from_mux() {
return 0.0f;
}
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();
}
}
}

5
mux.h Normal file
View File

@ -0,0 +1,5 @@
#pragma once
#include <stdint.h>
void set_mux_addr(uint8_t addr);
void update_inputs();