generate the grove #defines to easily handle multiple groves
This commit is contained in:
parent
b091d9aee4
commit
3513175b5d
|
@ -22,6 +22,8 @@ CFG_INCLUDE='GwConfigDefinitions.h'
|
|||
CFG_INCLUDE_IMPL='GwConfigDefImpl.h'
|
||||
XDR_INCLUDE='GwXdrTypeMappings.h'
|
||||
TASK_INCLUDE='GwUserTasks.h'
|
||||
GROVE_CONFIG="GwM5GroveGen.h"
|
||||
GROVE_CONFIG_IN="lib/hardware/GwM5Grove.in"
|
||||
EMBEDDED_INCLUDE="GwEmbeddedFiles.h"
|
||||
|
||||
def getEmbeddedFiles(env):
|
||||
|
@ -74,7 +76,7 @@ def generateFile(infile,outfile,callback,inMode='rb',outMode='w'):
|
|||
print("creating %s"%outfile)
|
||||
oh=None
|
||||
with open(infile,inMode) as ch:
|
||||
with open(outfile,'w') as oh:
|
||||
with open(outfile,outMode) as oh:
|
||||
try:
|
||||
callback(ch,oh,inFile=infile)
|
||||
oh.close()
|
||||
|
@ -263,6 +265,41 @@ def generateXdrMappings(fp,oh,inFile=''):
|
|||
oh.write(" #define %s %s\n"%(define,str(v)))
|
||||
idx+=1
|
||||
|
||||
class Grove:
|
||||
def __init__(self,name) -> None:
|
||||
self.name=name
|
||||
def _ss(self,z=False):
|
||||
if z:
|
||||
return self.name
|
||||
return self.name if self.name is not 'Z' else ''
|
||||
def _suffix(self):
|
||||
return '_'+self.name if self.name is not 'Z' else ''
|
||||
def replace(self,line):
|
||||
if line is None:
|
||||
return line
|
||||
return line.replace('$G$',self._ss()).replace('$Z$',self._ss(True)).replace('$GS$',self._suffix())
|
||||
def generateGroveDefs(inh,outh,inFile=''):
|
||||
GROVES=[Grove('Z'),Grove('A'),Grove('B'),Grove('C')]
|
||||
definition=[]
|
||||
started=False
|
||||
def writeConfig():
|
||||
for grove in GROVES:
|
||||
for cl in definition:
|
||||
outh.write(grove.replace(cl))
|
||||
|
||||
for line in inh:
|
||||
if re.match(" *#GROVE",line):
|
||||
started=True
|
||||
if len(definition) > 0:
|
||||
writeConfig()
|
||||
definition=[]
|
||||
continue
|
||||
if started:
|
||||
definition.append(line)
|
||||
if len(definition) > 0:
|
||||
writeConfig()
|
||||
|
||||
|
||||
|
||||
userTaskDirs=[]
|
||||
|
||||
|
@ -423,6 +460,7 @@ def prebuild(env):
|
|||
generateEmbedded(filedefs,os.path.join(outPath(),EMBEDDED_INCLUDE))
|
||||
genereateUserTasks(os.path.join(outPath(), TASK_INCLUDE))
|
||||
generateFile(os.path.join(basePath(),XDR_FILE),os.path.join(outPath(),XDR_INCLUDE),generateXdrMappings)
|
||||
generateFile(os.path.join(basePath(),GROVE_CONFIG_IN),os.path.join(outPath(),GROVE_CONFIG),generateGroveDefs,inMode='r')
|
||||
version="dev"+datetime.now().strftime("%Y%m%d")
|
||||
env.Append(CPPDEFINES=[('GWDEVVERSION',version)])
|
||||
|
||||
|
|
|
@ -33,16 +33,16 @@
|
|||
#define GWRESOURCE_USE(RES,USER) \
|
||||
__MSG(#RES " used by " #USER) \
|
||||
static int _resourceUsed ## RES =1;
|
||||
#define __USAGE __MSG
|
||||
#else
|
||||
#define GWRESOURCE_USE(...)
|
||||
#define __USAGE(...)
|
||||
#endif
|
||||
|
||||
#ifndef CFG_INIT
|
||||
#define CFG_INIT(...)
|
||||
#endif
|
||||
#ifndef GROOVE_IIC
|
||||
#define GROOVE_IIC(...)
|
||||
#endif
|
||||
|
||||
//general definitions for M5AtomLite
|
||||
//hint for groove pins:
|
||||
//according to some schematics the numbering is 1,2,3(VCC),4(GND)
|
||||
|
@ -162,265 +162,14 @@
|
|||
#define GWBUTTON_PULLUPDOWN
|
||||
#endif
|
||||
|
||||
//M5 Serial (Atomic RS232 Base)
|
||||
#ifdef M5_SERIAL_KIT_232
|
||||
GWRESOURCE_USE(BASE,M5_SERIAL_KIT_232)
|
||||
GWRESOURCE_USE(SERIAL1,M5_SERIAL_KIT_232)
|
||||
#define _GWI_SERIAL1 BOARD_LEFT1,BOARD_LEFT2,GWSERIAL_TYPE_BI
|
||||
#endif
|
||||
#include "GwM5Base.h"
|
||||
#include "GwM5Grove.h"
|
||||
|
||||
//M5 Serial (Atomic RS485 Base)
|
||||
#ifdef M5_SERIAL_KIT_485
|
||||
GWRESOURCE_USE(BASE,M5_SERIAL_KIT_485)
|
||||
GWRESOURCE_USE(SERIAL1,M5_SERIAL_KIT_485)
|
||||
#define _GWI_SERIAL1 BOARD_LEFT1,BOARD_LEFT2,GWSERIAL_TYPE_UNI
|
||||
#endif
|
||||
//M5 GPS (Atomic GPS Base)
|
||||
#ifdef M5_GPS_KIT
|
||||
GWRESOURCE_USE(BASE,M5_GPS_KIT)
|
||||
GWRESOURCE_USE(SERIAL1,M5_GPS_KIT)
|
||||
#define _GWI_SERIAL1 BOARD_LEFT1,-1,GWSERIAL_TYPE_UNI,"9600"
|
||||
#endif
|
||||
|
||||
//M5 ProtoHub
|
||||
#ifdef M5_PROTO_HUB
|
||||
GWRESOURCE_USE(BASE,M5_PROTO_HUB)
|
||||
#define PPIN22 BOARD_LEFT1
|
||||
#define PPIN19 BOARD_LEFT2
|
||||
#define PPIN23 BOARD_LEFT3
|
||||
#define PPIN33 BOARD_LEFT4
|
||||
#define PPIN21 BOARD_RIGHT1
|
||||
#define PPIN25 BOARD_RIGHT2
|
||||
#endif
|
||||
|
||||
//M5 PortABC extension
|
||||
#ifdef M5_PORTABC
|
||||
GWRESOURCE_USE(BASE,M5_PORTABC)
|
||||
#define GROOVEA_PIN_2 BOARD_RIGHT2
|
||||
#define GROOVEA_PIN_1 BOARD_RIGHT1
|
||||
#define GROOVEB_PIN_2 BOARD_LEFT3
|
||||
#define GROOVEB_PIN_1 BOARD_LEFT4
|
||||
#define GROOVEC_PIN_2 BOARD_LEFT1
|
||||
#define GROOVEC_PIN_1 BOARD_LEFT2
|
||||
#endif
|
||||
|
||||
//below we define the final device config based on the above
|
||||
//boards and peripherals
|
||||
//this allows us to easily also set them from outside
|
||||
//serial adapter at the M5 groove pins
|
||||
//we use serial2 for groove serial if serial1 is already defined
|
||||
//before (e.g. by serial kit)
|
||||
#ifdef SERIAL_GROOVE_485
|
||||
GWRESOURCE_USE(GROOVE,SERIAL_GROOVE_485)
|
||||
#define _GWI_SERIAL_GROOVE GWSERIAL_TYPE_UNI
|
||||
#endif
|
||||
#ifdef SERIAL_GROOVE_485_A
|
||||
GWRESOURCE_USE(GROOVEA,SERIAL_GROOVE_485_A)
|
||||
#define _GWI_SERIAL_GROOVE_A GWSERIAL_TYPE_UNI
|
||||
#endif
|
||||
#ifdef SERIAL_GROOVE_485_B
|
||||
GWRESOURCE_USE(GROOVEB,SERIAL_GROOVE_485_B)
|
||||
#define _GWI_SERIAL_GROOVE_B GWSERIAL_TYPE_UNI
|
||||
#endif
|
||||
#ifdef SERIAL_GROOVE_485_C
|
||||
GWRESOURCE_USE(GROOVEC,SERIAL_GROOVE_485_C)
|
||||
#define _GWI_SERIAL_GROOVE_C GWSERIAL_TYPE_UNI
|
||||
#endif
|
||||
#ifdef SERIAL_GROOVE_232
|
||||
GWRESOURCE_USE(GROOVE,SERIAL_GROOVE_232)
|
||||
#define _GWI_SERIAL_GROOVE GWSERIAL_TYPE_BI
|
||||
#endif
|
||||
#ifdef SERIAL_GROOVE_232_A
|
||||
GWRESOURCE_USE(GROOVEA,SERIAL_GROOVE_232_A)
|
||||
#define _GWI_SERIAL_GROOVE_A GWSERIAL_TYPE_BI
|
||||
#endif
|
||||
#ifdef SERIAL_GROOVE_232_B
|
||||
GWRESOURCE_USE(GROOVEB,SERIAL_GROOVE_232_B)
|
||||
#define _GWI_SERIAL_GROOVE_B GWSERIAL_TYPE_BI
|
||||
#endif
|
||||
#ifdef SERIAL_GROOVE_232_C
|
||||
GWRESOURCE_USE(GROOVEC,SERIAL_GROOVE_232_C)
|
||||
#define _GWI_SERIAL_GROOVE_C GWSERIAL_TYPE_BI
|
||||
#endif
|
||||
|
||||
|
||||
|
||||
|
||||
//http://docs.m5stack.com/en/unit/gps
|
||||
#ifdef M5_GPS_UNIT
|
||||
GWRESOURCE_USE(GROOVE,M5_GPS_UNIT)
|
||||
#define _GWI_SERIAL_GROOVE GWSERIAL_TYPE_RX,"9600"
|
||||
#endif
|
||||
#ifdef M5_GPS_UNIT_A
|
||||
GWRESOURCE_USE(GROOVEA,M5_GPS_UNIT_A)
|
||||
#define _GWI_SERIAL_GROOVE_A GWSERIAL_TYPE_RX,"9600"
|
||||
#endif
|
||||
#ifdef M5_GPS_UNIT_B
|
||||
GWRESOURCE_USE(GROOVEB,M5_GPS_UNIT_B)
|
||||
#define _GWI_SERIAL_GROOVE_B GWSERIAL_TYPE_RX,"9600"
|
||||
#endif
|
||||
#ifdef M5_GPS_UNIT_C
|
||||
GWRESOURCE_USE(GROOVEC,M5_GPS_UNIT)
|
||||
#define _GWI_SERIAL_GROOVE_C GWSERIAL_TYPE_RX,"9600"
|
||||
#endif
|
||||
|
||||
|
||||
|
||||
|
||||
//can kit for M5 Atom
|
||||
#ifdef M5_CAN_KIT
|
||||
GWRESOURCE_USE(BASE,M5_CAN_KIT)
|
||||
GWRESOURCE_USE(CAN,M5_CANKIT)
|
||||
#define ESP32_CAN_TX_PIN BOARD_LEFT1
|
||||
#define ESP32_CAN_RX_PIN BOARD_LEFT2
|
||||
#endif
|
||||
//CAN via groove
|
||||
#ifdef M5_CANUNIT
|
||||
GWRESOURCE_USE(GROOVE,M5_CANUNIT)
|
||||
GWRESOURCE_USE(CAN,M5_CANUNIT)
|
||||
#define ESP32_CAN_TX_PIN GROOVE_PIN_2
|
||||
#define ESP32_CAN_RX_PIN GROOVE_PIN_1
|
||||
#endif
|
||||
|
||||
#ifdef M5_CANUNIT_A
|
||||
GWRESOURCE_USE(GROOVEA,M5_CANUNIT_A)
|
||||
GWRESOURCE_USE(CAN,M5_CANUNIT_A)
|
||||
#define ESP32_CAN_TX_PIN GROOVEA_PIN_2
|
||||
#define ESP32_CAN_RX_PIN GROOVEA_PIN_1
|
||||
#endif
|
||||
#ifdef M5_CANUNIT_B
|
||||
GWRESOURCE_USE(GROOVEB,M5_CANUNIT_B)
|
||||
GWRESOURCE_USE(CAN,M5_CANUNIT_B)
|
||||
#define ESP32_CAN_TX_PIN GROOVEB_PIN_2
|
||||
#define ESP32_CAN_RX_PIN GROOVEA_PIN_1
|
||||
#endif
|
||||
#ifdef M5_CANUNIT_C
|
||||
GWRESOURCE_USE(GROOVEC,M5_CANUNIT_C)
|
||||
GWRESOURCE_USE(CAN,M5_CANUNIT_C)
|
||||
#define ESP32_CAN_TX_PIN GROOVEC_PIN_2
|
||||
#define ESP32_CAN_RX_PIN GROOVEC_PIN_1
|
||||
#endif
|
||||
|
||||
|
||||
#ifdef M5_ENV3
|
||||
#ifndef M5_GROOVEIIC
|
||||
#define M5_GROOVEIIC
|
||||
#endif
|
||||
GROOVE_IIC(SHT3X,Z,1)
|
||||
GROOVE_IIC(QMP6988,Z,1)
|
||||
#define _GWSHT3X
|
||||
#define _GWQMP6988
|
||||
#endif
|
||||
#ifdef M5_ENV3_A
|
||||
#ifndef M5_GROOVEIIC_A
|
||||
#define M5_GROOVEIIC_A
|
||||
#endif
|
||||
GROOVE_IIC(SHT3X,A,1)
|
||||
GROOVE_IIC(QMP6988,A,1)
|
||||
#define _GWSHT3X
|
||||
#define _GWQMP6988
|
||||
#endif
|
||||
#ifdef M5_ENV3_B
|
||||
#ifndef M5_GROOVEIIC_B
|
||||
#define M5_GROOVEIIC_B
|
||||
#endif
|
||||
GROOVE_IIC(SHT3X,B,1)
|
||||
GROOVE_IIC(QMP6988,B,1)
|
||||
#define _GWSHT3X
|
||||
#define _GWQMP6988
|
||||
#endif
|
||||
#ifdef M5_ENV3_C
|
||||
#ifndef M5_GROOVEIIC_C
|
||||
#define M5_GROOVEIIC_C
|
||||
#endif
|
||||
GROOVE_IIC(SHT3X,C,1)
|
||||
GROOVE_IIC(QMP6988,C,1)
|
||||
#define _GWSHT3X
|
||||
#define _GWQMP6988
|
||||
#endif
|
||||
|
||||
#ifdef M5_GROOVEIIC
|
||||
GWRESOURCE_USE(GROOVE,M5_GROOVEIIC)
|
||||
#ifndef _GWI_IIC1
|
||||
#define _GWI_IIC1 "Z",GROOVE_PIN_1,GROOVE_PIN_2
|
||||
#elif ! defined(_GWI_IIC2)
|
||||
#define _GWI_IIC2 "Z",GROOVE_PIN_1,GROOVE_PIN_2
|
||||
#else
|
||||
#error "both iic buses already in use"
|
||||
#endif
|
||||
#endif
|
||||
#ifdef M5_GROOVEIIC_A
|
||||
GWRESOURCE_USE(GROOVA,M5_GROOVEIIC_A)
|
||||
#ifndef _GWI_IIC1
|
||||
#define _GWI_IIC1 A,GROOVEA_PIN_1,GROOVEA_PIN_2
|
||||
#elif ! defined(_GWI_IIC2)
|
||||
#define _GWI_IIC2 A,GROOVEA_PIN_1,GROOVEA_PIN_2
|
||||
#else
|
||||
#error "both iic buses already in use"
|
||||
#endif
|
||||
#endif
|
||||
#ifdef M5_GROOVEIIC_B
|
||||
GWRESOURCE_USE(GROOVB,M5_GROOVEIIC_B)
|
||||
#ifndef _GWI_IIC1
|
||||
#define _GWI_IIC1 B,GROOVEB_PIN_1,GROOVEB_PIN_2
|
||||
#elif ! defined(_GWI_IIC2)
|
||||
#define _GWI_IIC2 B,GROOVEB_PIN_1,GROOVEB_PIN_2
|
||||
#else
|
||||
#error "both iic buses already in use"
|
||||
#endif
|
||||
#endif
|
||||
#ifdef M5_GROOVEIIC_C
|
||||
GWRESOURCE_USE(GROOVC,M5_GROOVEIIC_C)
|
||||
#ifndef _GWI_IIC1
|
||||
#define _GWI_IIC1 C,GROOVEC_PIN_1,GROOVEC_PIN_2
|
||||
#elif ! defined(_GWI_IIC2)
|
||||
#define _GWI_IIC2 C,GROOVEC_PIN_1,GROOVEC_PIN_2
|
||||
#else
|
||||
#error "both iic buses already in use"
|
||||
#endif
|
||||
#endif
|
||||
#if defined(_GWI_IIC1) || defined (_GWI_IIC2)
|
||||
#define _GWIIC
|
||||
#endif
|
||||
|
||||
#ifdef _GWI_SERIAL_GROOVE
|
||||
#ifndef _GWI_SERIAL1
|
||||
#define _GWI_SERIAL1 GROOVE_PIN_1,GROOVE_PIN_2,_GWI_SERIAL_GROOVE
|
||||
#elif ! defined(_GWI_SERIAL2)
|
||||
#define _GWI_SERIAL2 GROOVE_PIN_1,GROOVE_PIN_2,_GWI_SERIAL_GROOVE
|
||||
#else
|
||||
#error "both serial devices already in use"
|
||||
#endif
|
||||
#endif
|
||||
#ifdef _GWI_SERIAL_GROOVE_A
|
||||
#ifndef _GWI_SERIAL1
|
||||
#define _GWI_SERIAL1 GROOVEA_PIN_1,GROOVEA_PIN_2,_GWI_SERIAL_GROOVE_A
|
||||
#elif ! defined(_GWI_SERIAL2)
|
||||
#define _GWI_SERIAL2 GROOVEA_PIN_1,GROOVEA_PIN_2,_GWI_SERIAL_GROOVE_A
|
||||
#else
|
||||
#error "both serial devices already in use"
|
||||
#endif
|
||||
#endif
|
||||
#ifdef _GWI_SERIAL_GROOVE_B
|
||||
#ifndef _GWI_SERIAL1
|
||||
#define _GWI_SERIAL1 GROOVEB_PIN_1,GROOVEB_PIN_2,_GWI_SERIAL_GROOVE_B
|
||||
#elif ! defined(_GWI_SERIAL2)
|
||||
#define _GWI_SERIAL2 GROOVEB_PIN_1,GROOVEB_PIN_2,_GWI_SERIAL_GROOVE_B
|
||||
#else
|
||||
#error "both serial devices already in use"
|
||||
#endif
|
||||
#endif
|
||||
#ifdef _GWI_SERIAL_GROOVE_C
|
||||
#ifndef _GWI_SERIAL1
|
||||
#define _GWI_SERIAL1 GROOVEC_PIN_1,GROOVEC_PIN_2,_GWI_SERIAL_GROOVE_C
|
||||
#elif ! defined(_GWI_SERIAL2)
|
||||
#define _GWI_SERIAL2 GROOVEC_PIN_1,GROOVEC_PIN_2,_GWI_SERIAL_GROOVE_C
|
||||
#else
|
||||
#error "both serial devices already in use"
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#ifdef GWIIC_SDA
|
||||
#ifdef _GWI_IIC1
|
||||
#error "you must not define IIC1 on grove and GWIIC_SDA"
|
||||
#endif
|
||||
#ifndef GWIIC_SCL
|
||||
#error "you must both define GWIIC_SDA and GWIIC_SCL"
|
||||
#endif
|
||||
|
@ -432,6 +181,9 @@
|
|||
#define _GWIIC
|
||||
#endif
|
||||
#ifdef GWIIC_SDA2
|
||||
#ifdef _GWI_IIC2
|
||||
#error "you must not define IIC2 on grove and GWIIC_SDA2"
|
||||
#endif
|
||||
#ifndef GWIIC_SCL2
|
||||
#error "you must both define GWIIC_SDA2 and GWIIC_SCL2"
|
||||
#endif
|
||||
|
|
|
@ -0,0 +1,71 @@
|
|||
/*
|
||||
This code is free software; you can redistribute it and/or
|
||||
modify it under the terms of the GNU Lesser General Public
|
||||
License as published by the Free Software Foundation; either
|
||||
version 2.1 of the License, or (at your option) any later version.
|
||||
This code is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
Lesser General Public License for more details.
|
||||
You should have received a copy of the GNU Lesser General Public
|
||||
License along with this library; if not, write to the Free Software
|
||||
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
|
||||
unfortunately there is some typo here: M5 uses GROVE for their connections
|
||||
but we have GROOVE here.
|
||||
But to maintain compatibility to older build commands we keep the (wrong) wording
|
||||
*/
|
||||
//M5 Base Boards
|
||||
#ifndef _GWM5BASE_H
|
||||
#define _GWM5BASE_H
|
||||
//M5 Serial (Atomic RS232 Base)
|
||||
#ifdef M5_SERIAL_KIT_232
|
||||
GWRESOURCE_USE(BASE,M5_SERIAL_KIT_232)
|
||||
GWRESOURCE_USE(SERIAL1,M5_SERIAL_KIT_232)
|
||||
#define _GWI_SERIAL1 BOARD_LEFT1,BOARD_LEFT2,GWSERIAL_TYPE_BI
|
||||
#endif
|
||||
|
||||
//M5 Serial (Atomic RS485 Base)
|
||||
#ifdef M5_SERIAL_KIT_485
|
||||
GWRESOURCE_USE(BASE,M5_SERIAL_KIT_485)
|
||||
GWRESOURCE_USE(SERIAL1,M5_SERIAL_KIT_485)
|
||||
#define _GWI_SERIAL1 BOARD_LEFT1,BOARD_LEFT2,GWSERIAL_TYPE_UNI
|
||||
#endif
|
||||
//M5 GPS (Atomic GPS Base)
|
||||
#ifdef M5_GPS_KIT
|
||||
GWRESOURCE_USE(BASE,M5_GPS_KIT)
|
||||
GWRESOURCE_USE(SERIAL1,M5_GPS_KIT)
|
||||
#define _GWI_SERIAL1 BOARD_LEFT1,-1,GWSERIAL_TYPE_UNI,"9600"
|
||||
#endif
|
||||
|
||||
//M5 ProtoHub
|
||||
#ifdef M5_PROTO_HUB
|
||||
GWRESOURCE_USE(BASE,M5_PROTO_HUB)
|
||||
#define PPIN22 BOARD_LEFT1
|
||||
#define PPIN19 BOARD_LEFT2
|
||||
#define PPIN23 BOARD_LEFT3
|
||||
#define PPIN33 BOARD_LEFT4
|
||||
#define PPIN21 BOARD_RIGHT1
|
||||
#define PPIN25 BOARD_RIGHT2
|
||||
#endif
|
||||
|
||||
//M5 PortABC extension
|
||||
#ifdef M5_PORTABC
|
||||
GWRESOURCE_USE(BASE,M5_PORTABC)
|
||||
#define GROOVEA_PIN_2 BOARD_RIGHT2
|
||||
#define GROOVEA_PIN_1 BOARD_RIGHT1
|
||||
#define GROOVEB_PIN_2 BOARD_LEFT3
|
||||
#define GROOVEB_PIN_1 BOARD_LEFT4
|
||||
#define GROOVEC_PIN_2 BOARD_LEFT1
|
||||
#define GROOVEC_PIN_1 BOARD_LEFT2
|
||||
#endif
|
||||
|
||||
//can kit for M5 Atom
|
||||
#ifdef M5_CAN_KIT
|
||||
GWRESOURCE_USE(BASE,M5_CAN_KIT)
|
||||
GWRESOURCE_USE(CAN,M5_CANKIT)
|
||||
#define ESP32_CAN_TX_PIN BOARD_LEFT1
|
||||
#define ESP32_CAN_RX_PIN BOARD_LEFT2
|
||||
#endif
|
||||
|
||||
#endif
|
|
@ -0,0 +1,31 @@
|
|||
/*
|
||||
This code is free software; you can redistribute it and/or
|
||||
modify it under the terms of the GNU Lesser General Public
|
||||
License as published by the Free Software Foundation; either
|
||||
version 2.1 of the License, or (at your option) any later version.
|
||||
This code is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
Lesser General Public License for more details.
|
||||
You should have received a copy of the GNU Lesser General Public
|
||||
License along with this library; if not, write to the Free Software
|
||||
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
|
||||
unfortunately there is some typo here: M5 uses GROVE for their connections
|
||||
but we have GROOVE here.
|
||||
But to maintain compatibility to older build commands we keep the (wrong) wording
|
||||
*/
|
||||
//M5 Grove stuff
|
||||
#ifndef _GW5MGROVE_H
|
||||
#define _GW5MGROVE_H
|
||||
#ifndef GROOVE_IIC
|
||||
#define GROOVE_IIC(...)
|
||||
#endif
|
||||
#include "GwM5GroveGen.h"
|
||||
|
||||
#if defined(_GWI_IIC1) || defined (_GWI_IIC2)
|
||||
#define _GWIIC
|
||||
#endif
|
||||
|
||||
|
||||
#endif
|
|
@ -0,0 +1,145 @@
|
|||
/*
|
||||
This code is free software; you can redistribute it and/or
|
||||
modify it under the terms of the GNU Lesser General Public
|
||||
License as published by the Free Software Foundation; either
|
||||
version 2.1 of the License, or (at your option) any later version.
|
||||
This code is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
Lesser General Public License for more details.
|
||||
You should have received a copy of the GNU Lesser General Public
|
||||
License along with this library; if not, write to the Free Software
|
||||
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
|
||||
unfortunately there is some typo here: M5 uses GROVE for their connections
|
||||
but we have GROOVE here.
|
||||
But to maintain compatibility to older build commands we keep the (wrong) wording
|
||||
|
||||
This file contains M5 grove definitions.
|
||||
They will be expanded to match the supported groves
|
||||
|
||||
Each definition must start with a line start starts with #GROVE
|
||||
Afterwards you can use normal C header style
|
||||
$GS$ will be replaced with a grove suffix with _ (empty for first)
|
||||
$G$ will be replaced by the simple grove name (empty for base)
|
||||
$Z$ will be replaced by the simple name using "Z" for the first grove
|
||||
*/
|
||||
#GROVE
|
||||
#ifdef SERIAL_GROOVE_485$GS$
|
||||
GWRESOURCE_USE(GROOVE$G$,SERIAL_GROOVE_485$GS$)
|
||||
#define _GWI_SERIAL_GROOVE$GS$ GWSERIAL_TYPE_UNI
|
||||
#endif
|
||||
|
||||
#GROVE
|
||||
#ifdef SERIAL_GROOVE_232$GS$
|
||||
GWRESOURCE_USE(GROOVE$G$,SERIAL_GROOVE_232$GS$)
|
||||
#define _GWI_SERIAL_GROOVE$GS$ GWSERIAL_TYPE_BI
|
||||
#endif
|
||||
|
||||
#GROVE
|
||||
//http://docs.m5stack.com/en/unit/gps
|
||||
#ifdef M5_GPS_UNIT$GS$
|
||||
GWRESOURCE_USE(GROOVE$G$,M5_GPS_UNIT$GS$)
|
||||
#define _GWI_SERIAL_GROOVE$GS$ GWSERIAL_TYPE_RX,"9600"
|
||||
#endif
|
||||
|
||||
#GROVE
|
||||
//CAN via groove
|
||||
#ifdef M5_CANUNIT$GS$
|
||||
GWRESOURCE_USE(GROOVE$G$,M5_CANUNIT$GS$)
|
||||
GWRESOURCE_USE(CAN,M5_CANUNIT$GS$)
|
||||
#define ESP32_CAN_TX_PIN GROOVE$G$_PIN_2
|
||||
#define ESP32_CAN_RX_PIN GROOVE$G$_PIN_1
|
||||
#endif
|
||||
|
||||
#GROVE
|
||||
#ifdef M5_ENV3$GS$
|
||||
#ifndef M5_GROOVEIIC$GS$
|
||||
#define M5_GROOVEIIC$GS$
|
||||
#endif
|
||||
GROOVE_IIC(SHT3X,$Z$,1)
|
||||
GROOVE_IIC(QMP6988,$Z$,1)
|
||||
#define _GWSHT3X
|
||||
#define _GWQMP6988
|
||||
#endif
|
||||
|
||||
#GROVE
|
||||
//example: -DSHT3XG1_A : defines STH3Xn1 on grove A - x depends on the other devices
|
||||
#ifdef SHT3XG1$GS$
|
||||
#ifndef M5_GROOVEIIC$GS$
|
||||
#define M5_GROOVEIIC$GS$
|
||||
#endif
|
||||
GROOVE_IIC(SHT3X,$Z$,1)
|
||||
#define _GWSHT3X
|
||||
#endif
|
||||
|
||||
#GROVE
|
||||
#ifdef SHT3XG2$GS$
|
||||
#ifndef M5_GROOVEIIC$GS$
|
||||
#define M5_GROOVEIIC$GS$
|
||||
#endif
|
||||
GROOVE_IIC(SHT3X,$Z$,2)
|
||||
#define _GWSHT3X
|
||||
#endif
|
||||
|
||||
#GROVE
|
||||
#ifdef QMP6988G1$GS$
|
||||
#ifndef M5_GROOVEIIC$GS$
|
||||
#define M5_GROOVEIIC$GS$
|
||||
#endif
|
||||
GROOVE_IIC(QMP6988,$Z$,1)
|
||||
#define _GWQMP6988
|
||||
#endif
|
||||
|
||||
#GROVE
|
||||
#ifdef QMP6988G2$GS$
|
||||
#ifndef M5_GROOVEIIC$GS$
|
||||
#define M5_GROOVEIIC$GS$
|
||||
#endif
|
||||
GROOVE_IIC(QMP6988,$Z$,2)
|
||||
#define _GWQMP6988
|
||||
#endif
|
||||
|
||||
#GROVE
|
||||
#ifdef BME280G1$GS$
|
||||
#ifndef M5_GROOVEIIC$GS$
|
||||
#define M5_GROOVEIIC$GS$
|
||||
#endif
|
||||
GROOVE_IIC(BME280,$Z$,1)
|
||||
#define _GWBME280
|
||||
#endif
|
||||
|
||||
#GROVE
|
||||
#ifdef BME280G2$GS$
|
||||
#ifndef M5_GROOVEIIC$GS$
|
||||
#define M5_GROOVEIIC$GS$
|
||||
#endif
|
||||
GROOVE_IIC(BME280,$Z$,2)
|
||||
#define _GWBME280
|
||||
#endif
|
||||
|
||||
#GROVE
|
||||
//select up to 2 IIC devices for grove usage
|
||||
#ifdef M5_GROOVEIIC$GS$
|
||||
GWRESOURCE_USE(GROOVE$G$,M5_GROOVEIIC$GS$)
|
||||
#ifndef _GWI_IIC1
|
||||
__USAGE("IIC1 used by GROVE$GS$")
|
||||
#define _GWI_IIC1 "$Z$",GROOVE$G$_PIN_1,GROOVE$G$_PIN_2
|
||||
#elif ! defined(_GWI_IIC2)
|
||||
__USAGE("IIC2 used by GROVE$GS$")
|
||||
#define _GWI_IIC2 "$Z$",GROOVE$G$_PIN_1,GROOVE$G$_PIN_2
|
||||
#else
|
||||
#error "both iic buses already in use"
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#GROVE
|
||||
#ifdef _GWI_SERIAL_GROOVE$GS$
|
||||
#ifndef _GWI_SERIAL1
|
||||
#define _GWI_SERIAL1 GROOVE$G$_PIN_1,GROOVE$G$_PIN_2,_GWI_SERIAL_GROOVE$GS$
|
||||
#elif ! defined(_GWI_SERIAL2)
|
||||
#define _GWI_SERIAL2 GROOVE$G$_PIN_1,GROOVE$G$_PIN_2,_GWI_SERIAL_GROOVE$GS$
|
||||
#else
|
||||
#error "both serial devices already in use"
|
||||
#endif
|
||||
#endif
|
Loading…
Reference in New Issue