add DMS22B to build service
This commit is contained in:
		
							parent
							
								
									ebf0824d5e
								
							
						
					
					
						commit
						a87546bfdf
					
				| 
						 | 
					@ -15,6 +15,7 @@
 | 
				
			||||||
#include "GWDMS22B.h"
 | 
					#include "GWDMS22B.h"
 | 
				
			||||||
#include "GwApi.h"
 | 
					#include "GwApi.h"
 | 
				
			||||||
#include "N2kMessages.h"
 | 
					#include "N2kMessages.h"
 | 
				
			||||||
 | 
					#include "GwHardware.h"
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
#define CHECK_BUS(BUS) \
 | 
					#define CHECK_BUS(BUS) \
 | 
				
			||||||
| 
						 | 
					@ -28,7 +29,7 @@
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
#ifdef GWDMS22B11
 | 
					#ifdef GWDMS22B11
 | 
				
			||||||
    #define ADD22B11 ADD22B(DMS22B11,SPI0)
 | 
					    #define ADD22B11 ADD22B(DMS22B11,SPI1)
 | 
				
			||||||
    #ifndef GWDMS22B11_CS
 | 
					    #ifndef GWDMS22B11_CS
 | 
				
			||||||
        #define GWDMS22B11_CS -1
 | 
					        #define GWDMS22B11_CS -1
 | 
				
			||||||
    #endif
 | 
					    #endif
 | 
				
			||||||
| 
						 | 
					@ -38,7 +39,7 @@
 | 
				
			||||||
#endif
 | 
					#endif
 | 
				
			||||||
 | 
					
 | 
				
			||||||
#ifdef GWDMS22B12
 | 
					#ifdef GWDMS22B12
 | 
				
			||||||
    #define ADD22B12 ADD22B(DMS22B12,SPI0)
 | 
					    #define ADD22B12 ADD22B(DMS22B12,SPI1)
 | 
				
			||||||
    #ifndef GWDMS22B12_CS
 | 
					    #ifndef GWDMS22B12_CS
 | 
				
			||||||
        #error "you need to define GWDMS22B12_CS"
 | 
					        #error "you need to define GWDMS22B12_CS"
 | 
				
			||||||
    #endif
 | 
					    #endif
 | 
				
			||||||
| 
						 | 
					@ -51,7 +52,7 @@
 | 
				
			||||||
#endif
 | 
					#endif
 | 
				
			||||||
 | 
					
 | 
				
			||||||
#ifdef GWDMS22B13
 | 
					#ifdef GWDMS22B13
 | 
				
			||||||
    #define ADD22B13 ADD22B(DMS22B13,SPI0)
 | 
					    #define ADD22B13 ADD22B(DMS22B13,SPI1)
 | 
				
			||||||
    #ifndef GWDMS22B13_CS
 | 
					    #ifndef GWDMS22B13_CS
 | 
				
			||||||
        #error "you need to define GWDMS22B13_CS"
 | 
					        #error "you need to define GWDMS22B13_CS"
 | 
				
			||||||
    #endif
 | 
					    #endif
 | 
				
			||||||
| 
						 | 
					@ -64,7 +65,7 @@
 | 
				
			||||||
#endif
 | 
					#endif
 | 
				
			||||||
 | 
					
 | 
				
			||||||
#ifdef GWDMS22B21
 | 
					#ifdef GWDMS22B21
 | 
				
			||||||
    #define ADD22B21 ADD22B(DMS22B21,SPI1)
 | 
					    #define ADD22B21 ADD22B(DMS22B21,SPI2)
 | 
				
			||||||
    #ifndef GWDMS22B21_CS
 | 
					    #ifndef GWDMS22B21_CS
 | 
				
			||||||
        #define GWDMS22B21_CS -1
 | 
					        #define GWDMS22B21_CS -1
 | 
				
			||||||
    #endif
 | 
					    #endif
 | 
				
			||||||
| 
						 | 
					@ -74,7 +75,7 @@
 | 
				
			||||||
#endif
 | 
					#endif
 | 
				
			||||||
 | 
					
 | 
				
			||||||
#ifdef GWDMS22B22
 | 
					#ifdef GWDMS22B22
 | 
				
			||||||
    #define ADD22B22 ADD22B(DMS22B22,SPI1)
 | 
					    #define ADD22B22 ADD22B(DMS22B22,SPI2)
 | 
				
			||||||
    #ifndef GWDMS22B22_CS
 | 
					    #ifndef GWDMS22B22_CS
 | 
				
			||||||
        #error "you need to define GWDMS22B22_CS"
 | 
					        #error "you need to define GWDMS22B22_CS"
 | 
				
			||||||
    #endif
 | 
					    #endif
 | 
				
			||||||
