This commit is contained in:
cfif 2026-03-30 16:23:46 +03:00
parent 24f073a925
commit 70a78a02ae
3 changed files with 35 additions and 5 deletions

View File

@ -1,5 +0,0 @@
//
// Created by cfif on 03.06.2024.
//
#include "Sensor.h"

23
SensorSPI.c Normal file
View File

@ -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, &reg, 1000);
return result;
}
void SensorSpi_Init(tSensorSPI *env, tSpiPorts *spiPorts, tConns *conns) {
env->spiPorts = spiPorts;
env->conns = conns;
}

View File

@ -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