Skip to content

Commit

Permalink
fix #345: add support to Model4916
Browse files Browse the repository at this point in the history
  • Loading branch information
dhineshkumarmcci committed Dec 9, 2022
1 parent 17a7ecc commit 1969ced
Show file tree
Hide file tree
Showing 10 changed files with 465 additions and 0 deletions.
3 changes: 3 additions & 0 deletions src/Catena.h
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,9 @@ Copyright notice:
#elif defined(ARDUINO_MCCI_CATENA_4802)
# include "Catena4802.h"
# define CATENA_H_SUPER_ McciCatena::Catena4802
#elif defined(ARDUINO_MCCI_MODEL_4916) || defined(ARDUINO_MODEL_4916)
# include "Catena4916.h"
# define CATENA_H_SUPER_ McciCatena::Catena4916
/* fallback in case it's SAMD but not what we expect */
#elif defined(ARDUINO_ARCH_SAMD)
# include "CatenaSamd21.h"
Expand Down
63 changes: 63 additions & 0 deletions src/Catena4916.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
/*
Module: Catena4916.h
Function:
class Catena4916: CatenaBase Platform to represent a Catena 4916
Copyright notice:
See accompanying LICENSE file.
Author:
Dhinesh Kumar Pitchai, MCCI Corporation November 2022
*/

#ifndef _Catena4916_H_ /* prevent multiple includes */
#define _Catena4916_H_

#pragma once

#ifndef _CATENA491x_H_
# include "Catena491x.h"
#endif

