Skip to content

Commit 1969ced

Browse files
fix #345: add support to Model4916
1 parent 17a7ecc commit 1969ced

10 files changed

+465
-0
lines changed

src/Catena.h

+3
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,9 @@ Copyright notice:
6464
#elif defined(ARDUINO_MCCI_CATENA_4802)
6565
# include "Catena4802.h"
6666
# define CATENA_H_SUPER_ McciCatena::Catena4802
67+
#elif defined(ARDUINO_MCCI_MODEL_4916) || defined(ARDUINO_MODEL_4916)
68+
# include "Catena4916.h"
69+
# define CATENA_H_SUPER_ McciCatena::Catena4916
6770
/* fallback in case it's SAMD but not what we expect */
6871
#elif defined(ARDUINO_ARCH_SAMD)
6972
# include "CatenaSamd21.h"

src/Catena4916.h

+63
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,63 @@
1+
/*
2+
3+
Module: Catena4916.h
4+
5+
Function:
6+
class Catena4916: CatenaBase Platform to represent a Catena 4916
7+
8+
Copyright notice:
9+
See accompanying LICENSE file.
10+
11+
Author:
12+
Dhinesh Kumar Pitchai, MCCI Corporation November 2022
13+
14+
*/
15+
16+
#ifndef _Catena4916_H_ /* prevent multiple includes */
17+
#define _Catena4916_H_
18+
19+
#pragma once
20+
21+
#ifndef _CATENA491x_H_
22+
# include "Catena491x.h"
23+
#endif
24+
25+
namespace McciCatena {
26+
27+
class Catena4916 : public Catena491x
28+
{
29+
public:
30+
using Super = Catena4916;
31+
32+
// no specific constructor.
33+
Catena4916() {};
34+
35+
// uses default destructor
36+
37+
// neither copyable nor movable
38+
Catena4916(const Catena4916&) = delete;
39+
Catena4916& operator=(const Catena4916&) = delete;
40+
Catena4916(const Catena4916&&) = delete;
41+
Catena4916& operator=(const Catena4916&&) = delete;
42+
43+
virtual const char *CatenaName() const override { return "Catena 4916"; };
44+
virtual float ReadVbat(void) const override;
45+
virtual float ReadVbus(void) const override;
46+
47+
protected:
48+
// we are required to provide a table of platforms
49+
virtual void getPlatformTable(
50+
const CATENA_PLATFORM * const * &vPlatforms,
51+
size_t &nvPlatforms
52+
) override;
53+
54+
private:
55+
// the known platforms
56+
static const CATENA_PLATFORM(* const vPlatforms[]);
57+
static const size_t nvPlatforms;
58+
};
59+
60+
} // namespace McciCatena
61+
62+
/**** end of Catena4916.h ****/
63+
#endif /* _Catena4916_H_ */

src/Catena491x.h

