Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix #268: added platform support to Catena 4802 #269

Merged
merged 18 commits into from
Dec 23, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -136,7 +136,7 @@ script:
- _notsamd || arduino --verify $(_samdopts '' in866) $THISLIB/examples/catena_hello_lora/catena_hello_lora.ino

#
# *** TESTS FOR STM32L0 / Catena 4551. 46xx boards ****
# *** TESTS FOR STM32L0 / Catena 4551, 46xx, 480x boards ****
# test each of the STM32L0 boards
- _notstm32l0 || arduino --verify $(_stm32l0opts mcci_catena_4551) $THISLIB/examples/catena_hello/catena_hello.ino
- _notstm32l0 || arduino --verify $(_stm32l0opts mcci_catena_4551) $THISLIB/examples/catena_hello/catena_hello_lora.ino
Expand All @@ -154,6 +154,8 @@ script:
- _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
- _notstm32l0 || arduino --verify $(_stm32l0opts mcci_catena_4802) $THISLIB/examples/catena_hello/catena_hello.ino
- _notstm32l0 || arduino --verify $(_stm32l0opts mcci_catena_4802) $THISLIB/examples/catena_hello/catena_hello_lora.ino

#
# test the user-command and fsm examples on the 4610
Expand Down
20 changes: 16 additions & 4 deletions README.md

Large diffs are not rendered by default.

9 changes: 9 additions & 0 deletions assets/CatenaBase.plantuml
Original file line number Diff line number Diff line change
Expand Up @@ -267,6 +267,14 @@ class Catena4801 {
-{static}const CATENA_PLATFORM(* const vPlatforms[]);
-{static}const size_t nvPlatforms;
}

class Catena4802 {
+const char *CatenaName() const;
+float ReadVin() const;
#void getPlatformTable();
-{static}const CATENA_PLATFORM(* const vPlatforms[]);
-{static}const size_t nvPlatforms;
}
!endif

!if ($enableSamd == 1)
Expand Down Expand Up @@ -302,6 +310,7 @@ Catena461x <|-- Catena4617
Catena461x <|-- Catena4618
Catena463x <|-- Catena4630
Catena480x <|-- Catena4801
Catena480x <|-- Catena4802
!endif
}

Expand Down
6 changes: 6 additions & 0 deletions keywords.txt
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,13 @@ Catena455x KEYWORD1
Catena4610 KEYWORD1
Catena4611 KEYWORD1
Catena4612 KEYWORD1
Catena4617 KEYWORD1
Catena4618 KEYWORD1
Catena461x KEYWORD1
Catena4630 KEYWORD1
Catena463x KEYWORD1
Catena4801 KEYWORD1
Catena4802 KEYWORD1
Catena480x KEYWORD1
CatenaBase KEYWORD1
CatenaFeatherM0 KEYWORD1
Expand Down Expand Up @@ -99,6 +104,7 @@ PollAlarmState KEYWORD2
ReadAnalog KEYWORD2
ReadVbat KEYWORD2
ReadVbus KEYWORD2
ReadVin KEYWORD2
SECTOR_BASE KEYWORD2
SPICLOCK KEYWORD2
SafePrintf KEYWORD2
Expand Down
3 changes: 3 additions & 0 deletions src/Catena.h
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,9 @@ Copyright notice:
#elif defined(ARDUINO_MCCI_CATENA_4801) || defined(ARDUINO_CATENA_4801)
# include "Catena4801.h"
# define CATENA_H_SUPER_ McciCatena::Catena4801
#elif defined(ARDUINO_MCCI_CATENA_4802)
# include "Catena4802.h"
# define CATENA_H_SUPER_ McciCatena::Catena4802
/* fallback in case it's SAMD but not what we expect */
#elif defined(ARDUINO_ARCH_SAMD)
# include "CatenaSamd21.h"
Expand Down
62 changes: 62 additions & 0 deletions src/Catena4802.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
/*

Module: Catena4802.h

Function:
class Catena4802: CatenaBase Platform to represent a Catena 4802.

Copyright notice:
See accompanying LICENSE file.

Author:
Dhinesh Kumar Pitchai, MCCI Corporation November 2020

*/

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

#pragma once

#ifndef _CATENA480X_H_
# include "Catena480x.h"
#endif

