Skip to content

Commit

Permalink
Issue #323: major refactor of power, peripherals
Browse files Browse the repository at this point in the history
  • Loading branch information
terrillmoore committed Nov 29, 2021
1 parent 87b011f commit 11a9e90
Show file tree
Hide file tree
Showing 14 changed files with 1,517 additions and 62 deletions.
4 changes: 2 additions & 2 deletions library.properties
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
name=MCCI Catena Arduino Platform
version=0.21.2
version=0.23.0-pre1
author=Terry Moore, ChaeHee Won, Sungjoon Park, Dhinesh Kumar Pitchai
maintainer=MCCI Corporation <[email protected]>
sentence=Arduino library for MCCI Catena 44xx, 45xx, 46xx and 48xx systems.
paragraph=This library provides platform support for the MCCI Catena family of IoT systems, based on the Adafruit Feather M0 LoRa, or on the Murata LoRaWAN module. FRAM system configuration, generalized polling, and a number of low-level drivers are included for the peripherals that are included with the system. A non-blocking event-driven USB-serial command interface is also provided, along with a generalized command parsing framework.
category=Other
architectures=samd,stm32
architectures=*
url=https://github.com/mcci-catena/Catena-Arduino-Platform
dot_a_linkage=true
includes=Catena.h
Expand Down
144 changes: 144 additions & 0 deletions src/Catena.h
Original file line number Diff line number Diff line change
Expand Up @@ -104,9 +104,153 @@ class Catena : public CATENA_H_SUPER_
Catena(const Catena&&) = delete;
Catena& operator=(const Catena&&) = delete;

///
/// \brief implementation: set up everything on this particular board.
///
/// \return \c true if setup was successful.
///
virtual bool setup(void) override;

virtual uint32_t enable_3v3Boost(bool fRequest) override
{
return this->m_3v3.enable(fRequest);
}

virtual bool get_3v3BoostRequest() const override
{
return this->m_3v3.getRequest();
}

virtual bool has_3v3BoostControl() const override
{
return this->m_3v3.hasControl();
}

uint8_t has_screwTerminals() const override
{
return sizeof(this->m_screwTerminal) / sizeof(this->m_screwTerminal[0]);
}

//virtual const char *get_screwTerminalLabel(uint8_t iTerminal) const override;
//virtual uint8_t get_screwTerminalPin2(uint8_t iTerminal) const override;
//virtual uint8_t get_screwTerminalPin3(uint8_t iTerminal) const override;

virtual uint32_t enable_screwTerminalVdd(uint8_t iTerminal, bool fState) override
{
if (iTerminal < this->has_screwTerminals())
return this->m_screwTerminal[iTerminal].enable(fState);
else
return 0;
}
virtual bool get_screwTerminalVddRequest(uint8_t iTerminal) override
{
if (iTerminal < this->has_screwTerminals())
return this->m_screwTerminal[iTerminal].getRequest();
else
return false;
}
virtual bool has_screwTerminalVddControl(uint8_t iTerminal) override
{
if (iTerminal < this->has_screwTerminals())
return this->m_screwTerminal[iTerminal].hasControl();
else
return false;
}

virtual uint32_t enable_i2cVdd(bool fState) override
{
return this->m_i2cVdd.enable(fState);
}
virtual bool has_i2cVddControl() const override
{
return this->m_i2cVdd.hasControl();
}
virtual bool get_i2cVddRequest() const override
{
return this->m_i2cVdd.getRequest();
}

virtual bool has_flash() const override;

virtual cFlash *get_flash() const override;

virtual SPIClass *get_flashBus() const override;

virtual uint32_t enable_flashVdd(bool fState) override
{
return this->m_flashVdd.enable(fState);
}
virtual bool has_flashVddControl() const override
{
return this->m_flashVdd.hasControl();
}
virtual bool get_flashVddRequest() const override
{
return this->m_flashVdd.getRequest();
}

/// \brief determine whether flash was successfully probed
bool get_flashFound() const
{
return this->m_flashFound;
}

/// \brief record whether flash was successfully probed.
void set_flashFound(bool fFound)
{
this->m_flashFound = fFound;
}

virtual bool has_fram() const override;

// virtual cFram *getFram(void) override;
virtual uint32_t get_framSize() const override;
virtual ::TwoWire *get_framBus() const override;

virtual uint32_t enable_framVdd(bool fStatus) override
{
return this->m_framVdd.enable(fStatus);
}
virtual bool has_framVddControl() const override
{
return this->m_framVdd.hasControl();
}
virtual bool get_framVddRequest() const override
{
return this->m_framVdd.getRequest();
}