namespace McciCatena {

class Catena4916 : public Catena491x
{
public:
using Super = Catena4916;

// no specific constructor.
Catena4916() {};

// uses default destructor

// neither copyable nor movable
Catena4916(const Catena4916&) = delete;
Catena4916& operator=(const Catena4916&) = delete;
Catena4916(const Catena4916&&) = delete;
Catena4916& operator=(const Catena4916&&) = delete;

virtual const char *CatenaName() const override { return "Catena 4916"; };
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 Catena4916.h ****/
#endif /* _Catena4916_H_ */
104 changes: 104 additions & 0 deletions src/Catena491x.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,104 @@
/*
Module: Catena491x.h
Function:
class Catena491x: CatenaBase Platform to represent a Catena 491x
(such as the 4916).
Copyright notice:
See accompanying LICENSE file.
Author:
Dhinesh Kumar Pitchai, MCCI Corporation November 2022
*/

#ifndef _CATENA491X_H_ /* prevent multiple includes */
#define _CATENA491X_H_

#pragma once

#ifndef _CATENASTM32L0_H_
# include "CatenaStm32L0.h"
#endif

namespace McciCatena {

class Catena491x : public CatenaStm32L0
{
public:
using Super = CatenaStm32L0;

// no specific constructor.
Catena491x() {};

// uses default destructor

// neither copyable nor movable
Catena491x(const Catena491x&) = delete;
Catena491x& operator=(const Catena491x&) = delete;
Catena491x(const Catena491x&&) = delete;
Catena491x& operator=(const Catena491x&&) = delete;

// LoRaWAN binding
class LoRaWAN /* forward */;

enum ANALOG_PINS
{
APIN_VBAT_SENSE = A1,
// APIN_VBUS_SENSE = A4,
};

enum ANALOG_CHANNELS
{
ANALOG_CHANNEL_A1 = 5,
ANALOG_CHANNEL_A2 = 4,
ANALOG_CHANNEL_A3 = 3,
ANALOG_CHANNEL_A4 = 2,
ANALOG_CHANNEL_VBAT = ANALOG_CHANNEL_A1,
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 Catena491x::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(Catena491x *pParent);

protected:

private:
};

} // namespace McciCatena

/**** end of Catena491x.h ****/
#endif /* _CATENA491X_H_ */
4 changes: 4 additions & 0 deletions src/CatenaBase.h
Original file line number Diff line number Diff line change
Expand Up @@ -210,6 +210,10 @@ class CatenaBase
fHasSHT3x = 1 << 20,
//platform has I2C Level Shifter
fHasI2cLevelShifter = 1 << 21,
//platform has GPS SAM-M8Q
fHasSAMM8Q = 1 << 22,
//platform has ADS131M04
fHasADS131M04 = 1 << 23,

// special wiring variants all are offsets from M100...
// we support up to 127 variants, becuase we have 7
Expand Down
4 changes: 4 additions & 0 deletions src/Catena_Guids.h
Original file line number Diff line number Diff line change
Expand Up @@ -233,5 +233,9 @@ Copyright notice:
#define GUID_HW_CATENA_4802_BASE(f) \
MCCIADK_GUID_GEN_INIT(f, 0xdaaf345e, 0xb5d5, 0x4a32, 0xa3, 0x03, 0x3a, 0xc7, 0x0b, 0x81, 0xd2, 0x60)

// {2eadd9eb-80e3-4e14-99c6-851f036ffa8d}
#define GUID_HW_CATENA_4916_BASE(f) \
MCCIADK_GUID_GEN_INIT(f, 0x2eadd9eb, 0x80e3, 0x4e14, 0x99, 0xc6, 0x85, 0x1f, 0x03, 0x6f, 0xfa, 0x8d)

/**** end of catena_guids.h ****/
#endif /* _CATENA_GUIDS_H_ */
2 changes: 2 additions & 0 deletions src/Catena_Platforms.h
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,8 @@ extern const CATENA_PLATFORM gkPlatformCatena4630;
extern const CATENA_PLATFORM gkPlatformCatena4801;
extern const CATENA_PLATFORM gkPlatformCatena4802;

extern const CATENA_PLATFORM gkPlatformCatena4916;

} /* namespace McciCatena */

/**** end of Catena_Platforms.h ****/
Expand Down
61 changes: 61 additions & 0 deletions src/lib/stm32/catena491x/Catena4916_ReadVoltage.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
/*
Module: Catena4916_ReadVoltage.cpp
Function:
Catena4916::ReadVbat() and Catena4916::ReadVbus()
Copyright notice:
See accompanying LICENSE file.
Author:
Pranau R, MCCI Corporation November 2022
*/

#ifdef ARDUINO_ARCH_STM32

#include "Catena4916.h"
#include "Catena_Log.h"

#include <Arduino.h>
using namespace McciCatena;

/****************************************************************************\
|
| Manifest constants & typedefs.
|
\****************************************************************************/



/****************************************************************************\
|
| Read-only data.
|
\****************************************************************************/



/****************************************************************************\
|
| Variables.
|
\****************************************************************************/

float
Catena4916::ReadVbat(void) const
{
float volt = this->ReadAnalog(Catena491x::ANALOG_CHANNEL_VBAT, 1, 2);
return volt / 1000;
}

float
Catena4916::ReadVbus(void) const
{
return 0;
}

#endif // ARDUINO_ARCH_STM32

/**** end of Catena4916_ReadVoltage.cpp ****/
93 changes: 93 additions & 0 deletions src/lib/stm32/catena491x/Catena4916_getPlatformTable.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,93 @@
/*
Module: Catena4916_getPlatformTable.cpp
Function:
Catena4916::getPlatformTable()
Copyright notice:
See accompanying LICENSE file.
Author:
Pranau R, MCCI Corporation November 2022
*/

#ifdef ARDUINO_ARCH_STM32

#include "Catena4916.h"

#include "Catena_Log.h"
#include "Catena_Platforms.h"
#include "Catena_Guids.h"

/****************************************************************************\
|
| Read-only data.
|
\****************************************************************************/

namespace McciCatena {

const CATENA_PLATFORM gkPlatformCatena4916 =
{
Guid: GUID_HW_CATENA_4916_BASE(WIRE),
pParent: &gkPlatformCatena4916,
PlatformFlags:
CatenaBase::fHasLoRa |
CatenaBase::fHasTtnNycLoRa |
CatenaBase::fHasSHT3x |
CatenaBase::fHasBme680 |
CatenaBase::fHasADS131M04 |
CatenaBase::fHasSAMM8Q |
CatenaBase::fHasFRAM |
CatenaBase::fHasFlash
};

const CATENA_PLATFORM (* const Catena4916::vPlatforms[]) =
{
// entry 0 is the default
&gkPlatformCatena4916,
};

const size_t Catena4916::nvPlatforms = sizeof(Catena4916::vPlatforms) / sizeof(Catena4916::vPlatforms[0]);

/*
Name: Catena4916::getPlatformTable()
Function:
Get the known platform table.
Definition:
public: virtual
void Catena4916::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
Catena4916::getPlatformTable(
const CATENA_PLATFORM * const * &result_vPlatforms,
size_t &result_nvPlatforms
)
{
result_vPlatforms = vPlatforms;
result_nvPlatforms = nvPlatforms;
}

} /* namespace McciCatena */

#endif // ARDUINO_ARCH_STM32
Loading

0 comments on commit 1969ced

Please sign in to comment.