mirror of
https://github.com/thooge/esp32-nmea2000-obp60.git
synced 2025-12-14 06:23:07 +01:00
add DMS22B to build service
This commit is contained in:
@@ -15,6 +15,7 @@
|
||||
#include "GWDMS22B.h"
|
||||
#include "GwApi.h"
|
||||
#include "N2kMessages.h"
|
||||
#include "GwHardware.h"
|
||||
|
||||
|
||||
#define CHECK_BUS(BUS) \
|
||||
@@ -28,7 +29,7 @@
|
||||
}
|
||||
|
||||
#ifdef GWDMS22B11
|
||||
#define ADD22B11 ADD22B(DMS22B11,SPI0)
|
||||
#define ADD22B11 ADD22B(DMS22B11,SPI1)
|
||||
#ifndef GWDMS22B11_CS
|
||||
#define GWDMS22B11_CS -1
|
||||
#endif
|
||||
@@ -38,7 +39,7 @@
|
||||
#endif
|
||||
|
||||
#ifdef GWDMS22B12
|
||||
#define ADD22B12 ADD22B(DMS22B12,SPI0)
|
||||
#define ADD22B12 ADD22B(DMS22B12,SPI1)
|
||||
#ifndef GWDMS22B12_CS
|
||||
#error "you need to define GWDMS22B12_CS"
|
||||
#endif
|
||||
@@ -51,7 +52,7 @@
|
||||
#endif
|
||||
|
||||
#ifdef GWDMS22B13
|
||||
#define ADD22B13 ADD22B(DMS22B13,SPI0)
|
||||
#define ADD22B13 ADD22B(DMS22B13,SPI1)
|
||||
#ifndef GWDMS22B13_CS
|
||||
#error "you need to define GWDMS22B13_CS"
|
||||
#endif
|
||||
@@ -64,7 +65,7 @@
|
||||
#endif
|
||||
|
||||
#ifdef GWDMS22B21
|
||||
#define ADD22B21 ADD22B(DMS22B21,SPI1)
|
||||
#define ADD22B21 ADD22B(DMS22B21,SPI2)
|
||||
#ifndef GWDMS22B21_CS
|
||||
#define GWDMS22B21_CS -1
|
||||
#endif
|
||||
@@ -74,7 +75,7 @@
|
||||
#endif
|
||||
|
||||
#ifdef GWDMS22B22
|
||||
#define ADD22B22 ADD22B(DMS22B22,SPI1)
|
||||
#define ADD22B22 ADD22B(DMS22B22,SPI2)
|
||||
#ifndef GWDMS22B22_CS
|
||||
#error "you need to define GWDMS22B22_CS"
|
||||
#endif
|
||||
@@ -87,7 +88,7 @@
|
||||
#endif
|
||||
|
||||
#ifdef GWDMS22B23
|
||||
#define ADD22B23 ADD22B(DMS22B23,SPI1)
|
||||
#define ADD22B23 ADD22B(DMS22B23,SPI2)
|
||||
#ifndef GWDMS22B23_CS
|
||||
#error "you need to define GWDMS22B23_CS"
|
||||
#endif
|
||||
|
||||
@@ -136,6 +136,6 @@ class SSISensor : public SensorBase<BusType>{
|
||||
|
||||
};
|
||||
using SpiSensorList=SensorList<BusType>;
|
||||
#define GWSPI0_HOST SPI2_HOST
|
||||
#define GWSPI1_HOST SPI3_HOST
|
||||
#define GWSPI1_HOST SPI2_HOST
|
||||
#define GWSPI2_HOST SPI3_HOST
|
||||
#endif
|
||||
@@ -16,28 +16,13 @@
|
||||
#include "GwSpiSensor.h"
|
||||
#include "GWDMS22B.h"
|
||||
#include "GwTimer.h"
|
||||
#include "GwHardware.h"
|
||||
|
||||
static SPIBus bus1(GWSPI0_HOST);
|
||||
static SPIBus bus2(GWSPI1_HOST);
|
||||
static SPIBus bus1(GWSPI1_HOST);
|
||||
static SPIBus bus2(GWSPI2_HOST);
|
||||
|
||||
static SpiSensorList sensors;
|
||||
|
||||
#ifdef GWSPI0_CLK
|
||||
static const int spi0clk=GWSPI0_CLK;
|
||||
#else
|
||||
static const int spi0clk=-1;
|
||||
#endif
|
||||
#ifdef GWSPI0_MISO
|
||||
static const int spi0miso=GWSPI0_MISO;
|
||||
#else
|
||||
static const int spi0miso=-1;
|
||||
#endif
|
||||
#ifdef GWSPI0_MOSI
|
||||
static const int spi0mosi=GWSPI0_MOSI;
|
||||
#else
|
||||
static const int spi0mosi=-1;
|
||||
#endif
|
||||
|
||||
#ifdef GWSPI1_CLK
|
||||
static const int spi1clk=GWSPI1_CLK;
|
||||
#else
|
||||
@@ -54,6 +39,22 @@ static const int spi1mosi=GWSPI1_MOSI;
|
||||
static const int spi1mosi=-1;
|
||||
#endif
|
||||
|
||||
#ifdef GWSPI2_CLK
|
||||
static const int spi2clk=GWSPI2_CLK;
|
||||
#else
|
||||
static const int spi2clk=-1;
|
||||
#endif
|
||||
#ifdef GWSPI2_MISO
|
||||
static const int spi2miso=GWSPI2_MISO;
|
||||
#else
|
||||
static const int spi2miso=-1;
|
||||
#endif
|
||||
#ifdef GWSPI2_MOSI
|
||||
static const int spi2mosi=GWSPI2_MOSI;
|
||||
#else
|
||||
static const int spi2mosi=-1;
|
||||
#endif
|
||||
|
||||
void runSpiTask(GwApi *api){
|
||||
GwLog *logger=api->getLogger();
|
||||
std::map<int,SPIBus *> buses;
|
||||
@@ -63,22 +64,22 @@ void runSpiTask(GwApi *api){
|
||||
if (bus == buses.end()){
|
||||
switch (busId)
|
||||
{
|
||||
case GWSPI0_HOST:
|
||||
if (spi0clk < 0){
|
||||
case GWSPI1_HOST:
|
||||
if (spi1clk < 0){
|
||||
LOG_DEBUG(GwLog::ERROR,"SPI bus 1 not configured, cannot create %s",sensor->prefix.c_str());
|
||||
}
|
||||
else{
|
||||
if (bus1.init(logger,spi0mosi,spi0miso,spi0clk)){
|
||||
if (bus1.init(logger,spi1mosi,spi1miso,spi1clk)){
|
||||
buses[busId]=&bus1;
|
||||
}
|
||||
}
|
||||
break;
|
||||
case GWSPI1_HOST:
|
||||
if (spi1clk < 0){
|
||||
case GWSPI2_HOST:
|
||||
if (spi2clk < 0){
|
||||
LOG_DEBUG(GwLog::ERROR,"SPI bus 2 not configured, cannot create %s",sensor->prefix.c_str());
|
||||
}
|
||||
else{
|
||||
if (bus2.init(logger,spi1mosi,spi1miso,spi1clk)){
|
||||
if (bus2.init(logger,spi2mosi,spi2miso,spi2clk)){
|
||||
buses[busId]=&bus2;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user