+104
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,104 @@
1+
/*
2+
3+
Module: Catena491x.h
4+
5+
Function:
6+
class Catena491x: CatenaBase Platform to represent a Catena 491x
7+
(such as the 4916).
8+
9+
Copyright notice:
10+
See accompanying LICENSE file.
11+
12+
Author:
13+
Dhinesh Kumar Pitchai, MCCI Corporation November 2022
14+
15+
*/
16+
17+
#ifndef _CATENA491X_H_ /* prevent multiple includes */
18+
#define _CATENA491X_H_
19+
20+
#pragma once
21+
22+
#ifndef _CATENASTM32L0_H_
23+
# include "CatenaStm32L0.h"
24+
#endif
25+
26+
namespace McciCatena {
27+
28+
class Catena491x : public CatenaStm32L0
29+
{
30+
public:
31+
using Super = CatenaStm32L0;
32+
33+
// no specific constructor.
34+
Catena491x() {};
35+
36+
// uses default destructor
37+
38+
// neither copyable nor movable
39+
Catena491x(const Catena491x&) = delete;
40+
Catena491x& operator=(const Catena491x&) = delete;
41+
Catena491x(const Catena491x&&) = delete;
42+
Catena491x& operator=(const Catena491x&&) = delete;
43+
44+
// LoRaWAN binding
45+
class LoRaWAN /* forward */;
46+
47+
enum ANALOG_PINS
48+
{
49+
APIN_VBAT_SENSE = A1,
50+
// APIN_VBUS_SENSE = A4,
51+
};
52+
53+
enum ANALOG_CHANNELS
54+
{
55+
ANALOG_CHANNEL_A1 = 5,
56+
ANALOG_CHANNEL_A2 = 4,
57+
ANALOG_CHANNEL_A3 = 3,
58+
ANALOG_CHANNEL_A4 = 2,
59+
ANALOG_CHANNEL_VBAT = ANALOG_CHANNEL_A1,
60+
ANALOG_CHANNEL_VREF = 17,
61+
};
62+
63+
enum DIGITAL_PINS
64+
{
65+
PIN_STATUS_LED = D13,
66+
PIN_SPI2_FLASH_SS = D19,
67+
PIN_SPI2_MOSI = D23,
68+
PIN_SPI2_MISO = D22,
69+
PIN_SPI2_SCK = D24,
70+
};
71+
72+
// methods
73+
virtual bool begin() override;
74+
75+
protected:
76+
77+
private:
78+
};
79+
80+
/*
81+
|| The LoRaWAN class for the Catena 455x. Assumes The Things Network
82+
*/
83+
class Catena491x::LoRaWAN : public CatenaStm32L0::LoRaWAN
84+
{
85+
public:
86+
using Super = CatenaStm32L0::LoRaWAN;
87+
88+
/*
89+
|| the constructor. We don't do anything at this level, the
90+
|| Super constructor does most of the work.
91+
*/
92+
LoRaWAN() {};
93+
94+
bool begin(Catena491x *pParent);
95+
96+
protected:
97+
98+
private:
99+
};
100+
101+
} // namespace McciCatena
102+
103+
/**** end of Catena491x.h ****/
104+
#endif /* _CATENA491X_H_ */

src/CatenaBase.h

+4
Original file line numberDiff line numberDiff line change
@@ -210,6 +210,10 @@ class CatenaBase
210210
fHasSHT3x = 1 << 20,
211211
//platform has I2C Level Shifter
212212
fHasI2cLevelShifter = 1 << 21,
213+
//platform has GPS SAM-M8Q
214+
fHasSAMM8Q = 1 << 22,
215+
//platform has ADS131M04
216+
fHasADS131M04 = 1 << 23,
213217

214218
// special wiring variants all are offsets from M100...
215219
// we support up to 127 variants, becuase we have 7

src/Catena_Guids.h

+4
Original file line numberDiff line numberDiff line change
@@ -233,5 +233,9 @@ Copyright notice:
233233
#define GUID_HW_CATENA_4802_BASE(f) \
234234
MCCIADK_GUID_GEN_INIT(f, 0xdaaf345e, 0xb5d5, 0x4a32, 0xa3, 0x03, 0x3a, 0xc7, 0x0b, 0x81, 0xd2, 0x60)
235235

236+
// {2eadd9eb-80e3-4e14-99c6-851f036ffa8d}
237+
#define GUID_HW_CATENA_4916_BASE(f) \
238+
MCCIADK_GUID_GEN_INIT(f, 0x2eadd9eb, 0x80e3, 0x4e14, 0x99, 0xc6, 0x85, 0x1f, 0x03, 0x6f, 0xfa, 0x8d)
239+
236240
/**** end of catena_guids.h ****/
237241
#endif /* _CATENA_GUIDS_H_ */

src/Catena_Platforms.h

+2
Original file line numberDiff line numberDiff line change
@@ -79,6 +79,8 @@ extern const CATENA_PLATFORM gkPlatformCatena4630;
7979
extern const CATENA_PLATFORM gkPlatformCatena4801;
8080
extern const CATENA_PLATFORM gkPlatformCatena4802;
8181

82+
extern const CATENA_PLATFORM gkPlatformCatena4916;
83+
8284
} /* namespace McciCatena */
8385