namespace McciCatena {

class Catena4802 : public Catena480x
{
public:
using Super = Catena480x;

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

// uses default destructor

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

virtual const char *CatenaName() const override { return "Catena 4802"; };
float ReadVin(void) const;

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 Catena4802.h ****/
#endif /* _Catena4802_H_ */
4 changes: 2 additions & 2 deletions src/Catena480x.h
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ class Catena480x : public CatenaStm32L0

enum ANALOG_PINS
{
APIN_VBAT_SENSE = A0,
APIN_VBAT_SENSE = A0, /* for 4802 it is referred as VIN */
};

enum ANALOG_CHANNELS
Expand All @@ -79,7 +79,7 @@ class Catena480x : public CatenaStm32L0
ANALOG_CHANNEL_A2 = 4,
ANALOG_CHANNEL_A3 = 3,
ANALOG_CHANNEL_A4 = 2,
ANALOG_CHANNEL_VBAT = ANALOG_CHANNEL_A0,
ANALOG_CHANNEL_VBAT = ANALOG_CHANNEL_A0, /* for 4802 it is referred as VIN */
ANALOG_CHANNEL_VREF = 17,
};

Expand Down
4 changes: 3 additions & 1 deletion src/CatenaBase.h
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ Copyright notice:
#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, 19, 0, 30) /* v0.19.0.30 */
#define CATENA_ARDUINO_PLATFORM_VERSION CATENA_ARDUINO_PLATFORM_VERSION_CALC(0, 19, 0, 40) /* v0.19.0.40 */

#define CATENA_ARDUINO_PLATFORM_VERSION_GET_MAJOR(v) \
(((v) >> 24u) & 0xFFu)
Expand Down Expand Up @@ -178,6 +178,8 @@ class CatenaBase
fHasHS001 = 1 << 19,
//platform has SHT3x sensirion
fHasSHT3x = 1 << 20,
//platform has I2C Level Shifter
fHasI2cLevelShifter = 1 << 21,

// 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 @@ -229,5 +229,9 @@ Copyright notice:
#define GUID_HW_CATENA_4801_BASE(f) \
MCCIADK_GUID_GEN_INIT(f, 0x10ea7e25, 0xa4a4, 0x45fd, 0x89, 0x59, 0xc0, 0x4a, 0x6a, 0x5d, 0x7f, 0x95)

// {daaf345e-b5d5-4a32-a303-3ac70b81d260}
#define GUID_HW_CATENA_4802_BASE(f) \
MCCIADK_GUID_GEN_INIT(f, 0xdaaf345e, 0xb5d5, 0x4a32, 0xa3, 0x03, 0x3a, 0xc7, 0x0b, 0x81, 0xd2, 0x60)

/**** end of catena_guids.h ****/
#endif /* _CATENA_GUIDS_H_ */
1 change: 1 addition & 0 deletions src/Catena_Platforms.h
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,7 @@ extern const CATENA_PLATFORM gkPlatformCatena4618;
extern const CATENA_PLATFORM gkPlatformCatena4630;

extern const CATENA_PLATFORM gkPlatformCatena4801;
extern const CATENA_PLATFORM gkPlatformCatena4802;

} /* namespace McciCatena */

Expand Down
57 changes: 57 additions & 0 deletions src/lib/stm32/catena480x/Catena4802_ReadVoltage.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
/*

Module: Catena4802_ReadVoltage.cpp

Function:
Catena4802::ReadVin()

Copyright notice:
See accompanying LICENSE file.

Author:
Dhinesh Kumar Pitchai, MCCI Corporation November 2020

Revision history:
See https://github.com/mcci-catena/Catena-Arduino-Platform

*/

#ifdef ARDUINO_ARCH_STM32

#include "Catena4802.h"

#include <Arduino.h>
using namespace McciCatena;

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



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



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

float
Catena4802::ReadVin(void) const
dhineshkumarmcci marked this conversation as resolved.
Show resolved Hide resolved
{
float volt = this->ReadAnalog(Catena480x::ANALOG_CHANNEL_VBAT, 1, 3);
return volt / 1000;
}

#endif // ARDUINO_ARCH_STM32

/**** end of Catena4802_ReadVoltage.cpp ****/
86 changes: 86 additions & 0 deletions src/lib/stm32/catena480x/Catena4802_getPlatformTable.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,86 @@
/*

Module: Catena4802_getPlatformTable.cpp

Function:
Catena4802::getPlatformTable()

Copyright notice:
See accompanying LICENSE file.

Author:
Dhinesh Kumar Pitchai, MCCI Corporation November 2020

*/

#ifdef ARDUINO_ARCH_STM32

#include "Catena4802.h"

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

namespace McciCatena {

const CATENA_PLATFORM gkPlatformCatena4802 =
{
Guid: GUID_HW_CATENA_4802_BASE(WIRE),
pParent: &gkPlatformCatena4802,
PlatformFlags:
CatenaBase::fHasLoRa |
CatenaBase::fHasTtnNycLoRa |
CatenaBase::fHasFRAM |
CatenaBase::fHasFlash |
CatenaBase::fHasRS485 |
CatenaBase::fHasSHT3x |
CatenaBase::fHasI2cLevelShifter
};

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

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

/*

Name: Catena4802::getPlatformTable()

Function:
Get the known platform table.

Definition:
public: virtual
void Catena4802::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
Catena4802::getPlatformTable(
const CATENA_PLATFORM * const * &result_vPlatforms,
size_t &result_nvPlatforms
)
{
result_vPlatforms = vPlatforms;
result_nvPlatforms = nvPlatforms;
}

} /* namespace McciCatena */

#endif // ARDUINO_ARCH_STM32