// virtual bool has_externalI2cBus() const override;
// virtual uint32_t enable_externalI2cBridgeVdd(bool fStatus) override;
// virtual bool get_externalI2cBridgeVddRequest() const override;
// virtual bool has_externalI2cBridgeVddControl() const override;

// sensors -- these go in the individual files.

// virtual bool has_BME280() const override;
// virtual bool has_BME680() const override;
// virtual bool has_HS3001() const override;
// virtual bool has_SHT3x() const override;
// virtual uint32_t enable_SHT3x(bool fStatus) override;
// virtual bool get_SHT3xRequest() const override;
// virtual bool has_SHT3xPowerControl() const override;
// virtual bool has_SGPC3() const override;
// virtual uint32_t enable_SGPC3(bool) override;
// virtual bool get_SGPC3Request() const override;
// virtual bool has_SGPC3PowerControl() const override;
// virtual bool has_PMS7003() const override;
// virtual uint32_t enable_PMS7003(bool fStatus) override;
// virtual bool get_PMS7003Request() const override;
// virtual bool has_PMS7003Control() const override;
// virtual bool has_Si1133() const override;
// virtual bool has_BH1750() const override;
// virtual bool get_PMS7003Request() const override;

protected:

private:
/// \brief local routine to isolate the flash / download setup.
bool setup_flash(void);
};

} // namespace McciCatena
Expand Down
63 changes: 63 additions & 0 deletions src/Catena455x.h
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,70 @@ class Catena455x : public CatenaStm32L0
virtual float ReadVbat(void) const override;
virtual float ReadVbus(void) const override;

virtual const char *get_screwTerminalLabel(uint8_t iTerminal) const override
{
static const char jp3[] = "JP3";
static const char jp4[] = "JP4";
return iTerminal == 0 ? jp3 : iTerminal == 1 ? jp4 : nullptr;
}

virtual uint8_t get_screwTerminalPin2(uint8_t iTerminal) const override
{
return iTerminal == 0 ? D5 : iTerminal == 1 ? A1 : 0;
}
virtual uint8_t get_screwTerminalPin3(uint8_t iTerminal) const override
{
return iTerminal == 0 ? D12 : iTerminal == 1 ? A2 : 0;
}

virtual bool has_BME280() const override
{ return true; }
// virtual bool has_BME680() const override;
// virtual bool has_HS3001() const override;
// virtual bool has_SHT3x() const override;
// virtual uint32_t enable_SHT3x(bool fStatus) override;
// virtual bool get_SHT3xRequest() const override;
// virtual bool has_SHT3xPowerControl() const override;
// virtual bool has_SGPC3() const override;
// virtual uint32_t enable_SGPC3(bool) override;
// virtual bool get_SGPC3Request() const override;
// virtual bool has_SGPC3PowerControl() const override;
// virtual bool has_PMS7003() const override;
// virtual uint32_t enable_PMS7003(bool fStatus) override;
// virtual bool get_PMS7003Request() const override;
// virtual bool has_PMS7003Control() const override;
virtual bool has_Si1133() const override
{ return true; }
// virtual bool has_BH1750() const override;
// virtual bool get_PMS7003Request() const override;
// virtual uint32_t enable_tcxo(bool fStatus) override;
// virtual bool get_tcxoRequest() const override;
// virtual bool has_txcoControl() const override;
virtual bool has_usbPort() const override
{
return true;
}
virtual bool get_consoleIsUsb() const override
{
#ifdef USBCON
return true;
#else
return false;
#endif
}
virtual bool has_usbVbusMeasurementStandard() const override
{ return true; }
virtual uint8_t get_usbVbusMeasurementPin() const override
{ return APIN_VBUS_SENSE; }

protected:
cPowerControlDummy m_3v3;
cPowerControlDummy m_flashVdd;
cPowerControlDummy m_screwTerminal[2];
cPowerControlDummy m_i2cVdd;
cPowerControlDummy m_framVdd;
cPowerControlDummy m_externalI2cBridgeVdd;
cPowerControlDummy m_tcxo;

private:
};
Expand Down
94 changes: 72 additions & 22 deletions src/Catena4612.h
Original file line number Diff line number Diff line change
@@ -1,37 +1,16 @@
/* Catena4612.h Fri Dec 28 2018 13:58:18 chwon */