8486
/**** end of Catena_Platforms.h ****/
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,61 @@
1+
/*
2+
3+
Module: Catena4916_ReadVoltage.cpp
4+
5+
Function:
6+
Catena4916::ReadVbat() and Catena4916::ReadVbus()
7+
8+
Copyright notice:
9+
See accompanying LICENSE file.
10+
11+
Author:
12+
Pranau R, MCCI Corporation November 2022
13+
14+
*/
15+
16+
#ifdef ARDUINO_ARCH_STM32
17+
18+
#include "Catena4916.h"
19+
#include "Catena_Log.h"
20+
21+
#include <Arduino.h>
22+
using namespace McciCatena;
23+
24+
/****************************************************************************\
25+
|
26+
| Manifest constants & typedefs.
27+
|
28+
\****************************************************************************/
29+
30+
31+
32+
/****************************************************************************\
33+
|
34+
| Read-only data.
35+
|
36+
\****************************************************************************/
37+
38+
39+
40+
/****************************************************************************\
41+
|
42+
| Variables.
43+
|
44+
\****************************************************************************/
45+
46+
float
47+
Catena4916::ReadVbat(void) const
48+
{
49+
float volt = this->ReadAnalog(Catena491x::ANALOG_CHANNEL_VBAT, 1, 2);
50+
return volt / 1000;
51+
}
52+
53+
float
54+
Catena4916::ReadVbus(void) const
55+
{
56+
return 0;
57+
}
58+
59+
#endif // ARDUINO_ARCH_STM32
60+
61+
/**** end of Catena4916_ReadVoltage.cpp ****/
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,93 @@
1+
/*
2+
3+
Module: Catena4916_getPlatformTable.cpp
4+
5+
Function:
6+
Catena4916::getPlatformTable()
7+
8+
Copyright notice:
9+
See accompanying LICENSE file.
10+
11+
Author:
12+
Pranau R, MCCI Corporation November 2022
13+
14+
*/
15+
16+
#ifdef ARDUINO_ARCH_STM32
17+
18+
#include "Catena4916.h"
19+
20+
#include "Catena_Log.h"
21+
#include "Catena_Platforms.h"
22+
#include "Catena_Guids.h"
23+
24+
/****************************************************************************\
25+
|
26+
| Read-only data.
27+
|
28+
\****************************************************************************/
29+
30+
namespace McciCatena {
31+
32+
const CATENA_PLATFORM gkPlatformCatena4916 =
33+
{
34+
Guid: GUID_HW_CATENA_4916_BASE(WIRE),
35+
pParent: &gkPlatformCatena4916,
36+
PlatformFlags:
37+
CatenaBase::fHasLoRa |
38+
CatenaBase::fHasTtnNycLoRa |
39+
CatenaBase::fHasSHT3x |
40+
CatenaBase::fHasBme680 |
41+
CatenaBase::fHasADS131M04 |
42+
CatenaBase::fHasSAMM8Q |
43+
CatenaBase::fHasFRAM |
44+
CatenaBase::fHasFlash
45+
};
46+
47+
const CATENA_PLATFORM (* const Catena4916::vPlatforms[]) =
48+
{
49+
// entry 0 is the default
50+
&gkPlatformCatena4916,
51+
};
52+
53+
const size_t Catena4916::nvPlatforms = sizeof(Catena4916::vPlatforms) / sizeof(Catena4916::vPlatforms[0]);
54+
55+
/*
56+
57+
Name: Catena4916::getPlatformTable()
58+
59+
Function:
60+
Get the known platform table.
61+
62+
Definition:
63+
public: virtual
64+
void Catena4916::getPlatformTable(
65+
const CATENA_PLATFORM * const * &vPlatforms,
66+
size_t &nvPlatforms
67+
) override;
68+
69+
Description:
70+
This override for getPlatformTable() returns the vector of platform
71+
GUIDs for this Catena.
72+
73+
Returns:
74+
vPlatforms is set to the base of the array of pointers to platform
75+
stuctures; and nvPlatforms is set to the number of entries in
76+
the table.
77+
78+
*/
79+
80+
/* public virtual override */
81+
void
82+
Catena4916::getPlatformTable(
83+
const CATENA_PLATFORM * const * &result_vPlatforms,
84+
size_t &result_nvPlatforms
85+
)
86+
{
87+
result_vPlatforms = vPlatforms;
88+
result_nvPlatforms = nvPlatforms;
89+
}
90+
91+
} /* namespace McciCatena */
92+
93+
#endif // ARDUINO_ARCH_STM32

0 commit comments

Comments
 (0)