From c67d31ab8cc54c425a793dec65cec367ea3a61ee Mon Sep 17 00:00:00 2001 From: Dhinesh Kumar Pitchai Date: Tue, 25 Jun 2019 23:54:51 +0530 Subject: [PATCH] Fix #135: Added support for Catena 4617, 4618 and 4630 --- .travis.yml | 6 + README.md | 3 + src/Catena.h | 42 ++----- src/Catena4617.h | 66 +++++++++++ src/Catena4618.h | 66 +++++++++++ src/Catena4630.h | 63 +++++++++++ src/Catena463x.h | 106 ++++++++++++++++++ src/CatenaBase.h | 46 ++------ src/Catena_Guids.h | 62 ++++------ src/Catena_Platforms.h | 47 ++------ .../catena461x/Catena4617_ReadVoltage.cpp | 88 +++++++++++++++ .../Catena4617_getPlatformTable.cpp | 94 ++++++++++++++++ .../catena461x/Catena4618_ReadVoltage.cpp | 88 +++++++++++++++ .../Catena4618_getPlatformTable.cpp | 94 ++++++++++++++++ .../catena463x/Catena4630_ReadVoltage.cpp | 81 +++++++++++++ .../Catena4630_getPlatformTable.cpp | 91 +++++++++++++++ .../catena463x/Catena463x_LoRaWAN_begin.cpp | 68 +++++++++++ src/lib/stm32/catena463x/Catena463x_begin.cpp | 63 +++++++++++ 18 files changed, 1028 insertions(+), 146 deletions(-) create mode 100644 src/Catena4617.h create mode 100644 src/Catena4618.h create mode 100644 src/Catena4630.h create mode 100644 src/Catena463x.h create mode 100644 src/lib/stm32/catena461x/Catena4617_ReadVoltage.cpp create mode 100644 src/lib/stm32/catena461x/Catena4617_getPlatformTable.cpp create mode 100644 src/lib/stm32/catena461x/Catena4618_ReadVoltage.cpp create mode 100644 src/lib/stm32/catena461x/Catena4618_getPlatformTable.cpp create mode 100644 src/lib/stm32/catena463x/Catena4630_ReadVoltage.cpp create mode 100644 src/lib/stm32/catena463x/Catena4630_getPlatformTable.cpp create mode 100644 src/lib/stm32/catena463x/Catena463x_LoRaWAN_begin.cpp create mode 100644 src/lib/stm32/catena463x/Catena463x_begin.cpp diff --git a/.travis.yml b/.travis.yml index c0afda0..ce8effb 100644 --- a/.travis.yml +++ b/.travis.yml @@ -137,6 +137,12 @@ script: - _notstm32l0 || arduino --verify $(_stm32l0opts mcci_catena_4611) $THISLIB/examples/catena_hello/catena_hello_lora.ino - _notstm32l0 || arduino --verify $(_stm32l0opts mcci_catena_4612) $THISLIB/examples/catena_hello/catena_hello.ino - _notstm32l0 || arduino --verify $(_stm32l0opts mcci_catena_4612) $THISLIB/examples/catena_hello/catena_hello_lora.ino + - _notstm32l0 || arduino --verify $(_stm32l0opts mcci_catena_4617) $THISLIB/examples/catena_hello/catena_hello.ino + - _notstm32l0 || arduino --verify $(_stm32l0opts mcci_catena_4617) $THISLIB/examples/catena_hello/catena_hello_lora.ino + - _notstm32l0 || arduino --verify $(_stm32l0opts mcci_catena_4618) $THISLIB/examples/catena_hello/catena_hello.ino + - _notstm32l0 || arduino --verify $(_stm32l0opts mcci_catena_4618) $THISLIB/examples/catena_hello/catena_hello_lora.ino + - _notstm32l0 || arduino --verify $(_stm32l0opts mcci_catena_4630) $THISLIB/examples/catena_hello/catena_hello.ino + - _notstm32l0 || arduino --verify $(_stm32l0opts mcci_catena_4630) $THISLIB/examples/catena_hello/catena_hello_lora.ino - _notstm32l0 || arduino --verify $(_stm32l0opts mcci_catena_4801) $THISLIB/examples/catena_hello/catena_hello.ino - _notstm32l0 || arduino --verify $(_stm32l0opts mcci_catena_4801) $THISLIB/examples/catena_hello/catena_hello_lora.ino diff --git a/README.md b/README.md index d8ea356..e50c7b6 100644 --- a/README.md +++ b/README.md @@ -104,6 +104,9 @@ Class | Header File | Description `Catena4610` | `Catena4610.h` | MCCI Catena 4610 second-generation Murata-based board with LiPo charging `Catena4611` | `Catena4611.h` | MCCI Catena 4611 second-generation Murata-based board with fixed Vdd, no charging `Catena4612` | `Catena4612.h` | MCCI Catena 4612 second-generation Murata-based board with variable Vdd, no charging. +`Catena4617` | `Catena4617.h` | MCCI Catena 4617 second-generation Murata-based board with variable Vdd, no charging +`Catena4618` | `Catena4618.h` | MCCI Catena 4618 second-generation Murata-based board with variable Vdd, no charging. +`Catena4630` | `Catena4630.h` | MCCI Catena 4630 Murata-based board with Air Quality Sensor. `Catena4801` | `Catena4801.h` | MCCI Catena 4801 Murata-based board with Modbus. ### Class derivation diff --git a/src/Catena.h b/src/Catena.h index 4c2bcaf..011ebb7 100644 --- a/src/Catena.h +++ b/src/Catena.h @@ -1,43 +1,16 @@ -/* Catena.h Thu Nov 15 2018 15:06:41 chwon */ - /* Module: Catena.h Function: - class Catena: virtual CatenaBase derivative representing + class Catena: virtual CatenaBase derivative representing the target Catena for this build. -Version: - V0.11.0 Thu Nov 15 2018 15:06:42 chwon Edit level 4 - Copyright notice: - This file copyright (C) 2017-2018 by - - MCCI Corporation - 3520 Krums Corners Road - Ithaca, NY 14850 - - An unpublished work. All rights reserved. - - This file is proprietary information, and may not be disclosed or - copied without the prior permission of MCCI Corporation. + See accompanying LICENSE file. Author: - ChaeHee Won, MCCI Corporation October 2017 - -Revision history: - 0.6.0 Fri Oct 13 2017 15:19:30 chwon - Module created. - - 0.7.0 Wed Dec 13 2017 17:29:35 tmm - Refactor. - - 0.9.0 Sat Mar 31 2018 19:28:30 tmm - Add Catena 4460 support, use BSP symbols. - - 0.11.0 Thu Nov 15 2018 15:06:42 chwon - Add Catena 461x support. + ChaeHee Won, MCCI Corporation October 2017 */ @@ -76,6 +49,15 @@ Revision history: #elif defined(ARDUINO_MCCI_CATENA_4612) || defined(ARDUINO_CATENA_4612) # include "Catena4612.h" # define CATENA_H_SUPER_ McciCatena::Catena4612 +#elif defined(ARDUINO_MCCI_CATENA_4630) +# include "Catena4630.h" +# define CATENA_H_SUPER_ McciCatena::Catena4630 +#elif defined(ARDUINO_MCCI_CATENA_4617) +# include "Catena4617.h" +# define CATENA_H_SUPER_ McciCatena::Catena4617 +#elif defined(ARDUINO_MCCI_CATENA_4618) +# include "Catena4618.h" +# define CATENA_H_SUPER_ McciCatena::Catena4618 #elif defined(ARDUINO_MCCI_CATENA_4801) || defined(ARDUINO_CATENA_4801) # include "Catena4801.h" # define CATENA_H_SUPER_ McciCatena::Catena4801 diff --git a/src/Catena4617.h b/src/Catena4617.h new file mode 100644 index 0000000..d9f6467 --- /dev/null +++ b/src/Catena4617.h @@ -0,0 +1,66 @@ +/* + +Module: Catena4617.h + +Function: + class Catena4617: CatenaBase Platform to represent a Catena 4617 + +Copyright notice: + See accompanying LICENSE file. + +Author: + Lakshmi Priya Natarajan, MCCI Corporation June 2019 + +Revision history: + See https://github.com/mcci-catena/Catena-Arduino-Platform + +*/ + +#ifndef _Catena4617_H_ /* prevent multiple includes */ +#define _Catena4617_H_ + +#pragma once + +#ifndef _CATENA461X_H_ +# include "Catena461x.h" +#endif + +namespace McciCatena { + +class Catena4617 : public Catena461x + { +public: + using Super = Catena461x; + + // no specific constructor. + Catena4617() {}; + + // uses default destructor + + // neither copyable nor movable + Catena4617(const Catena4617&) = delete; + Catena4617& operator=(const Catena4617&) = delete; + Catena4617(const Catena4617&&) = delete; + Catena4617& operator=(const Catena4617&&) = delete; + + virtual const char *CatenaName() const override { return "Catena 4617"; }; + virtual float ReadVbat(void) const override; + virtual float ReadVbus(void) const override; + +protected: + // we are required to provide a table of platforms + virtual void getPlatformTable( + const CATENA_PLATFORM * const * &vPlatforms, + size_t &nvPlatforms + ) override; + +private: + // the known platforms + static const CATENA_PLATFORM(* const vPlatforms[]); + static const size_t nvPlatforms; + }; + +} // namespace McciCatena + +/**** end of Catena4617.h ****/ +#endif /* _Catena4617_H_ */ diff --git a/src/Catena4618.h b/src/Catena4618.h new file mode 100644 index 0000000..5ea1762 --- /dev/null +++ b/src/Catena4618.h @@ -0,0 +1,66 @@ +/* + +Module: Catena4618.h + +Function: + class Catena4618: CatenaBase Platform to represent a Catena 4618 + +Copyright notice: + See accompanying LICENSE file. + +Author: + Lakshmi Priya Natarajan, MCCI Corporation June 2019 + +Revision history: + See https://github.com/mcci-catena/Catena-Arduino-Platform + +*/ + +#ifndef _Catena4618_H_ /* prevent multiple includes */ +#define _Catena4618_H_ + +#pragma once + +#ifndef _CATENA461X_H_ +# include "Catena461x.h" +#endif + +namespace McciCatena { + +class Catena4618 : public Catena461x + { +public: + using Super = Catena461x; + + // no specific constructor. + Catena4618() {}; + + // uses default destructor + + // neither copyable nor movable + Catena4618(const Catena4618&) = delete; + Catena4618& operator=(const Catena4618&) = delete; + Catena4618(const Catena4618&&) = delete; + Catena4618& operator=(const Catena4618&&) = delete; + + virtual const char *CatenaName() const override { return "Catena 4618"; }; + virtual float ReadVbat(void) const override; + virtual float ReadVbus(void) const override; + +protected: + // we are required to provide a table of platforms + virtual void getPlatformTable( + const CATENA_PLATFORM * const * &vPlatforms, + size_t &nvPlatforms + ) override; + +private: + // the known platforms + static const CATENA_PLATFORM(* const vPlatforms[]); + static const size_t nvPlatforms; + }; + +} // namespace McciCatena + +/**** end of Catena4618.h ****/ +#endif /* _Catena4618_H_ */ diff --git a/src/Catena4630.h b/src/Catena4630.h new file mode 100644 index 0000000..b709dfc --- /dev/null +++ b/src/Catena4630.h @@ -0,0 +1,63 @@ +/* + +Module: Catena4630.h + +Function: + class Catena4630: CatenaBase Platform to represent a Catena 4630. + +Copyright notice: + See accompanying LICENSE file. + +Author: + Dhinesh Kumar Pitchai, MCCI Corporation April 2019 + +*/ + +#ifndef _Catena4630_H_ /* prevent multiple includes */ +#define _Catena4630_H_ + +#pragma once + +#ifndef _CATENA463X_H_ +# include "Catena463x.h" +#endif + +namespace McciCatena { + +class Catena4630 : public Catena463x + { +public: + using Super = Catena463x; + + // no specific constructor. + Catena4630() {}; + + // uses default destructor + + // neither copyable nor movable + Catena4630(const Catena4630&) = delete; + Catena4630& operator=(const Catena4630&) = delete; + Catena4630(const Catena4630&&) = delete; + Catena4630& operator=(const Catena4630&&) = delete; + + virtual const char *CatenaName() const override { return "Catena 4630"; }; + virtual float ReadVbat(void) const override; + virtual float ReadVbus(void) const override; + +protected: + // we are required to provide a table of platforms + virtual void getPlatformTable( + const CATENA_PLATFORM * const * &vPlatforms, + size_t &nvPlatforms + ) override; + +private: + // the known platforms + static const CATENA_PLATFORM(* const vPlatforms[]); + static const size_t nvPlatforms; + }; + +} // namespace McciCatena + +/**** end of Catena4630.h ****/ +#endif /* _Catena4630_H_ */ diff --git a/src/Catena463x.h b/src/Catena463x.h new file mode 100644 index 0000000..4fa32ff --- /dev/null +++ b/src/Catena463x.h @@ -0,0 +1,106 @@ +/* + +Module: Catena463x.h + +Function: + class Catena463x: CatenaBase Platform to represent a Catena 463x + (such as the 4630). + +Copyright notice: + See accompanying LICENSE file. + +Author: + Dhinesh Kumar Pitchai, MCCI Corporation April 2019 + +*/ + +#ifndef _CATENA463X_H_ /* prevent multiple includes */ +#define _CATENA463X_H_ + +#pragma once + +#ifndef _CATENASTM32L0_H_ +# include "CatenaStm32L0.h" +#endif + +namespace McciCatena { + +class Catena463x : public CatenaStm32L0 + { +public: + using Super = CatenaStm32L0; + + // no specific constructor. + Catena463x() {}; + + // uses default destructor + + // neither copyable nor movable + Catena463x(const Catena463x&) = delete; + Catena463x& operator=(const Catena463x&) = delete; + Catena463x(const Catena463x&&) = delete; + Catena463x& operator=(const Catena463x&&) = delete; + + // LoRaWAN binding + class LoRaWAN /* forward */; + + enum ANALOG_PINS + { + APIN_VBAT_SENSE = A1, + APIN_VBUS_SENSE = A2, + }; + + enum ANALOG_CHANNELS + { + ANALOG_CHANNEL_A0 = 0, + ANALOG_CHANNEL_A1 = 5, + ANALOG_CHANNEL_A2 = 4, + ANALOG_CHANNEL_A3 = 3, + ANALOG_CHANNEL_A4 = 2, + ANALOG_CHANNEL_VBAT = ANALOG_CHANNEL_A1, + ANALOG_CHANNEL_VBUS = ANALOG_CHANNEL_A2, + ANALOG_CHANNEL_VREF = 17, + }; + + enum DIGITAL_PINS + { + PIN_STATUS_LED = D13, + PIN_SPI2_FLASH_SS = D19, + PIN_SPI2_MOSI = D23, + PIN_SPI2_MISO = D22, + PIN_SPI2_SCK = D24, + }; + + // methods + virtual bool begin() override; + +protected: + +private: + }; + +/* +|| The LoRaWAN class for the Catena 455x. Assumes The Things Network +*/ +class Catena463x::LoRaWAN : public CatenaStm32L0::LoRaWAN + { +public: + using Super = CatenaStm32L0::LoRaWAN; + + /* + || the constructor. We don't do anything at this level, the + || Super constructor does most of the work. + */ + LoRaWAN() {}; + + bool begin(Catena463x *pParent); + +protected: + +private: + }; + +} // namespace McciCatena + +/**** end of Catena463x.h ****/ +#endif /* _CATENA463X_H_ */ diff --git a/src/CatenaBase.h b/src/CatenaBase.h index bfedeff..6bc9207 100644 --- a/src/CatenaBase.h +++ b/src/CatenaBase.h @@ -1,5 +1,3 @@ -/* CatenaBase.h Wed Dec 05 2018 14:01:28 chwon */ - /* Module: CatenaBase.h @@ -7,46 +5,12 @@ Module: CatenaBase.h Function: class CatenaBase interfaces. -Version: - V0.12.0 Wed Dec 05 2018 14:01:28 chwon Edit level 6 - Copyright notice: - This file copyright (C) 2016-2018 by - - MCCI Corporation - 3520 Krums Corners Road - Ithaca, NY 14850 - - An unpublished work. All rights reserved. - - This file is released under terms of the accompanying LICENSE file. + See accompanying LICENSE file. Author: Terry Moore, MCCI Corporation October 2016 -Revision history: - 0.1.0 Tue Oct 25 2016 01:58:25 tmm - Module created. - - 0.3.0 Thu Oct 27 2016 22:46:30 tmm - Change buffer types away from array, types are just not intuitive. - - 0.5.0 Sun Mar 19 2017 15:00:21 tmm - Major update for comamand support, etc. - - 0.9.0 Sat Mar 31 2018 19:28:30 tmm - Add fHasBme680. - - 0.9.1 Sat Apr 28 2018 16:52:31 tmm - Add support for RS485 (for Catena 4470). - - 0.11.0 Mon Nov 19 2018 12:07:02 chwon - Add Sleep() virtual method. - - 0.12.0 Wed Dec 05 2018 14:01:29 chwon - Add getFram() method and FRAM access methods. Move CPUID_PLATFORM_MAP - structure and related methods. - */ #ifndef _CATENABASE_H_ /* prevent multiple includes */ @@ -91,7 +55,7 @@ Revision history: #define CATENA_ARDUINO_PLATFORM_VERSION_CALC(major, minor, patch, local) \ (((major) << 24u) | ((minor) << 16u) | ((patch) << 8u) | (local)) -#define CATENA_ARDUINO_PLATFORM_VERSION CATENA_ARDUINO_PLATFORM_VERSION_CALC(0, 14, 0, 70) /* v0.14.0.70 */ +#define CATENA_ARDUINO_PLATFORM_VERSION CATENA_ARDUINO_PLATFORM_VERSION_CALC(0, 14, 70, 0) /* v0.14.70.0 */ #define CATENA_ARDUINO_PLATFORM_VERSION_GET_MAJOR(v) \ (((v) >> 24u) & 0xFFu) @@ -193,6 +157,12 @@ class CatenaBase fHasRS485 = 1 << 16, // platform uses A2 to control VOUT1 (on terminals) fHasVout1 = 1 << 17, + // platform has ZMOD4410 Air Quality sensor + fHasZMOD4410 = 1 << 18, + //platform has IDT HS001 + fHasHS001 = 1 << 19, + //platform has SHT3x sensirion + fHasSHT3x = 1 << 20, // special wiring variants all are offsets from M100... // we support up to 127 variants, becuase we have 7 diff --git a/src/Catena_Guids.h b/src/Catena_Guids.h index 2a11f16..3e050ca 100644 --- a/src/Catena_Guids.h +++ b/src/Catena_Guids.h @@ -1,45 +1,15 @@ -/* Catena_Guids.h Thu Nov 15 2018 15:15:37 chwon */ - /* Module: Catena_Guids.h Function: - GUIDs for the Catena family. - -Version: - V0.11.0 Thu Nov 15 2018 15:15:37 chwon Edit level 6 + GUIDs for the Catena family. Copyright notice: - This file copyright (C) 2016-2018 by - - MCCI Corporation - 3520 Krums Corners Road - Ithaca, NY 14850 + See accompanying LICENSE file. - An unpublished work. All rights reserved. - - This file is proprietary information, and may not be disclosed or - copied without the prior permission of MCCI Corporation. - Author: - Terry Moore, MCCI Corporation October 2016 - -Revision history: - 0.1.0 Mon Oct 17 2016 01:15:25 tmm - Module created. - - 0.4.0 Wed Mar 8 2017 17:25:02 tmm - Add Catena 4450 material. - - 0.5.0 Sun Mar 19 2017 18:23:19 tmm - Fix internal naming, and add storage FRAM guids. - - 0.9.0 Sat Mar 31 2018 19:28:30 tmm - Add Catena 4460 material. - - 0.11.0 Thu Nov 15 2018 15:15:37 chwon - Add Catena 461x material. + Terry Moore, MCCI Corporation October 2016 */ @@ -54,9 +24,9 @@ Revision history: | | Platform GUIDs | -| After adding here, you must add the corresponding entries to +| After adding here, you must add the corresponding entries to | - [ ] Catena_Platforms.h -| - [ ] CatenaStm32_gk_PlatformHierarchy.cpp or +| - [ ] CatenaStm32_gk_PlatformHierarchy.cpp or | CatenaSamd_gk_PlatformHierarchy.cpp | - [ ] As appropriate to the vPlatforms[] array for | Catena*_GetPlatformForID.cpp @@ -65,9 +35,9 @@ Revision history: // {2E6DFED4-F577-47D5-9137-B3E63976AE92} #define GUID_HW_FEATHER_M0(f) \ - MCCIADK_GUID_GEN_INIT(f, 0x2e6dfed4, 0xf577, 0x47d5, 0x91, 0x37, 0xb3, 0xe6, 0x39, 0x76, 0xae, 0x92) + MCCIADK_GUID_GEN_INIT(f, 0x2e6dfed4, 0xf577, 0x47d5, 0x91, 0x37, 0xb3, 0xe6, 0x39, 0x76, 0xae, 0x92) -// {E2DECCC8-55FA-4BD3-94C3-CE66BCD0BAAC} +// {E2DECCC8-55FA-4BD3-94C3-CE66BCD0BAAC} #define GUID_HW_FEATHER_M0_LORA(f) \ MCCIADK_GUID_GEN_INIT(f, 0xe2deccc8, 0x55fa, 0x4bd3, 0x94, 0xc3, 0xce, 0x66, 0xbc, 0xd0, 0xba, 0xac) @@ -87,7 +57,7 @@ Revision history: 0x3bab150f, 0x6e32, 0x4459, 0xa2, 0xb6, 0x72, 0xac, 0xed, 0x75, 0x5, 0x9f) -// {6785BBF2-B3F5-4D86-BB1F-BB132F9CB217} +// {6785BBF2-B3F5-4D86-BB1F-BB132F9CB217} #define GUID_HW_CATENA_4410_BASE(f) \ MCCIADK_GUID_GEN_INIT(f, 0x6785bbf2, 0xb3f5, 0x4d86, 0xbb, 0x1f, 0xbb, 0x13, 0x2f, 0x9c, 0xb2, 0x17) @@ -95,11 +65,11 @@ Revision history: #define GUID_HW_CATENA_4410_GH(f) \ MCCIADK_GUID_GEN_INIT(f, 0xe2f07d9, 0x3074, 0x406b, 0x94, 0x33, 0xcd, 0x55, 0x8c, 0xc2, 0x4f, 0xb1) -// {D87BDEDB-4E52-481F-A87D-1BB7021B1C0E} +// {D87BDEDB-4E52-481F-A87D-1BB7021B1C0E} #define GUID_HW_CATENA_4410_MH(f) \ MCCIADK_GUID_GEN_INIT(f, 0xd87bdedb, 0x4e52, 0x481f, 0xa8, 0x7d, 0x1b, 0xb7, 0x2, 0x1b, 0x1c, 0xe) -// {CAC018DD-7D55-4C79-96C9-9FD879ADDF8F} +// {CAC018DD-7D55-4C79-96C9-9FD879ADDF8F} #define GUID_HW_CATENA_4410_SWH(f) \ MCCIADK_GUID_GEN_INIT(f, 0xcac018dd, 0x7d55, 0x4c79, 0x96, 0xc9, 0x9f, 0xd8, 0x79, 0xad, 0xdf, 0x8f) @@ -243,6 +213,18 @@ Revision history: #define GUID_HW_CATENA_4612_M104(f) \ MCCIADK_GUID_GEN_INIT(f, 0xdea48489, 0xcdac, 0x43f4, 0xb8, 0xad, 0xed, 0xb0, 0x8c, 0xe2, 0x15, 0x46) +// {6767c2f6-d5d5-43f4-81af-db0d4d08815a} +#define GUID_HW_CATENA_4617_BASE(f) \ + MCCIADK_GUID_GEN_INIT(f, 0x6767c2f6, 0xd5d5, 0x43f4, 0x81, 0xaf, 0xdb, 0x0d, 0x4d, 0x08, 0x81, 0x5a) + +// {b75ed77b-b06e-4b26-a968-9c15f222dfb2} +#define GUID_HW_CATENA_4618_BASE(f) \ + MCCIADK_GUID_GEN_INIT(f, 0xb75ed77b, 0xb06e, 0x4b26, 0xa9, 0x68, 0x9c, 0x15, 0xf2, 0x22, 0xdf, 0xb2) + +// {17281c12-d78a-4e4f-9c42-c8bbc5499c91} +#define GUID_HW_CATENA_4630_BASE(f) \ + MCCIADK_GUID_GEN_INIT(f, 0x17281c12, 0xd78a, 0x4e4f, 0x9c, 0x42, 0xc8, 0xbb, 0xc5, 0x49, 0x9c, 0x91) + // {10ea7e25-a4a4-45fd-8959-c04a6a5d7f95} #define GUID_HW_CATENA_4801_BASE(f) \ MCCIADK_GUID_GEN_INIT(f, 0x10ea7e25, 0xa4a4, 0x45fd, 0x89, 0x59, 0xc0, 0x4a, 0x6a, 0x5d, 0x7f, 0x95) diff --git a/src/Catena_Platforms.h b/src/Catena_Platforms.h index 3a04c14..ff231a9 100644 --- a/src/Catena_Platforms.h +++ b/src/Catena_Platforms.h @@ -1,51 +1,18 @@ -/* Catena_Platforms.h Thu Nov 15 2018 15:24:45 chwon */ - /* Module: Catena_Platforms.h Function: - The global platform definitions. - -Version: - V0.11.0 Thu Nov 15 2018 15:24:45 chwon Edit level 9 + The global platform definitions. Copyright notice: - This file copyright (C) 2016-2018 by - - MCCI Corporation - 3520 Krums Corners Road - Ithaca, NY 14850 + See accompanying LICENSE file. - An unpublished work. All rights reserved. - - This file is proprietary information, and may not be disclosed or - copied without the prior permission of MCCI Corporation. - Author: - Terry Moore, MCCI Corporation October 2016 + Terry Moore, MCCI Corporation October 2016 Revision history: - 0.1.0 Mon Oct 17 2016 03:35:01 tmm - Module created. - - 0.3.0 Mon Oct 31 2016 13:52:28 tmm - Add anatolian platform. - - 0.4.0 Wed Mar 8 2017 18:11:46 tmm - Add Catena 4450 platforms. - - 0.5.0 Sat Mar 11 2017 13:57:05 tmm - Revise to match naming standards; add McciCatena namespace. - - 0.7.0 Wed Dec 06 2017 19:27:10 tmm - Add Catena 455x support. - - 0.9.0 Sat Mar 31 2018 19:28:30 tmm - Add Catena 4460 support. - - 0.11.0 Thu Nov 15 2018 15:24:45 chwon - Add Catena 461x support. + See https://github.com/mcci-catena/Catena-Arduino-Platform */ @@ -65,7 +32,7 @@ extern const CATENA_PLATFORM gkPlatformCatena4410; extern const CATENA_PLATFORM gkPlatformCatena4410_anatolian; extern const CATENA_PLATFORM gkPlatformCatena4410_gh; extern const CATENA_PLATFORM gkPlatformCatena4410_mh; -extern const CATENA_PLATFORM gkPlatformCatena4410_swh; +extern const CATENA_PLATFORM gkPlatformCatena4410_swh; extern const CATENA_PLATFORM gkPlatformCatena4410_pond; extern const CATENA_PLATFORM gkPlatformCatena4450; extern const CATENA_PLATFORM gkPlatformCatena4450_m101; @@ -104,6 +71,10 @@ extern const CATENA_PLATFORM gkPlatformCatena4612_m101; extern const CATENA_PLATFORM gkPlatformCatena4612_m102; extern const CATENA_PLATFORM gkPlatformCatena4612_m103; extern const CATENA_PLATFORM gkPlatformCatena4612_m104; +extern const CATENA_PLATFORM gkPlatformCatena4617; +extern const CATENA_PLATFORM gkPlatformCatena4618; + +extern const CATENA_PLATFORM gkPlatformCatena4630; extern const CATENA_PLATFORM gkPlatformCatena4801; diff --git a/src/lib/stm32/catena461x/Catena4617_ReadVoltage.cpp b/src/lib/stm32/catena461x/Catena4617_ReadVoltage.cpp new file mode 100644 index 0000000..8db0ab9 --- /dev/null +++ b/src/lib/stm32/catena461x/Catena4617_ReadVoltage.cpp @@ -0,0 +1,88 @@ +/* + +Module: Catena4617_ReadAnalog.cpp + +Function: + Catena4617::ReadVbat() and Catena4617::ReadVbus() + +Copyright notice: + See accompanying LICENSE file. + +Author: + Lakshmi Priya Natarajan, MCCI Corporation June 2019 + +Revision history: + See https://github.com/mcci-catena/Catena-Arduino-Platform + +*/ + +#ifdef ARDUINO_ARCH_STM32 + +#include "Catena4617.h" +#include "Catena_Log.h" + +#include +using namespace McciCatena; + +/****************************************************************************\ +| +| Manifest constants & typedefs. +| +\****************************************************************************/ + + + +/****************************************************************************\ +| +| Read-only data. +| +\****************************************************************************/ + + + +/****************************************************************************\ +| +| Variables. +| +\****************************************************************************/ + +float +Catena4617::ReadVbat(void) const + { + float volt = this->ReadAnalog(Catena461x::ANALOG_CHANNEL_VBAT, 1, 1); + return volt / 1000; + } + +float +Catena4617::ReadVbus(void) const + { + // on the Catena 4617, the Vbus divider impedance is very high, + // so charge transfer from the previous channel causes problems. + // Therefore, let's read one extra time; the prvious ADC will + // have had some time to bleed off. + float volt = this->ReadAnalog(Catena461x::ANALOG_CHANNEL_VBUS, 6, 3); + return volt / 1000; + } + +#if defined(ARDUINO_MCCI_CATENA_4617) && defined(USBD_LL_ConnectionState_WEAK) + +extern "C" { + +uint32_t USBD_LL_ConnectionState(void) + { + uint32_t vBus; + bool fStatus; + + fStatus = CatenaStm32L0_ReadAnalog( + Catena461x::ANALOG_CHANNEL_VBUS, 6, 3, &vBus + ); + return (fStatus && vBus < 3000) ? 0 : 1; + } + +} + +#endif // ARDUINO_MCCI_CATENA_4617 + +#endif // ARDUINO_ARCH_STM32 + +/**** end of Catena4617_ReadAnalog.cpp ****/ diff --git a/src/lib/stm32/catena461x/Catena4617_getPlatformTable.cpp b/src/lib/stm32/catena461x/Catena4617_getPlatformTable.cpp new file mode 100644 index 0000000..669d7bd --- /dev/null +++ b/src/lib/stm32/catena461x/Catena4617_getPlatformTable.cpp @@ -0,0 +1,94 @@ +/* + +Module: Catena4617_getPlatformTable.cpp + +Function: + Catena4617::getPlatformTable() + +Copyright notice: + See accompanying LICENSE file. + +Author: + Lakshmi Priya Natarajan, MCCI Corporation June 2019 + +Revision history: + See https://github.com/mcci-catena/Catena-Arduino-Platform + +*/ + +#ifdef ARDUINO_ARCH_STM32 + +#include "Catena4617.h" + +#include "Catena_Log.h" +#include "Catena_Platforms.h" +#include "Catena_Guids.h" + +/****************************************************************************\ +| +| Read-only data. +| +\****************************************************************************/ + +namespace McciCatena { + +const CATENA_PLATFORM gkPlatformCatena4617 = + { + Guid: GUID_HW_CATENA_4617_BASE(WIRE), + pParent: &gkPlatformCatena4617, + PlatformFlags: + CatenaBase::fHasLoRa | + CatenaBase::fHasTtnNycLoRa | + CatenaBase::fHasHS001 | + CatenaBase::fHasLuxSi1133 | + CatenaBase::fHasFRAM | + CatenaBase::fHasFlash + }; + +const CATENA_PLATFORM (* const Catena4617::vPlatforms[]) = + { + // entry 0 is the default + &gkPlatformCatena4617, + }; + +const size_t Catena4617::nvPlatforms = sizeof(Catena4617::vPlatforms) / sizeof(Catena4617::vPlatforms[0]); + +/* + +Name: Catena4617::getPlatformTable() + +Function: + Get the known platform table. + +Definition: + public: virtual + void Catena4617::getPlatformTable( + const CATENA_PLATFORM * const * &vPlatforms, + size_t &nvPlatforms + ) override; + +Description: + This override for getPlatformTable() returns the vector of platform + GUIDs for this Catena. + +Returns: + vPlatforms is set to the base of the array of pointers to platform + stuctures; and nvPlatforms is set to the number of entries in + the table. + +*/ + +/* public virtual override */ +void +Catena4617::getPlatformTable( + const CATENA_PLATFORM * const * &result_vPlatforms, + size_t &result_nvPlatforms + ) + { + result_vPlatforms = vPlatforms; + result_nvPlatforms = nvPlatforms; + } + +} /* namespace McciCatena */ + +#endif // ARDUINO_ARCH_STM32 diff --git a/src/lib/stm32/catena461x/Catena4618_ReadVoltage.cpp b/src/lib/stm32/catena461x/Catena4618_ReadVoltage.cpp new file mode 100644 index 0000000..dfdd80e --- /dev/null +++ b/src/lib/stm32/catena461x/Catena4618_ReadVoltage.cpp @@ -0,0 +1,88 @@ +/* + +Module: Catena4618_ReadAnalog.cpp + +Function: + Catena4618::ReadVbat() and Catena4618::ReadVbus() + +Copyright notice: + See accompanying LICENSE file. + +Author: + Lakshmi Priya Natarajan, MCCI Corporation June 2019 + +Revision history: + See https://github.com/mcci-catena/Catena-Arduino-Platform + +*/ + +#ifdef ARDUINO_ARCH_STM32 + +#include "Catena4618.h" +#include "Catena_Log.h" + +#include +using namespace McciCatena; + +/****************************************************************************\ +| +| Manifest constants & typedefs. +| +\****************************************************************************/ + + + +/****************************************************************************\ +| +| Read-only data. +| +\****************************************************************************/ + + + +/****************************************************************************\ +| +| Variables. +| +\****************************************************************************/ + +float +Catena4618::ReadVbat(void) const + { + float volt = this->ReadAnalog(Catena461x::ANALOG_CHANNEL_VBAT, 1, 1); + return volt / 1000; + } + +float +Catena4618::ReadVbus(void) const + { + // on the Catena 4618, the Vbus divider impedance is very high, + // so charge transfer from the previous channel causes problems. + // Therefore, let's read one extra time; the prvious ADC will + // have had some time to bleed off. + float volt = this->ReadAnalog(Catena461x::ANALOG_CHANNEL_VBUS, 6, 3); + return volt / 1000; + } + +#if defined(ARDUINO_MCCI_CATENA_4618) && defined(USBD_LL_ConnectionState_WEAK) + +extern "C" { + +uint32_t USBD_LL_ConnectionState(void) + { + uint32_t vBus; + bool fStatus; + + fStatus = CatenaStm32L0_ReadAnalog( + Catena461x::ANALOG_CHANNEL_VBUS, 6, 3, &vBus + ); + return (fStatus && vBus < 3000) ? 0 : 1; + } + +} + +#endif // ARDUINO_MCCI_CATENA_4618 + +#endif // ARDUINO_ARCH_STM32 + +/**** end of Catena4618_ReadAnalog.cpp ****/ diff --git a/src/lib/stm32/catena461x/Catena4618_getPlatformTable.cpp b/src/lib/stm32/catena461x/Catena4618_getPlatformTable.cpp new file mode 100644 index 0000000..546218f --- /dev/null +++ b/src/lib/stm32/catena461x/Catena4618_getPlatformTable.cpp @@ -0,0 +1,94 @@ +/* + +Module: Catena4618_getPlatformTable.cpp + +Function: + Catena4618::getPlatformTable() + +Copyright notice: + See accompanying LICENSE file. + +Author: + Lakshmi Priya Natarajan, MCCI Corporation June 2019 + +Revision history: + See https://github.com/mcci-catena/Catena-Arduino-Platform + +*/ + +#ifdef ARDUINO_ARCH_STM32 + +#include "Catena4618.h" + +#include "Catena_Log.h" +#include "Catena_Platforms.h" +#include "Catena_Guids.h" + +/****************************************************************************\ +| +| Read-only data. +| +\****************************************************************************/ + +namespace McciCatena { + +const CATENA_PLATFORM gkPlatformCatena4618 = + { + Guid: GUID_HW_CATENA_4618_BASE(WIRE), + pParent: &gkPlatformCatena4618, + PlatformFlags: + CatenaBase::fHasLoRa | + CatenaBase::fHasTtnNycLoRa | + CatenaBase::fHasSHT3x | + CatenaBase::fHasLuxSi1133 | + CatenaBase::fHasFRAM | + CatenaBase::fHasFlash + }; + +const CATENA_PLATFORM (* const Catena4618::vPlatforms[]) = + { + // entry 0 is the default + &gkPlatformCatena4618, + }; + +const size_t Catena4618::nvPlatforms = sizeof(Catena4618::vPlatforms) / sizeof(Catena4618::vPlatforms[0]); + +/* + +Name: Catena4618::getPlatformTable() + +Function: + Get the known platform table. + +Definition: + public: virtual + void Catena4618::getPlatformTable( + const CATENA_PLATFORM * const * &vPlatforms, + size_t &nvPlatforms + ) override; + +Description: + This override for getPlatformTable() returns the vector of platform + GUIDs for this Catena. + +Returns: + vPlatforms is set to the base of the array of pointers to platform + stuctures; and nvPlatforms is set to the number of entries in + the table. + +*/ + +/* public virtual override */ +void +Catena4618::getPlatformTable( + const CATENA_PLATFORM * const * &result_vPlatforms, + size_t &result_nvPlatforms + ) + { + result_vPlatforms = vPlatforms; + result_nvPlatforms = nvPlatforms; + } + +} /* namespace McciCatena */ + +#endif // ARDUINO_ARCH_STM32 diff --git a/src/lib/stm32/catena463x/Catena4630_ReadVoltage.cpp b/src/lib/stm32/catena463x/Catena4630_ReadVoltage.cpp new file mode 100644 index 0000000..4d4ed30 --- /dev/null +++ b/src/lib/stm32/catena463x/Catena4630_ReadVoltage.cpp @@ -0,0 +1,81 @@ +/* + +Module: Catena4630_ReadAnalog.cpp + +Function: + Catena4630::ReadVbat() and Catena4630::ReadVbus() + +Copyright notice: + See accompanying LICENSE file. + +Author: + Dhinesh Kumar Pitchai, MCCI Corporation April 2019 + +*/ + +#ifdef ARDUINO_ARCH_STM32 + +#include "Catena4630.h" +#include "Catena_Log.h" + +#include +using namespace McciCatena; + +/****************************************************************************\ +| +| Manifest constants & typedefs. +| +\****************************************************************************/ + + + +/****************************************************************************\ +| +| Read-only data. +| +\****************************************************************************/ + + + +/****************************************************************************\ +| +| Variables. +| +\****************************************************************************/ + +float +Catena4630::ReadVbat(void) const + { + float volt = this->ReadAnalog(Catena463x::ANALOG_CHANNEL_VBAT, 1, 2); + return volt / 1000; + } + +float +Catena4630::ReadVbus(void) const + { + float volt = this->ReadAnalog(Catena463x::ANALOG_CHANNEL_VBUS, 1, 3); + return volt / 1000; + } + +#if defined(ARDUINO_MCCI_CATENA_4630) && defined(USBD_LL_ConnectionState_WEAK) + +extern "C" { + +uint32_t USBD_LL_ConnectionState(void) + { + uint32_t vBus; + bool fStatus; + + fStatus = CatenaStm32L0_ReadAnalog( + Catena463x::ANALOG_CHANNEL_VBUS, 1, 3, &vBus + ); + return (fStatus && vBus < 3000) ? 0 : 1; + } + +} + +#endif // ARDUINO_MCCI_CATENA_4630 + +#endif // ARDUINO_ARCH_STM32 + +/**** end of Catena4630_ReadAnalog.cpp ****/ diff --git a/src/lib/stm32/catena463x/Catena4630_getPlatformTable.cpp b/src/lib/stm32/catena463x/Catena4630_getPlatformTable.cpp new file mode 100644 index 0000000..67d19ba --- /dev/null +++ b/src/lib/stm32/catena463x/Catena4630_getPlatformTable.cpp @@ -0,0 +1,91 @@ +/* + +Module: Catena4630_getPlatformTable.cpp + +Function: + Catena4630::getPlatformTable() + +Copyright notice: + See accompanying LICENSE file. + +Author: + Dhinesh Kumar Pitchai, MCCI Corporation April 2019 + +*/ + +#ifdef ARDUINO_ARCH_STM32 + +#include "Catena4630.h" + +#include "Catena_Log.h" +#include "Catena_Platforms.h" +#include "Catena_Guids.h" + +/****************************************************************************\ +| +| Read-only data. +| +\****************************************************************************/ + +namespace McciCatena { + +const CATENA_PLATFORM gkPlatformCatena4630 = + { + Guid: GUID_HW_CATENA_4630_BASE(WIRE), + pParent: &gkPlatformCatena4630, + PlatformFlags: + CatenaBase::fHasLoRa | + CatenaBase::fHasTtnNycLoRa | + CatenaBase::fHasBme280 | + CatenaBase::fHasZMOD4410 | + CatenaBase::fHasFRAM | + CatenaBase::fHasFlash + }; + +const CATENA_PLATFORM (* const Catena4630::vPlatforms[]) = + { + // entry 0 is the default + &gkPlatformCatena4630, + }; + +const size_t Catena4630::nvPlatforms = sizeof(Catena4630::vPlatforms) / sizeof(Catena4630::vPlatforms[0]); + +/* + +Name: Catena4630::getPlatformTable() + +Function: + Get the known platform table. + +Definition: + public: virtual + void Catena4630::getPlatformTable( + const CATENA_PLATFORM * const * &vPlatforms, + size_t &nvPlatforms + ) override; + +Description: + This override for getPlatformTable() returns the vector of platform + GUIDs for this Catena. + +Returns: + vPlatforms is set to the base of the array of pointers to platform + stuctures; and nvPlatforms is set to the number of entries in + the table. + +*/ + +/* public virtual override */ +void +Catena4630::getPlatformTable( + const CATENA_PLATFORM * const * &result_vPlatforms, + size_t &result_nvPlatforms + ) + { + result_vPlatforms = vPlatforms; + result_nvPlatforms = nvPlatforms; + } + +} /* namespace McciCatena */ + +#endif // ARDUINO_ARCH_STM32 diff --git a/src/lib/stm32/catena463x/Catena463x_LoRaWAN_begin.cpp b/src/lib/stm32/catena463x/Catena463x_LoRaWAN_begin.cpp new file mode 100644 index 0000000..86a8200 --- /dev/null +++ b/src/lib/stm32/catena463x/Catena463x_LoRaWAN_begin.cpp @@ -0,0 +1,68 @@ +/* + +Module: Catena463x_LoRaWAN_begin.cpp + +Function: + Catena463x::LoRaWAN::begin() + +Copyright notice: + See accompanying LICENSE file. + +Author: + Dhinesh Kumar Pitchai, MCCI Corporation April 2019 + +*/ + +#ifdef ARDUINO_ARCH_STM32 + +#include "Catena463x.h" + +#include "Catena_Log.h" +#include "mcciadk_baselib.h" + +using namespace McciCatena; + +/* + +Name: Catena463x::LoRaWAN::begin() + +Function: + Record linkage to main Catena object and set up LoRaWAN. + +Definition: + bool Catena463x::LoRaWAN::begin( + Catena463x *pParent + ); + +Description: + We record parent pointers, and other useful things for later. + +Returns: + true for success, false for failure. + +*/ + +bool +Catena463x::LoRaWAN::begin( + Catena463x *pParent + ) + { + gLog.printf(gLog.kTrace, "+Catena463x::LoRaWAN::begin()\n"); + + /* call the base begin */ + if (! this->Super::begin(pParent)) + { + gLog.printf( + gLog.kBug, + "?Catena463x::LoRaWAN::begin: Super::begin() failed\n" + ); + return false; + } + + /* indicate success to the client */ + return true; + } + +#endif // ARDUINO_ARCH_STM32 + +/**** end of Catena463x_LoRaWAN_begin.cpp ****/ diff --git a/src/lib/stm32/catena463x/Catena463x_begin.cpp b/src/lib/stm32/catena463x/Catena463x_begin.cpp new file mode 100644 index 0000000..ce578aa --- /dev/null +++ b/src/lib/stm32/catena463x/Catena463x_begin.cpp @@ -0,0 +1,63 @@ +/* + +Module: Catena463x_begin.cpp + +Function: + Catena463x::begin(). + +Copyright notice: + See accompanying LICENSE file. + +Author: + Dhinesh Kumar Pitchai, MCCI Corporation April 2019 + +*/ + +#ifdef ARDUINO_ARCH_STM32 + +#include "Catena463x.h" + +#include "Catena_Log.h" + +using namespace McciCatena; + +/* + +Name: Catena463x::begin() + +Function: + Set up all the well-known board peripherals. + +Definition: + bool Catena463x::begin(); + +Description: + Issues begin() for all the Catena463x things. + +Returns: + true for success, false for failure. + +*/ + +bool Catena463x::begin() + { + Serial.begin(115200); + Wire.begin(); + delay(1000); + gLog.begin(cLog::DebugFlags(gLog.kError | gLog.kBug)); + gLog.printf( + gLog.kTrace, + "\n+Catena463x::begin() for %s\n", + CatenaName() + ); + + // do the platform selection. + if (! this->Super::begin()) + return false; + + return true; + } + +#endif // ARDUINO_ARCH_STM32 + +/**** end of Catena463x_begin.cpp ****/