| 
						 | 
					@ -87,7 +88,7 @@
 | 
				
			||||||
#endif
 | 
					#endif
 | 
				
			||||||
 | 
					
 | 
				
			||||||
#ifdef GWDMS22B23
 | 
					#ifdef GWDMS22B23
 | 
				
			||||||
    #define ADD22B23 ADD22B(DMS22B23,SPI1)
 | 
					    #define ADD22B23 ADD22B(DMS22B23,SPI2)
 | 
				
			||||||
    #ifndef GWDMS22B23_CS
 | 
					    #ifndef GWDMS22B23_CS
 | 
				
			||||||
        #error "you need to define GWDMS22B23_CS"
 | 
					        #error "you need to define GWDMS22B23_CS"
 | 
				
			||||||
    #endif
 | 
					    #endif
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -136,6 +136,6 @@ class SSISensor : public SensorBase<BusType>{
 | 
				
			||||||
    
 | 
					    
 | 
				
			||||||
};
 | 
					};
 | 
				
			||||||
using SpiSensorList=SensorList<BusType>;
 | 
					using SpiSensorList=SensorList<BusType>;
 | 
				
			||||||
#define GWSPI0_HOST SPI2_HOST
 | 
					#define GWSPI1_HOST SPI2_HOST
 | 
				
			||||||
#define GWSPI1_HOST SPI3_HOST
 | 
					#define GWSPI2_HOST SPI3_HOST
 | 
				
			||||||
#endif
 | 
					#endif
 | 
				
			||||||
| 
						 | 
					@ -16,28 +16,13 @@
 | 
				
			||||||
#include "GwSpiSensor.h"
 | 
					#include "GwSpiSensor.h"
 | 
				
			||||||
#include "GWDMS22B.h"
 | 
					#include "GWDMS22B.h"
 | 
				
			||||||
#include "GwTimer.h"
 | 
					#include "GwTimer.h"
 | 
				
			||||||
 | 
					#include "GwHardware.h"
 | 
				
			||||||
 | 
					
 | 
				
			||||||
static SPIBus bus1(GWSPI0_HOST);
 | 
					static SPIBus bus1(GWSPI1_HOST);
 | 
				
			||||||
static SPIBus bus2(GWSPI1_HOST);
 | 
					static SPIBus bus2(GWSPI2_HOST);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
static SpiSensorList sensors;
 | 
					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
 | 
					#ifdef GWSPI1_CLK
 | 
				
			||||||
static const int spi1clk=GWSPI1_CLK;
 | 
					static const int spi1clk=GWSPI1_CLK;
 | 
				
			||||||
#else
 | 
					#else
 | 
				
			||||||
| 
						 | 
					@ -54,6 +39,22 @@ static const int spi1mosi=GWSPI1_MOSI;
 | 
				
			||||||
static const int spi1mosi=-1;
 | 
					static const int spi1mosi=-1;
 | 
				
			||||||
