From 70a78a02ae3e7e13d2d3e4c893022566c76e04c8 Mon Sep 17 00:00:00 2001 From: cfif Date: Mon, 30 Mar 2026 16:23:46 +0300 Subject: [PATCH] Init --- Sensor.c | 5 ----- SensorSPI.c | 23 +++++++++++++++++++++++ Sensor.h => SensorSPI.h | 12 ++++++++++++ 3 files changed, 35 insertions(+), 5 deletions(-) delete mode 100644 Sensor.c create mode 100644 SensorSPI.c rename Sensor.h => SensorSPI.h (58%) diff --git a/Sensor.c b/Sensor.c deleted file mode 100644 index d5e7a45..0000000 --- a/Sensor.c +++ /dev/null @@ -1,5 +0,0 @@ -// -// Created by cfif on 03.06.2024. -// -#include "Sensor.h" - diff --git a/SensorSPI.c b/SensorSPI.c new file mode 100644 index 0000000..e557582 --- /dev/null +++ b/SensorSPI.c @@ -0,0 +1,23 @@ +// +// Created by cfif on 03.06.2024. +// +#include "SensorSPI.h" + +bool setSpiSensor(tSensorSPI *env, uint16_t reg) { + + GpioPinSet(&env->conns->COON_A_B9_B10.En1, false); + GpioPinSet(&env->conns->COON_A_B9_B10.En1, true); + + GpioPinSet(&env->conns->COON_A_B9_B10.Con.A, false); + GpioPinSet(&env->conns->COON_A_B9_B10.Con.B, false); + GpioPinSet(&env->conns->COON_A_B9_B10.Con.C, false); + + bool result = SpiPortTransmit(&env->spiPorts->Spi1_IO, ®, 1000); + + return result; +} + +void SensorSpi_Init(tSensorSPI *env, tSpiPorts *spiPorts, tConns *conns) { + env->spiPorts = spiPorts; + env->conns = conns; +} \ No newline at end of file diff --git a/Sensor.h b/SensorSPI.h similarity index 58% rename from Sensor.h rename to SensorSPI.h index 452ad52..2f3dcef 100644 --- a/Sensor.h +++ b/SensorSPI.h @@ -6,6 +6,7 @@ #define SMART_COMPONENTS_SENSOR_H #include "GpioPin.h" +#include "SpiPorts.h" typedef struct { tGpioPin A; @@ -19,4 +20,15 @@ typedef struct { tGpioPin En2; } tConn; +typedef struct { + tConn COON_A_B9_B10; +} tConns; + +typedef struct { + tConns *conns; + tSpiPorts *spiPorts; +} tSensorSPI; + +void SensorSpi_Init(tSensorSPI *env, tSpiPorts *spiPorts, tConns *conns); + #endif //SMART_COMPONENTS_SENSOR_H