/*
Module: Catena4612.h
Function:
class Catena4612: CatenaBase Platform to represent a Catena 4612
Version:
V0.13.0 Fri Dec 28 2018 13:58:19 chwon Edit level 2
Copyright notice:
This file copyright (C) 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 November 2018
Revision history:
0.11.0 Thu Nov 15 2018 15:07:23 chwon
Module created.
0.13.0 Fri Dec 28 2018 13:58:19 chwon
Add ReadVbat() and ReadVbus() override.
*/

#ifndef _Catena4612_H_ /* prevent multiple includes */
Expand Down Expand Up @@ -65,6 +44,77 @@ class Catena4612 : public Catena461x
virtual float ReadVbat(void) const override;
virtual float ReadVbus(void) const override;

virtual const char *get_screwTerminalLabel(uint8_t iTerminal) const override
{
static const char jp4[] = "JP4";
static const char jp5[] = "JP5";
return iTerminal == 0 ? jp4 : iTerminal == 1 ? jp5 : nullptr;
}

virtual uint8_t get_screwTerminalPin2(uint8_t iTerminal) const override
{
return iTerminal == 0 ? D5 : iTerminal == 1 ? A1 : 0;
}
virtual uint8_t get_screwTerminalPin3(uint8_t iTerminal) const override
{
return iTerminal == 0 ? D12 : iTerminal == 1 ? A2 : 0;
}

virtual bool has_BME280() const override
{ return true; }
// virtual bool has_BME680() const override;
// virtual bool has_HS3001() const override;
// virtual bool has_SHT3x() const override;
// virtual uint32_t enable_SHT3x(bool fStatus) override;
// virtual bool get_SHT3xRequest() const override;
// virtual bool has_SHT3xPowerControl() const override;
// virtual bool has_SGPC3() const override;
// virtual uint32_t enable_SGPC3(bool) override;
// virtual bool get_SGPC3Request() const override;
// virtual bool has_SGPC3PowerControl() const override;
// virtual bool has_PMS7003() const override;
// virtual uint32_t enable_PMS7003(bool fStatus) override;
// virtual bool get_PMS7003Request() const override;
// virtual bool has_PMS7003Control() const override;
virtual bool has_Si1133() const override
{ return true; }
// virtual bool has_BH1750() const override;
// virtual bool get_PMS7003Request() const override;
virtual uint32_t enable_tcxo(bool fStatus) override
{ return this->m_tcxo.enable(fStatus); }
virtual bool get_tcxoRequest() const override
{ return this->m_tcxo.getRequest(); }
virtual bool has_tcxoControl() const override
{ return this->m_tcxo.hasControl(); }
virtual bool has_usbPort() const override
{
return true;
}
virtual bool get_consoleIsUsb() const override
{
#ifdef USBCON
return true;
#else
return false;
#endif
}
virtual bool has_usbVbusMeasurementStandard() const override
{ return true; }
virtual uint8_t get_usbVbusMeasurementPin() const override
{ return APIN_VBUS_SENSE; }

protected:
cPowerControlGPIO m_Vout1 = cPowerControlGPIO{ D10, 10 };
cPowerControlGPIO m_Vout2 = cPowerControlGPIO{ D11, 10 };
cPowerControlNested m_screwTerminal[2] = { cPowerControlNested{this->m_Vout1}, cPowerControlNested{this->m_Vout2} };
cPowerControlGPIO m_PB8 = cPowerControlGPIO{ D33, 10 };
cPowerControlNested m_3v3 = cPowerControlNested{ this->m_PB8 };
cPowerControlNested m_tcxo = cPowerControlNested{ this->m_PB8 };
cPowerControlDummy m_flashVdd;
cPowerControlDummy m_i2cVdd;
cPowerControlDummy m_framVdd;
cPowerControlDummy m_externalI2cBridgeVdd;

protected:
// we are required to provide a table of platforms
virtual void getPlatformTable(
Expand Down
16 changes: 1 addition & 15 deletions src/Catena461x.h
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
/* Catena461x.h Fri Dec 28 2018 13:54:46 chwon */

/*
Module: Catena461x.h
Expand All @@ -8,20 +6,8 @@ Module: Catena461x.h
class Catena461x: CatenaBase Platform to represent a Catena 461x
(4610, 4611, 4612, etc.)
Version:
V0.13.0 Fri Dec 28 2018 13:54:47 chwon Edit level 3
Copyright notice:
This file copyright (C) 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 November 2018
Expand Down
Loading

0 comments on commit 11a9e90

Please sign in to comment.