#endif
 | 
					#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){
 | 
					void runSpiTask(GwApi *api){
 | 
				
			||||||
    GwLog *logger=api->getLogger();
 | 
					    GwLog *logger=api->getLogger();
 | 
				
			||||||
    std::map<int,SPIBus *> buses;
 | 
					    std::map<int,SPIBus *> buses;
 | 
				
			||||||
| 
						 | 
					@ -63,22 +64,22 @@ void runSpiTask(GwApi *api){
 | 
				
			||||||
        if (bus == buses.end()){
 | 
					        if (bus == buses.end()){
 | 
				
			||||||
            switch (busId)
 | 
					            switch (busId)
 | 
				
			||||||
            {
 | 
					            {
 | 
				
			||||||
            case GWSPI0_HOST:
 | 
					            case GWSPI1_HOST:
 | 
				
			||||||
                if (spi0clk < 0){
 | 
					                if (spi1clk < 0){
 | 
				
			||||||
                    LOG_DEBUG(GwLog::ERROR,"SPI bus 1 not configured, cannot create %s",sensor->prefix.c_str());
 | 
					                    LOG_DEBUG(GwLog::ERROR,"SPI bus 1 not configured, cannot create %s",sensor->prefix.c_str());
 | 
				
			||||||
                }
 | 
					                }
 | 
				
			||||||
                else{
 | 
					                else{
 | 
				
			||||||
                    if (bus1.init(logger,spi0mosi,spi0miso,spi0clk)){
 | 
					                    if (bus1.init(logger,spi1mosi,spi1miso,spi1clk)){
 | 
				
			||||||
                        buses[busId]=&bus1;
 | 
					                        buses[busId]=&bus1;
 | 
				
			||||||
                    }
 | 
					                    }
 | 
				
			||||||
                }
 | 
					                }
 | 
				
			||||||
                break;
 | 
					                break;
 | 
				
			||||||
            case GWSPI1_HOST:
 | 
					            case GWSPI2_HOST:
 | 
				
			||||||
                if (spi1clk < 0){
 | 
					                if (spi2clk < 0){
 | 
				
			||||||
                    LOG_DEBUG(GwLog::ERROR,"SPI bus 2 not configured, cannot create %s",sensor->prefix.c_str());
 | 
					                    LOG_DEBUG(GwLog::ERROR,"SPI bus 2 not configured, cannot create %s",sensor->prefix.c_str());
 | 
				
			||||||
                }
 | 
					                }
 | 
				
			||||||
                else{
 | 
					                else{
 | 
				
			||||||
                    if (bus2.init(logger,spi1mosi,spi1miso,spi1clk)){
 | 
					                    if (bus2.init(logger,spi2mosi,spi2miso,spi2clk)){
 | 
				
			||||||
                        buses[busId]=&bus2;
 | 
					                        buses[busId]=&bus2;
 | 
				
			||||||
                    }
 | 
					                    }
 | 
				
			||||||
                }
 | 
					                }
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -428,6 +428,78 @@ types:
 | 
				
			||||||
            values: 
 | 
					            values: 
 | 
				
			||||||
              - key: true
 | 
					              - key: true
 | 
				
			||||||
                value: GWBME280#busname#2
 | 
					                value: GWBME280#busname#2
 | 
				
			||||||
 | 
					  
 | 
				
			||||||
 | 
					  - &spisensors
 | 
				
			||||||
 | 
					    type: checkbox
 | 
				
			||||||
 | 
					    label: "SPI/SSI #busname#"
 | 
				
			||||||
 | 
					    key: "spi#busname#"
 | 
				
			||||||
 | 
					    description: "SPI(SSI) Bus #busname#"
 | 
				
			||||||
 | 
					    values:
 | 
				
			||||||
 | 
					      - key: true
 | 
				
			||||||
 | 
					        children:
 | 
				
			||||||
 | 
					          - <<: *gpiopin
 | 
				
			||||||
 | 
					            label: CLK
 | 
				
			||||||
 | 
					            key: clk
 | 
				
			||||||
 | 
					            mandatory: true
 | 
				
			||||||
 | 
					            target: "define:GWSPI#bus#_CLK"
 | 
				
			||||||
 | 
					          - <<: *gpiopin
 | 
				
			||||||
 | 
					            label: MISO
 | 
				
			||||||
 | 
					            key: miso
 | 
				
			||||||
 | 
					            mandatory: false
 | 
				
			||||||
 | 
					            target: "define:GWSPI#bus#_MISO"
 | 
				
			||||||
 | 
					          - <<: *gpiopin
 | 
				
			||||||
 | 
					            label: MOSI
 | 
				
			||||||
 | 
					            key: mosi
 | 
				
			||||||
 | 
					            mandatory: false
 | 
				
			||||||
 | 
					            target: "define:GWSPI#bus#_MOSI"
 | 
				
			||||||
 | 
					            description: "GPIO pin for MOSI, not necessary for SSI"
 | 
				
			||||||
 | 
					          - type: checkbox
 | 
				
			||||||
 | 
					            label: GWDMS22B-#busname#-1
 | 
				
			||||||
 | 
					            description: "DMS22B rotatory encoder (SSI)"
 | 
				
			||||||
 | 
					            key: dms22b#busname#1
 | 
				
			||||||
 | 
					            target: define
 | 
				
			||||||
 | 
					            url: "https://www.mouser.de/datasheet/2/54/bour_s_a0011704065_1-2262614.pdf"
 | 
				
			||||||
 | 
					            values: 
 | 
				
			||||||
 | 
					              - key: true
 | 
				
			||||||
 | 
					                value: GWDMS22B#busname#1
 | 
				
			||||||
 | 
					                children:
 | 
				
			||||||
 | 
					                  - <<: *gpiopin
 | 
				
			||||||
 | 
					                    label: CS
 | 
				
			||||||
 | 
					                    key: dms22b#busname#1cs
 | 
				
			||||||
 | 
					                    description: "chip select pin, only necessary for multiple devices on this bus"
 | 
				
			||||||
 | 
					                    target: "define:GWDMS22B#busname#1_CS"
 | 
				
			||||||
 | 
					          - type: checkbox
 | 
				
			||||||
 | 
					            label: GWDMS22B-#busname#-2
 | 
				
			||||||
 | 
					            description: "DMS22B rotatory encoder (SSI)"
 | 
				
			||||||
 | 
					            key: dms22b#busname#2
 | 
				
			||||||
 | 
					            target: define
 | 
				
			||||||
 | 
					            url: "https://www.mouser.de/datasheet/2/54/bour_s_a0011704065_1-2262614.pdf"
 | 
				
			||||||
 | 
					            values: 
 | 
				
			||||||
 | 
					              - key: true
 | 
				
			||||||
 | 
					                value: GWDMS22B#busname#2
 | 
				
			||||||
 | 
					                children:
 | 
				
			||||||
 | 
					                  - <<: *gpiopin
 | 
				
			||||||
 | 
					                    label: CS
 | 
				
			||||||
 | 
					                    key: dms22b#busname#2cs
 | 
				
			||||||
 | 
					                    description: "chip select pin, only necessary for multiple devices on this bus"
 | 
				
			||||||
 | 
					                    target: "define:GWDMS22B#busname#2_CS"
 | 
				
			||||||
 | 
					          - type: checkbox
 | 
				
			||||||
 | 
					            label: GWDMS22B-#busname#-3
 | 
				
			||||||
 | 
					            description: "DMS22B rotatory encoder (SSI)"
 | 
				
			||||||
 | 
					            key: dms22b#busname#3
 | 
				
			||||||
 | 
					            target: define
 | 
				
			||||||
 | 
					            url: "https://www.mouser.de/datasheet/2/54/bour_s_a0011704065_1-2262614.pdf"
 | 
				
			||||||
 | 
					            values: 
 | 
				
			||||||
 | 
					              - key: true
 | 
				
			||||||
 | 
					                value: GWDMS22B#busname#3
 | 
				
			||||||
 | 
					                children:
 | 
				
			||||||
 | 
					                  - <<: *gpiopin
 | 
				
			||||||
 | 
					                    label: CS
 | 
				
			||||||
 | 
					                    key: dms22b#busname#3cs
 | 
				
			||||||
 | 
					                    description: "chip select pin, only necessary for multiple devices on this bus"
 | 
				
			||||||
 | 
					                    target: "define:GWDMS22B#busname#3_CS"
 | 
				
			||||||
 | 
					  
 | 
				
			||||||
 | 
					  
 | 
				
			||||||
  - &m5protochildren
 | 
					  - &m5protochildren
 | 
				
			||||||
      - *serial1
 | 
					      - *serial1
 | 
				
			||||||
      - *serial2
 | 
					      - *serial2
 | 
				
			||||||
| 
						 | 
					@ -440,7 +512,14 @@ types:
 | 
				
			||||||
        base: 
 | 
					        base: 
 | 
				
			||||||
          busname: "2"
 | 
					          busname: "2"
 | 
				
			||||||
          bus: "2"
 | 
					          bus: "2"
 | 
				
			||||||
        
 | 
					      - <<: *spisensors
 | 
				
			||||||
 | 
					        base:
 | 
				
			||||||
 | 
					          busname: "1"
 | 
				
			||||||
 | 
					          bus: "1"
 | 
				
			||||||
 | 
					      - <<: *spisensors
 | 
				
			||||||
 | 
					        base:
 | 
				
			||||||
 | 
					          busname: "2"
 | 
				
			||||||
 | 
					          bus: "2"        
 | 
				
			||||||
 | 
					
 | 
				
			||||||
                
 | 
					                
 | 
				
			||||||
  - &m5base
 | 
					  - &m5base
 | 
				
			||||||
| 
						 | 
					@ -538,5 +617,13 @@ config:
 | 
				
			||||||
                bus: ""
 | 
					                bus: ""
 | 
				
			||||||
            - <<: *iicsensors
 | 
					            - <<: *iicsensors
 | 
				
			||||||
              base: 
 | 
					              base: 
 | 
				
			||||||
 | 
					                busname: "2"
 | 
				
			||||||
 | 
					                bus: "2"
 | 
				
			||||||
 | 
					            - <<: *spisensors
 | 
				
			||||||
 | 
					              base:
 | 
				
			||||||
 | 
					                busname: "1"
 | 
				
			||||||
 | 
					                bus: "1"
 | 
				
			||||||
 | 
					            - <<: *spisensors
 | 
				
			||||||
 | 
					              base:
 | 
				
			||||||
                busname: "2"
 | 
					                busname: "2"
 | 
				
			||||||
                bus: "2"
 | 
					                bus: "2"
 | 
				
			||||||
		Loading…
	
		Reference in New Issue