46 lines
1.1 KiB
C
46 lines
1.1 KiB
C
#include "pico/stdlib.h"
|
|
#include "SelectionCapteur.h"
|
|
|
|
#define PIN_ADRESSE_A0 5
|
|
#define PIN_ADRESSE_A1 4
|
|
#define PIN_ADRESSE_A2 3
|
|
#define PIN_ADRESSE_A3 2
|
|
|
|
#define PIN_COM 6
|
|
|
|
void Selection_capteur_init_pin_low(uint pin);
|
|
|
|
void Selection_capteur_init(void){
|
|
|
|
Selection_capteur_init_pin_low(PIN_COM);
|
|
Selection_capteur_init_pin_low(PIN_ADRESSE_A0);
|
|
Selection_capteur_init_pin_low(PIN_ADRESSE_A1);
|
|
Selection_capteur_init_pin_low(PIN_ADRESSE_A2);
|
|
Selection_capteur_init_pin_low(PIN_ADRESSE_A3);
|
|
Selection_capteur_deselect();
|
|
|
|
}
|
|
|
|
/// @brief Désactive le capteur en question
|
|
/// @param capteur capteur, numéroté de 0 à 11
|
|
void Selection_capteur_select(uint32_t capteur){
|
|
uint32_t io_value;
|
|
|
|
io_value = 0;
|
|
io_value |= ((capteur & 0x08) >> 3) << 2;
|
|
io_value |= ((capteur & 0x04) >> 2) << 3;
|
|
io_value |= ((capteur & 0x02) >> 1) << 4;
|
|
io_value |= (capteur & 0x01) << 5;
|
|
|
|
gpio_put_masked(0b111100, io_value);
|
|
}
|
|
|
|
void Selection_capteur_init_pin_low(uint pin){
|
|
gpio_init(pin);
|
|
gpio_set_dir(pin, GPIO_OUT);
|
|
gpio_put(pin, 0);
|
|
}
|
|
|
|
void Selection_capteur_deselect(){
|
|
Selection_capteur_select(15);
|
|
} |