├── src ├── Catena_CommandStream_vmicro_fixup.h ├── lib │ ├── stm32 │ │ ├── stm32l0 │ │ │ ├── CatenaStm32L0_FlashParams_kPageEndSignature1_Guid.cpp │ │ │ ├── CatenaStm32L0_GetSystemClockRate.cpp │ │ │ ├── CatenaStm32L0_LoRaWAN_storage.cpp │ │ │ ├── CatenaStm32L0_Sleep.cpp │ │ │ ├── CatenaStm32L0_LoRaWAN_getprovisioningstyle.cpp │ │ │ ├── CatenaStm32L0_registerCommands.cpp │ │ │ └── CatenaStm32L0_LoRaWAN_getotaaprovisioninginfo.cpp │ │ ├── catena463x │ │ │ ├── Catena463x_begin.cpp │ │ │ ├── Catena463x_LoRaWAN_begin.cpp │ │ │ ├── Catena4630_ReadVoltage.cpp │ │ │ └── Catena4630_getPlatformTable.cpp │ │ ├── CatenaStm32.cpp │ │ ├── catena480x │ │ │ ├── Catena4802_ReadVoltage.cpp │ │ │ ├── Catena480x_begin.cpp │ │ │ ├── Catena480x_LoRaWAN_begin.cpp │ │ │ ├── Catena4802_getPlatformTable.cpp │ │ │ ├── Catena480x_ReadVoltage.cpp │ │ │ └── Catena4801_getPlatformTable.cpp │ │ ├── catena461x │ │ │ ├── Catena461x_begin.cpp │ │ │ ├── Catena461x_LoRaWAN_begin.cpp │ │ │ ├── Catena4617_ReadVoltage.cpp │ │ │ ├── Catena4618_ReadVoltage.cpp │ │ │ ├── Catena4617_getPlatformTable.cpp │ │ │ ├── Catena4618_getPlatformTable.cpp │ │ │ ├── Catena4610_ReadVoltage.cpp │ │ │ └── Catena4611_ReadVoltage.cpp │ │ ├── catena455x │ │ │ ├── Catena455x_begin.cpp │ │ │ ├── Catena455x_LoRaWAN_begin.cpp │ │ │ └── Catena455x_ReadVoltage.cpp │ │ ├── CatenaStm32_registerCommands.cpp │ │ └── CatenaStm32_GetUniqueID.cpp │ ├── samd │ │ ├── catena4420 │ │ │ ├── Catena4420.cpp │ │ │ ├── Catena4420_gk_lorawan_keys.cpp │ │ │ └── catena4420_getlorawankeys.cpp │ │ ├── catenawingfram2k │ │ │ ├── CatenaWingFram2k_ReadVbat.cpp │ │ │ ├── CatenaWingFram2k_registerCommands.cpp │ │ │ ├── CatenaWingFram2k_LoRaWAN_begin.cpp │ │ │ └── CatenaWingFram2k_begin.cpp │ │ ├── featherm0 │ │ │ ├── catenafeatherm0_readvbat.cpp │ │ │ ├── catenafeatherm0_begin.cpp │ │ │ ├── catenafeatherm0_lorawan_getprovisioningstyle.cpp │ │ │ ├── catenafeatherm0_lorawan_getotaaprovisioninginfo.cpp │ │ │ └── catenafeatherm0_lorawan_getabpprovisioninginfo.cpp │ │ ├── CatenaSamd21.cpp │ │ ├── catena4410 │ │ │ ├── Catena4410_gk_lorawan_keys.cpp │ │ │ ├── Catena4410.cpp │ │ │ └── catena4410_getlorawankeys.cpp │ │ ├── catena4470 │ │ │ └── Catena4470_getPlatformTable.cpp │ │ ├── catena4450 │ │ │ └── Catena4450_getPlatformTable.cpp │ │ ├── catena4460 │ │ │ └── Catena4460_getPlatformTable.cpp │ │ ├── catenasamd21_getuniqueid.cpp │ │ ├── CatenaSamd21_registerCommands.cpp │ │ └── CatenaSamd21_Sleep.cpp │ ├── Catena_Log.cpp │ ├── CatenaBase_GetSysEUI.cpp │ ├── CatenaBase_GetUniqueIDstring.cpp │ ├── CatenaBase.cpp │ ├── CatenaBase_SafePrintf.cpp │ └── CatenaBase_NetSave.cpp ├── McciHwInfo.h ├── CatenaBase_types.h ├── Catena4410_project_config.h ├── Catena4420_project_config.h ├── Catena_Guids_FramStorage.h ├── Catena4802.h ├── Catena4630.h ├── Catena_Completion.h ├── Catena4617.h ├── Catena4618.h ├── CatenaStm32.h ├── Catena_WatchdogTimer.h ├── Catena4420.h ├── Catena4801.h ├── Catena4551.h ├── Catena4470.h ├── Catena4460.h ├── Catena4610.h ├── Catena4611.h ├── Catena4612.h ├── Catena_PersistentStorage.h ├── Catena_Fram2k.h ├── Catena_Fram8k.h ├── Catena_functional.h ├── Catena_Flash.h ├── Catena_Mb85rc64ta.h ├── CatenaStm32L0Rtc.h ├── Catena463x.h ├── Catena4450.h ├── CatenaSamd21.h ├── Catena455x.h ├── CatenaRTC.h ├── CatenaFeatherM0.h ├── Catena_Totalizer.h └── Catena_limits.h ├── .gitignore ├── library.properties ├── assets ├── FSMexample.plantuml ├── Catena_PollableInterface.plantuml ├── cFramStorage.plantuml └── cFram.plantuml ├── LICENSE ├── examples ├── catena_hello │ └── catena_hello.ino └── catena_hello_lora │ └── catena_hello_lora.ino └── TODO.md /src/Catena_CommandStream_vmicro_fixup.h: -------------------------------------------------------------------------------- 1 | /* 2 | 3 | Module: Catena_CommandStream_vmicro_fixup.h 4 | 5 | Function: 6 | Define some symbols needed by Visual Micro .ino processing. 7 | 8 | Copyright: 9 | See accompanying LICENSE file. 10 | 11 | Author: 12 | Terry Moore, MCCI Corporation April 2019 13 | 14 | */ 15 | 16 | #pragma once 17 | 18 | #ifndef _CATENA_COMMANDSTREAM_VMICRO_FIXUP_H_ 19 | #define _CATENA_COMMANDSTREAM_VMICRO_FIXUP_H_ 20 | 21 | typedef McciCatena::cCommandStream::CommandStatus CommandStatus; 22 | typedef McciCatena::cCommandStream cCommandStream; 23 | 24 | #endif /* _CATENA_COMMANDSTREAM_VMICRO_FIXUP_H_ */ 25 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | # Compiled Object files 2 | *.slo 3 | *.lo 4 | *.o 5 | *.obj 6 | 7 | # Precompiled Headers 8 | *.gch 9 | *.pch 10 | 11 | # Compiled Dynamic libraries 12 | *.so 13 | *.dylib 14 | *.dll 15 | 16 | # Fortran module files 17 | *.mod 18 | *.smod 19 | 20 | # Compiled Static libraries 21 | *.lai 22 | *.la 23 | *.a 24 | *.lib 25 | 26 | # Executables 27 | *.exe 28 | *.out 29 | *.app 30 | 31 | # Backup and checkpoint files 32 | *.BAK 33 | *.CKP 34 | emacs.core 35 | 36 | # vs code files 37 | .vscode 38 | *~ 39 | 40 | # visual micro files 41 | *.vcxitems 42 | vs-readme.txt 43 | 44 | # visual studio things 45 | .vs 46 | Debug 47 | __vm 48 | *.vcxproj 49 | *.vcxproj.filters 50 | *.vcxproj.user 51 | -------------------------------------------------------------------------------- /src/lib/stm32/stm32l0/CatenaStm32L0_FlashParams_kPageEndSignature1_Guid.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | 3 | Name: CatenaStm32L0_FlashParams_kPageEndSignature1_Guid.cpp 4 | 5 | Function: 6 | Defines the value of the page-end signature GUID. 7 | 8 | Copyright and License: 9 | See accompanying LICENSE file for copyright and license information. 10 | 11 | Author: 12 | Terry Moore, MCCI Corporation Demember 2019 13 | 14 | */ 15 | 16 | #include 17 | #include 18 | 19 | using namespace McciCatena; 20 | 21 | #ifdef ARDUINO_ARCH_STM32 22 | 23 | const MCCIADK_GUID_WIRE FlashParamsStm32L0_t::kPageEndSignature1_Guid 24 | { 25 | MCCIADK_GUID_BYTES_INIT(0xb39bc7ac, 0x3e7a, 0x4ac8, 0x92, 0xa3, 0xd9, 0x53, 0x5d, 0xc6, 0xa1, 0x23) 26 | }; 27 | 28 | #endif 29 | -------------------------------------------------------------------------------- /library.properties: -------------------------------------------------------------------------------- 1 | name=MCCI Catena Arduino Platform 2 | version=0.24.1 3 | author=Terry Moore, ChaeHee Won, Sungjoon Park, Dhinesh Kumar Pitchai 4 | maintainer=MCCI Corporation 5 | sentence=Arduino library for MCCI Catena 44xx, 45xx, 46xx and 48xx systems. 6 | 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. 7 | category=Other 8 | architectures=samd,stm32 9 | url=https://github.com/mcci-catena/Catena-Arduino-Platform 10 | dot_a_linkage=true 11 | includes=Catena.h 12 | depends=MCCI LoRaWAN LMIC library,MCCI Arduino LoRaWAN Library,MCCI Arduino Development Kit ADK,MCCI FRAM I2C,MCCI LTR-329ALS 13 | -------------------------------------------------------------------------------- /src/lib/samd/catena4420/Catena4420.cpp: -------------------------------------------------------------------------------- 1 | /* Catena4420.cpp Mon Dec 5 2016 02:02:51 tmm */ 2 | 3 | /* 4 | 5 | Module: Catena4420.cpp 6 | 7 | Function: 8 | Catena4420::Catena4420(). 9 | 10 | Version: 11 | V0.4.0 Mon Dec 5 2016 02:02:51 tmm Edit level 1 12 | 13 | Copyright notice: 14 | This file copyright (C) 2016 by 15 | 16 | MCCI Corporation 17 | 3520 Krums Corners Road 18 | Ithaca, NY 14850 19 | 20 | An unpublished work. All rights reserved. 21 | 22 | This file is proprietary information, and may not be disclosed or 23 | copied without the prior permission of MCCI Corporation. 24 | 25 | Author: 26 | Terry Moore, MCCI Corporation December 2016 27 | 28 | Revision history: 29 | 0.4.0 Mon Dec 5 2016 02:02:51 tmm 30 | Module created. 31 | 32 | */ 33 | 34 | #ifdef ARDUINO_ARCH_SAMD 35 | 36 | #include "Catena4420.h" 37 | using namespace McciCatena; 38 | 39 | 40 | Catena4420::Catena4420() 41 | { 42 | /* this function does nothing */ 43 | } 44 | 45 | #endif // ARDUINO_ARCH_SAMD 46 | -------------------------------------------------------------------------------- /assets/FSMexample.plantuml: -------------------------------------------------------------------------------- 1 | @startuml 2 | /' 3 | 4 | Module: FSMexample.plantuml 5 | 6 | Function: 7 | PlantUML reference source for cFSM state diagram. 8 | 9 | Copyright: 10 | See accompanying LICENSE file at 11 | https:://github.com/mcci-catena/Catena-Arduino-Platform 12 | 13 | Author: 14 | Terry Moore, MCCI Corporation July 2019 15 | 16 | Notes: 17 | PlantUML images in REAMDE.md are generated by pasting this file into 18 | the server at http://www.plantuml.com/plantuml, and grabbing the 19 | resulting URLs. That has to be done several times, with different 20 | values edited into the variables below. The comments in README.md 21 | will tell you what's needed. 22 | 23 | '/ 24 | 25 | [*] --> stLocked : stInitial 26 | 27 | state stLocked 28 | state stUnlocked 29 | 30 | stLocked --> stLocked : evPush 31 | stLocked : Entry/ lock the turnstile 32 | stLocked --> stUnlocked : evCoin 33 | stLocked -left-> [*] : shutdown\nstFinal 34 | 35 | stUnlocked --> stUnlocked : evCoin 36 | stUnlocked : Entry/ unlock the turnstile 37 | stUnlocked --> stLocked : evPush | shutdown 38 | @enduml 39 | -------------------------------------------------------------------------------- /src/McciHwInfo.h: -------------------------------------------------------------------------------- 1 | /* McciHwInfo.h Sun Oct 16 2016 22:31:53 tmm */ 2 | 3 | /* 4 | 5 | Module: McciHwInfo.h 6 | 7 | Function: 8 | Arduino library header for the hardware info database. 9 | 10 | Version: 11 | V0.1.0 Sun Oct 16 2016 22:31:53 tmm Edit level 1 12 | 13 | Copyright notice: 14 | This file copyright (C) 2016 by 15 | 16 | MCCI Corporation 17 | 3520 Krums Corners Road 18 | Ithaca, NY 14850 19 | 20 | An unpublished work. All rights reserved. 21 | 22 | This file is proprietary information, and may not be disclosed or 23 | copied without the prior permission of MCCI Corporation. 24 | 25 | Author: 26 | Terry Moore, MCCI Corporation October 2016 27 | 28 | Revision history: 29 | 0.1.0 Sun Oct 16 2016 22:31:53 tmm 30 | Module created. 31 | 32 | */ 33 | 34 | #ifndef _MCCIHWINFO_H_ /* prevent multiple includes */ 35 | #define _MCCIHWINFO_H_ 36 | 37 | #ifndef _MCCIXDK_GUID_H_ 38 | # include "mcciadk_guid.h" 39 | #endif 40 | 41 | typedef struct MCCIHWINFO_KEY_s 42 | { 43 | MCCIXDK_GUID_WIRE Key; 44 | } MCCIHWINFO_KEY; 45 | 46 | /**** end of McciHwInfo.h ****/ 47 | #endif /* _MCCIHWINFO_H_ */ 48 | -------------------------------------------------------------------------------- /src/CatenaBase_types.h: -------------------------------------------------------------------------------- 1 | /* CatenaBase_types.h Sun Mar 19 2017 15:14:08 tmm */ 2 | 3 | /* 4 | 5 | Module: CatenaBase_types.h 6 | 7 | Function: 8 | The common types for class CatenaBase. 9 | 10 | Version: 11 | V0.5.0 Sun Mar 19 2017 15:14:08 tmm Edit level 1 12 | 13 | Copyright notice: 14 | This file copyright (C) 2017 by 15 | 16 | MCCI Corporation 17 | 3520 Krums Corners Road 18 | Ithaca, NY 14850 19 | 20 | An unpublished work. All rights reserved. 21 | 22 | This file is proprietary information, and may not be disclosed or 23 | copied without the prior permission of MCCI Corporation. 24 | 25 | Author: 26 | Terry Moore, MCCI Corporation March 2017 27 | 28 | Revision history: 29 | 0.5.0 Sun Mar 19 2017 15:14:08 tmm 30 | Module created. 31 | 32 | */ 33 | 34 | #ifndef _CATENABASE_TYPES_H_ /* prevent multiple includes */ 35 | #define _CATENABASE_TYPES_H_ 36 | 37 | #pragma once 38 | 39 | namespace McciCatena { 40 | 41 | // the forward-reference scalar types from CatenaBase 42 | class CatenaBase; 43 | 44 | } /* namespace McciCatena */ 45 | 46 | /**** end of CatenaBase_types.h ****/ 47 | #endif /* _CATENABASE_TYPES_H_ */ 48 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2016-2025 MCCI Corporation. 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /src/lib/samd/catenawingfram2k/CatenaWingFram2k_ReadVbat.cpp: -------------------------------------------------------------------------------- 1 | /* CatenaWingFram2k_ReadVbat.cpp Tue Dec 04 2018 13:32:29 chwon */ 2 | 3 | /* 4 | 5 | Module: CatenaWingFram2k_ReadVbat.cpp 6 | 7 | Function: 8 | CatenaWingFram2k::ReadVbat() 9 | 10 | Version: 11 | V0.12.0 Tue Dec 04 2018 13:32:29 chwon Edit level 1 12 | 13 | Copyright notice: 14 | This file copyright (C) 2018 by 15 | 16 | MCCI Corporation 17 | 3520 Krums Corners Road 18 | Ithaca, NY 14850 19 | 20 | An unpublished work. All rights reserved. 21 | 22 | This file is proprietary information, and may not be disclosed or 23 | copied without the prior permission of MCCI Corporation 24 | 25 | Author: 26 | ChaeHee Won, MCCI Corporation December 2018 27 | 28 | Revision history: 29 | 0.12.0 Tue Dec 04 2018 13:32:29 chwon 30 | Module created. 31 | 32 | */ 33 | 34 | #ifdef ARDUINO_ARCH_SAMD 35 | 36 | #include "CatenaWingFram2k.h" 37 | 38 | #include "Arduino.h" 39 | using namespace McciCatena; 40 | 41 | 42 | float 43 | CatenaWingFram2k::ReadVbat(void) const 44 | { 45 | float rawVoltage = analogRead(CatenaWingFram2k::APIN_VBAT_SENSE); 46 | return rawVoltage * 2 * 3.3 / 1024; 47 | } 48 | 49 | #endif // ARDUINO_ARCH_SAMD 50 | -------------------------------------------------------------------------------- /examples/catena_hello/catena_hello.ino: -------------------------------------------------------------------------------- 1 | /* 2 | 3 | Module: catena_hello.ino 4 | 5 | Function: 6 | Simple hello-world (and compile-test) app 7 | 8 | Copyright notice and License: 9 | See LICENSE file accompanying this project. 10 | 11 | Author: 12 | Terry Moore, MCCI Corporation April 2018 13 | 14 | */ 15 | 16 | #include 17 | #include 18 | 19 | using namespace McciCatena; 20 | 21 | // declare the global object for the platform. 22 | Catena gCatena; 23 | 24 | // declare the LED object 25 | StatusLed gLed (Catena::PIN_STATUS_LED); 26 | 27 | void setup() 28 | { 29 | gCatena.begin(); 30 | 31 | gCatena.SafePrintf("Hello, world!\n"); 32 | gCatena.SafePrintf("This is a basic demo program for the MCCI Catena-Arduino-Platform library.\n"); 33 | gCatena.SafePrintf("Enter 'help' for a list of commands.\n"); 34 | gCatena.SafePrintf("(remember to select 'Line Ending: Newline' at the bottom of the monitor window.)\n"); 35 | 36 | gLed.begin(); 37 | gCatena.registerObject(&gLed); 38 | gLed.Set(LedPattern::FastFlash); 39 | } 40 | 41 | void loop() 42 | { 43 | gCatena.poll(); 44 | } 45 | -------------------------------------------------------------------------------- /src/lib/stm32/catena463x/Catena463x_begin.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | 3 | Module: Catena463x_begin.cpp 4 | 5 | Function: 6 | Catena463x::begin(). 7 | 8 | Copyright notice: 9 | See accompanying LICENSE file. 10 | 11 | Author: 12 | Dhinesh Kumar Pitchai, MCCI Corporation April 2019 13 | 14 | */ 15 | 16 | #ifdef ARDUINO_ARCH_STM32 17 | 18 | #include "Catena463x.h" 19 | 20 | #include "Catena_Log.h" 21 | 22 | using namespace McciCatena; 23 | 24 | /* 25 | 26 | Name: Catena463x::begin() 27 | 28 | Function: 29 | Set up all the well-known board peripherals. 30 | 31 | Definition: 32 | bool Catena463x::begin(); 33 | 34 | Description: 35 | Issues begin() for all the Catena463x things. 36 | 37 | Returns: 38 | true for success, false for failure. 39 | 40 | */ 41 | 42 | bool Catena463x::begin() 43 | { 44 | Serial.begin(115200); 45 | Wire.begin(); 46 | delay(1000); 47 | gLog.begin(cLog::DebugFlags(gLog.kError | gLog.kBug)); 48 | gLog.printf( 49 | gLog.kTrace, 50 | "\n+Catena463x::begin() for %s\n", 51 | CatenaName() 52 | ); 53 | 54 | // do the platform selection. 55 | if (! this->Super::begin()) 56 | return false; 57 | 58 | return true; 59 | } 60 | 61 | #endif // ARDUINO_ARCH_STM32 62 | 63 | /**** end of Catena463x_begin.cpp ****/ 64 | -------------------------------------------------------------------------------- /src/lib/samd/featherm0/catenafeatherm0_readvbat.cpp: -------------------------------------------------------------------------------- 1 | /* catenafeatherm0_readvbat.cpp Wed Dec 06 2017 18:32:28 tmm */ 2 | 3 | /* 4 | 5 | Module: catenafeatherm0_readvbat.cpp 6 | 7 | Function: 8 | CatenaFeatherM0::ReadVbat() 9 | 10 | Version: 11 | V0.7.0 Wed Dec 06 2017 18:32:28 tmm Edit level 2 12 | 13 | Copyright notice: 14 | This file copyright (C) 2016-2017 by 15 | 16 | MCCI Corporation 17 | 3520 Krums Corners Road 18 | Ithaca, NY 14850 19 | 20 | An unpublished work. All rights reserved. 21 | 22 | This file is proprietary information, and may not be disclosed or 23 | copied without the prior permission of MCCI Corporation. 24 | 25 | Author: 26 | Terry Moore, MCCI Corporation October 2016 27 | 28 | Revision history: 29 | 0.1.0 Sat Oct 15 2016 23:33:29 tmm 30 | Module created. 31 | 32 | 0.7.0 Wed Dec 06 2017 18:32:28 tmm 33 | Refactoring for adding Catena 4551. 34 | 35 | */ 36 | 37 | #ifdef ARDUINO_ARCH_SAMD 38 | 39 | #include "CatenaFeatherM0.h" 40 | 41 | #include "Arduino.h" 42 | using namespace McciCatena; 43 | 44 | 45 | float 46 | CatenaFeatherM0::ReadVbat(void) const 47 | { 48 | float rawVoltage = analogRead(CatenaFeatherM0::APIN_VBAT_SENSE); 49 | return rawVoltage * 2 * 3.3 / 1024; 50 | } 51 | 52 | #endif // ARDUINO_ARCH_SAMD 53 | -------------------------------------------------------------------------------- /src/Catena4410_project_config.h: -------------------------------------------------------------------------------- 1 | /* Catena4410_project_config.h Tue Nov 1 2016 11:59:47 tmm */ 2 | 3 | /* 4 | 5 | Module: Catena4410_project_config.h 6 | 7 | Function: 8 | Bridge from anywhere to the lmic project_config 9 | 10 | Version: 11 | V0.3.0 Tue Nov 1 2016 11:59:47 tmm Edit level 1 12 | 13 | Copyright notice: 14 | This file copyright (C) 2016 by 15 | 16 | MCCI Corporation 17 | 3520 Krums Corners Road 18 | Ithaca, NY 14850 19 | 20 | An unpublished work. All rights reserved. 21 | 22 | This file is proprietary information, and may not be disclosed or 23 | copied without the prior permission of MCCI Corporation. 24 | 25 | Author: 26 | Terry Moore, MCCI Corporation November 2016 27 | 28 | Revision history: 29 | 0.3.0 Tue Nov 1 2016 11:59:47 tmm 30 | Module created. 31 | 32 | */ 33 | 34 | #ifndef _CATENA4410_PROJECT_CONFIG_H_ /* prevent multiple includes */ 35 | #define _CATENA4410_PROJECT_CONFIG_H_ 36 | 37 | #include "../../arduino-lmic/src/lmic/lmic_config_preconditions.h" 38 | 39 | /* define the following non-zero for using a static key file */ 40 | #ifndef CATENA4410_USE_STATIC_KEYS /* PARAM */ 41 | # define CATENA4410_USE_STATIC_KEYS 0 42 | #endif 43 | 44 | /**** end of Catena4410_project_config.h ****/ 45 | #endif /* _CATENA4410_PROJECT_CONFIG_H_ */ 46 | -------------------------------------------------------------------------------- /src/Catena4420_project_config.h: -------------------------------------------------------------------------------- 1 | /* Catena4420_project_config.h Tue Nov 1 2016 11:59:47 tmm */ 2 | 3 | /* 4 | 5 | Module: Catena4420_project_config.h 6 | 7 | Function: 8 | Bridge from anywhere to the lmic project_config 9 | 10 | Version: 11 | V0.3.0 Tue Nov 1 2016 11:59:47 tmm Edit level 1 12 | 13 | Copyright notice: 14 | This file copyright (C) 2016 by 15 | 16 | MCCI Corporation 17 | 3520 Krums Corners Road 18 | Ithaca, NY 14850 19 | 20 | An unpublished work. All rights reserved. 21 | 22 | This file is proprietary information, and may not be disclosed or 23 | copied without the prior permission of MCCI Corporation. 24 | 25 | Author: 26 | Terry Moore, MCCI Corporation November 2016 27 | 28 | Revision history: 29 | 0.3.0 Tue Nov 1 2016 11:59:47 tmm 30 | Module created. 31 | 32 | */ 33 | 34 | #ifndef _CATENA4420_PROJECT_CONFIG_H_ /* prevent multiple includes */ 35 | #define _CATENA4420_PROJECT_CONFIG_H_ 36 | 37 | #include "../../arduino-lmic/src/lmic/lmic_config_preconditions.h" 38 | 39 | /* define the following non-zero for using a static key file */ 40 | #ifndef CATENA4420_USE_STATIC_KEYS /* PARAM */ 41 | # define CATENA4420_USE_STATIC_KEYS 0 42 | #endif 43 | 44 | /**** end of Catena4420_project_config.h ****/ 45 | #endif /* _CATENA4420_PROJECT_CONFIG_H_ */ 46 | -------------------------------------------------------------------------------- /src/lib/samd/CatenaSamd21.cpp: -------------------------------------------------------------------------------- 1 | /* CatenaSamd21.cpp Sun Mar 19 2017 17:17:58 tmm */ 2 | 3 | /* 4 | 5 | Module: CatenaSamd21.cpp 6 | 7 | Function: 8 | Miscellaneous methods for CatenaSamd21. 9 | 10 | Version: 11 | V0.5.0 Sun Mar 19 2017 17:17:58 tmm Edit level 1 12 | 13 | Copyright notice: 14 | This file copyright (C) 2017 by 15 | 16 | MCCI Corporation 17 | 3520 Krums Corners Road 18 | Ithaca, NY 14850 19 | 20 | An unpublished work. All rights reserved. 21 | 22 | This file is proprietary information, and may not be disclosed or 23 | copied without the prior permission of MCCI Corporation. 24 | 25 | Author: 26 | Terry Moore, MCCI Corporation March 2017 27 | 28 | Revision history: 29 | 0.5.0 Sun Mar 19 2017 17:17:58 tmm 30 | Module created. 31 | 32 | */ 33 | 34 | #ifdef ARDUINO_ARCH_SAMD 35 | 36 | #include "CatenaSamd21.h" 37 | 38 | using namespace McciCatena; 39 | 40 | /* public virtual */ 41 | bool 42 | CatenaSamd21::cSerialReady::isReady() const 43 | { 44 | // unfortunately, we can't use !! Serial (or bool(Serial) -- 45 | // it doesn't really check what we want, and then it inserts 46 | // a 10ms delay unconditionally. 47 | // so we just check DTR instead. 48 | return (Serial.dtr()); 49 | } 50 | 51 | #endif // ARDUINO_ARCH_SAMD 52 | -------------------------------------------------------------------------------- /src/lib/stm32/CatenaStm32.cpp: -------------------------------------------------------------------------------- 1 | /* CatenaStm32.cpp Fri Oct 13 2017 15:19:30 chwon */ 2 | 3 | /* 4 | 5 | Module: CatenaStm32.cpp 6 | 7 | Function: 8 | Miscellaneous methods for CatenaStm32. 9 | 10 | Version: 11 | V0.6.0 Fri Oct 13 2017 15:19:30 chwon Edit level 1 12 | 13 | Copyright notice: 14 | This file copyright (C) 2017 by 15 | 16 | MCCI Corporation 17 | 3520 Krums Corners Road 18 | Ithaca, NY 14850 19 | 20 | An unpublished work. All rights reserved. 21 | 22 | This file is proprietary information, and may not be disclosed or 23 | copied without the prior permission of MCCI Corporation. 24 | 25 | Author: 26 | ChaeHee Won, MCCI Corporation October 2017 27 | 28 | Revision history: 29 | 0.6.0 Fri Oct 13 2017 15:19:30 chwon 30 | Module created. 31 | 32 | */ 33 | 34 | #ifdef ARDUINO_ARCH_STM32 35 | 36 | #include "CatenaStm32.h" 37 | 38 | using namespace McciCatena; 39 | 40 | /* public virtual */ 41 | bool 42 | CatenaStm32::cSerialReady::isReady() const 43 | { 44 | // unfortunately, we can't use !! Serial (or bool(Serial) -- 45 | // it doesn't really check what we want, and then it inserts 46 | // a 10ms delay unconditionally. 47 | // so we just check DTR instead. 48 | return (Serial.dtr()); 49 | } 50 | 51 | #endif // ARDUINO_ARCH_STM32 52 | 53 | /**** end of CatenaStm32.cpp ****/ 54 | -------------------------------------------------------------------------------- /src/lib/stm32/catena463x/Catena463x_LoRaWAN_begin.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | 3 | Module: Catena463x_LoRaWAN_begin.cpp 4 | 5 | Function: 6 | Catena463x::LoRaWAN::begin() 7 | 8 | Copyright notice: 9 | See accompanying LICENSE file. 10 | 11 | Author: 12 | Dhinesh Kumar Pitchai, MCCI Corporation April 2019 13 | 14 | */ 15 | 16 | #ifdef ARDUINO_ARCH_STM32 17 | 18 | #include "Catena463x.h" 19 | 20 | #include "Catena_Log.h" 21 | #include "mcciadk_baselib.h" 22 | 23 | using namespace McciCatena; 24 | 25 | /* 26 | 27 | Name: Catena463x::LoRaWAN::begin() 28 | 29 | Function: 30 | Record linkage to main Catena object and set up LoRaWAN. 31 | 32 | Definition: 33 | bool Catena463x::LoRaWAN::begin( 34 | Catena463x *pParent 35 | ); 36 | 37 | Description: 38 | We record parent pointers, and other useful things for later. 39 | 40 | Returns: 41 | true for success, false for failure. 42 | 43 | */ 44 | 45 | bool 46 | Catena463x::LoRaWAN::begin( 47 | Catena463x *pParent 48 | ) 49 | { 50 | gLog.printf(gLog.kTrace, "+Catena463x::LoRaWAN::begin()\n"); 51 | 52 | /* call the base begin */ 53 | if (! this->Super::begin(pParent)) 54 | { 55 | gLog.printf( 56 | gLog.kBug, 57 | "?Catena463x::LoRaWAN::begin: Super::begin() failed\n" 58 | ); 59 | return false; 60 | } 61 | 62 | /* indicate success to the client */ 63 | return true; 64 | } 65 | 66 | #endif // ARDUINO_ARCH_STM32 67 | 68 | /**** end of Catena463x_LoRaWAN_begin.cpp ****/ 69 | -------------------------------------------------------------------------------- /src/lib/stm32/catena480x/Catena4802_ReadVoltage.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | 3 | Module: Catena4802_ReadVoltage.cpp 4 | 5 | Function: 6 | Catena4802::ReadVin() 7 | 8 | Copyright notice: 9 | See accompanying LICENSE file. 10 | 11 | Author: 12 | Dhinesh Kumar Pitchai, MCCI Corporation November 2020 13 | 14 | Revision history: 15 | See https://github.com/mcci-catena/Catena-Arduino-Platform 16 | 17 | */ 18 | 19 | #ifdef ARDUINO_ARCH_STM32 20 | 21 | #include "Catena4802.h" 22 | 23 | #include 24 | using namespace McciCatena; 25 | 26 | /****************************************************************************\ 27 | | 28 | | Manifest constants & typedefs. 29 | | 30 | \****************************************************************************/ 31 | 32 | 33 | 34 | /****************************************************************************\ 35 | | 36 | | Read-only data. 37 | | 38 | \****************************************************************************/ 39 | 40 | 41 | 42 | /****************************************************************************\ 43 | | 44 | | Variables. 45 | | 46 | \****************************************************************************/ 47 | 48 | float 49 | Catena4802::ReadVin(void) const 50 | { 51 | float volt = this->ReadAnalog(Catena480x::ANALOG_CHANNEL_VBAT, 1, 3); 52 | return volt / 1000; 53 | } 54 | 55 | #endif // ARDUINO_ARCH_STM32 56 | 57 | /**** end of Catena4802_ReadVoltage.cpp ****/ 58 | -------------------------------------------------------------------------------- /src/Catena_Guids_FramStorage.h: -------------------------------------------------------------------------------- 1 | /* Catena_Guids_FramStorage.h Sun Mar 19 2017 18:28:38 tmm */ 2 | 3 | /* 4 | 5 | Module: Catena_Guids_FramStorage.h 6 | 7 | Function: 8 | Guids for FRAM storage 9 | 10 | Version: 11 | V0.5.0 Sun Mar 19 2017 18:28:38 tmm Edit level 1 12 | 13 | Copyright notice: 14 | This file copyright (C) 2017 by 15 | 16 | MCCI Corporation 17 | 3520 Krums Corners Road 18 | Ithaca, NY 14850 19 | 20 | An unpublished work. All rights reserved. 21 | 22 | This file is proprietary information, and may not be disclosed or 23 | copied without the prior permission of MCCI Corporation. 24 | 25 | Author: 26 | Terry Moore, MCCI Corporation March 2017 27 | 28 | Revision history: 29 | 0.5.0 Sun Mar 19 2017 18:28:38 tmm 30 | Module created. 31 | 32 | */ 33 | 34 | #ifndef _CATENA_GUIDS_FRAMSTORAGE_H_ /* prevent multiple includes */ 35 | #define _CATENA_GUIDS_FRAMSTORAGE_H_ 36 | 37 | #ifndef _MCCIADK_GUID_H_ 38 | # include "mcciadk_guid.h" 39 | #endif 40 | 41 | /****************************************************************************\ 42 | | 43 | | The storage format GUID 44 | | 45 | \****************************************************************************/ 46 | 47 | // {1DE7CDCD-0647-4B3C-A18D-8138A3D9613F} 48 | #define GUID_FRAM_CATENA_V1(f) \ 49 | MCCIADK_GUID_GEN_INIT(f, 0x1de7cdcd, 0x647, 0x4b3c, 0xa1, 0x8d, 0x81, 0x38, 0xa3, 0xd9, 0x61, 0x3f) 50 | 51 | /**** end of Catena_Guids_FramStorage.h ****/ 52 | #endif /* _CATENA_GUIDS_FRAMSTORAGE_H_ */ 53 | -------------------------------------------------------------------------------- /src/lib/Catena_Log.cpp: -------------------------------------------------------------------------------- 1 | /* Catena_Log.cpp Sun Mar 19 2017 01:51:18 tmm */ 2 | 3 | /* 4 | 5 | Module: Catena_Log.cpp 6 | 7 | Function: 8 | class McciCatena::cLog. 9 | 10 | Version: 11 | V0.5.0 Sun Mar 19 2017 01:51:18 tmm Edit level 1 12 | 13 | Copyright notice: 14 | This file copyright (C) 2017 by 15 | 16 | MCCI Corporation 17 | 3520 Krums Corners Road 18 | Ithaca, NY 14850 19 | 20 | An unpublished work. All rights reserved. 21 | 22 | This file is proprietary information, and may not be disclosed or 23 | copied without the prior permission of MCCI Corporation. 24 | 25 | Author: 26 | Terry Moore, MCCI Corporation March 2017 27 | 28 | Revision history: 29 | 0.5.0 Sun Mar 19 2017 01:51:18 tmm 30 | Module created. 31 | 32 | */ 33 | 34 | #include "Catena_Log.h" 35 | 36 | #include 37 | #include 38 | #include 39 | 40 | using namespace McciCatena; 41 | 42 | // the global instance 43 | cLog McciCatena::gLog; 44 | 45 | void 46 | cLog::printf( 47 | DebugFlags uDebugFlags, 48 | const char *fmt, 49 | ... 50 | ) 51 | { 52 | if (! Serial.dtr()) 53 | return; 54 | 55 | // either inbound mask must be zero or must match 56 | if (! this->isEnabled(uDebugFlags)) 57 | return; 58 | 59 | char buf[128]; 60 | va_list ap; 61 | 62 | va_start(ap, fmt); 63 | (void) vsnprintf(buf, sizeof(buf) - 1, fmt, ap); 64 | va_end(ap); 65 | 66 | // in case we overflowed: 67 | buf[sizeof(buf) - 1] = '\0'; 68 | if (Serial.dtr()) Serial.print(buf); 69 | } 70 | -------------------------------------------------------------------------------- /assets/Catena_PollableInterface.plantuml: -------------------------------------------------------------------------------- 1 | @startuml 2 | /' 3 | 4 | Module: CatenaBase.plantuml 5 | 6 | Function: 7 | PlantUML reference source for cPollableInterface class diagram. 8 | 9 | Copyright: 10 | See accompanying LICENSE file 11 | 12 | Author: 13 | Terry Moore, MCCI Corporation July 2019 14 | 15 | Notes: 16 | PlantUML images in REAMDE.md are generated by pasting this file into 17 | the server at http://www.plantuml.com/plantuml, and grabbing the 18 | resulting URLs. That has to be done several times, with different 19 | values edited into the variables below. The comments in README.md 20 | will tell you what's needed. 21 | 22 | '/ 23 | 24 | hide empty members 25 | 26 | namespace McciCatena { 27 | 28 | interface cPollableInterface { 29 | +{abstract} ~cPollableInterface() 30 | +{abstract} void poll(); 31 | } 32 | 33 | class cPollingEngine <> { 34 | +void poll(); 35 | +void begin(); 36 | +void registerObject(cPollableObject *); 37 | -cPollableObject *m_pHead; 38 | } 39 | 40 | abstract class cPollableObject <> { 41 | -cPollableObject *m_pNext; 42 | -cPollableObject *m_pLast; 43 | +{abstract} void poll(); 44 | } 45 | 46 | cPollableInterface <|-- cPollingEngine 47 | cPollableInterface <|-- cPollableObject 48 | cPollingEngine o-> "0:*" cPollableObject 49 | } 50 | class UserClass1 <> { 51 | +void poll(); 52 | } 53 | class UserClass2 as "..." <> { 54 | +void poll(); 55 | } 56 | McciCatena.cPollableObject <|--- UserClass1 57 | McciCatena.cPollableObject <|--- UserClass2 58 | 59 | @enduml 60 | -------------------------------------------------------------------------------- /src/Catena4802.h: -------------------------------------------------------------------------------- 1 | /* 2 | 3 | Module: Catena4802.h 4 | 5 | Function: 6 | class Catena4802: CatenaBase Platform to represent a Catena 4802. 7 | 8 | Copyright notice: 9 | See accompanying LICENSE file. 10 | 11 | Author: 12 | Dhinesh Kumar Pitchai, MCCI Corporation November 2020 13 | 14 | */ 15 | 16 | #ifndef _Catena4802_H_ /* prevent multiple includes */ 17 | #define _Catena4802_H_ 18 | 19 | #pragma once 20 | 21 | #ifndef _CATENA480X_H_ 22 | # include "Catena480x.h" 23 | #endif 24 | 25 | namespace McciCatena { 26 | 27 | class Catena4802 : public Catena480x 28 | { 29 | public: 30 | using Super = Catena480x; 31 | 32 | // no specific constructor. 33 | Catena4802() {}; 34 | 35 | // uses default destructor 36 | 37 | // neither copyable nor movable 38 | Catena4802(const Catena4802&) = delete; 39 | Catena4802& operator=(const Catena4802&) = delete; 40 | Catena4802(const Catena4802&&) = delete; 41 | Catena4802& operator=(const Catena4802&&) = delete; 42 | 43 | virtual const char *CatenaName() const override { return "Catena 4802"; }; 44 | float ReadVin(void) const; 45 | 46 | protected: 47 | // we are required to provide a table of platforms 48 | virtual void getPlatformTable( 49 | const CATENA_PLATFORM * const * &vPlatforms, 50 | size_t &nvPlatforms 51 | ) override; 52 | 53 | private: 54 | // the known platforms 55 | static const CATENA_PLATFORM(* const vPlatforms[]); 56 | static const size_t nvPlatforms; 57 | }; 58 | 59 | } // namespace McciCatena 60 | 61 | /**** end of Catena4802.h ****/ 62 | #endif /* _Catena4802_H_ */ 63 | -------------------------------------------------------------------------------- /src/lib/samd/catena4410/Catena4410_gk_lorawan_keys.cpp: -------------------------------------------------------------------------------- 1 | /* gk_lorawan_keys.cpp Wed Dec 06 2017 19:27:10 tmm */ 2 | 3 | /* 4 | 5 | Module: gk_lorawan_keys.cpp 6 | 7 | Function: 8 | pointer to the real provisioning keys 9 | 10 | Version: 11 | V0.7.0 Wed Dec 06 2017 19:27:10 Edit level 12 12 | 13 | Copyright notice: 14 | This file copyright (C) 2016 by 15 | 16 | MCCI Corporation 17 | 3520 Krums Corners Road 18 | Ithaca, NY 14850 19 | 20 | An unpublished work. All rights reserved. 21 | 22 | Author: 23 | Terry Moore, MCCI Corporation November 2016 24 | 25 | Revision history: 26 | 0.3.0 Tue Nov 1 2016 13:46:08 tmm 27 | Module created. 28 | 29 | 0.7.0 Wed Dec 06 2017 19:27:10 tmm 30 | Refactored for Catena 4551 support. 31 | 32 | */ 33 | 34 | #ifdef ARDUINO_ARCH_SAMD 35 | 36 | #include 37 | #include 38 | 39 | using namespace McciCatena; 40 | 41 | /* 42 | 43 | Use the script extra/make-lorawan-keys-entry.sh to generate 44 | the entries in this table. 45 | 46 | */ 47 | 48 | static const Arduino_LoRaWAN::ProvisioningInfo 49 | skProvisioningInfo[] = 50 | { 51 | /* to make it easier to manage the keys, we store the real keys elsewhere */ 52 | #if CATENA4410_USE_STATIC_KEYS 53 | #include "../../../../../catena-lorawan-provisioning/extra/gk_lorawan_keys.project.cpp" 54 | #endif 55 | }; 56 | 57 | const Arduino_LoRaWAN::ProvisioningTable Catena4410::gk_LoRaWAN_Keys = 58 | { 59 | pInfo: skProvisioningInfo, 60 | nInfo: MCCIADK_LENOF(skProvisioningInfo) 61 | }; 62 | 63 | #endif // ARDUINO_ARCH_SAMD 64 | -------------------------------------------------------------------------------- /src/lib/samd/catena4420/Catena4420_gk_lorawan_keys.cpp: -------------------------------------------------------------------------------- 1 | /* Catena4420_gk_lorawan_keys.cpp Wed Dec 06 2017 19:27:10 tmm */ 2 | 3 | /* 4 | 5 | Module: Catena4420_gk_lorawan_keys.cpp 6 | 7 | Function: 8 | Catena4420::gk_LoRaWAN_Keys; 9 | 10 | Version: 11 | V0.7.0 Wed Dec 06 2017 19:27:10 tmm Edit level 2 12 | 13 | Copyright notice: 14 | This file copyright (C) 2016-2017 by 15 | 16 | MCCI Corporation 17 | 3520 Krums Corners Road 18 | Ithaca, NY 14850 19 | 20 | An unpublished work. All rights reserved. 21 | 22 | Author: 23 | Terry Moore, MCCI Corporation December 2016 24 | 25 | Revision history: 26 | 0.4.0 Sun Dec 4 2016 23:00:37 tmm 27 | Module created. 28 | 29 | 0.7.0 Wed Dec 06 2017 19:27:10 tmm 30 | Refactored for Catena 4551 support. 31 | 32 | */ 33 | 34 | #ifdef ARDUINO_ARCH_SAMD 35 | 36 | #include 37 | #include 38 | 39 | using namespace McciCatena; 40 | 41 | 42 | /* 43 | 44 | Use the script extra/make-lorawan-keys-entry.sh to generate 45 | the entries in this table. 46 | 47 | */ 48 | 49 | static const Arduino_LoRaWAN::ProvisioningInfo 50 | skProvisioningInfo[] = 51 | { 52 | /* to make it easier to manage the keys, we store the real keys elsewhere */ 53 | #if CATENA4420_USE_STATIC_KEYS 54 | #include "../../../../../catena-lorawan-provisioning/extra/gk_lorawan_keys.4420.cpp" 55 | #endif 56 | }; 57 | 58 | const Arduino_LoRaWAN::ProvisioningTable Catena4420::gk_LoRaWAN_Keys = 59 | { 60 | pInfo: skProvisioningInfo, 61 | nInfo: MCCIADK_LENOF(skProvisioningInfo) 62 | }; 63 | 64 | #endif // ARDUINO_ARCH_SAMD 65 | -------------------------------------------------------------------------------- /src/Catena4630.h: -------------------------------------------------------------------------------- 1 | /* 2 | 3 | Module: Catena4630.h 4 | 5 | Function: 6 | class Catena4630: CatenaBase Platform to represent a Catena 4630. 7 | 8 | Copyright notice: 9 | See accompanying LICENSE file. 10 | 11 | Author: 12 | Dhinesh Kumar Pitchai, MCCI Corporation April 2019 13 | 14 | */ 15 | 16 | #ifndef _Catena4630_H_ /* prevent multiple includes */ 17 | #define _Catena4630_H_ 18 | 19 | #pragma once 20 | 21 | #ifndef _CATENA463X_H_ 22 | # include "Catena463x.h" 23 | #endif 24 | 25 | namespace McciCatena { 26 | 27 | class Catena4630 : public Catena463x 28 | { 29 | public: 30 | using Super = Catena463x; 31 | 32 | // no specific constructor. 33 | Catena4630() {}; 34 | 35 | // uses default destructor 36 | 37 | // neither copyable nor movable 38 | Catena4630(const Catena4630&) = delete; 39 | Catena4630& operator=(const Catena4630&) = delete; 40 | Catena4630(const Catena4630&&) = delete; 41 | Catena4630& operator=(const Catena4630&&) = delete; 42 | 43 | virtual const char *CatenaName() const override { return "Catena 4630"; }; 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 Catena4630.h ****/ 63 | #endif /* _Catena4630_H_ */ 64 | -------------------------------------------------------------------------------- /src/Catena_Completion.h: -------------------------------------------------------------------------------- 1 | /* Catena_Completion.h Sat Mar 18 2017 16:34:53 tmm */ 2 | 3 | /* 4 | 5 | Module: Catena_Completion.h 6 | 7 | Function: 8 | class McciCatena::cCompletion 9 | 10 | Version: 11 | V0.5.0 Sat Mar 18 2017 16:34:53 tmm Edit level 1 12 | 13 | Copyright notice: 14 | This file copyright (C) 2017 by 15 | 16 | MCCI Corporation 17 | 3520 Krums Corners Road 18 | Ithaca, NY 14850 19 | 20 | An unpublished work. All rights reserved. 21 | 22 | This file is proprietary information, and may not be disclosed or 23 | copied without the prior permission of MCCI Corporation. 24 | 25 | Author: 26 | Terry Moore, MCCI Corporation March 2017 27 | 28 | Revision history: 29 | 0.5.0 Sat Mar 18 2017 16:34:53 tmm 30 | Module created. 31 | 32 | */ 33 | 34 | #ifndef _CATENA_COMPLETION_H_ /* prevent multiple includes */ 35 | #define _CATENA_COMPLETION_H_ 36 | 37 | #pragma once 38 | 39 | namespace McciCatena { 40 | 41 | // a completion is an abstract class; pass a pointer to this to 42 | // any of the event processors, and it will get dispatched. Note that 43 | // in your derived version, 44 | class cCompletion 45 | { 46 | public: 47 | virtual ~cCompletion() {}; 48 | 49 | // neither copyable nor movable 50 | cCompletion(const cCompletion&) = delete; 51 | cCompletion& operator=(const cCompletion&) = delete; 52 | cCompletion(const cCompletion&&) = delete; 53 | cCompletion& operator=(const cCompletion&&) = delete; 54 | 55 | // the interface functions: 56 | virtual void Callback(void) = delete; 57 | }; 58 | 59 | }; // namespace McciCatena 60 | 61 | /**** end of Catena_Completion.h ****/ 62 | #endif /* _CATENA_COMPLETION_H_ */ 63 | -------------------------------------------------------------------------------- /src/lib/stm32/stm32l0/CatenaStm32L0_GetSystemClockRate.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | 3 | Module: CatenaStm32L0_GetSystemClockRate.cpp 4 | 5 | Function: 6 | CatenaStm32L0::GetSystemClockRate() 7 | 8 | Copyright notice: 9 | See accompanying license 10 | 11 | Author: 12 | Terry Moore, MCCI Corporation April 2019 13 | 14 | */ 15 | 16 | #ifdef ARDUINO_ARCH_STM32 17 | 18 | #include "CatenaStm32L0.h" 19 | 20 | #include 21 | 22 | using namespace McciCatena; 23 | 24 | /****************************************************************************\ 25 | | 26 | | Manifest constants & typedefs. 27 | | 28 | \****************************************************************************/ 29 | 30 | 31 | /****************************************************************************\ 32 | | 33 | | Read-only data. 34 | | 35 | \****************************************************************************/ 36 | 37 | 38 | 39 | /****************************************************************************\ 40 | | 41 | | Variables. 42 | | 43 | \****************************************************************************/ 44 | 45 | 46 | /* 47 | 48 | Name: CatenaStm32L0::GetSystemCLockRate 49 | 50 | Function: 51 | Return the system clock rate 52 | 53 | Definition: 54 | virtual uint64_t CatenaStm32L0::GetSystemClockRate( 55 | void 56 | ) const override; 57 | 58 | Description: 59 | This function returns the system clock rate in Hz. 60 | 61 | Returns: 62 | Analog value 63 | 64 | */ 65 | 66 | uint64_t CatenaStm32L0::GetSystemClockRate( 67 | void 68 | ) const 69 | { 70 | return HAL_RCC_GetHCLKFreq(); 71 | } 72 | 73 | #endif // ARDUINO_ARCH_STM32 74 | 75 | /**** end of CatenaStm32L0_GetSystemClockRate.cpp ****/ 76 | -------------------------------------------------------------------------------- /src/lib/samd/featherm0/catenafeatherm0_begin.cpp: -------------------------------------------------------------------------------- 1 | /* catenafeatherm0_begin.cpp Tue Dec 04 2018 13:33:34 chwon */ 2 | 3 | /* 4 | 5 | Module: catenafeatherm0_begin.cpp 6 | 7 | Function: 8 | CatenaFeatherM0::begin() 9 | 10 | Version: 11 | V0.12.0 Tue Dec 04 2018 13:33:34 chwon Edit level 1 12 | 13 | Copyright notice: 14 | This file copyright (C) 2018 by 15 | 16 | MCCI Corporation 17 | 3520 Krums Corners Road 18 | Ithaca, NY 14850 19 | 20 | An unpublished work. All rights reserved. 21 | 22 | This file is proprietary information, and may not be disclosed or 23 | copied without the prior permission of MCCI Corporation 24 | 25 | Author: 26 | ChaeHee Won, MCCI Corporation December 2018 27 | 28 | Revision history: 29 | 0.12.0 Tue Dec 04 2018 13:33:34 chwon 30 | Module created. 31 | 32 | */ 33 | 34 | #ifdef ARDUINO_ARCH_SAMD 35 | 36 | #include "CatenaFeatherM0.h" 37 | 38 | #include "Catena_Log.h" 39 | 40 | using namespace McciCatena; 41 | 42 | /* 43 | 44 | Name: CatenaFeatherM0::begin() 45 | 46 | Function: 47 | Set up all the well-known board peripherals. 48 | 49 | Definition: 50 | bool CatenaFeatherM0::begin(); 51 | 52 | Description: 53 | Issues begin() for all the CatenaFeatherM0 things. 54 | 55 | Returns: 56 | true for success, false for failure. 57 | 58 | */ 59 | 60 | 61 | bool CatenaFeatherM0::begin() 62 | { 63 | gLog.printf(gLog.kTrace, "+CatenaFeatherM0::begin()\n"); 64 | 65 | // do the platform selection. 66 | if (! this->Super::begin()) 67 | { 68 | gLog.printf( 69 | gLog.kError, 70 | "?CatenaFeatherM0::begin:" 71 | " Super::begin() failed\n" 72 | ); 73 | return false; 74 | } 75 | 76 | return true; 77 | } 78 | 79 | #endif // ARDUINO_ARCH_SAMD 80 | -------------------------------------------------------------------------------- /assets/cFramStorage.plantuml: -------------------------------------------------------------------------------- 1 | @startuml "cFramStorage hierarchy" 2 | /' PlantUML image for FRAM 3 | '/ 4 | namespace McciCatena { 5 | 6 | class cFramStorage { 7 | +enum StandardKeys 8 | +typedef uint32_t Offset; 9 | +{static}const StandardItem vItemDefs[]; 10 | 11 | } 12 | 13 | class cFramStorage::StandardItem { 14 | -uint32_t makeValue(); 15 | +uint32_t getSize(); 16 | +StandardKeys getKey(); 17 | +bool isNumber(); 18 | +bool isReplicated(); 19 | +const GUID *getGuid(); 20 | -uint32_t uValue; 21 | } 22 | 23 | class cFramStorage::ObjectRaw { 24 | +uint32_t uSizeKey 25 | +GUID Guid 26 | +uint8_t uKey 27 | +uint8_t uVer[3] 28 | +bool isStandard() 29 | +cFramStorage::Object *getStandardObject() 30 | } 31 | 32 | class cFramStorage::Object { 33 | +uint16_t getObjectSize() 34 | +uint16_t nextObjectOffset(); 35 | +uint16_t getObjectClicks(); 36 | +bool setObjectSize(); 37 | +uint16_t hasValidSize(); 38 | +uint16_t getDataSize(); 39 | +bool matchesGuid(); 40 | +int getKey(); 41 | +{static}uint16_t neededClicks(); 42 | +bool validDataSize(); 43 | +bool isReplicated(); 44 | +unsigned nReplicants(); 45 | +uint32_t offsetOfReplicant(); 46 | +uint8_t getCurrent(); 47 | +void setCurrent(); 48 | +uint8_t *getDiscriminatorBuffer(); 49 | +size_t getDiscriminatorBufferSize(); 50 | +size_t offsetOfDiscriminator(); 51 | +size_t getBufferSize(); 52 | +uint8_t *getBuffer(); 53 | +bool initialize(); 54 | +bool isValid(); 55 | } 56 | 57 | cFramStorage "1" *--> "kMax" cFramStorage::StandardItem : vItemDefs[] 58 | 59 | class cFramStorage::StandardKeys 60 | 61 | cFramStorage *--> cFramStorage::StandardKeys 62 | 63 | cFramStorage::ObjectRaw <|-- "cFramStorage::Object" 64 | 65 | 66 | } 67 | @enduml -------------------------------------------------------------------------------- /src/lib/stm32/catena461x/Catena461x_begin.cpp: -------------------------------------------------------------------------------- 1 | /* Catena461x_begin.cpp Thu Nov 15 2018 14:52:31 chwon */ 2 | 3 | /* 4 | 5 | Module: Catena461x_begin.cpp 6 | 7 | Function: 8 | Catena461x::begin() 9 | 10 | Version: 11 | V0.11.0 Thu Nov 15 2018 14:52:31 chwon Edit level 1 12 | 13 | Copyright notice: 14 | This file copyright (C) 2018 by 15 | 16 | MCCI Corporation 17 | 3520 Krums Corners Road 18 | Ithaca, NY 14850 19 | 20 | An unpublished work. All rights reserved. 21 | 22 | This file is proprietary information, and may not be disclosed or 23 | copied without the prior permission of MCCI Corporation 24 | 25 | Author: 26 | ChaeHee Won, MCCI Corporation November 2018 27 | 28 | Revision history: 29 | 0.11.0 Thu Nov 15 2018 14:52:31 chwon 30 | Module created. 31 | 32 | */ 33 | 34 | #ifdef ARDUINO_ARCH_STM32 35 | 36 | #include "Catena461x.h" 37 | 38 | #include "Catena_Log.h" 39 | 40 | using namespace McciCatena; 41 | 42 | /* 43 | 44 | Name: Catena461x::begin() 45 | 46 | Function: 47 | Set up all the well-known board peripherals. 48 | 49 | Definition: 50 | bool Catena461x::begin(); 51 | 52 | Description: 53 | Issues begin() for all the Catena461x things. 54 | 55 | Returns: 56 | true for success, false for failure. 57 | 58 | */ 59 | 60 | bool Catena461x::begin() 61 | { 62 | Serial.begin(115200); 63 | Wire.begin(); 64 | delay(1000); 65 | gLog.begin(cLog::DebugFlags(gLog.kError | gLog.kBug)); 66 | gLog.printf( 67 | gLog.kTrace, 68 | "\n+Catena461x::begin() for %s\n", 69 | CatenaName() 70 | ); 71 | 72 | // do the platform selection. 73 | if (! this->Super::begin()) 74 | return false; 75 | 76 | return true; 77 | } 78 | 79 | #endif // ARDUINO_ARCH_STM32 80 | 81 | /**** end of Catena461x_begin.cpp ****/ 82 | -------------------------------------------------------------------------------- /src/lib/stm32/catena480x/Catena480x_begin.cpp: -------------------------------------------------------------------------------- 1 | /* Catena480x_begin.cpp Thu Nov 15 2018 14:52:31 chwon */ 2 | 3 | /* 4 | 5 | Module: Catena480x_begin.cpp 6 | 7 | Function: 8 | Catena480x::begin() 9 | 10 | Version: 11 | V0.11.0 Thu Nov 15 2018 14:52:31 chwon Edit level 1 12 | 13 | Copyright notice: 14 | This file copyright (C) 2018 by 15 | 16 | MCCI Corporation 17 | 3520 Krums Corners Road 18 | Ithaca, NY 14850 19 | 20 | An unpublished work. All rights reserved. 21 | 22 | This file is proprietary information, and may not be disclosed or 23 | copied without the prior permission of MCCI Corporation 24 | 25 | Author: 26 | ChaeHee Won, MCCI Corporation November 2018 27 | 28 | Revision history: 29 | 0.11.0 Thu Nov 15 2018 14:52:31 chwon 30 | Module created. 31 | 32 | */ 33 | 34 | #ifdef ARDUINO_ARCH_STM32 35 | 36 | #include "Catena480x.h" 37 | 38 | #include "Catena_Log.h" 39 | 40 | using namespace McciCatena; 41 | 42 | /* 43 | 44 | Name: Catena480x::begin() 45 | 46 | Function: 47 | Set up all the well-known board peripherals. 48 | 49 | Definition: 50 | bool Catena480x::begin(); 51 | 52 | Description: 53 | Issues begin() for all the Catena480x things. 54 | 55 | Returns: 56 | true for success, false for failure. 57 | 58 | */ 59 | 60 | bool Catena480x::begin() 61 | { 62 | Serial.begin(115200); 63 | Wire.begin(); 64 | delay(1000); 65 | gLog.begin(cLog::DebugFlags(gLog.kError | gLog.kBug)); 66 | gLog.printf( 67 | gLog.kTrace, 68 | "\n+Catena480x::begin() for %s\n", 69 | CatenaName() 70 | ); 71 | 72 | // do the platform selection. 73 | if (! this->Super::begin()) 74 | return false; 75 | 76 | return true; 77 | } 78 | 79 | #endif // ARDUINO_ARCH_STM32 80 | 81 | /**** end of Catena480x_begin.cpp ****/ 82 | -------------------------------------------------------------------------------- /src/Catena4617.h: -------------------------------------------------------------------------------- 1 | /* 2 | 3 | Module: Catena4617.h 4 | 5 | Function: 6 | class Catena4617: CatenaBase Platform to represent a Catena 4617 7 | 8 | Copyright notice: 9 | See accompanying LICENSE file. 10 | 11 | Author: 12 | Lakshmi Priya Natarajan, MCCI Corporation June 2019 13 | 14 | Revision history: 15 | See https://github.com/mcci-catena/Catena-Arduino-Platform 16 | 17 | */ 18 | 19 | #ifndef _Catena4617_H_ /* prevent multiple includes */ 20 | #define _Catena4617_H_ 21 | 22 | #pragma once 23 | 24 | #ifndef _CATENA461X_H_ 25 | # include "Catena461x.h" 26 | #endif 27 | 28 | namespace McciCatena { 29 | 30 | class Catena4617 : public Catena461x 31 | { 32 | public: 33 | using Super = Catena461x; 34 | 35 | // no specific constructor. 36 | Catena4617() {}; 37 | 38 | // uses default destructor 39 | 40 | // neither copyable nor movable 41 | Catena4617(const Catena4617&) = delete; 42 | Catena4617& operator=(const Catena4617&) = delete; 43 | Catena4617(const Catena4617&&) = delete; 44 | Catena4617& operator=(const Catena4617&&) = delete; 45 | 46 | virtual const char *CatenaName() const override { return "Catena 4617"; }; 47 | virtual float ReadVbat(void) const override; 48 | virtual float ReadVbus(void) const override; 49 | 50 | protected: 51 | // we are required to provide a table of platforms 52 | virtual void getPlatformTable( 53 | const CATENA_PLATFORM * const * &vPlatforms, 54 | size_t &nvPlatforms 55 | ) override; 56 | 57 | private: 58 | // the known platforms 59 | static const CATENA_PLATFORM(* const vPlatforms[]); 60 | static const size_t nvPlatforms; 61 | }; 62 | 63 | } // namespace McciCatena 64 | 65 | /**** end of Catena4617.h ****/ 66 | #endif /* _Catena4617_H_ */ 67 | -------------------------------------------------------------------------------- /src/Catena4618.h: -------------------------------------------------------------------------------- 1 | /* 2 | 3 | Module: Catena4618.h 4 | 5 | Function: 6 | class Catena4618: CatenaBase Platform to represent a Catena 4618 7 | 8 | Copyright notice: 9 | See accompanying LICENSE file. 10 | 11 | Author: 12 | Lakshmi Priya Natarajan, MCCI Corporation June 2019 13 | 14 | Revision history: 15 | See https://github.com/mcci-catena/Catena-Arduino-Platform 16 | 17 | */ 18 | 19 | #ifndef _Catena4618_H_ /* prevent multiple includes */ 20 | #define _Catena4618_H_ 21 | 22 | #pragma once 23 | 24 | #ifndef _CATENA461X_H_ 25 | # include "Catena461x.h" 26 | #endif 27 | 28 | namespace McciCatena { 29 | 30 | class Catena4618 : public Catena461x 31 | { 32 | public: 33 | using Super = Catena461x; 34 | 35 | // no specific constructor. 36 | Catena4618() {}; 37 | 38 | // uses default destructor 39 | 40 | // neither copyable nor movable 41 | Catena4618(const Catena4618&) = delete; 42 | Catena4618& operator=(const Catena4618&) = delete; 43 | Catena4618(const Catena4618&&) = delete; 44 | Catena4618& operator=(const Catena4618&&) = delete; 45 | 46 | virtual const char *CatenaName() const override { return "Catena 4618"; }; 47 | virtual float ReadVbat(void) const override; 48 | virtual float ReadVbus(void) const override; 49 | 50 | protected: 51 | // we are required to provide a table of platforms 52 | virtual void getPlatformTable( 53 | const CATENA_PLATFORM * const * &vPlatforms, 54 | size_t &nvPlatforms 55 | ) override; 56 | 57 | private: 58 | // the known platforms 59 | static const CATENA_PLATFORM(* const vPlatforms[]); 60 | static const size_t nvPlatforms; 61 | }; 62 | 63 | } // namespace McciCatena 64 | 65 | /**** end of Catena4618.h ****/ 66 | #endif /* _Catena4618_H_ */ 67 | -------------------------------------------------------------------------------- /src/CatenaStm32.h: -------------------------------------------------------------------------------- 1 | /* CatenaStm32.h Wed Dec 05 2018 14:09:27 chwon */ 2 | 3 | /* 4 | 5 | Module: CatenaStm32.h 6 | 7 | Function: 8 | class CatenaStm32 9 | 10 | Version: 11 | V0.12.0 Wed Dec 05 2018 14:09:27 chwon Edit level 3 12 | 13 | Copyright notice: 14 | This file copyright (C) 2017-2018 by 15 | 16 | MCCI Corporation 17 | 3520 Krums Corners Road 18 | Ithaca, NY 14850 19 | 20 | An unpublished work. All rights reserved. 21 | 22 | Author: 23 | ChaeHee Won, MCCI Corporation October 2017 24 | 25 | Revision history: 26 | 0.6.0 Fri Oct 13 2017 15:19:30 chwon 27 | Module created. 28 | 29 | 0.7.0 Thu Dec 14 2017 14:55:06 tmm 30 | Refactor common code. 31 | 32 | 0.12.0 Wed Dec 05 2018 14:09:27 chwon 33 | Move UniqueuID and CPUID_PLATFORM_MAP structure and related methods to 34 | CatenaBase class. 35 | 36 | */ 37 | 38 | #ifndef _CATENASTM32_H_ /* prevent multiple includes */ 39 | #define _CATENASTM32_H_ 40 | 41 | #pragma once 42 | 43 | #ifndef _CATENABASE_H_ 44 | # include "CatenaBase.h" 45 | #endif 46 | 47 | namespace McciCatena { 48 | 49 | /* the class for Stm32-based Catenas */ 50 | class CatenaStm32 : public CatenaBase 51 | { 52 | public: 53 | using Super = CatenaBase; 54 | 55 | /* 56 | || Methods 57 | */ 58 | 59 | // start the Stm32 level 60 | virtual bool begin(void); 61 | bool begin(uint32_t uOverrideMask); 62 | bool begin(uint32_t uClearMask, uint32_t uSetMask); 63 | 64 | virtual void GetUniqueID( 65 | UniqueID_buffer_t *pIdBuffer 66 | ) override; 67 | 68 | protected: 69 | virtual void registerCommands(void); 70 | 71 | /* 72 | || Class-level information 73 | */ 74 | private: 75 | }; 76 | 77 | } // namespace McciCatena 78 | 79 | /**** end of CatenaStm32.h ****/ 80 | #endif /* _CATENASTM32_H_ */ 81 | -------------------------------------------------------------------------------- /src/lib/CatenaBase_GetSysEUI.cpp: -------------------------------------------------------------------------------- 1 | /* CatenaBase_GetSysEUI.cpp Mon Dec 03 2018 13:04:44 chwon */ 2 | 3 | /* 4 | 5 | Module: CatenaBase_GetSysEUI.cpp 6 | 7 | Function: 8 | CatenaBase::GetSysEUI() 9 | 10 | Version: 11 | V0.12.0 Mon Dec 03 2018 13:04:44 chwon Edit level 1 12 | 13 | Copyright notice: 14 | This file copyright (C) 2018 by 15 | 16 | MCCI Corporation 17 | 3520 Krums Corners Road 18 | Ithaca, NY 14850 19 | 20 | An unpublished work. All rights reserved. 21 | 22 | This file is proprietary information, and may not be disclosed or 23 | copied without the prior permission of MCCI Corporation 24 | 25 | Author: 26 | ChaeHee Won, MCCI Corporation December 2018 27 | 28 | Revision history: 29 | 0.12.0 Mon Dec 03 2018 13:04:44 chwon 30 | Module created. 31 | 32 | */ 33 | 34 | #include "CatenaBase.h" 35 | 36 | using namespace McciCatena; 37 | 38 | /* 39 | 40 | Name: CatenaBase::GetSysEUI() 41 | 42 | Function: 43 | Returns the SysEUI for this platform 44 | 45 | Definition: 46 | const CatenaBase::EUI64_buffer_t * 47 | CatenaBase::GetSysEUI( 48 | void 49 | ); 50 | 51 | Description: 52 | Looks in the FRAM and returns the value there. 53 | 54 | Returns: 55 | Pointer to the SysEUI. 56 | 57 | */ 58 | 59 | /* public: virtual override */ 60 | const CatenaBase::EUI64_buffer_t * 61 | CatenaBase::GetSysEUI(void) 62 | { 63 | auto const pFram = this->getFram(); 64 | 65 | if (pFram == nullptr || 66 | ! pFram->getField(cFramStorage::StandardKeys::kSysEUI, 67 | this->m_SysEUI 68 | )) 69 | { 70 | /* not able to get the EUI. fill with zero */ 71 | memset( (uint8_t *) &this->m_SysEUI, 72 | 0, 73 | sizeof(this->m_SysEUI) 74 | ); 75 | } 76 | 77 | return &this->m_SysEUI; 78 | } 79 | 80 | /**** end of CatenaBase_GetSysEUI.cpp ****/ 81 | -------------------------------------------------------------------------------- /src/Catena_WatchdogTimer.h: -------------------------------------------------------------------------------- 1 | /* 2 | 3 | Module: Catena_WatchdogTimer.h 4 | 5 | Function: 6 | class Catena_WatchdogTimer 7 | 8 | Copyright notice and License: 9 | See LICENSE file accompanying this project. 10 | 11 | Author: 12 | Pranau R, MCCI Corporation April 2024 13 | 14 | */ 15 | 16 | #ifndef _CATENA_WATCHDOGTIMER_H_ /* prevent multiple includes */ 17 | #define _CATENA_WATCHDOGTIMER_H_ 18 | 19 | #pragma once 20 | 21 | #include 22 | 23 | namespace McciCatena { 24 | 25 | class cWatchdogTimer 26 | { 27 | public: 28 | enum : uint32_t 29 | { 30 | IWDG_KEY_ENABLE = 0xCCCC, 31 | IWDG_KEY_WRITE_ACCESS_ENABLE = 0x5555, 32 | IWDG_KEY_WRITE_ACCESS_DISABLE = 0, 33 | IWDG_KEY_REFRESH = 0xAAAA, 34 | }; 35 | 36 | cWatchdogTimer() {}; 37 | 38 | // uses default destructor 39 | 40 | // neither copyable nor movable 41 | cWatchdogTimer(const cWatchdogTimer&) = delete; 42 | cWatchdogTimer& operator=(const cWatchdogTimer&) = delete; 43 | cWatchdogTimer(const cWatchdogTimer&&) = delete; 44 | cWatchdogTimer& operator=(const cWatchdogTimer&&) = delete; 45 | 46 | static constexpr uint32_t kWatchdogSeconds = 26; 47 | 48 | /// @brief setup STM32Lxx IWDG to require 20 second updates. 49 | void setupWatchdog(); 50 | 51 | /// @brief get another 20 seconds before the watchdog triggers 52 | void refreshWatchdog(); 53 | 54 | /// @brief delay for a while, and refresh the watchdog. 55 | /// @param millis number of milliseconds, as for \c ::delay(). 56 | void safeDelay(uint32_t millis); 57 | }; 58 | 59 | extern cWatchdogTimer gIwdgTimer; 60 | 61 | } // namespace McciCatena 62 | 63 | /**** end of Catena_WatchdogTimer.h ****/ 64 | #endif /* _CATENA_WATCHDOGTIMER_H_ */ -------------------------------------------------------------------------------- /src/lib/CatenaBase_GetUniqueIDstring.cpp: -------------------------------------------------------------------------------- 1 | /* GetUniqueIDstring.cpp Thu Oct 27 2016 23:15:50 tmm */ 2 | 3 | /* 4 | 5 | Module: GetUniqueIDstring.cpp 6 | 7 | Function: 8 | CatenaBase::GetUniqueIDstring() 9 | 10 | Version: 11 | V0.3.0 Thu Oct 27 2016 23:15:50 tmm Edit level 2 12 | 13 | Copyright notice: 14 | This file copyright (C) 2016 by 15 | 16 | MCCI Corporation 17 | 3520 Krums Corners Road 18 | Ithaca, NY 14850 19 | 20 | An unpublished work. All rights reserved. 21 | 22 | This file is proprietary information, and may not be disclosed or 23 | copied without the prior permission of MCCI Corporation. 24 | 25 | Author: 26 | Terry Moore, MCCI Corporation October 2016 27 | 28 | Revision history: 29 | 0.1.0 Tue Oct 25 2016 03:19:12 tmm 30 | Module created. 31 | 32 | */ 33 | 34 | #include 35 | 36 | #include 37 | 38 | using namespace McciCatena; 39 | 40 | char *CatenaBase::GetUniqueIDstring( 41 | UniqueID_string_t *pStringBuf 42 | ) 43 | { 44 | UniqueID_buffer_t CPUid; 45 | 46 | this->GetUniqueID(&CPUid); 47 | 48 | unsigned i; 49 | int j; 50 | 51 | for (i = 0, j = 0; i < sizeof(CPUid.b); ++i) 52 | { 53 | const int nBuf = sizeof(*pStringBuf) - j; 54 | const int jResult = 55 | snprintf( 56 | &pStringBuf->c[j], 57 | nBuf, 58 | "%s%02x", 59 | i == 0 ? "" : "-", 60 | CPUid.b[i] 61 | ); 62 | 63 | /* deal with errors and overflow */ 64 | if (jResult < 0 || jResult >= nBuf) 65 | break; 66 | 67 | j += jResult; 68 | } 69 | 70 | return &pStringBuf->c[0]; 71 | } 72 | -------------------------------------------------------------------------------- /src/Catena4420.h: -------------------------------------------------------------------------------- 1 | /* 2 | 3 | Module: Catena4420.h 4 | 5 | Function: 6 | class Catena4420 (Aduino header file) 7 | 8 | Copyright notice: 9 | See LICENSE file accompanying this project. 10 | 11 | Author: 12 | Terry Moore, MCCI Corporation December 2016 13 | 14 | */ 15 | 16 | #ifndef _CATENA4420_H_ /* prevent multiple includes */ 17 | #define _CATENA4420_H_ 18 | 19 | #ifndef _CATENAFEATHERM0_H_ 20 | # include "CatenaFeatherM0.h" 21 | #endif 22 | 23 | namespace McciCatena { 24 | 25 | class Catena4420 : public CatenaFeatherM0 26 | { 27 | public: 28 | /* 29 | || Methods 30 | */ 31 | Catena4420(); 32 | 33 | /* 34 | || LoRaWAN binding 35 | */ 36 | class LoRaWAN /* forward */; 37 | 38 | virtual const char *CatenaName() const override { return "Catena 4420"; }; 39 | 40 | protected: 41 | using Super = CatenaFeatherM0; 42 | virtual const Arduino_LoRaWAN::ProvisioningTable * 43 | GetLoRaWANkeys(void) const override; 44 | 45 | virtual void getCpuIdPlatformTable( 46 | const CPUID_PLATFORM_MAP * &vCpuIdToPlatform, 47 | size_t &nvCpuIdToPlatform 48 | ) override; 49 | 50 | private: 51 | static const Arduino_LoRaWAN::ProvisioningTable gk_LoRaWAN_Keys 52 | /* __attribute__((__weak__)) */; 53 | 54 | static const CPUID_PLATFORM_MAP vCpuIdToPlatform[]; 55 | static const size_t nvCpuIdToPlatform; 56 | }; 57 | 58 | /* 59 | || The LoRaWAN class for the Catena4420. For now, we assume The Things 60 | || Network. 61 | */ 62 | class Catena4420::LoRaWAN : public CatenaFeatherM0::LoRaWAN 63 | { 64 | public: 65 | using Super = CatenaFeatherM0::LoRaWAN; 66 | 67 | /* 68 | || the constructor. 69 | */ 70 | LoRaWAN() {}; 71 | 72 | protected: 73 | /* 74 | || we use the CatenaFeatherM0 defaults 75 | */ 76 | 77 | private: 78 | }; 79 | 80 | } /* namespace McciCatena */ 81 | 82 | 83 | /**** end of Catena4420.h ****/ 84 | #endif /* _CATENA4420_H_ */ 85 | -------------------------------------------------------------------------------- /src/lib/stm32/catena455x/Catena455x_begin.cpp: -------------------------------------------------------------------------------- 1 | /* Catena455x_begin.cpp Tue Nov 20 2018 13:53:31 chwon */ 2 | 3 | /* 4 | 5 | Module: Catena455x_begin.cpp 6 | 7 | Function: 8 | Catena455x::begin() 9 | 10 | Version: 11 | V0.11.0 Tue Nov 20 2018 13:53:31 chwon Edit level 3 12 | 13 | Copyright notice: 14 | This file copyright (C) 2017-2018 by 15 | 16 | MCCI Corporation 17 | 3520 Krums Corners Road 18 | Ithaca, NY 14850 19 | 20 | An unpublished work. All rights reserved. 21 | 22 | This file is proprietary information, and may not be disclosed or 23 | copied without the prior permission of MCCI Corporation. 24 | 25 | Author: 26 | ChaeHee Won, MCCI Corporation October 2017 27 | 28 | Revision history: 29 | 0.6.0 Fri Oct 13 2017 15:19:30 chwon 30 | Module created. 31 | 32 | 0.6.0 Wed Dec 06 2017 15:31:37 chwon 33 | Set debug flag. 34 | 35 | 0.11.0 Tue Nov 20 2018 13:53:31 chwon 36 | Move common code to CatenaStm32L0::begin(). 37 | 38 | */ 39 | 40 | #ifdef ARDUINO_ARCH_STM32 41 | 42 | #include "Catena455x.h" 43 | 44 | #include "Catena_Log.h" 45 | 46 | using namespace McciCatena; 47 | 48 | /* 49 | 50 | Name: Catena455x::begin() 51 | 52 | Function: 53 | Set up all the well-known board peripherals. 54 | 55 | Definition: 56 | bool Catena455x::begin(); 57 | 58 | Description: 59 | Issues begin() for all the Catena455x things. 60 | 61 | Returns: 62 | true for success, false for failure. 63 | 64 | */ 65 | 66 | bool Catena455x::begin() 67 | { 68 | Serial.begin(115200); 69 | Wire.begin(); 70 | delay(1000); 71 | gLog.begin(cLog::DebugFlags(gLog.kError | gLog.kBug)); 72 | gLog.printf( 73 | gLog.kTrace, 74 | "\n+Catena455x::begin() for %s\n", 75 | CatenaName() 76 | ); 77 | 78 | // do the platform selection. 79 | if (! this->Super::begin()) 80 | return false; 81 | 82 | return true; 83 | } 84 | 85 | #endif // ARDUINO_ARCH_STM32 86 | 87 | /**** end of Catena455x_begin.cpp ****/ 88 | -------------------------------------------------------------------------------- /src/lib/samd/catenawingfram2k/CatenaWingFram2k_registerCommands.cpp: -------------------------------------------------------------------------------- 1 | /* CatenaWingFram2k_registerCommands.cpp Wed Dec 05 2018 14:33:00 chwon */ 2 | 3 | /* 4 | 5 | Module: CatenaWingFram2k_registerCommands.cpp 6 | 7 | Function: 8 | CatenaWingFram2k::registerCommands() 9 | 10 | Version: 11 | V0.12.0 Wed Dec 05 2018 14:33:00 chwon Edit level 2 12 | 13 | Copyright notice: 14 | This file copyright (C) 2017-2018 by 15 | 16 | MCCI Corporation 17 | 3520 Krums Corners Road 18 | Ithaca, NY 14850 19 | 20 | An unpublished work. All rights reserved. 21 | 22 | This file is proprietary information, and may not be disclosed or 23 | copied without the prior permission of MCCI Corporation. 24 | 25 | Author: 26 | Terry Moore, MCCI Corporation March 2017 27 | 28 | Revision history: 29 | 0.5.0 Sun Mar 19 2017 14:53:33 tmm 30 | Module created. 31 | 32 | 0.12.0 Wed Dec 05 2018 14:33:00 chwon 33 | Move adding commands to CatenaBase class. 34 | 35 | */ 36 | 37 | #ifdef ARDUINO_ARCH_SAMD 38 | 39 | #include "CatenaWingFram2k.h" 40 | 41 | #include "Catena_CommandStream.h" 42 | 43 | using namespace McciCatena; 44 | 45 | /****************************************************************************\ 46 | | 47 | | Manifest constants 48 | | 49 | \****************************************************************************/ 50 | 51 | 52 | /****************************************************************************\ 53 | | 54 | | The command tables 55 | | 56 | \****************************************************************************/ 57 | 58 | 59 | /****************************************************************************\ 60 | | 61 | | The method function 62 | | 63 | \****************************************************************************/ 64 | 65 | /* protected virtual */ 66 | void 67 | CatenaWingFram2k::registerCommands() 68 | { 69 | this->Super::registerCommands(); 70 | } 71 | 72 | #endif // ARDUINO_ARCH_SAMD 73 | -------------------------------------------------------------------------------- /src/lib/stm32/catena461x/Catena461x_LoRaWAN_begin.cpp: -------------------------------------------------------------------------------- 1 | /* Catena461x_LoRaWAN_begin.cpp Thu Nov 15 2018 14:54:47 chwon */ 2 | 3 | /* 4 | 5 | Module: Catena461x_LoRaWAN_begin.cpp 6 | 7 | Function: 8 | Catena461x::LoRaWAN::begin() 9 | 10 | Version: 11 | V0.11.0 Thu Nov 15 2018 14:54:47 chwon Edit level 1 12 | 13 | Copyright notice: 14 | This file copyright (C) 2018 by 15 | 16 | MCCI Corporation 17 | 3520 Krums Corners Road 18 | Ithaca, NY 14850 19 | 20 | An unpublished work. All rights reserved. 21 | 22 | This file is proprietary information, and may not be disclosed or 23 | copied without the prior permission of MCCI Corporation 24 | 25 | Author: 26 | ChaeHee Won, MCCI Corporation November 2018 27 | 28 | Revision history: 29 | 0.11.0 Thu Nov 15 2018 14:54:47 chwon 30 | Module created. 31 | 32 | */ 33 | 34 | #ifdef ARDUINO_ARCH_STM32 35 | 36 | #include "Catena461x.h" 37 | 38 | #include "Catena_Log.h" 39 | #include "mcciadk_baselib.h" 40 | 41 | using namespace McciCatena; 42 | 43 | /* 44 | 45 | Name: Catena461x::LoRaWAN::begin() 46 | 47 | Function: 48 | Record linkage to main Catena object and set up LoRaWAN. 49 | 50 | Definition: 51 | bool Catena461x::LoRaWAN::begin( 52 | Catena461x *pParent 53 | ); 54 | 55 | Description: 56 | We record parent pointers, and other useful things for later. 57 | 58 | Returns: 59 | true for success, false for failure. 60 | 61 | */ 62 | 63 | bool 64 | Catena461x::LoRaWAN::begin( 65 | Catena461x *pParent 66 | ) 67 | { 68 | gLog.printf(gLog.kTrace, "+Catena461x::LoRaWAN::begin()\n"); 69 | 70 | /* call the base begin */ 71 | if (! this->Super::begin(pParent)) 72 | { 73 | gLog.printf( 74 | gLog.kBug, 75 | "?Catena461x::LoRaWAN::begin: Super::begin() failed\n" 76 | ); 77 | return false; 78 | } 79 | 80 | /* indicate success to the client */ 81 | return true; 82 | } 83 | 84 | #endif // ARDUINO_ARCH_STM32 85 | 86 | /**** end of Catena461x_LoRaWAN_begin.cpp ****/ 87 | -------------------------------------------------------------------------------- /src/lib/stm32/catena480x/Catena480x_LoRaWAN_begin.cpp: -------------------------------------------------------------------------------- 1 | /* Catena480x_LoRaWAN_begin.cpp Thu Nov 15 2018 14:54:47 chwon */ 2 | 3 | /* 4 | 5 | Module: Catena480x_LoRaWAN_begin.cpp 6 | 7 | Function: 8 | Catena480x::LoRaWAN::begin() 9 | 10 | Version: 11 | V0.11.0 Thu Nov 15 2018 14:54:47 chwon Edit level 1 12 | 13 | Copyright notice: 14 | This file copyright (C) 2018 by 15 | 16 | MCCI Corporation 17 | 3520 Krums Corners Road 18 | Ithaca, NY 14850 19 | 20 | An unpublished work. All rights reserved. 21 | 22 | This file is proprietary information, and may not be disclosed or 23 | copied without the prior permission of MCCI Corporation 24 | 25 | Author: 26 | ChaeHee Won, MCCI Corporation November 2018 27 | 28 | Revision history: 29 | 0.11.0 Thu Nov 15 2018 14:54:47 chwon 30 | Module created. 31 | 32 | */ 33 | 34 | #ifdef ARDUINO_ARCH_STM32 35 | 36 | #include "Catena480x.h" 37 | 38 | #include "Catena_Log.h" 39 | #include "mcciadk_baselib.h" 40 | 41 | using namespace McciCatena; 42 | 43 | /* 44 | 45 | Name: Catena480x::LoRaWAN::begin() 46 | 47 | Function: 48 | Record linkage to main Catena object and set up LoRaWAN. 49 | 50 | Definition: 51 | bool Catena480x::LoRaWAN::begin( 52 | Catena480x *pParent 53 | ); 54 | 55 | Description: 56 | We record parent pointers, and other useful things for later. 57 | 58 | Returns: 59 | true for success, false for failure. 60 | 61 | */ 62 | 63 | bool 64 | Catena480x::LoRaWAN::begin( 65 | Catena480x *pParent 66 | ) 67 | { 68 | gLog.printf(gLog.kTrace, "+Catena480x::LoRaWAN::begin()\n"); 69 | 70 | /* call the base begin */ 71 | if (! this->Super::begin(pParent)) 72 | { 73 | gLog.printf( 74 | gLog.kBug, 75 | "?Catena480x::LoRaWAN::begin: Super::begin() failed\n" 76 | ); 77 | return false; 78 | } 79 | 80 | /* indicate success to the client */ 81 | return true; 82 | } 83 | 84 | #endif // ARDUINO_ARCH_STM32 85 | 86 | /**** end of Catena480x_LoRaWAN_begin.cpp ****/ 87 | -------------------------------------------------------------------------------- /src/lib/stm32/stm32l0/CatenaStm32L0_LoRaWAN_storage.cpp: -------------------------------------------------------------------------------- 1 | /* CatenaStm32L0_LoRaWAN_storage.cpp Wed Dec 05 2018 14:31:03 chwon */ 2 | 3 | /* 4 | 5 | Module: CatenaStm32L0_LoRaWAN_storage.cpp 6 | 7 | Function: 8 | Interface from LoRaWAN to FRAM. 9 | 10 | Version: 11 | V0.12.0 Wed Dec 05 2018 14:31:03 chwon Edit level 2 12 | 13 | Copyright notice: 14 | This file copyright (C) 2017-2018 by 15 | 16 | MCCI Corporation 17 | 3520 Krums Corners Road 18 | Ithaca, NY 14850 19 | 20 | An unpublished work. All rights reserved. 21 | 22 | This file is proprietary information, and may not be disclosed or 23 | copied without the prior permission of MCCI Corporation. 24 | 25 | Author: 26 | ChaeHee Won, MCCI Corporation October 2017 27 | 28 | Revision history: 29 | 0.6.0 Fri Oct 13 2017 15:19:30 chwon 30 | Module created. 31 | 32 | 0.12.0 Wed Dec 05 2018 14:31:03 chwon 33 | Use Catena NetSave methods. 34 | 35 | */ 36 | 37 | #ifdef ARDUINO_ARCH_STM32 38 | 39 | #include 40 | 41 | #include 42 | #include 43 | 44 | using namespace McciCatena; 45 | 46 | void 47 | CatenaStm32L0::LoRaWAN::NetSaveSessionInfo( 48 | const SessionInfo &Info, 49 | const uint8_t *pExtraInfo, 50 | size_t nExtraInfo 51 | ) 52 | { 53 | CatenaStm32L0 * const pCatena = this->m_pCatena; 54 | 55 | pCatena->NetSaveSessionInfo(Info, pExtraInfo, nExtraInfo); 56 | } 57 | 58 | void 59 | CatenaStm32L0::LoRaWAN::NetSaveSessionState( 60 | const SessionState &State 61 | ) 62 | { 63 | CatenaStm32L0 * const pCatena = this->m_pCatena; 64 | 65 | pCatena->NetSaveSessionState(State); 66 | } 67 | 68 | bool 69 | CatenaStm32L0::LoRaWAN::NetGetSessionState( 70 | SessionState &State 71 | ) 72 | { 73 | CatenaStm32L0 * const pCatena = this->m_pCatena; 74 | 75 | return pCatena->NetGetSessionState(State); 76 | } 77 | 78 | #endif // ARDUINO_ARCH_STM32 79 | 80 | /**** end of CatenaStm32L0_LoRaWAN_storage.cpp ****/ 81 | -------------------------------------------------------------------------------- /src/lib/stm32/stm32l0/CatenaStm32L0_Sleep.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | 3 | Module: CatenaStm32L0_Sleep.cpp 4 | 5 | Function: 6 | Home for CatenaStm32L0::Sleep() 7 | 8 | Copyright notice: 9 | See accompanying LICENSE file. 10 | 11 | Author: 12 | ChaeHee Won, MCCI Corporation October 2018 13 | 14 | */ 15 | 16 | #ifdef ARDUINO_ARCH_STM32 17 | 18 | #include "CatenaStm32L0.h" 19 | 20 | using namespace McciCatena; 21 | 22 | /****************************************************************************\ 23 | | 24 | | Manifest constants & typedefs. 25 | | 26 | \****************************************************************************/ 27 | 28 | 29 | 30 | /****************************************************************************\ 31 | | 32 | | Read-only data. 33 | | 34 | \****************************************************************************/ 35 | 36 | 37 | 38 | /****************************************************************************\ 39 | | 40 | | Variables. 41 | | 42 | \****************************************************************************/ 43 | 44 | 45 | /* 46 | 47 | Name: CatenaStm32L0::Sleep() 48 | 49 | Function: 50 | Put system in sleep mode 51 | 52 | Definition: 53 | void CatenaStm32L0::Sleep(uint32_t howLongInSeconds); 54 | 55 | Description: 56 | This function sets the alarm with given howLongInSeconds and puts the 57 | system in low power sleep mode. The system will be wake up when alarm 58 | happen in howLongInSeconds. 59 | 60 | Returns: 61 | No explicit result. 62 | 63 | */ 64 | 65 | void CatenaStm32L0::Sleep(uint32_t howLongInSeconds) 66 | { 67 | 68 | this->m_Rtc.SetAlarm(howLongInSeconds); 69 | this->m_Rtc.SleepForAlarm(CatenaStm32L0Rtc::SleepMode::StopWithLowPowerRegulator); 70 | 71 | // add the number of ms that we were asleep to the millisecond timer. 72 | // we don't need extreme accuracy. 73 | this->m_Rtc.AdjustMillisForward(howLongInSeconds * 1000); 74 | } 75 | 76 | #endif // ARDUINO_ARCH_STM32 77 | 78 | /**** end of CatenaStm32L0_Sleep.cpp ****/ 79 | -------------------------------------------------------------------------------- /src/lib/stm32/catena463x/Catena4630_ReadVoltage.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | 3 | Module: Catena4630_ReadAnalog.cpp 4 | 5 | Function: 6 | Catena4630::ReadVbat() and Catena4630::ReadVbus() 7 | 8 | Copyright notice: 9 | See accompanying LICENSE file. 10 | 11 | Author: 12 | Dhinesh Kumar Pitchai, MCCI Corporation April 2019 13 | 14 | */ 15 | 16 | #ifdef ARDUINO_ARCH_STM32 17 | 18 | #include "Catena4630.h" 19 | #include "Catena_Log.h" 20 | 21 | #include 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 | Catena4630::ReadVbat(void) const 48 | { 49 | float volt = this->ReadAnalog(Catena463x::ANALOG_CHANNEL_VBAT, 1, 2); 50 | return volt / 1000; 51 | } 52 | 53 | float 54 | Catena4630::ReadVbus(void) const 55 | { 56 | float volt = this->ReadAnalog(Catena463x::ANALOG_CHANNEL_VBUS, 1, 3); 57 | return volt / 1000; 58 | } 59 | 60 | #if defined(ARDUINO_MCCI_CATENA_4630) && defined(USBD_LL_ConnectionState_WEAK) 61 | 62 | extern "C" { 63 | 64 | uint32_t USBD_LL_ConnectionState(void) 65 | { 66 | uint32_t vBus; 67 | bool fStatus; 68 | 69 | fStatus = CatenaStm32L0_ReadAnalog( 70 | Catena463x::ANALOG_CHANNEL_VBUS, 1, 3, &vBus 71 | ); 72 | return (fStatus && vBus < 3000) ? 0 : 1; 73 | } 74 | 75 | } 76 | 77 | #endif // ARDUINO_MCCI_CATENA_4630 78 | 79 | #endif // ARDUINO_ARCH_STM32 80 | 81 | /**** end of Catena4630_ReadAnalog.cpp ****/ 82 | -------------------------------------------------------------------------------- /src/Catena4801.h: -------------------------------------------------------------------------------- 1 | /* Catena4801.h Thu Nov 15 2018 15:07:23 chwon */ 2 | 3 | /* 4 | 5 | Module: Catena4801.h 6 | 7 | Function: 8 | class Catena4801: CatenaBase Platform to represent a Catena 4801 9 | 10 | Version: 11 | V0.11.0 Thu Nov 15 2018 15:07:23 chwon Edit level 1 12 | 13 | Copyright notice: 14 | This file copyright (C) 2018 by 15 | 16 | MCCI Corporation 17 | 3520 Krums Corners Road 18 | Ithaca, NY 14850 19 | 20 | An unpublished work. All rights reserved. 21 | 22 | This file is proprietary information, and may not be disclosed or 23 | copied without the prior permission of MCCI Corporation 24 | 25 | Author: 26 | ChaeHee Won, MCCI Corporation November 2018 27 | 28 | Revision history: 29 | 0.11.0 Thu Nov 15 2018 15:07:23 chwon 30 | Module created. 31 | 32 | */ 33 | 34 | #ifndef _Catena4801_H_ /* prevent multiple includes */ 35 | #define _Catena4801_H_ 36 | 37 | #pragma once 38 | 39 | #ifndef _CATENA480X_H_ 40 | # include "Catena480x.h" 41 | #endif 42 | 43 | namespace McciCatena { 44 | 45 | class Catena4801 : public Catena480x 46 | { 47 | public: 48 | using Super = Catena480x; 49 | 50 | // no specific constructor. 51 | Catena4801() {}; 52 | 53 | // uses default destructor 54 | 55 | // neither copyable nor movable 56 | Catena4801(const Catena4801&) = delete; 57 | Catena4801& operator=(const Catena4801&) = delete; 58 | Catena4801(const Catena4801&&) = delete; 59 | Catena4801& operator=(const Catena4801&&) = delete; 60 | 61 | virtual const char *CatenaName() const override { return "Catena 4801"; }; 62 | 63 | protected: 64 | // we are required to provide a table of platforms 65 | virtual void getPlatformTable( 66 | const CATENA_PLATFORM * const * &vPlatforms, 67 | size_t &nvPlatforms 68 | ) override; 69 | 70 | private: 71 | // the known platforms 72 | static const CATENA_PLATFORM(* const vPlatforms[]); 73 | static const size_t nvPlatforms; 74 | }; 75 | 76 | } // namespace McciCatena 77 | 78 | /**** end of Catena4801.h ****/ 79 | #endif /* _Catena4801_H_ */ 80 | -------------------------------------------------------------------------------- /src/lib/stm32/catena455x/Catena455x_LoRaWAN_begin.cpp: -------------------------------------------------------------------------------- 1 | /* Catena455x_LoRaWAN_begin.cpp Tue Nov 20 2018 13:55:23 chwon */ 2 | 3 | /* 4 | 5 | Module: Catena455x_LoRaWAN_begin.cpp 6 | 7 | Function: 8 | Catena455x::LoRaWAN::begin() 9 | 10 | Version: 11 | V0.11.0 Tue Nov 20 2018 13:55:23 chwon Edit level 2 12 | 13 | Copyright notice: 14 | This file copyright (C) 2017-2018 by 15 | 16 | MCCI Corporation 17 | 3520 Krums Corners Road 18 | Ithaca, NY 14850 19 | 20 | An unpublished work. All rights reserved. 21 | 22 | This file is proprietary information, and may not be disclosed or 23 | copied without the prior permission of MCCI Corporation. 24 | 25 | Author: 26 | ChaeHee Won, MCCI Corporation October 2017 27 | 28 | Revision history: 29 | 0.6.0 Fri Oct 13 2017 15:19:30 chwon 30 | Module created. 31 | 32 | 0.11.0 Tue Nov 20 2018 13:55:23 chwon 33 | Move common code to CatenaStm32L0::LoRaWAN::begin(). 34 | 35 | */ 36 | 37 | #ifdef ARDUINO_ARCH_STM32 38 | 39 | #include "Catena455x.h" 40 | 41 | #include "Catena_Log.h" 42 | #include "mcciadk_baselib.h" 43 | 44 | using namespace McciCatena; 45 | 46 | /* 47 | 48 | Name: Catena455x::LoRaWAN::begin() 49 | 50 | Function: 51 | Record linkage to main Catena object and set up LoRaWAN. 52 | 53 | Definition: 54 | bool Catena455x::LoRaWAN::begin( 55 | Catena455x *pParent 56 | ); 57 | 58 | Description: 59 | We record parent pointers, and other useful things for later. 60 | 61 | Returns: 62 | true for success, false for failure. 63 | 64 | */ 65 | 66 | bool 67 | Catena455x::LoRaWAN::begin( 68 | Catena455x *pParent 69 | ) 70 | { 71 | gLog.printf(gLog.kTrace, "+Catena455x::LoRaWAN::begin()\n"); 72 | 73 | /* call the base begin */ 74 | if (! this->Super::begin(pParent)) 75 | { 76 | gLog.printf( 77 | gLog.kBug, 78 | "?Catena455x::LoRaWAN::begin: Super::begin() failed\n" 79 | ); 80 | return false; 81 | } 82 | 83 | /* indicate success to the client */ 84 | return true; 85 | } 86 | 87 | #endif // ARDUINO_ARCH_STM32 88 | 89 | /**** end of Catena455x_LoRaWAN_begin.cpp ****/ 90 | -------------------------------------------------------------------------------- /src/Catena4551.h: -------------------------------------------------------------------------------- 1 | /* Catena4551.h Wed Dec 13 2017 17:29:35 tmm */ 2 | 3 | /* 4 | 5 | Module: Catena4551.h 6 | 7 | Function: 8 | class Catena4551: CatenaBase Platform to represent a Catena 4551 9 | 10 | Version: 11 | V0.7.0 Wed Dec 13 2017 17:29:35 tmm Edit level 2 12 | 13 | Copyright notice: 14 | This file copyright (C) 2017 by 15 | 16 | MCCI Corporation 17 | 3520 Krums Corners Road 18 | Ithaca, NY 14850 19 | 20 | An unpublished work. All rights reserved. 21 | 22 | This file is proprietary information, and may not be disclosed or 23 | copied without the prior permission of MCCI Corporation. 24 | 25 | Author: 26 | ChaeHee Won, MCCI Corporation October 2017 27 | 28 | Revision history: 29 | 0.6.0 Fri Oct 13 2017 15:19:30 chwon 30 | Module created. 31 | 32 | 0.7.0 Wed Dec 13 2017 17:29:35 tmm 33 | Refactor. 34 | 35 | */ 36 | 37 | #ifndef _CATENA4551_H_ /* prevent multiple includes */ 38 | #define _CATENA4551_H_ 39 | 40 | #pragma once 41 | 42 | #ifndef _CATENA455X_H_ 43 | # include "Catena455x.h" 44 | #endif 45 | 46 | namespace McciCatena { 47 | 48 | class Catena4551 : public Catena455x 49 | { 50 | public: 51 | using Super = Catena455x; 52 | 53 | // no specific constructor. 54 | Catena4551() {}; 55 | 56 | // uses default destructor 57 | 58 | // neither copyable nor movable 59 | Catena4551(const Catena4551&) = delete; 60 | Catena4551& operator=(const Catena4551&) = delete; 61 | Catena4551(const Catena4551&&) = delete; 62 | Catena4551& operator=(const Catena4551&&) = delete; 63 | 64 | virtual const char *CatenaName() const override { return "Catena 4551"; }; 65 | 66 | protected: 67 | // we are required to provide a table of platforms 68 | virtual void getPlatformTable( 69 | const CATENA_PLATFORM * const * &vPlatforms, 70 | size_t &nvPlatforms 71 | ) override; 72 | 73 | private: 74 | // the known platforms 75 | static const CATENA_PLATFORM(* const vPlatforms[]); 76 | static const size_t nvPlatforms; 77 | }; 78 | 79 | } // namespace McciCatena 80 | 81 | /**** end of Catena4551.h ****/ 82 | #endif /* _CATENA4551_H_ */ 83 | -------------------------------------------------------------------------------- /src/lib/samd/featherm0/catenafeatherm0_lorawan_getprovisioningstyle.cpp: -------------------------------------------------------------------------------- 1 | /* catenafeatherm0_lorawan_getprovisioningstyle.cpp 0.7.0 Wed Dec 06 2017 19:27:10 tmm tmm */ 2 | 3 | /* 4 | 5 | Module: catenafeatherm0_lorawan_getprovisioningstyle.cpp 6 | 7 | Function: 8 | CatenaFeatherM0::LoRaWAN::GetProvisioningStyle(). 9 | 10 | Version: 11 | V0.3.0 0.7.0 Wed Dec 06 2017 19:27:10 tmm tmm Edit level 1 12 | 13 | Copyright notice: 14 | This file copyright (C) 2016-2017 by 15 | 16 | MCCI Corporation 17 | 3520 Krums Corners Road 18 | Ithaca, NY 14850 19 | 20 | An unpublished work. All rights reserved. 21 | 22 | This file is proprietary information, and may not be disclosed or 23 | copied without the prior permission of MCCI Corporation. 24 | 25 | Author: 26 | Terry Moore, MCCI Corporation October 2016 27 | 28 | Revision history: 29 | 0.3.0 Mon Oct 31 2016 17:06:29 tmm 30 | Module created. Barbarously long name needed to prevent 31 | in-library collisions. 32 | 33 | 0.7.0 Wed Dec 06 2017 19:27:10 tmm 34 | Refactored for Catena 4551 support. 35 | 36 | 37 | */ 38 | 39 | #ifdef ARDUINO_ARCH_SAMD 40 | 41 | #include 42 | 43 | #include 44 | using namespace McciCatena; 45 | 46 | 47 | 48 | Arduino_LoRaWAN::ProvisioningStyle 49 | CatenaFeatherM0::LoRaWAN::GetProvisioningStyle( 50 | void 51 | ) 52 | { 53 | CatenaFeatherM0 * const pCatena = this->m_pCatena; 54 | const ProvisioningInfo * const pInstance = pCatena->GetProvisioningInfo(); 55 | 56 | if (! pInstance) 57 | { 58 | ARDUINO_LORAWAN_PRINTF( 59 | LogVerbose, 60 | "%s: no provisioning info\n", 61 | __func__ 62 | ); 63 | 64 | return Arduino_LoRaWAN::ProvisioningStyle::kNone; 65 | } 66 | else 67 | { 68 | return pInstance->Style; 69 | } 70 | } 71 | 72 | #endif // ARDUINO_ARCH_SAMD 73 | -------------------------------------------------------------------------------- /src/lib/stm32/stm32l0/CatenaStm32L0_LoRaWAN_getprovisioningstyle.cpp: -------------------------------------------------------------------------------- 1 | /* CatenaStm32L0_LoRaWAN_getprovisioningstyle.cpp Wed Dec 05 2018 14:36:35 chwon */ 2 | 3 | /* 4 | 5 | Module: CatenaStm32L0_LoRaWAN_getprovisioningstyle.cpp 6 | 7 | Function: 8 | CatenaStm32L0::LoRaWAN::GetProvisioningStyle(). 9 | 10 | Version: 11 | V0.12.0 Wed Dec 05 2018 14:36:35 chwon Edit level 2 12 | 13 | Copyright notice: 14 | This file copyright (C) 2017-2018 by 15 | 16 | MCCI Corporation 17 | 3520 Krums Corners Road 18 | Ithaca, NY 14850 19 | 20 | An unpublished work. All rights reserved. 21 | 22 | This file is proprietary information, and may not be disclosed or 23 | copied without the prior permission of MCCI Corporation. 24 | 25 | Author: 26 | ChaeHee Won, MCCI Corporation October 2017 27 | 28 | Revision history: 29 | 0.6.0 Fri Oct 13 2017 15:19:30 chwon 30 | Module created. 31 | 32 | 0.12.0 Wed Dec 05 2018 14:36:35 chwon 33 | Use Catena provisioning method. 34 | 35 | */ 36 | 37 | #ifdef ARDUINO_ARCH_STM32 38 | 39 | #include 40 | 41 | #include 42 | #include 43 | 44 | using namespace McciCatena; 45 | 46 | /****************************************************************************\ 47 | | 48 | | Manifest constants & typedefs. 49 | | 50 | \****************************************************************************/ 51 | 52 | 53 | 54 | /****************************************************************************\ 55 | | 56 | | Read-only data. 57 | | 58 | \****************************************************************************/ 59 | 60 | 61 | 62 | /****************************************************************************\ 63 | | 64 | | VARIABLES: 65 | | 66 | \****************************************************************************/ 67 | 68 | 69 | CatenaStm32L0::LoRaWAN::ProvisioningStyle 70 | CatenaStm32L0::LoRaWAN::GetProvisioningStyle( 71 | void 72 | ) 73 | { 74 | CatenaStm32L0 * const pCatena = this->m_pCatena; 75 | 76 | return pCatena->GetProvisioningStyle(); 77 | } 78 | 79 | #endif // ARDUINO_ARCH_STM32 80 | 81 | /**** end of CatenaStm32L0_LoRaWAN_getprovisioningstyle.cpp ****/ 82 | -------------------------------------------------------------------------------- /src/Catena4470.h: -------------------------------------------------------------------------------- 1 | /* Catena4470.h Wed Nov 21 2018 13:45:22 chwon */ 2 | 3 | /* 4 | 5 | Module: Catena4470.h 6 | 7 | Function: 8 | class Catena4470: CatenaBase Platform to represent a Catena 4470 9 | 10 | Version: 11 | V0.11.0 Wed Nov 21 2018 13:45:23 chwon Edit level 2 12 | 13 | Copyright notice: 14 | This file copyright (C) 2018 by 15 | 16 | MCCI Corporation 17 | 3520 Krums Corners Road 18 | Ithaca, NY 14850 19 | 20 | An unpublished work. All rights reserved. 21 | 22 | This file is proprietary information, and may not be disclosed or 23 | copied without the prior permission of MCCI Corporation. 24 | 25 | Author: 26 | Terry Moore, MCCI Corporation March 2018 27 | 28 | Revision history: 29 | 0.9.0 Sat Mar 31 2018 19:28:30 tmm 30 | Module created. 31 | 32 | 0.11.0 Wed Nov 21 2018 13:45:23 chwon 33 | Add CatenaName() method. 34 | 35 | */ 36 | 37 | #ifndef _CATENA4470_H_ /* prevent multiple includes */ 38 | #define _CATENA4470_H_ 39 | 40 | #pragma once 41 | 42 | #ifndef _CATENAWINGFRAM2K_H_ 43 | # include "CatenaWingFram2k.h" 44 | #endif 45 | 46 | namespace McciCatena { 47 | 48 | class Catena4470 : public CatenaWingFram2k 49 | { 50 | public: 51 | using Super = CatenaWingFram2k; 52 | 53 | // no specific constructor. 54 | Catena4470() {}; 55 | 56 | // uses default destructor 57 | 58 | // neither copyable nor movable 59 | Catena4470(const Catena4470&) = delete; 60 | Catena4470& operator=(const Catena4470&) = delete; 61 | Catena4470(const Catena4470&&) = delete; 62 | Catena4470& operator=(const Catena4470&&) = delete; 63 | 64 | virtual const char *CatenaName() const override { return "Catena 4470"; }; 65 | 66 | protected: 67 | // we are required to provide a table of platforms 68 | virtual void getPlatformTable( 69 | const CATENA_PLATFORM * const * &vPlatforms, 70 | size_t &nvPlatforms 71 | ) override; 72 | 73 | private: 74 | // the known platforms 75 | static const CATENA_PLATFORM (* const vPlatforms[]); 76 | static const size_t nvPlatforms; 77 | }; 78 | 79 | } /* namespace McciCatena */ 80 | 81 | /**** end of Catena4470.h ****/ 82 | #endif /* _CATENA4470_H_ */ 83 | -------------------------------------------------------------------------------- /assets/cFram.plantuml: -------------------------------------------------------------------------------- 1 | @startuml "cFram class hierarchy" 2 | /' PlantUML image for FRAM 3 | '/ 4 | namespace McciCatena { 5 | abstract class cPersistentStorage { 6 | +{abstract} virtual bool begin(); 7 | +{abstract} virtual bool initialize(); 8 | +{abstract} virtual bool reset(); 9 | +{abstract} virtual bool isValid(); 10 | +{abstract} virtual bool isReady(); 11 | +{abstract} virtual void invalidate(); 12 | } 13 | 14 | cPersistentStorage <|-- cFram 15 | 16 | abstract class cFram { 17 | +virtual bool begin(); 18 | +virtual bool initialize(); 19 | +virtual bool reset(); 20 | +virtual bool isValid(); 21 | +virtual bool isReady(); 22 | +virtual void invalidate(); 23 | +{abstract} size_t read(); 24 | +{abstract} size_t write(); 25 | +{abstract} cFramStorage::Offset getsize(); 26 | +bool addCommands(); 27 | +{static}cCommandStream::CommandStatus doDump(); 28 | +{static}cCommandStream::CmmandStatus doReset(); 29 | +void saveField(); 30 | +template void saveField(); 31 | +bool getField(); 32 | +template bool getField(); 33 | #bool m_fReady 34 | #cFramStorage::Offset m_offsetCache[] 35 | #uint8_t m_uVerCache[]; 36 | #cFramStorage::Offset m_endOffset; 37 | #void loadCache(); 38 | #void resetCache(); 39 | #void setCacheEntry(); 40 | #cFramStorage::Offset allocate(); 41 | #bool writeItemData(); 42 | } 43 | 44 | class cFram2K { 45 | +bool begin(); 46 | +size_t read(); 47 | +size_t write(); 48 | +cFramStorage::Offset getsize(); 49 | -MCCI_FRAM_I2C m_hw 50 | } 51 | 52 | cFram <|-- cFram2K 53 | 54 | class cFram::Cursor { 55 | +bool create(); 56 | +bool isbound(); 57 | +bool islocated(); 58 | +bool locate(cFramStorage::StandardItem); 59 | +bool locate(cFramStorage::StandardKeys); 60 | +bool getitem(); 61 | +size_t getitemsize(); 62 | +bool get(uint8_t *, size_t); 63 | +bool getuint32(uint32_t &); 64 | +bool put(const uint8_t *, size_t); 65 | +bool putuint32(uint32_t &); 66 | +bool parsevalue(); 67 | +size_t formatvalue(); 68 | -cFramStorage::StandardItem getItem(); 69 | -cFram *m_pFram; 70 | -uint16_t m_uSize; 71 | -uint8_t m_uKey; 72 | -uint8_t m_uVer; 73 | -uint32_t m_offset; 74 | } 75 | 76 | cFram <- cFram::Cursor 77 | } 78 | @enduml -------------------------------------------------------------------------------- /src/Catena4460.h: -------------------------------------------------------------------------------- 1 | /* Catnea4460.h Wed Nov 21 2018 13:45:25 chwon */ 2 | 3 | /* 4 | 5 | Module: Catena4460.h 6 | 7 | Function: 8 | class Catena4460: CatenaBase Platform to represent a Catena 4460 9 | 10 | Version: 11 | V0.11.0 Wed Nov 21 2018 13:45:25 chwon Edit level 2 12 | 13 | Copyright notice: 14 | This file copyright (C) 2018 by 15 | 16 | MCCI Corporation 17 | 3520 Krums Corners Road 18 | Ithaca, NY 14850 19 | 20 | An unpublished work. All rights reserved. 21 | 22 | This file is proprietary information, and may not be disclosed or 23 | copied without the prior permission of MCCI Corporation. 24 | 25 | Author: 26 | Terry Moore, MCCI Corporation March 2018 27 | 28 | Revision history: 29 | 0.9.0 Sat Mar 31 2018 19:28:30 tmm 30 | Module created. 31 | 32 | 0.11.0 Wed Nov 21 2018 13:45:25 chwon 33 | Add CatenaName() method. 34 | 35 | */ 36 | 37 | #ifndef _CATENA4460_H_ /* prevent multiple includes */ 38 | #define _CATENA4460_H_ 39 | 40 | #pragma once 41 | 42 | #ifndef _CATENAWINGFRAM2K_H_ 43 | # include "CatenaWingFram2k.h" 44 | #endif 45 | 46 | namespace McciCatena { 47 | 48 | class Catena4460 : public CatenaWingFram2k 49 | { 50 | public: 51 | using Super = CatenaWingFram2k; 52 | 53 | // no specific constructor. 54 | Catena4460() {}; 55 | 56 | // uses default destructor 57 | 58 | // neither copyable nor movable 59 | Catena4460(const Catena4460&) = delete; 60 | Catena4460& operator=(const Catena4460&) = delete; 61 | Catena4460(const Catena4460&&) = delete; 62 | Catena4460& operator=(const Catena4460&&) = delete; 63 | 64 | virtual const char *CatenaName() const override { return "Catena 4460"; }; 65 | 66 | protected: 67 | // we are required to provide a table of platforms 68 | virtual void getPlatformTable( 69 | const CATENA_PLATFORM * const * &vPlatforms, 70 | size_t &nvPlatforms 71 | ) override; 72 | 73 | 74 | private: 75 | // the known platforms 76 | static const CATENA_PLATFORM (* const vPlatforms[]); 77 | static const size_t nvPlatforms; 78 | }; 79 | 80 | } /* namespace McciCatena */ 81 | 82 | /**** end of Catena4460.h ****/ 83 | #endif /* _CATENA4460_H_ */ 84 | -------------------------------------------------------------------------------- /src/Catena4610.h: -------------------------------------------------------------------------------- 1 | /* Catena4610.h Fri Dec 28 2018 13:58:16 chwon */ 2 | 3 | /* 4 | 5 | Module: Catena4610.h 6 | 7 | Function: 8 | class Catena4610: CatenaBase Platform to represent a Catena 4610 9 | 10 | Version: 11 | V0.13.0 Fri Dec 28 2018 13:58:16 chwon Edit level 2 12 | 13 | Copyright notice: 14 | This file copyright (C) 2018 by 15 | 16 | MCCI Corporation 17 | 3520 Krums Corners Road 18 | Ithaca, NY 14850 19 | 20 | An unpublished work. All rights reserved. 21 | 22 | This file is proprietary information, and may not be disclosed or 23 | copied without the prior permission of MCCI Corporation 24 | 25 | Author: 26 | ChaeHee Won, MCCI Corporation November 2018 27 | 28 | Revision history: 29 | 0.11.0 Thu Nov 15 2018 15:07:23 chwon 30 | Module created. 31 | 32 | 0.13.0 Fri Dec 28 2018 13:58:16 chwon 33 | Add ReadVbat() and ReadVbus() override. 34 | 35 | */ 36 | 37 | #ifndef _Catena4610_H_ /* prevent multiple includes */ 38 | #define _Catena4610_H_ 39 | 40 | #pragma once 41 | 42 | #ifndef _CATENA461X_H_ 43 | # include "Catena461x.h" 44 | #endif 45 | 46 | namespace McciCatena { 47 | 48 | class Catena4610 : public Catena461x 49 | { 50 | public: 51 | using Super = Catena461x; 52 | 53 | // no specific constructor. 54 | Catena4610() {}; 55 | 56 | // uses default destructor 57 | 58 | // neither copyable nor movable 59 | Catena4610(const Catena4610&) = delete; 60 | Catena4610& operator=(const Catena4610&) = delete; 61 | Catena4610(const Catena4610&&) = delete; 62 | Catena4610& operator=(const Catena4610&&) = delete; 63 | 64 | virtual const char *CatenaName() const override { return "Catena 4610"; }; 65 | virtual float ReadVbat(void) const override; 66 | virtual float ReadVbus(void) const override; 67 | 68 | protected: 69 | // we are required to provide a table of platforms 70 | virtual void getPlatformTable( 71 | const CATENA_PLATFORM * const * &vPlatforms, 72 | size_t &nvPlatforms 73 | ) override; 74 | 75 | private: 76 | // the known platforms 77 | static const CATENA_PLATFORM(* const vPlatforms[]); 78 | static const size_t nvPlatforms; 79 | }; 80 | 81 | } // namespace McciCatena 82 | 83 | /**** end of Catena4610.h ****/ 84 | #endif /* _Catena4610_H_ */ 85 | -------------------------------------------------------------------------------- /src/Catena4611.h: -------------------------------------------------------------------------------- 1 | /* Catena4611.h Fri Dec 28 2018 13:57:54 chwon */ 2 | 3 | /* 4 | 5 | Module: Catena4611.h 6 | 7 | Function: 8 | class Catena4611: CatenaBase Platform to represent a Catena 4611 9 | 10 | Version: 11 | V0.13.0 Fri Dec 28 2018 13:57:54 chwon Edit level 2 12 | 13 | Copyright notice: 14 | This file copyright (C) 2018 by 15 | 16 | MCCI Corporation 17 | 3520 Krums Corners Road 18 | Ithaca, NY 14850 19 | 20 | An unpublished work. All rights reserved. 21 | 22 | This file is proprietary information, and may not be disclosed or 23 | copied without the prior permission of MCCI Corporation 24 | 25 | Author: 26 | ChaeHee Won, MCCI Corporation November 2018 27 | 28 | Revision history: 29 | 0.11.0 Thu Nov 15 2018 15:07:23 chwon 30 | Module created. 31 | 32 | 0.13.0 Fri Dec 28 2018 13:57:54 chwon 33 | Add ReadVbat() and ReadVbus() override. 34 | 35 | */ 36 | 37 | #ifndef _Catena4611_H_ /* prevent multiple includes */ 38 | #define _Catena4611_H_ 39 | 40 | #pragma once 41 | 42 | #ifndef _CATENA461X_H_ 43 | # include "Catena461x.h" 44 | #endif 45 | 46 | namespace McciCatena { 47 | 48 | class Catena4611 : public Catena461x 49 | { 50 | public: 51 | using Super = Catena461x; 52 | 53 | // no specific constructor. 54 | Catena4611() {}; 55 | 56 | // uses default destructor 57 | 58 | // neither copyable nor movable 59 | Catena4611(const Catena4611&) = delete; 60 | Catena4611& operator=(const Catena4611&) = delete; 61 | Catena4611(const Catena4611&&) = delete; 62 | Catena4611& operator=(const Catena4611&&) = delete; 63 | 64 | virtual const char *CatenaName() const override { return "Catena 4611"; }; 65 | virtual float ReadVbat(void) const override; 66 | virtual float ReadVbus(void) const override; 67 | 68 | protected: 69 | // we are required to provide a table of platforms 70 | virtual void getPlatformTable( 71 | const CATENA_PLATFORM * const * &vPlatforms, 72 | size_t &nvPlatforms 73 | ) override; 74 | 75 | private: 76 | // the known platforms 77 | static const CATENA_PLATFORM(* const vPlatforms[]); 78 | static const size_t nvPlatforms; 79 | }; 80 | 81 | } // namespace McciCatena 82 | 83 | /**** end of Catena4611.h ****/ 84 | #endif /* _Catena4611_H_ */ 85 | -------------------------------------------------------------------------------- /src/Catena4612.h: -------------------------------------------------------------------------------- 1 | /* Catena4612.h Fri Dec 28 2018 13:58:18 chwon */ 2 | 3 | /* 4 | 5 | Module: Catena4612.h 6 | 7 | Function: 8 | class Catena4612: CatenaBase Platform to represent a Catena 4612 9 | 10 | Version: 11 | V0.13.0 Fri Dec 28 2018 13:58:19 chwon Edit level 2 12 | 13 | Copyright notice: 14 | This file copyright (C) 2018 by 15 | 16 | MCCI Corporation 17 | 3520 Krums Corners Road 18 | Ithaca, NY 14850 19 | 20 | An unpublished work. All rights reserved. 21 | 22 | This file is proprietary information, and may not be disclosed or 23 | copied without the prior permission of MCCI Corporation 24 | 25 | Author: 26 | ChaeHee Won, MCCI Corporation November 2018 27 | 28 | Revision history: 29 | 0.11.0 Thu Nov 15 2018 15:07:23 chwon 30 | Module created. 31 | 32 | 0.13.0 Fri Dec 28 2018 13:58:19 chwon 33 | Add ReadVbat() and ReadVbus() override. 34 | 35 | */ 36 | 37 | #ifndef _Catena4612_H_ /* prevent multiple includes */ 38 | #define _Catena4612_H_ 39 | 40 | #pragma once 41 | 42 | #ifndef _CATENA461X_H_ 43 | # include "Catena461x.h" 44 | #endif 45 | 46 | namespace McciCatena { 47 | 48 | class Catena4612 : public Catena461x 49 | { 50 | public: 51 | using Super = Catena461x; 52 | 53 | // no specific constructor. 54 | Catena4612() {}; 55 | 56 | // uses default destructor 57 | 58 | // neither copyable nor movable 59 | Catena4612(const Catena4612&) = delete; 60 | Catena4612& operator=(const Catena4612&) = delete; 61 | Catena4612(const Catena4612&&) = delete; 62 | Catena4612& operator=(const Catena4612&&) = delete; 63 | 64 | virtual const char *CatenaName() const override { return "Catena 4612"; }; 65 | virtual float ReadVbat(void) const override; 66 | virtual float ReadVbus(void) const override; 67 | 68 | protected: 69 | // we are required to provide a table of platforms 70 | virtual void getPlatformTable( 71 | const CATENA_PLATFORM * const * &vPlatforms, 72 | size_t &nvPlatforms 73 | ) override; 74 | 75 | private: 76 | // the known platforms 77 | static const CATENA_PLATFORM(* const vPlatforms[]); 78 | static const size_t nvPlatforms; 79 | }; 80 | 81 | } // namespace McciCatena 82 | 83 | /**** end of Catena4612.h ****/ 84 | #endif /* _Catena4612_H_ */ 85 | -------------------------------------------------------------------------------- /src/lib/samd/catena4410/Catena4410.cpp: -------------------------------------------------------------------------------- 1 | /* Catena4410.cpp Sat Oct 15 2016 22:50:43 tmm */ 2 | 3 | /* 4 | 5 | Module: Catena4410.cpp 6 | 7 | Function: 8 | Catena4410::Catea4410() 9 | 10 | Version: 11 | V0.1.0 Sat Oct 15 2016 22:50:43 tmm Edit level 1 12 | 13 | Copyright notice: 14 | This file copyright (C) 2016 by 15 | 16 | MCCI Corporation 17 | 3520 Krums Corners Road 18 | Ithaca, NY 14850 19 | 20 | An unpublished work. All rights reserved. 21 | 22 | This file is proprietary information, and may not be disclosed or 23 | copied without the prior permission of MCCI Corporation. 24 | 25 | Author: 26 | Terry Moore, MCCI Corporation October 2016 27 | 28 | Revision history: 29 | 0.1.0 Sat Oct 15 2016 22:50:43 tmm 30 | Module created. 31 | 32 | */ 33 | 34 | #ifdef ARDUINO_ARCH_SAMD 35 | 36 | #include "Catena4410.h" 37 | 38 | using namespace McciCatena; 39 | 40 | 41 | /****************************************************************************\ 42 | | 43 | | Manifest constants & typedefs. 44 | | 45 | | This is strictly for private types and constants which will not 46 | | be exported. 47 | | 48 | \****************************************************************************/ 49 | 50 | 51 | 52 | /****************************************************************************\ 53 | | 54 | | Read-only data. 55 | | 56 | | If program is to be ROM-able, these must all be tagged read-only 57 | | using the ROM storage class; they may be global. 58 | | 59 | \****************************************************************************/ 60 | 61 | 62 | 63 | /****************************************************************************\ 64 | | 65 | | VARIABLES: 66 | | 67 | | If program is to be ROM-able, these must be initialized 68 | | using the BSS keyword. (This allows for compilers that require 69 | | every variable to have an initializer.) Note that only those 70 | | variables owned by this module should be declared here, using the BSS 71 | | keyword; this allows for linkers that dislike multiple declarations 72 | | of objects. 73 | | 74 | \****************************************************************************/ 75 | 76 | Catena4410::Catena4410() 77 | { 78 | /* this function does nothing */ 79 | } 80 | 81 | #endif // ARDUINO_ARCH_SAMD 82 | -------------------------------------------------------------------------------- /src/Catena_PersistentStorage.h: -------------------------------------------------------------------------------- 1 | /* Catena_PersistentStorage.h Sun Mar 12 2017 17:49:22 tmm */ 2 | 3 | /* 4 | 5 | Module: Catena_PersistentStorage.h 6 | 7 | Function: 8 | Framework for persistent storage on Arduino Catenas. 9 | 10 | Version: 11 | V0.5.0 Sun Mar 12 2017 17:49:22 tmm Edit level 1 12 | 13 | Copyright notice: 14 | This file copyright (C) 2017 by 15 | 16 | MCCI Corporation 17 | 3520 Krums Corners Road 18 | Ithaca, NY 14850 19 | 20 | An unpublished work. All rights reserved. 21 | 22 | This file is proprietary information, and may not be disclosed or 23 | copied without the prior permission of MCCI Corporation. 24 | 25 | Author: 26 | Terry Moore, MCCI Corporation March 2017 27 | 28 | Revision history: 29 | 0.5.0 Sun Mar 12 2017 17:49:22 tmm 30 | Module created. 31 | 32 | */ 33 | 34 | #ifndef _CATENA_PERSISTENTSTORAGE_H_ /* prevent multiple includes */ 35 | #define _CATENA_PERSISTENTSTORAGE_H_ 36 | 37 | #pragma once 38 | 39 | #ifndef _MCCIADK_GUID_H_ 40 | # include "mcciadk_guid.h" 41 | #endif 42 | 43 | namespace McciCatena { 44 | 45 | class cPersistentStorage 46 | { 47 | public: 48 | // constructor 49 | cPersistentStorage() {}; 50 | // destructor 51 | virtual ~cPersistentStorage() {}; 52 | 53 | // neither copyable nor movable 54 | cPersistentStorage(const cPersistentStorage&) = delete; 55 | cPersistentStorage& operator=(const cPersistentStorage&) = delete; 56 | cPersistentStorage(const cPersistentStorage&&) = delete; 57 | cPersistentStorage& operator=(const cPersistentStorage&&) = delete; 58 | 59 | // start storage operations 60 | virtual bool begin() = 0; 61 | 62 | // initialize the store (gently) - do not overwite store if valid 63 | virtual bool initialize() = 0; 64 | 65 | // initialize the store (forcibly). 66 | virtual bool reset() = 0; 67 | 68 | // return the state of the store. 69 | virtual bool isValid() = 0; 70 | 71 | // query whether the FRAM is valid and ready 72 | virtual bool isReady() const = 0; 73 | 74 | // invalidate any cached ready state 75 | virtual void invalidate() = 0; 76 | 77 | private: 78 | }; 79 | 80 | } // namespace McciCatena 81 | 82 | /**** end of Catena_PersistentStorage.h ****/ 83 | #endif /* _CATENA_OBJECT_H_ */ 84 | -------------------------------------------------------------------------------- /src/Catena_Fram2k.h: -------------------------------------------------------------------------------- 1 | /* Catena_Fram2k.h Sun Mar 12 2017 17:47:52 tmm */ 2 | 3 | /* 4 | 5 | Module: Catena_Fram2k.h 6 | 7 | Function: 8 | class McciCatena::cFram2k 9 | 10 | Version: 11 | V0.5.0 Sun Mar 12 2017 17:47:52 tmm Edit level 1 12 | 13 | Copyright notice: 14 | This file copyright (C) 2017 by 15 | 16 | MCCI Corporation 17 | 3520 Krums Corners Road 18 | Ithaca, NY 14850 19 | 20 | An unpublished work. All rights reserved. 21 | 22 | This file is proprietary information, and may not be disclosed or 23 | copied without the prior permission of MCCI Corporation. 24 | 25 | Author: 26 | Terry Moore, MCCI Corporation March 2017 27 | 28 | Revision history: 29 | 0.5.0 Sun Mar 12 2017 17:47:52 tmm 30 | Module created. 31 | 32 | */ 33 | 34 | #ifndef _CATENA_FRAM2K_H_ /* prevent multiple includes */ 35 | #define _CATENA_FRAM2K_H_ 36 | 37 | #pragma once 38 | 39 | #ifndef _CATENA_FRAM_H_ 40 | # include "Catena_Fram.h" 41 | #endif 42 | 43 | #ifndef _MCCI_FRAM_I2C_H_ 44 | # include 45 | #endif 46 | 47 | /****************************************************************************\ 48 | | 49 | | The contents 50 | | 51 | \****************************************************************************/ 52 | 53 | 54 | namespace McciCatena { 55 | 56 | 57 | class cFram2k : public cFram 58 | { 59 | protected: 60 | using Super = cFram; 61 | 62 | public: 63 | cFram2k() { this->m_fReady = false; }; 64 | virtual ~cFram2k() {}; 65 | 66 | // begin working with the FRAM 67 | virtual bool begin() override; 68 | 69 | // read from the store 70 | virtual size_t read( 71 | cFramStorage::Offset uOffset, uint8_t *pBuffer, size_t nBuffer 72 | ) override; 73 | 74 | // write to the store 75 | virtual bool write( 76 | cFramStorage::Offset uOffset, const uint8_t *pBuffer, size_t nBuffer 77 | ) override; 78 | 79 | virtual cFramStorage::Offset getsize() const override 80 | { 81 | return 2 * 1024; 82 | }; 83 | 84 | 85 | protected: 86 | private: 87 | MCCI_FRAM_I2C m_hw; 88 | }; 89 | 90 | }; // namespace McciCatena 91 | 92 | /**** end of Catena_Fram2k.h ****/ 93 | #endif /* _CATENA_FRAM2K_H_ */ 94 | -------------------------------------------------------------------------------- /src/lib/stm32/catena480x/Catena4802_getPlatformTable.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | 3 | Module: Catena4802_getPlatformTable.cpp 4 | 5 | Function: 6 | Catena4802::getPlatformTable() 7 | 8 | Copyright notice: 9 | See accompanying LICENSE file. 10 | 11 | Author: 12 | Dhinesh Kumar Pitchai, MCCI Corporation November 2020 13 | 14 | */ 15 | 16 | #ifdef ARDUINO_ARCH_STM32 17 | 18 | #include "Catena4802.h" 19 | 20 | #include "Catena_Log.h" 21 | #include "Catena_Platforms.h" 22 | #include "Catena_Guids.h" 23 | 24 | namespace McciCatena { 25 | 26 | const CATENA_PLATFORM gkPlatformCatena4802 = 27 | { 28 | Guid: GUID_HW_CATENA_4802_BASE(WIRE), 29 | pParent: &gkPlatformCatena4802, 30 | PlatformFlags: 31 | CatenaBase::fHasLoRa | 32 | CatenaBase::fHasTtnNycLoRa | 33 | CatenaBase::fHasFRAM | 34 | CatenaBase::fHasFlash | 35 | CatenaBase::fHasRS485 | 36 | CatenaBase::fHasSHT3x | 37 | CatenaBase::fHasI2cLevelShifter 38 | }; 39 | 40 | const CATENA_PLATFORM (* const Catena4802::vPlatforms[]) = 41 | { 42 | // entry 0 is the default 43 | &gkPlatformCatena4802, 44 | }; 45 | 46 | const size_t Catena4802::nvPlatforms = sizeof(Catena4802::vPlatforms) / sizeof(Catena4802::vPlatforms[0]); 47 | 48 | /* 49 | 50 | Name: Catena4802::getPlatformTable() 51 | 52 | Function: 53 | Get the known platform table. 54 | 55 | Definition: 56 | public: virtual 57 | void Catena4802::getPlatformTable( 58 | const CATENA_PLATFORM * const * &vPlatforms, 59 | size_t &nvPlatforms 60 | ) override; 61 | 62 | Description: 63 | This override for getPlatformTable() returns the vector of platform 64 | GUIDs for this Catena. 65 | 66 | Returns: 67 | vPlatforms is set to the base of the array of pointers to platform 68 | stuctures; and nvPlatforms is set to the number of entries in 69 | the table. 70 | 71 | */ 72 | 73 | /* public virtual override */ 74 | void 75 | Catena4802::getPlatformTable( 76 | const CATENA_PLATFORM * const * &result_vPlatforms, 77 | size_t &result_nvPlatforms 78 | ) 79 | { 80 | result_vPlatforms = vPlatforms; 81 | result_nvPlatforms = nvPlatforms; 82 | } 83 | 84 | } /* namespace McciCatena */ 85 | 86 | #endif // ARDUINO_ARCH_STM32 87 | -------------------------------------------------------------------------------- /src/Catena_Fram8k.h: -------------------------------------------------------------------------------- 1 | /* Catena_Fram8k.h Fri Oct 13 2017 15:19:30 chwon */ 2 | 3 | /* 4 | 5 | Module: Catena_Fram8k.h 6 | 7 | Function: 8 | class McciCatena::cFram8k 9 | 10 | Version: 11 | V0.6.0 Fri Oct 13 2017 15:19:30 chwon Edit level 1 12 | 13 | Copyright notice: 14 | This file copyright (C) 2017 by 15 | 16 | MCCI Corporation 17 | 3520 Krums Corners Road 18 | Ithaca, NY 14850 19 | 20 | An unpublished work. All rights reserved. 21 | 22 | This file is proprietary information, and may not be disclosed or 23 | copied without the prior permission of MCCI Corporation. 24 | 25 | Author: 26 | ChaeHee Won, MCCI Corporation October 2017 27 | 28 | Revision history: 29 | 0.6.0 Fri Oct 13 2017 15:19:30 chwon 30 | Module created. 31 | 32 | */ 33 | 34 | #ifndef _CATENA_FRAM2K_H_ /* prevent multiple includes */ 35 | #define _CATENA_FRAM2K_H_ 36 | 37 | #pragma once 38 | 39 | #ifndef _CATENA_FRAM_H_ 40 | # include "Catena_Fram.h" 41 | #endif 42 | 43 | #ifndef _CATENA_MB85RC64TA_H_ 44 | # include "Catena_Mb85rc64ta.h" 45 | #endif 46 | 47 | /****************************************************************************\ 48 | | 49 | | The contents 50 | | 51 | \****************************************************************************/ 52 | 53 | 54 | namespace McciCatena { 55 | 56 | 57 | class cFram8k : public cFram 58 | { 59 | protected: 60 | using Super = cFram; 61 | 62 | public: 63 | cFram8k() { this->m_fReady = false; }; 64 | virtual ~cFram8k() {}; 65 | 66 | // begin working with the FRAM 67 | virtual bool begin() override; 68 | 69 | // read from the store 70 | virtual size_t read( 71 | cFramStorage::Offset uOffset, uint8_t *pBuffer, size_t nBuffer 72 | ) override; 73 | 74 | // write to the store 75 | virtual bool write( 76 | cFramStorage::Offset uOffset, const uint8_t *pBuffer, size_t nBuffer 77 | ) override; 78 | 79 | virtual cFramStorage::Offset getsize() const override 80 | { 81 | return 8 * 1024; 82 | }; 83 | 84 | 85 | protected: 86 | private: 87 | Catena_Mb85rc64ta m_hw; 88 | }; 89 | 90 | }; // namespace McciCatena 91 | 92 | /**** end of Catena_Fram8k.h ****/ 93 | #endif /* _CATENA_FRAM2K_H_ */ 94 | -------------------------------------------------------------------------------- /src/Catena_functional.h: -------------------------------------------------------------------------------- 1 | /* Catena_functional.h Sat Mar 18 2017 16:06:51 tmm */ 2 | 3 | /* 4 | 5 | Module: Catena_functional.h 6 | 7 | Function: 8 | Wrapper for when working with Arduino code. 9 | 10 | Version: 11 | V0.5.0 Sat Mar 18 2017 16:06:51 tmm Edit level 1 12 | 13 | Copyright notice: 14 | This file copyright (C) 2017 by 15 | 16 | MCCI Corporation 17 | 3520 Krums Corners Road 18 | Ithaca, NY 14850 19 | 20 | An unpublished work. All rights reserved. 21 | 22 | This file is proprietary information, and may not be disclosed or 23 | copied without the prior permission of MCCI Corporation. 24 | 25 | Author: 26 | Terry Moore, MCCI Corporation March 2017 27 | 28 | Revision history: 29 | 0.5.0 Sat Mar 18 2017 16:06:51 tmm 30 | Module created. 31 | 32 | */ 33 | 34 | #ifndef _CATENA_FUNCTIONAL_H_ /* prevent multiple includes */ 35 | #define _CATENA_FUNCTIONAL_H_ 36 | 37 | #pragma once 38 | 39 | // this is ugly. Arduino.h defines macros min() and max().... which clobber 40 | // functional. So we do some dark magic. 41 | #if defined(Arduino_h) 42 | # define CATENA_FUNCTIONAL_min_defined 1 43 | # define CATENA_FUNCTIONAL_max_defined 1 44 | #else 45 | # if defined(min) 46 | # define CATENA_FUNCTIONAL_min_defined 1 47 | # else 48 | # define CATENA_FUNCTIONAL_min_defined 0 49 | # endif 50 | # if defined(max) 51 | # define CATENA_FUNCTIONAL_max_defined 1 52 | # else 53 | # define CATENA_FUNCTIONAL_max_defined 0 54 | # endif 55 | #endif 56 | 57 | #if CATENA_FUNCTIONAL_min_defined 58 | # undef min 59 | #endif 60 | #if CATENA_FUNCTIONAL_max_defined 61 | # undef max 62 | #endif 63 | 64 | #include 65 | 66 | /* 67 | || Now, we reinstate the Arduino.h values... I said it was ugly. 68 | || In an ideal world we'd be able to save and restore the below. Bear 69 | || in mind that there may be other words that Arduino.h steps on, 70 | || breaking C++ header files: it defines a number of lower-case macros with 71 | || commonly-used words. Since there are no namespaces for macros, it's 72 | || an unpleasant situation. 73 | */ 74 | #if CATENA_FUNCTIONAL_min_defined 75 | # define min(a,b) ((a)<(b)?(a):(b)) 76 | #endif 77 | 78 | #if CATENA_FUNCTIONAL_max_defined 79 | # define max(a,b) ((a)>(b)?(a):(b)) 80 | #endif 81 | 82 | /**** end of Catena_functional.h ****/ 83 | #endif /* _CATENA_FUNCTIONAL_H_ */ 84 | -------------------------------------------------------------------------------- /src/lib/samd/catena4470/Catena4470_getPlatformTable.cpp: -------------------------------------------------------------------------------- 1 | /* Catena4470_getPlatformTable.cpp Wed Apr 12 2017 13:26:14 tmm */ 2 | 3 | /* 4 | 5 | Module: Catena4470_getPlatformTable.cpp 6 | 7 | Function: 8 | Catena4470::getPlatformTable() 9 | 10 | Version: 11 | V0.5.0 Wed Apr 12 2017 13:26:14 tmm Edit level 1 12 | 13 | Copyright notice: 14 | This file copyright (C) 2017 by 15 | 16 | MCCI Corporation 17 | 3520 Krums Corners Road 18 | Ithaca, NY 14850 19 | 20 | An unpublished work. All rights reserved. 21 | 22 | This file is proprietary information, and may not be disclosed or 23 | copied without the prior permission of MCCI Corporation. 24 | 25 | Author: 26 | Terry Moore, MCCI Corporation April 2017 27 | 28 | Revision history: 29 | 0.5.0 Wed Apr 12 2017 13:26:14 tmm 30 | Module created. 31 | 32 | */ 33 | 34 | #ifdef ARDUINO_ARCH_SAMD 35 | 36 | #include "Catena4470.h" 37 | 38 | #include "Catena_Log.h" 39 | #include "Catena_Platforms.h" 40 | 41 | using namespace McciCatena; 42 | 43 | const CATENA_PLATFORM (* const Catena4470::vPlatforms[]) = 44 | { 45 | // entry 0 is the default 46 | &gkPlatformCatena4470, 47 | &gkPlatformCatena4470_m101, 48 | }; 49 | 50 | const size_t Catena4470::nvPlatforms = sizeof(Catena4470::vPlatforms) / sizeof(Catena4470::vPlatforms[0]); 51 | 52 | /* 53 | 54 | Name: Catena4470::getPlatformTable() 55 | 56 | Function: 57 | Get the known platform table. 58 | 59 | Definition: 60 | public: virtual 61 | void Catena4470::getPlatformTable( 62 | const CATENA_PLATFORM * const * &vPlatforms, 63 | size_t &nvPlatforms 64 | ) override; 65 | 66 | Description: 67 | This override for getPlatformTable() returns the vector of platform 68 | GUIDs for this Catena. 69 | 70 | Returns: 71 | vPlatforms is set to the base of the array of pointers to platform 72 | stuctures; and nvPlatforms is set to the number of entries in 73 | the table. 74 | 75 | */ 76 | 77 | /* public virtual override */ 78 | void 79 | Catena4470::getPlatformTable( 80 | const CATENA_PLATFORM * const * &result_vPlatforms, 81 | size_t &result_nvPlatforms 82 | ) 83 | { 84 | result_vPlatforms = vPlatforms; 85 | result_nvPlatforms = nvPlatforms; 86 | } 87 | 88 | #endif // ARDUINO_ARCH_SAMD 89 | -------------------------------------------------------------------------------- /src/lib/stm32/catena461x/Catena4617_ReadVoltage.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | 3 | Module: Catena4617_ReadAnalog.cpp 4 | 5 | Function: 6 | Catena4617::ReadVbat() and Catena4617::ReadVbus() 7 | 8 | Copyright notice: 9 | See accompanying LICENSE file. 10 | 11 | Author: 12 | Lakshmi Priya Natarajan, MCCI Corporation June 2019 13 | 14 | Revision history: 15 | See https://github.com/mcci-catena/Catena-Arduino-Platform 16 | 17 | */ 18 | 19 | #ifdef ARDUINO_ARCH_STM32 20 | 21 | #include "Catena4617.h" 22 | #include "Catena_Log.h" 23 | 24 | #include 25 | using namespace McciCatena; 26 | 27 | /****************************************************************************\ 28 | | 29 | | Manifest constants & typedefs. 30 | | 31 | \****************************************************************************/ 32 | 33 | 34 | 35 | /****************************************************************************\ 36 | | 37 | | Read-only data. 38 | | 39 | \****************************************************************************/ 40 | 41 | 42 | 43 | /****************************************************************************\ 44 | | 45 | | Variables. 46 | | 47 | \****************************************************************************/ 48 | 49 | float 50 | Catena4617::ReadVbat(void) const 51 | { 52 | float volt = this->ReadAnalog(Catena461x::ANALOG_CHANNEL_VBAT, 1, 1); 53 | return volt / 1000; 54 | } 55 | 56 | float 57 | Catena4617::ReadVbus(void) const 58 | { 59 | // on the Catena 4617, the Vbus divider impedance is very high, 60 | // so charge transfer from the previous channel causes problems. 61 | // Therefore, let's read one extra time; the prvious ADC will 62 | // have had some time to bleed off. 63 | float volt = this->ReadAnalog(Catena461x::ANALOG_CHANNEL_VBUS, 6, 3); 64 | return volt / 1000; 65 | } 66 | 67 | #if defined(ARDUINO_MCCI_CATENA_4617) && defined(USBD_LL_ConnectionState_WEAK) 68 | 69 | extern "C" { 70 | 71 | uint32_t USBD_LL_ConnectionState(void) 72 | { 73 | uint32_t vBus; 74 | bool fStatus; 75 | 76 | fStatus = CatenaStm32L0_ReadAnalog( 77 | Catena461x::ANALOG_CHANNEL_VBUS, 6, 3, &vBus 78 | ); 79 | return (fStatus && vBus < 3000) ? 0 : 1; 80 | } 81 | 82 | } 83 | 84 | #endif // ARDUINO_MCCI_CATENA_4617 85 | 86 | #endif // ARDUINO_ARCH_STM32 87 | 88 | /**** end of Catena4617_ReadAnalog.cpp ****/ 89 | -------------------------------------------------------------------------------- /src/lib/stm32/catena461x/Catena4618_ReadVoltage.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | 3 | Module: Catena4618_ReadAnalog.cpp 4 | 5 | Function: 6 | Catena4618::ReadVbat() and Catena4618::ReadVbus() 7 | 8 | Copyright notice: 9 | See accompanying LICENSE file. 10 | 11 | Author: 12 | Lakshmi Priya Natarajan, MCCI Corporation June 2019 13 | 14 | Revision history: 15 | See https://github.com/mcci-catena/Catena-Arduino-Platform 16 | 17 | */ 18 | 19 | #ifdef ARDUINO_ARCH_STM32 20 | 21 | #include "Catena4618.h" 22 | #include "Catena_Log.h" 23 | 24 | #include 25 | using namespace McciCatena; 26 | 27 | /****************************************************************************\ 28 | | 29 | | Manifest constants & typedefs. 30 | | 31 | \****************************************************************************/ 32 | 33 | 34 | 35 | /****************************************************************************\ 36 | | 37 | | Read-only data. 38 | | 39 | \****************************************************************************/ 40 | 41 | 42 | 43 | /****************************************************************************\ 44 | | 45 | | Variables. 46 | | 47 | \****************************************************************************/ 48 | 49 | float 50 | Catena4618::ReadVbat(void) const 51 | { 52 | float volt = this->ReadAnalog(Catena461x::ANALOG_CHANNEL_VBAT, 1, 1); 53 | return volt / 1000; 54 | } 55 | 56 | float 57 | Catena4618::ReadVbus(void) const 58 | { 59 | // on the Catena 4618, the Vbus divider impedance is very high, 60 | // so charge transfer from the previous channel causes problems. 61 | // Therefore, let's read one extra time; the prvious ADC will 62 | // have had some time to bleed off. 63 | float volt = this->ReadAnalog(Catena461x::ANALOG_CHANNEL_VBUS, 6, 3); 64 | return volt / 1000; 65 | } 66 | 67 | #if defined(ARDUINO_MCCI_CATENA_4618) && defined(USBD_LL_ConnectionState_WEAK) 68 | 69 | extern "C" { 70 | 71 | uint32_t USBD_LL_ConnectionState(void) 72 | { 73 | uint32_t vBus; 74 | bool fStatus; 75 | 76 | fStatus = CatenaStm32L0_ReadAnalog( 77 | Catena461x::ANALOG_CHANNEL_VBUS, 6, 3, &vBus 78 | ); 79 | return (fStatus && vBus < 3000) ? 0 : 1; 80 | } 81 | 82 | } 83 | 84 | #endif // ARDUINO_MCCI_CATENA_4618 85 | 86 | #endif // ARDUINO_ARCH_STM32 87 | 88 | /**** end of Catena4618_ReadAnalog.cpp ****/ 89 | -------------------------------------------------------------------------------- /src/Catena_Flash.h: -------------------------------------------------------------------------------- 1 | /* 2 | 3 | Name: Catena_Flash.h 4 | 5 | Function: 6 | Abstract flash base class for McciCatena. 7 | 8 | Copyright: 9 | See accompanying LICENSE file. 10 | 11 | Author: 12 | Terry Moore, MCCI Corporation April 2021 13 | 14 | */ 15 | 16 | #pragma once 17 | 18 | #ifndef _catena_flash_h_ 19 | #define _catena_flash_h_ 20 | 21 | #include 22 | #include 23 | 24 | namespace McciCatena { 25 | 26 | class cFlash 27 | { 28 | public: 29 | // default constructor 30 | cFlash() {} 31 | // neither copyable nor movable 32 | cFlash(const cFlash&) = delete; 33 | cFlash& operator=(const cFlash&) = delete; 34 | cFlash(const cFlash&&) = delete; 35 | cFlash& operator=(const cFlash&&) = delete; 36 | 37 | // public methods 38 | 39 | /// \brief initialize flash system 40 | virtual bool begin(SPIClass *pSpi, uint8_t ChipSelectPin) = 0; 41 | 42 | /// \brief stop the flash system 43 | virtual void end() = 0; 44 | 45 | /// \brief reset chip 46 | virtual void reset(void) = 0; 47 | 48 | /// \brief read JEDEC id 49 | virtual void readId(uint8_t *pManufacturerId, uint16_t *pDeviceId) = 0; 50 | 51 | /// \brief chip erase 52 | virtual void eraseChip(void) = 0; 53 | 54 | /// \brief erase a 4k page 55 | virtual void eraseSector(uint32_t SectorAddress) = 0; 56 | 57 | /// \brief erase a 32k page 58 | virtual void eraseBlock32(uint32_t Block32Address) = 0; 59 | 60 | /// \brief erase a 64k page 61 | virtual void eraseBlock64(uint32_t Block64Address) = 0; 62 | 63 | // set protection -- CATENA_MX25V8035F_PL_xxx 64 | virtual void setProtection(uint8_t protectionLevel) = 0; 65 | 66 | /// \brief read buffer 67 | virtual void read(uint32_t Address, uint8_t *pBuffer, size_t nBuffer) = 0; 68 | 69 | /// \brief program buffer 70 | virtual void program(uint32_t Address, const uint8_t *pBuffer, size_t nBuffer) = 0; 71 | 72 | /// \brief program at most one page. 73 | /// \returns number of bytes not consumed from buffer. 74 | virtual size_t programPage(uint32_t Address, const uint8_t *pBuffer, size_t nBuffer) = 0; 75 | 76 | /// \brief power flash down 77 | virtual void powerDown(void) = 0; 78 | 79 | /// \brief power flash ups 80 | virtual void powerUp(void) = 0; 81 | }; 82 | 83 | } // namespace McciCatena 84 | 85 | #endif /* _catena_flash_h_ */ 86 | -------------------------------------------------------------------------------- /src/Catena_Mb85rc64ta.h: -------------------------------------------------------------------------------- 1 | /* Catena_Mb85rc64ta.h Wed Dec 06 2017 15:30:56 chwon */ 2 | 3 | /* 4 | 5 | Module: Catena_Mb85rc64ta.h 6 | 7 | Function: 8 | class Catena_Mb85rc64ta 9 | 10 | Version: 11 | V0.6.0 Wed Dec 06 2017 15:30:56 chwon Edit level 2 12 | 13 | Copyright notice: 14 | This file copyright (C) 2017 by 15 | 16 | MCCI Corporation 17 | 3520 Krums Corners Road 18 | Ithaca, NY 14850 19 | 20 | An unpublished work. All rights reserved. 21 | 22 | This file is proprietary information, and may not be disclosed or 23 | copied without the prior permission of MCCI Corporation. 24 | 25 | Author: 26 | ChaeHee Won, MCCI Corporation October 2017 27 | 28 | Revision history: 29 | 0.6.0 Fri Oct 13 2017 15:19:30 chwon 30 | Module created. 31 | 32 | 0.6.0 Wed Dec 06 2017 15:30:56 chwon 33 | Add readId and power control. 34 | 35 | */ 36 | 37 | #ifndef _CATENA_MB85RC64TA_H_ /* prevent multiple includes */ 38 | #define _CATENA_MB85RC64TA_H_ 39 | 40 | #pragma once 41 | 42 | #include 43 | #include 44 | 45 | /* TODO: change these to enums and constepxrs in the McciCatena namespace */ 46 | 47 | #define CATENA_MB85RC64TA_ADDRESS (0x50) 48 | #define CATENA_MB85RC64TA_SLAVE_ID (0xF8 >> 1) 49 | 50 | namespace McciCatena { 51 | 52 | class Catena_Mb85rc64ta 53 | { 54 | public: 55 | Catena_Mb85rc64ta(void); 56 | 57 | // set up and probe device 58 | bool begin(uint8_t DeviceAddress = CATENA_MB85RC64TA_ADDRESS, 59 | TwoWire *pWire = &Wire); 60 | 61 | // write a single byte 62 | bool write8(uint16_t framAddr, uint8_t value); 63 | 64 | // write a buffer 65 | size_t write(uint16_t framAddr, uint8_t const *pBuffer, size_t nBuffer); 66 | 67 | // read a single byte -- no error check. 68 | uint8_t read8(uint16_t framAddr); 69 | 70 | // read a buffer -- error if result ! nBuffer 71 | size_t read(uint16_t framAddr, uint8_t *pBuffer, size_t nBuffer); 72 | 73 | // read ID 74 | bool readId(uint16_t *pManufactureId, uint16_t *pProductId); 75 | 76 | // power management 77 | void powerDown(void); 78 | void powerUp(void); 79 | 80 | private: 81 | uint8_t m_DeviceAddress; 82 | boolean m_Initialized; 83 | boolean m_PowerDown; 84 | TwoWire * m_pWire; 85 | 86 | void prepIO(void) const; 87 | }; 88 | 89 | } // namespace McciCatena 90 | 91 | /**** end of Catena_Mb85rc64ta.h ****/ 92 | #endif /* _CATENA_MB85RC64TA_H_ */ 93 | -------------------------------------------------------------------------------- /src/lib/samd/catena4410/catena4410_getlorawankeys.cpp: -------------------------------------------------------------------------------- 1 | /* catena4410_getlorawankeys.cpp Sun Dec 4 2016 22:26:46 tmm */ 2 | 3 | /* 4 | 5 | Module: catena4410_getlorawankeys.cpp 6 | 7 | Function: 8 | Catena4410::GetLoRaWANkeys() 9 | 10 | Version: 11 | V0.4.0 Sun Dec 4 2016 22:26:46 tmm Edit level 1 12 | 13 | Copyright notice: 14 | This file copyright (C) 2016 by 15 | 16 | MCCI Corporation 17 | 3520 Krums Corners Road 18 | Ithaca, NY 14850 19 | 20 | An unpublished work. All rights reserved. 21 | 22 | This file is proprietary information, and may not be disclosed or 23 | copied without the prior permission of MCCI Corporation. 24 | 25 | Author: 26 | Terry Moore, MCCI Corporation December 2016 27 | 28 | Revision history: 29 | 0.4.0 Sun Dec 4 2016 22:26:46 tmm 30 | Module created. 31 | 32 | */ 33 | 34 | #ifdef ARDUINO_ARCH_SAMD 35 | 36 | #include 37 | using namespace McciCatena; 38 | 39 | 40 | /****************************************************************************\ 41 | | 42 | | Manifest constants & typedefs. 43 | | 44 | | This is strictly for private types and constants which will not 45 | | be exported. 46 | | 47 | \****************************************************************************/ 48 | 49 | 50 | 51 | /****************************************************************************\ 52 | | 53 | | Read-only data. 54 | | 55 | | If program is to be ROM-able, these must all be tagged read-only 56 | | using the ROM storage class; they may be global. 57 | | 58 | \****************************************************************************/ 59 | 60 | 61 | 62 | /****************************************************************************\ 63 | | 64 | | VARIABLES: 65 | | 66 | | If program is to be ROM-able, these must be initialized 67 | | using the BSS keyword. (This allows for compilers that require 68 | | every variable to have an initializer.) Note that only those 69 | | variables owned by this module should be declared here, using the BSS 70 | | keyword; this allows for linkers that dislike multiple declarations 71 | | of objects. 72 | | 73 | \****************************************************************************/ 74 | 75 | const Arduino_LoRaWAN::ProvisioningTable * 76 | Catena4410::GetLoRaWANkeys( 77 | void 78 | ) const 79 | { 80 | return &Catena4410::gk_LoRaWAN_Keys; 81 | } 82 | 83 | #endif // ARDUINO_ARCH_SAMD 84 | -------------------------------------------------------------------------------- /src/lib/samd/catena4420/catena4420_getlorawankeys.cpp: -------------------------------------------------------------------------------- 1 | /* catena4420_getlorawankeys.cpp Sun Dec 4 2016 22:26:46 tmm */ 2 | 3 | /* 4 | 5 | Module: catena4420_getlorawankeys.cpp 6 | 7 | Function: 8 | Catena4420::GetLoRaWANkeys() 9 | 10 | Version: 11 | V0.4.0 Sun Dec 4 2016 22:26:46 tmm Edit level 1 12 | 13 | Copyright notice: 14 | This file copyright (C) 2016 by 15 | 16 | MCCI Corporation 17 | 3520 Krums Corners Road 18 | Ithaca, NY 14850 19 | 20 | An unpublished work. All rights reserved. 21 | 22 | This file is proprietary information, and may not be disclosed or 23 | copied without the prior permission of MCCI Corporation. 24 | 25 | Author: 26 | Terry Moore, MCCI Corporation December 2016 27 | 28 | Revision history: 29 | 0.4.0 Sun Dec 4 2016 22:26:46 tmm 30 | Module created. 31 | 32 | */ 33 | 34 | #ifdef ARDUINO_ARCH_SAMD 35 | 36 | #include 37 | using namespace McciCatena; 38 | 39 | 40 | /****************************************************************************\ 41 | | 42 | | Manifest constants & typedefs. 43 | | 44 | | This is strictly for private types and constants which will not 45 | | be exported. 46 | | 47 | \****************************************************************************/ 48 | 49 | 50 | 51 | /****************************************************************************\ 52 | | 53 | | Read-only data. 54 | | 55 | | If program is to be ROM-able, these must all be tagged read-only 56 | | using the ROM storage class; they may be global. 57 | | 58 | \****************************************************************************/ 59 | 60 | 61 | 62 | /****************************************************************************\ 63 | | 64 | | VARIABLES: 65 | | 66 | | If program is to be ROM-able, these must be initialized 67 | | using the BSS keyword. (This allows for compilers that require 68 | | every variable to have an initializer.) Note that only those 69 | | variables owned by this module should be declared here, using the BSS 70 | | keyword; this allows for linkers that dislike multiple declarations 71 | | of objects. 72 | | 73 | \****************************************************************************/ 74 | 75 | const Arduino_LoRaWAN::ProvisioningTable * 76 | Catena4420::GetLoRaWANkeys( 77 | void 78 | ) const 79 | { 80 | return &Catena4420::gk_LoRaWAN_Keys; 81 | } 82 | 83 | #endif // ARDUINO_ARCH_SAMD 84 | -------------------------------------------------------------------------------- /src/lib/samd/catena4450/Catena4450_getPlatformTable.cpp: -------------------------------------------------------------------------------- 1 | /* Catena4450_getPlatformTable.cpp Wed Apr 12 2017 13:26:14 tmm */ 2 | 3 | /* 4 | 5 | Module: Catena4450_getPlatformTable.cpp 6 | 7 | Function: 8 | Catena4450::getPlatformTable() 9 | 10 | Version: 11 | V0.5.0 Wed Apr 12 2017 13:26:14 tmm Edit level 1 12 | 13 | Copyright notice: 14 | This file copyright (C) 2017 by 15 | 16 | MCCI Corporation 17 | 3520 Krums Corners Road 18 | Ithaca, NY 14850 19 | 20 | An unpublished work. All rights reserved. 21 | 22 | This file is proprietary information, and may not be disclosed or 23 | copied without the prior permission of MCCI Corporation. 24 | 25 | Author: 26 | Terry Moore, MCCI Corporation April 2017 27 | 28 | Revision history: 29 | 0.5.0 Wed Apr 12 2017 13:26:14 tmm 30 | Module created. 31 | 32 | */ 33 | 34 | #ifdef ARDUINO_ARCH_SAMD 35 | 36 | #include "Catena4450.h" 37 | 38 | #include "Catena_Log.h" 39 | #include "Catena_Platforms.h" 40 | 41 | using namespace McciCatena; 42 | 43 | const CATENA_PLATFORM (* const Catena4450::vPlatforms[]) = 44 | { 45 | // entry 0 is the default 46 | &gkPlatformCatena4450, 47 | &gkPlatformCatena4450_m101, 48 | &gkPlatformCatena4450_m102, 49 | &gkPlatformCatena4450_m103, 50 | &gkPlatformCatena4450_m104, 51 | }; 52 | 53 | const size_t Catena4450::nvPlatforms = sizeof(Catena4450::vPlatforms) / sizeof(Catena4450::vPlatforms[0]); 54 | 55 | /* 56 | 57 | Name: Catena4450::getPlatformTable() 58 | 59 | Function: 60 | Get the known platform table. 61 | 62 | Definition: 63 | public: virtual 64 | void Catena4450::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 | Catena4450::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 | #endif // ARDUINO_ARCH_SAMD 92 | -------------------------------------------------------------------------------- /src/lib/samd/catena4460/Catena4460_getPlatformTable.cpp: -------------------------------------------------------------------------------- 1 | /* Catena4460_getPlatformTable.cpp Wed Apr 12 2017 13:26:14 tmm */ 2 | 3 | /* 4 | 5 | Module: Catena4460_getPlatformTable.cpp 6 | 7 | Function: 8 | Catena4460::getPlatformTable() 9 | 10 | Version: 11 | V0.5.0 Wed Apr 12 2017 13:26:14 tmm Edit level 1 12 | 13 | Copyright notice: 14 | This file copyright (C) 2017 by 15 | 16 | MCCI Corporation 17 | 3520 Krums Corners Road 18 | Ithaca, NY 14850 19 | 20 | An unpublished work. All rights reserved. 21 | 22 | This file is proprietary information, and may not be disclosed or 23 | copied without the prior permission of MCCI Corporation. 24 | 25 | Author: 26 | Terry Moore, MCCI Corporation April 2017 27 | 28 | Revision history: 29 | 0.5.0 Wed Apr 12 2017 13:26:14 tmm 30 | Module created. 31 | 32 | */ 33 | 34 | #ifdef ARDUINO_ARCH_SAMD 35 | 36 | #include "Catena4460.h" 37 | 38 | #include "Catena_Log.h" 39 | #include "Catena_Platforms.h" 40 | 41 | using namespace McciCatena; 42 | 43 | const CATENA_PLATFORM (* const Catena4460::vPlatforms[]) = 44 | { 45 | // entry 0 is the default 46 | &gkPlatformCatena4460, 47 | &gkPlatformCatena4460_m101, 48 | &gkPlatformCatena4460_m102, 49 | &gkPlatformCatena4460_m103, 50 | &gkPlatformCatena4460_m104, 51 | }; 52 | 53 | const size_t Catena4460::nvPlatforms = sizeof(Catena4460::vPlatforms) / sizeof(Catena4460::vPlatforms[0]); 54 | 55 | /* 56 | 57 | Name: Catena4460::getPlatformTable() 58 | 59 | Function: 60 | Get the known platform table. 61 | 62 | Definition: 63 | public: virtual 64 | void Catena4460::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 | Catena4460::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 | #endif // ARDUINO_ARCH_SAMD 92 | -------------------------------------------------------------------------------- /src/lib/stm32/catena463x/Catena4630_getPlatformTable.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | 3 | Module: Catena4630_getPlatformTable.cpp 4 | 5 | Function: 6 | Catena4630::getPlatformTable() 7 | 8 | Copyright notice: 9 | See accompanying LICENSE file. 10 | 11 | Author: 12 | Dhinesh Kumar Pitchai, MCCI Corporation April 2019 13 | 14 | */ 15 | 16 | #ifdef ARDUINO_ARCH_STM32 17 | 18 | #include "Catena4630.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 gkPlatformCatena4630 = 33 | { 34 | Guid: GUID_HW_CATENA_4630_BASE(WIRE), 35 | pParent: &gkPlatformCatena4630, 36 | PlatformFlags: 37 | CatenaBase::fHasLoRa | 38 | CatenaBase::fHasTtnNycLoRa | 39 | CatenaBase::fHasBme280 | 40 | CatenaBase::fHasZMOD4410 | 41 | CatenaBase::fHasFRAM | 42 | CatenaBase::fHasFlash 43 | }; 44 | 45 | const CATENA_PLATFORM (* const Catena4630::vPlatforms[]) = 46 | { 47 | // entry 0 is the default 48 | &gkPlatformCatena4630, 49 | }; 50 | 51 | const size_t Catena4630::nvPlatforms = sizeof(Catena4630::vPlatforms) / sizeof(Catena4630::vPlatforms[0]); 52 | 53 | /* 54 | 55 | Name: Catena4630::getPlatformTable() 56 | 57 | Function: 58 | Get the known platform table. 59 | 60 | Definition: 61 | public: virtual 62 | void Catena4630::getPlatformTable( 63 | const CATENA_PLATFORM * const * &vPlatforms, 64 | size_t &nvPlatforms 65 | ) override; 66 | 67 | Description: 68 | This override for getPlatformTable() returns the vector of platform 69 | GUIDs for this Catena. 70 | 71 | Returns: 72 | vPlatforms is set to the base of the array of pointers to platform 73 | stuctures; and nvPlatforms is set to the number of entries in 74 | the table. 75 | 76 | */ 77 | 78 | /* public virtual override */ 79 | void 80 | Catena4630::getPlatformTable( 81 | const CATENA_PLATFORM * const * &result_vPlatforms, 82 | size_t &result_nvPlatforms 83 | ) 84 | { 85 | result_vPlatforms = vPlatforms; 86 | result_nvPlatforms = nvPlatforms; 87 | } 88 | 89 | } /* namespace McciCatena */ 90 | 91 | #endif // ARDUINO_ARCH_STM32 92 | -------------------------------------------------------------------------------- /src/CatenaStm32L0Rtc.h: -------------------------------------------------------------------------------- 1 | /* CatenaStm32L0Rtc.h Fri Dec 01 2017 13:59:17 chwon */ 2 | 3 | /* 4 | 5 | Module: CatenaStm32L0Rtc.h 6 | 7 | Function: 8 | Class CatenaStm32L0Rtc 9 | 10 | Version: 11 | V0.6.0 Fri Dec 01 2017 13:59:17 chwon Edit level 2 12 | 13 | Copyright notice: 14 | This file copyright (C) 2017 by 15 | 16 | MCCI Corporation 17 | 3520 Krums Corners Road 18 | Ithaca, NY 14850 19 | 20 | An unpublished work. All rights reserved. 21 | 22 | This file is proprietary information, and may not be disclosed or 23 | copied without the prior permission of MCCI Corporation. 24 | 25 | Author: 26 | ChaeHee Won, MCCI Corporation October 2017 27 | 28 | Revision history: 29 | 0.6.0 Fri Oct 13 2017 15:19:30 chwon 30 | Module created. 31 | 32 | 0.6.0 Fri Dec 01 2017 13:59:17 chwon 33 | Include Arduino.h instead of variant.h. 34 | 35 | */ 36 | 37 | #ifndef _CATENASTM32L0RTC_H_ /* prevent multiple includes */ 38 | #define _CATENASTM32L0RTC_H_ 39 | 40 | #ifdef STM32L0xx /* This is valid only STM32L0xx CPU */ 41 | 42 | #pragma once 43 | 44 | #include 45 | 46 | namespace McciCatena { 47 | 48 | class CatenaStm32L0Rtc 49 | { 50 | public: 51 | struct CalendarTime; 52 | enum class SleepMode 53 | { 54 | SleepWithRegulator = 0, 55 | SleepWithLowPowerRegulator, 56 | StopWithRegulator, 57 | StopWithLowPowerRegulator, 58 | Standby 59 | }; 60 | 61 | struct CalendarTime 62 | { 63 | uint8_t Year, Month, Day; 64 | uint8_t Hour, Minute, Second; 65 | 66 | bool Advance(uint32_t delta); 67 | }; 68 | 69 | // static constexpr ostime_t CATENA_STM32L0_RTC_BASE_YEAR = 2017; 70 | 71 | CatenaStm32L0Rtc() {}; 72 | bool begin(bool fResetTime = false); 73 | 74 | CalendarTime GetTime(); 75 | 76 | bool SetTime(const CalendarTime *pNow); 77 | 78 | void SetAlarm(uint32_t delta); 79 | 80 | void SetAlarm(const CalendarTime *pNow); 81 | 82 | bool PollAlarmState(void); 83 | 84 | void SleepForAlarm(SleepMode howSleep = SleepMode::SleepWithRegulator); 85 | 86 | uint32_t AdjustMillisForward(uint32_t delta); 87 | 88 | private: 89 | RTC_HandleTypeDef m_hRtc; 90 | volatile uint32_t m_Alarm; 91 | bool m_fAlarmEnabled; 92 | static const uint16_t md[13]; 93 | }; 94 | 95 | } // namespace McciCatena 96 | 97 | #endif /* STM32L0xx */ 98 | 99 | /**** end of CatenaStm32L0Rtc.h ****/ 100 | #endif /* _CATENASTM32L0RTC_H_ */ 101 | -------------------------------------------------------------------------------- /src/lib/samd/catenawingfram2k/CatenaWingFram2k_LoRaWAN_begin.cpp: -------------------------------------------------------------------------------- 1 | /* CatenaWingFram2k_LoRaWAN_begin.cpp Wed Jan 09 2019 14:24:20 chwon */ 2 | 3 | /* 4 | 5 | Module: CatenaWingFram2k_LoRaWAN_begin.cpp 6 | 7 | Function: 8 | CatenaWingFram2k::LoRaWAN::begin() 9 | 10 | Version: 11 | V0.13.0 Wed Jan 09 2019 14:24:20 chwon Edit level 3 12 | 13 | Copyright notice: 14 | This file copyright (C) 2017-2019 by 15 | 16 | MCCI Corporation 17 | 3520 Krums Corners Road 18 | Ithaca, NY 14850 19 | 20 | An unpublished work. All rights reserved. 21 | 22 | This file is proprietary information, and may not be disclosed or 23 | copied without the prior permission of MCCI Corporation. 24 | 25 | Author: 26 | Terry Moore, MCCI Corporation March 2017 27 | 28 | Revision history: 29 | 0.5.0 Sun Mar 12 2017 19:31:15 tmm 30 | Module created. 31 | 32 | 0.12.0 Wed Dec 05 2018 14:27:52 chwon 33 | Call Arduino_LoRaWAN::begin() and use Catena addLoRaWanCommands(). 34 | 35 | 0.13.0 Wed Jan 09 2019 14:24:20 chwon 36 | Need to set up LoRaWan command before call Arduino_LoRaWAN::begin(). 37 | 38 | */ 39 | 40 | #ifdef ARDUINO_ARCH_SAMD 41 | 42 | #include "CatenaWingFram2k.h" 43 | 44 | #include "Catena_Log.h" 45 | #include "mcciadk_baselib.h" 46 | 47 | using namespace McciCatena; 48 | 49 | /* 50 | 51 | Name: CatenaWingFram2k::LoRaWAN::begin() 52 | 53 | Function: 54 | Record linkage to main Catena object and set up LoRaWAN. 55 | 56 | Definition: 57 | bool CatenaWingFram2k::LoRaWAN::begin( 58 | CatenaWingFram2k *pParent 59 | ); 60 | 61 | Description: 62 | We record parent pointers, and other useful things for later. 63 | 64 | Returns: 65 | true for success, false for failure. 66 | 67 | */ 68 | 69 | bool 70 | CatenaWingFram2k::LoRaWAN::begin( 71 | CatenaWingFram2k *pParent 72 | ) 73 | { 74 | gLog.printf(gLog.kTrace, "+CatenaWingFram2k::LoRaWAN::begin()\n"); 75 | 76 | this->m_pCatena = pParent; 77 | this->m_ulDebugMask |= LOG_VERBOSE | LOG_ERRORS | LOG_BASIC; 78 | 79 | /* first set up command processor -- just in case begin() failed */ 80 | pParent->addLoRaWanCommands(); 81 | 82 | /* call the base begin */ 83 | if (! this->Arduino_LoRaWAN::begin()) 84 | { 85 | gLog.printf( 86 | gLog.kError, 87 | "?CatenaWingFram2k::LoRaWAN::begin:" 88 | " Arduino_LoRaWAN:begin failed\n" 89 | ); 90 | return false; 91 | } 92 | 93 | /* indicate success to the client */ 94 | return true; 95 | } 96 | 97 | #endif // ARDUINO_ARCH_SAMD 98 | -------------------------------------------------------------------------------- /src/Catena463x.h: -------------------------------------------------------------------------------- 1 | /* 2 | 3 | Module: Catena463x.h 4 | 5 | Function: 6 | class Catena463x: CatenaBase Platform to represent a Catena 463x 7 | (such as the 4630). 8 | 9 | Copyright notice: 10 | See accompanying LICENSE file. 11 | 12 | Author: 13 | Dhinesh Kumar Pitchai, MCCI Corporation April 2019 14 | 15 | */ 16 | 17 | #ifndef _CATENA463X_H_ /* prevent multiple includes */ 18 | #define _CATENA463X_H_ 19 | 20 | #pragma once 21 | 22 | #ifndef _CATENASTM32L0_H_ 23 | # include "CatenaStm32L0.h" 24 | #endif 25 | 26 | namespace McciCatena { 27 | 28 | class Catena463x : public CatenaStm32L0 29 | { 30 | public: 31 | using Super = CatenaStm32L0; 32 | 33 | // no specific constructor. 34 | Catena463x() {}; 35 | 36 | // uses default destructor 37 | 38 | // neither copyable nor movable 39 | Catena463x(const Catena463x&) = delete; 40 | Catena463x& operator=(const Catena463x&) = delete; 41 | Catena463x(const Catena463x&&) = delete; 42 | Catena463x& operator=(const Catena463x&&) = delete; 43 | 44 | // LoRaWAN binding 45 | class LoRaWAN /* forward */; 46 | 47 | enum ANALOG_PINS 48 | { 49 | APIN_VBAT_SENSE = A1, 50 | APIN_VBUS_SENSE = A2, 51 | }; 52 | 53 | enum ANALOG_CHANNELS 54 | { 55 | ANALOG_CHANNEL_A0 = 0, 56 | ANALOG_CHANNEL_A1 = 5, 57 | ANALOG_CHANNEL_A2 = 4, 58 | ANALOG_CHANNEL_A3 = 3, 59 | ANALOG_CHANNEL_A4 = 2, 60 | ANALOG_CHANNEL_VBAT = ANALOG_CHANNEL_A1, 61 | ANALOG_CHANNEL_VBUS = ANALOG_CHANNEL_A2, 62 | ANALOG_CHANNEL_VREF = 17, 63 | }; 64 | 65 | enum DIGITAL_PINS 66 | { 67 | PIN_STATUS_LED = D13, 68 | PIN_SPI2_FLASH_SS = D19, 69 | PIN_SPI2_MOSI = D23, 70 | PIN_SPI2_MISO = D22, 71 | PIN_SPI2_SCK = D24, 72 | }; 73 | 74 | // methods 75 | virtual bool begin() override; 76 | 77 | protected: 78 | 79 | private: 80 | }; 81 | 82 | /* 83 | || The LoRaWAN class for the Catena 455x. Assumes The Things Network 84 | */ 85 | class Catena463x::LoRaWAN : public CatenaStm32L0::LoRaWAN 86 | { 87 | public: 88 | using Super = CatenaStm32L0::LoRaWAN; 89 | 90 | /* 91 | || the constructor. We don't do anything at this level, the 92 | || Super constructor does most of the work. 93 | */ 94 | LoRaWAN() {}; 95 | 96 | bool begin(Catena463x *pParent); 97 | 98 | protected: 99 | 100 | private: 101 | }; 102 | 103 | } // namespace McciCatena 104 | 105 | /**** end of Catena463x.h ****/ 106 | #endif /* _CATENA463X_H_ */ 107 | -------------------------------------------------------------------------------- /src/lib/stm32/catena461x/Catena4617_getPlatformTable.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | 3 | Module: Catena4617_getPlatformTable.cpp 4 | 5 | Function: 6 | Catena4617::getPlatformTable() 7 | 8 | Copyright notice: 9 | See accompanying LICENSE file. 10 | 11 | Author: 12 | Lakshmi Priya Natarajan, MCCI Corporation June 2019 13 | 14 | Revision history: 15 | See https://github.com/mcci-catena/Catena-Arduino-Platform 16 | 17 | */ 18 | 19 | #ifdef ARDUINO_ARCH_STM32 20 | 21 | #include "Catena4617.h" 22 | 23 | #include "Catena_Log.h" 24 | #include "Catena_Platforms.h" 25 | #include "Catena_Guids.h" 26 | 27 | /****************************************************************************\ 28 | | 29 | | Read-only data. 30 | | 31 | \****************************************************************************/ 32 | 33 | namespace McciCatena { 34 | 35 | const CATENA_PLATFORM gkPlatformCatena4617 = 36 | { 37 | Guid: GUID_HW_CATENA_4617_BASE(WIRE), 38 | pParent: &gkPlatformCatena4617, 39 | PlatformFlags: 40 | CatenaBase::fHasLoRa | 41 | CatenaBase::fHasTtnNycLoRa | 42 | CatenaBase::fHasHS001 | 43 | CatenaBase::fHasLuxSi1133 | 44 | CatenaBase::fHasFRAM | 45 | CatenaBase::fHasFlash 46 | }; 47 | 48 | const CATENA_PLATFORM (* const Catena4617::vPlatforms[]) = 49 | { 50 | // entry 0 is the default 51 | &gkPlatformCatena4617, 52 | }; 53 | 54 | const size_t Catena4617::nvPlatforms = sizeof(Catena4617::vPlatforms) / sizeof(Catena4617::vPlatforms[0]); 55 | 56 | /* 57 | 58 | Name: Catena4617::getPlatformTable() 59 | 60 | Function: 61 | Get the known platform table. 62 | 63 | Definition: 64 | public: virtual 65 | void Catena4617::getPlatformTable( 66 | const CATENA_PLATFORM * const * &vPlatforms, 67 | size_t &nvPlatforms 68 | ) override; 69 | 70 | Description: 71 | This override for getPlatformTable() returns the vector of platform 72 | GUIDs for this Catena. 73 | 74 | Returns: 75 | vPlatforms is set to the base of the array of pointers to platform 76 | stuctures; and nvPlatforms is set to the number of entries in 77 | the table. 78 | 79 | */ 80 | 81 | /* public virtual override */ 82 | void 83 | Catena4617::getPlatformTable( 84 | const CATENA_PLATFORM * const * &result_vPlatforms, 85 | size_t &result_nvPlatforms 86 | ) 87 | { 88 | result_vPlatforms = vPlatforms; 89 | result_nvPlatforms = nvPlatforms; 90 | } 91 | 92 | } /* namespace McciCatena */ 93 | 94 | #endif // ARDUINO_ARCH_STM32 95 | -------------------------------------------------------------------------------- /src/Catena4450.h: -------------------------------------------------------------------------------- 1 | /* Catena4450.h Wed Dec 05 2018 14:22:06 chwon */ 2 | 3 | /* 4 | 5 | Module: Catena4450.h 6 | 7 | Function: 8 | class Catena4450: CatenaBase Platform to represent a Catena 4450 9 | 10 | Version: 11 | V0.12.0 Wed Dec 05 2018 14:22:06 chwon Edit level 4 12 | 13 | Copyright notice: 14 | This file copyright (C) 2017-2018 by 15 | 16 | MCCI Corporation 17 | 3520 Krums Corners Road 18 | Ithaca, NY 14850 19 | 20 | An unpublished work. All rights reserved. 21 | 22 | This file is proprietary information, and may not be disclosed or 23 | copied without the prior permission of MCCI Corporation. 24 | 25 | Author: 26 | Terry Moore, MCCI Corporation March 2017 27 | 28 | Revision history: 29 | 0.5.0 Sun Mar 12 2017 18:16:07 tmm 30 | Module created. 31 | 32 | 0.11.0 Wed Nov 21 2018 13:44:27 chwon 33 | Add CatenaName() method. 34 | 35 | 0.12.0 Wed Dec 05 2018 14:22:06 chwon 36 | Add getCpuIdPlatformTable() method override. 37 | 38 | */ 39 | 40 | #ifndef _CATENA4450_H_ /* prevent multiple includes */ 41 | #define _CATENA4450_H_ 42 | 43 | #pragma once 44 | 45 | #ifndef _CATENAWINGFRAM2K_H_ 46 | # include "CatenaWingFram2k.h" 47 | #endif 48 | 49 | namespace McciCatena { 50 | 51 | class Catena4450 : public CatenaWingFram2k 52 | { 53 | public: 54 | using Super = CatenaWingFram2k; 55 | 56 | // no specific constructor. 57 | Catena4450() {}; 58 | 59 | // uses default destructor 60 | 61 | // neither copyable nor movable 62 | Catena4450(const Catena4450&) = delete; 63 | Catena4450& operator=(const Catena4450&) = delete; 64 | Catena4450(const Catena4450&&) = delete; 65 | Catena4450& operator=(const Catena4450&&) = delete; 66 | 67 | virtual const char *CatenaName() const override { return "Catena 4450"; }; 68 | 69 | protected: 70 | // we are required to provide a table of platforms 71 | virtual void getPlatformTable( 72 | const CATENA_PLATFORM * const * &vPlatforms, 73 | size_t &nvPlatforms 74 | ) override; 75 | 76 | virtual void getCpuIdPlatformTable( 77 | const CPUID_PLATFORM_MAP * &vCpuIdToPlatform, 78 | size_t &nvCpuIdToPlatform 79 | ) override; 80 | 81 | private: 82 | // the known platforms 83 | static const CATENA_PLATFORM (* const vPlatforms[]); 84 | static const size_t nvPlatforms; 85 | 86 | static const CPUID_PLATFORM_MAP vCpuIdToPlatform[]; 87 | static const size_t nvCpuIdToPlatform; 88 | }; 89 | 90 | } /* namespace McciCatena */ 91 | 92 | /**** end of Catena4450.h ****/ 93 | #endif /* _CATENA4450_H_ */ 94 | -------------------------------------------------------------------------------- /TODO.md: -------------------------------------------------------------------------------- 1 | # TO-DO List 2 | 3 | 4 | 5 | - [Useful info](#useful-info) 6 | - [General changes](#general-changes) 7 | - [Possibly-breaking changes](#possibly-breaking-changes) 8 | - [STM32 changes](#stm32-changes) 9 | - [Commands](#commands) 10 | 11 | 12 | 13 | ## Useful info 14 | 15 | - [x] update `keywords.txt`. Used `arduino-keywords` with a filter, as follows: 16 | 17 | ```console 18 | $ pip install arduinokeywords 19 | $ arduino-keywords -o /c/tmp src 20 | $ cat /c/Users/tmm/Documents/Arduino/libraries/MCCI-Catena4410-Arduino-Library/keywords.txt /c/tmp/keywords.txt |\ 21 | sed -e 's/[ \t][ \t]*/\t/g' \ 22 | -e /::/d -e '/^operator=/d' |\ 23 | LC_ALL=C sort >/c/tmp/keywords2.txt -k 1,2 -u 24 | ``` 25 | 26 | ## General changes 27 | 28 | - [ ] Eliminate proprietary notices. (This can be done on an on-going basis, but we ought to do a major pass.) 29 | 30 | - [ ] Expand all tabs. 31 | 32 | - [ ] Rename `McciCatena::CATENA_PLATFORM` to `McciCatena::CatenaBase::PLATFORM`? 33 | 34 | - [ ] Add example apps 35 | 36 | ## Possibly-breaking changes 37 | 38 | - [ ] change 'flags' to be method functions; we want to portably query, but we may need to store different capabilities based on the platform. 39 | 40 | ## STM32 changes 41 | 42 | - [ ] Change the STM32 UniqueID to match CPU (96-bit). The type is defined in a hw-specific header file, so should be OK. 43 | 44 | ## Commands 45 | 46 | 1. Add "system configure" and "lorawan configure" variants that display all the settable paramters. 47 | 48 | 2. Extend help to show the settable paramters 49 | 50 | 3. Add "lorawan reset" which gives us a way to clear out most of the settings 51 | 52 | 4. Add "system configure reset" which keeps the platform guid, syseui, and operating flags but resets everything else. 53 | 54 | 5. Add "lorawan configure DataRate n" to set the data rate 55 | 56 | 6. Change lmic to allow transmit power to be set manually; and add "lorawan configure txpower #" to set the dB. 57 | 58 | 7. Allow enabling of ADR (and test adr) 59 | 60 | 8. add reference to [mcci-catena-provision](https://github.com/mcci-catena/mcci-catena-provision) 61 | 62 | 9. Write a test app that tests the radio at all channels and all drs. 63 | 64 | 10. add command echo option (so can see what you've done) 65 | 66 | 11. If things are configured but join isn't set, don't try to join (bug). 67 | 68 | 12. if appkey is changed, reset nwskey and appskey (and request a join) 69 | 70 | 13. pull out the older Catena code and support for non-FRAM systems. 71 | -------------------------------------------------------------------------------- /src/lib/CatenaBase.cpp: -------------------------------------------------------------------------------- 1 | /* CatenaBase.cpp Wed Dec 05 2018 14:22:45 chwon */ 2 | 3 | /* 4 | 5 | Module: CatenaBase.cpp 6 | 7 | Function: 8 | Implemenation of class CatenaBase; 9 | 10 | Version: 11 | V0.12.0 Wed Dec 05 2018 14:22:45 chwon Edit level 2 12 | 13 | Copyright notice: 14 | This file copyright (C) 2017-2018 by 15 | 16 | MCCI Corporation 17 | 3520 Krums Corners Road 18 | Ithaca, NY 14850 19 | 20 | An unpublished work. All rights reserved. 21 | 22 | This file is proprietary information, and may not be disclosed or 23 | copied without the prior permission of MCCI Corporation. 24 | 25 | Author: 26 | Terry Moore, MCCI Corporation March 2017 27 | 28 | Revision history: 29 | 0.5.0 Sun Mar 19 2017 15:53:34 tmm 30 | Module created. 31 | 32 | 0.12.0 Wed Dec 05 2018 14:22:45 chwon 33 | Move common code from child class. 34 | 35 | */ 36 | 37 | #include "CatenaBase.h" 38 | 39 | #include "Catena_Log.h" 40 | 41 | using namespace McciCatena; 42 | 43 | // the static pointer to the abstract view of the object. 44 | CatenaBase *CatenaBase::pCatenaBase; 45 | 46 | /* the constructor */ 47 | CatenaBase::CatenaBase() 48 | { 49 | pCatenaBase = this; 50 | } 51 | 52 | /* begin operating */ 53 | bool 54 | CatenaBase::begin(void) 55 | { 56 | UniqueID_buffer_t CpuID; 57 | 58 | // use default debug flags 59 | gLog.begin(); 60 | 61 | this->m_PollingEngine.begin(); 62 | 63 | /* get the CPU ID */ 64 | this->GetUniqueID(&CpuID); 65 | this->m_pPlatform = this->GetPlatformForID( 66 | &CpuID, 67 | &this->m_SysEUI, 68 | &this->m_OperatingFlags 69 | ); 70 | 71 | // set up the command line collector 72 | this->m_Collector.begin(&Serial, &this->m_SerialReady); 73 | this->registerObject(&this->m_Collector); 74 | 75 | // set up the command line processor 76 | this->m_CommandStream.begin(&this->m_Collector, this); 77 | 78 | return true; 79 | } 80 | 81 | /* register a pollable object with the polling engine */ 82 | void 83 | CatenaBase::registerObject( 84 | McciCatena::cPollableObject *pObject 85 | ) 86 | { 87 | this->m_PollingEngine.registerObject(pObject); 88 | } 89 | 90 | /* poll all the registered objects */ 91 | void 92 | CatenaBase::poll() 93 | { 94 | this->m_PollingEngine.poll(); 95 | } 96 | 97 | /* add a number of commands to the command table */ 98 | void 99 | CatenaBase::addCommands( 100 | cCommandStream::cDispatch &dispatch, 101 | void *pContext 102 | ) 103 | { 104 | this->m_CommandStream.registerCommands(&dispatch, pContext); 105 | } 106 | -------------------------------------------------------------------------------- /examples/catena_hello_lora/catena_hello_lora.ino: -------------------------------------------------------------------------------- 1 | /* 2 | 3 | Module: catena_hello_lora.ino 4 | 5 | Function: 6 | Simple hello-world (and compile-test) app 7 | 8 | Copyright notice and License: 9 | See LICENSE file accompanying this project. 10 | 11 | Author: 12 | Terry Moore, MCCI Corporation April 2018 13 | 14 | */ 15 | 16 | #include 17 | #include 18 | 19 | using namespace McciCatena; 20 | 21 | // declare the global object for the platform. 22 | Catena gCatena; 23 | Catena::LoRaWAN gLoRaWAN; 24 | 25 | // declare the LED object 26 | StatusLed gLed (Catena::PIN_STATUS_LED); 27 | 28 | // declare the callback function. 29 | Arduino_LoRaWAN::SendBufferCbFn uplinkDone; 30 | 31 | bool gfSuccess; 32 | bool gfTxStarted; 33 | bool gfTxDone; 34 | 35 | uint8_t uplinkBuffer[] = { 0xCA, 0xFE, 0xBA, 0xBE }; 36 | 37 | void setup() 38 | { 39 | gCatena.begin(); 40 | 41 | gCatena.SafePrintf("Hello, world (with LoRa)!\n"); 42 | gCatena.SafePrintf("This is a basic demo program for the MCCI Catena-Arduino-Platform library.\n"); 43 | gCatena.SafePrintf("Enter 'help' for a list of commands.\n"); 44 | gCatena.SafePrintf("(remember to select 'Line Ending: Newline' at the bottom of the monitor window.)\n"); 45 | 46 | gLed.begin(); 47 | gCatena.registerObject(&gLed); 48 | gLed.Set(LedPattern::FastFlash); 49 | 50 | gLoRaWAN.begin(&gCatena); 51 | gCatena.registerObject(&gLoRaWAN); 52 | 53 | if (! gLoRaWAN.IsProvisioned()) 54 | gCatena.SafePrintf("LoRaWAN not provisioned yet. Use the commands to set it up.\n"); 55 | else 56 | { 57 | // send a confirmed uplink 58 | if (gLoRaWAN.SendBuffer(uplinkBuffer, sizeof(uplinkBuffer), uplinkDone, nullptr, true, /* port */ 16)) 59 | gfTxStarted = true; 60 | else 61 | gCatena.SafePrintf("SendBuffer failed!\n"); 62 | } 63 | } 64 | 65 | void loop() 66 | { 67 | gCatena.poll(); 68 | if (gfTxStarted && gfTxDone) 69 | { 70 | gfTxStarted = false; 71 | if (gfSuccess) 72 | gCatena.SafePrintf("Transmit succeeded.\n"); 73 | else 74 | gCatena.SafePrintf("Message uplink failed!\n"); 75 | } 76 | } 77 | 78 | void uplinkDone(void *pCtx, bool fSuccess) 79 | { 80 | gfTxDone = true; 81 | gfSuccess = fSuccess; 82 | } 83 | -------------------------------------------------------------------------------- /src/lib/stm32/catena455x/Catena455x_ReadVoltage.cpp: -------------------------------------------------------------------------------- 1 | /* Catena455x_ReadVoltage.cpp Mon Nov 26 2018 16:18:29 chwon */ 2 | 3 | /* 4 | 5 | Module: Catena455x_ReadVoltage.cpp 6 | 7 | Function: 8 | Catena455x::ReadVbat() and Catena455x::ReadVbus() 9 | 10 | Version: 11 | V0.12.0 Mon Nov 26 2018 16:18:29 chwon Edit level 1 12 | 13 | Copyright notice: 14 | This file copyright (C) 2018 by 15 | 16 | MCCI Corporation 17 | 3520 Krums Corners Road 18 | Ithaca, NY 14850 19 | 20 | An unpublished work. All rights reserved. 21 | 22 | This file is proprietary information, and may not be disclosed or 23 | copied without the prior permission of MCCI Corporation 24 | 25 | Author: 26 | ChaeHee Won, MCCI Corporation November 2018 27 | 28 | Revision history: 29 | 0.12.0 Mon Nov 26 2018 16:18:29 chwon 30 | Module created. 31 | 32 | */ 33 | 34 | #ifdef ARDUINO_ARCH_STM32 35 | 36 | #include "Catena455x.h" 37 | 38 | #include 39 | using namespace McciCatena; 40 | 41 | /****************************************************************************\ 42 | | 43 | | Manifest constants & typedefs. 44 | | 45 | | This is strictly for private types and constants which will not 46 | | be exported. 47 | | 48 | \****************************************************************************/ 49 | 50 | 51 | 52 | /****************************************************************************\ 53 | | 54 | | Read-only data. 55 | | 56 | | If program is to be ROM-able, these must all be tagged read-only 57 | | using the ROM storage class; they may be global. 58 | | 59 | \****************************************************************************/ 60 | 61 | 62 | 63 | /****************************************************************************\ 64 | | 65 | | VARIABLES: 66 | | 67 | | If program is to be ROM-able, these must be initialized 68 | | using the BSS keyword. (This allows for compilers that require 69 | | every variable to have an initializer.) Note that only those 70 | | variables owned by this module should be declared here, using the BSS 71 | | keyword; this allows for linkers that dislike multiple declarations 72 | | of objects. 73 | | 74 | \****************************************************************************/ 75 | 76 | float 77 | Catena455x::ReadVbat(void) const 78 | { 79 | float rawVoltage = analogRead(Catena455x::APIN_VBAT_SENSE); 80 | return rawVoltage * 3.3 / 1024; 81 | } 82 | 83 | float 84 | Catena455x::ReadVbus(void) const 85 | { 86 | float rawVoltage = analogRead(Catena455x::APIN_VBUS_SENSE); 87 | return rawVoltage * 3.3 / 1024; 88 | } 89 | 90 | #endif // ARDUINO_ARCH_STM32 91 | 92 | /**** end of Catena455x_ReadVoltage.cpp ****/ 93 | -------------------------------------------------------------------------------- /src/lib/samd/featherm0/catenafeatherm0_lorawan_getotaaprovisioninginfo.cpp: -------------------------------------------------------------------------------- 1 | /* catenafeatherm0_lorawan_getotaaprovisioninginfo.cpp Mon Dec 5 2016 02:09:31 tmm */ 2 | 3 | /* 4 | 5 | Module: catenafeatherm0_lorawan_getotaaprovisioninginfo.cpp 6 | 7 | Function: 8 | CatenaFeatherM0::LoRaWAN::GetOtaaProvisioningInfo() 9 | 10 | Version: 11 | V0.4.0 Mon Dec 5 2016 02:09:31 tmm Edit level 2 12 | 13 | Copyright notice: 14 | This file copyright (C) 2016 by 15 | 16 | MCCI Corporation 17 | 3520 Krums Corners Road 18 | Ithaca, NY 14850 19 | 20 | An unpublished work. All rights reserved. 21 | 22 | This file is proprietary information, and may not be disclosed or 23 | copied without the prior permission of MCCI Corporation. 24 | 25 | Author: 26 | Terry Moore, MCCI Corporation October 2016 27 | 28 | Revision history: 29 | 0.3.0 Mon Oct 31 2016 18:04:04 tmm 30 | Module created. 31 | 32 | */ 33 | 34 | #ifdef ARDUINO_ARCH_SAMD 35 | 36 | #include 37 | 38 | #include 39 | using namespace McciCatena; 40 | 41 | 42 | /****************************************************************************\ 43 | | 44 | | Manifest constants & typedefs. 45 | | 46 | \****************************************************************************/ 47 | 48 | 49 | /****************************************************************************\ 50 | | 51 | | Read-only data. 52 | | 53 | \****************************************************************************/ 54 | 55 | 56 | /****************************************************************************\ 57 | | 58 | | VARIABLES: 59 | | 60 | \****************************************************************************/ 61 | 62 | 63 | bool 64 | CatenaFeatherM0::LoRaWAN::GetOtaaProvisioningInfo( 65 | CatenaFeatherM0::LoRaWAN::OtaaProvisioningInfo *pInfo 66 | ) 67 | { 68 | CatenaFeatherM0 * const pCatena = this->m_pCatena; 69 | const ProvisioningInfo * const pInstance = pCatena->GetProvisioningInfo(); 70 | 71 | if (! pInstance || 72 | pInstance->Style != ProvisioningStyle::kOTAA) 73 | { 74 | if (pInfo) 75 | { 76 | // ensure consistent behavior 77 | memset(pInfo, 0, sizeof(*pInfo)); 78 | } 79 | 80 | return false; 81 | } 82 | 83 | // got instance data 84 | if (pInfo) 85 | { 86 | *pInfo = pInstance->OtaaInfo; 87 | } 88 | 89 | return true; 90 | } 91 | 92 | #endif // ARDUINO_ARCH_SAMD 93 | -------------------------------------------------------------------------------- /src/lib/stm32/catena480x/Catena480x_ReadVoltage.cpp: -------------------------------------------------------------------------------- 1 | /* Catena480x_ReadVoltage.cpp Wed Jan 16 2019 10:40:07 chwon */ 2 | 3 | /* 4 | 5 | Module: Catena480x_ReadVoltage.cpp 6 | 7 | Function: 8 | Catena480x::ReadVbat() and Catena480x::ReadVbus() 9 | 10 | Version: 11 | V0.13.0 Wed Jan 16 2019 10:40:07 chwon Edit level 2 12 | 13 | Copyright notice: 14 | This file copyright (C) 2018-2019 by 15 | 16 | MCCI Corporation 17 | 3520 Krums Corners Road 18 | Ithaca, NY 14850 19 | 20 | An unpublished work. All rights reserved. 21 | 22 | This file is proprietary information, and may not be disclosed or 23 | copied without the prior permission of MCCI Corporation 24 | 25 | Author: 26 | ChaeHee Won, MCCI Corporation November 2018 27 | 28 | Revision history: 29 | 0.12.0 Mon Nov 26 2018 16:18:29 chwon 30 | Module created. 31 | 32 | 0.13.0 Wed Jan 16 2019 10:40:07 chwon 33 | Use CatenaStm32L0::ReadAnalog() method. 34 | 35 | */ 36 | 37 | #ifdef ARDUINO_ARCH_STM32 38 | 39 | #include "Catena480x.h" 40 | 41 | #include 42 | using namespace McciCatena; 43 | 44 | /****************************************************************************\ 45 | | 46 | | Manifest constants & typedefs. 47 | | 48 | | This is strictly for private types and constants which will not 49 | | be exported. 50 | | 51 | \****************************************************************************/ 52 | 53 | 54 | 55 | /****************************************************************************\ 56 | | 57 | | Read-only data. 58 | | 59 | | If program is to be ROM-able, these must all be tagged read-only 60 | | using the ROM storage class; they may be global. 61 | | 62 | \****************************************************************************/ 63 | 64 | 65 | 66 | /****************************************************************************\ 67 | | 68 | | VARIABLES: 69 | | 70 | | If program is to be ROM-able, these must be initialized 71 | | using the BSS keyword. (This allows for compilers that require 72 | | every variable to have an initializer.) Note that only those 73 | | variables owned by this module should be declared here, using the BSS 74 | | keyword; this allows for linkers that dislike multiple declarations 75 | | of objects. 76 | | 77 | \****************************************************************************/ 78 | 79 | float 80 | Catena480x::ReadVbat(void) const 81 | { 82 | float volt = this->ReadAnalog(Catena480x::ANALOG_CHANNEL_VBAT, 1, 1); 83 | return volt / 1000; 84 | } 85 | 86 | float 87 | Catena480x::ReadVbus(void) const 88 | { 89 | return 0.0; 90 | } 91 | 92 | #endif // ARDUINO_ARCH_STM32 93 | 94 | /**** end of Catena480x_ReadVoltage.cpp ****/ 95 | -------------------------------------------------------------------------------- /src/lib/samd/catenasamd21_getuniqueid.cpp: -------------------------------------------------------------------------------- 1 | /* GetUniqueID.cpp Tue Oct 25 2016 02:20:03 tmm */ 2 | 3 | /* 4 | 5 | Module: GetUniqueID.cpp 6 | 7 | Function: 8 | Catena4410::GetUniqueID() 9 | 10 | Version: 11 | V0.1.0 Tue Oct 25 2016 02:20:03 tmm Edit level 2 12 | 13 | Copyright notice: 14 | This file copyright (C) 2016 by 15 | 16 | MCCI Corporation 17 | 3520 Krums Corners Road 18 | Ithaca, NY 14850 19 | 20 | An unpublished work. All rights reserved. 21 | 22 | This file is proprietary information, and may not be disclosed or 23 | copied without the prior permission of MCCI Corporation. 24 | 25 | Author: 26 | Terry Moore, MCCI Corporation October 2016 27 | 28 | Revision history: 29 | 0.1.0 Sat Oct 15 2016 22:35:27 tmm 30 | Module created. 31 | 32 | */ 33 | 34 | #ifdef ARDUINO_ARCH_SAMD 35 | 36 | #include 37 | using namespace McciCatena; 38 | 39 | /****************************************************************************\ 40 | | 41 | | Manifest constants & typedefs. 42 | | 43 | | This is strictly for private types and constants which will not 44 | | be exported. 45 | | 46 | \****************************************************************************/ 47 | 48 | 49 | 50 | /****************************************************************************\ 51 | | 52 | | Read-only data. 53 | | 54 | | If program is to be ROM-able, these must all be tagged read-only 55 | | using the ROM storage class; they may be global. 56 | | 57 | \****************************************************************************/ 58 | 59 | 60 | 61 | /****************************************************************************\ 62 | | 63 | | VARIABLES: 64 | | 65 | | If program is to be ROM-able, these must be initialized 66 | | using the BSS keyword. (This allows for compilers that require 67 | | every variable to have an initializer.) Note that only those 68 | | variables owned by this module should be declared here, using the BSS 69 | | keyword; this allows for linkers that dislike multiple declarations 70 | | of objects. 71 | | 72 | \****************************************************************************/ 73 | 74 | void CatenaSamd21::GetUniqueID( 75 | UniqueID_buffer_t *pIdBuffer 76 | ) 77 | { 78 | uint32_t const idWords[4] = { 0x80A00C, 0x80A040, 0x80A044, 0x80A048 }; 79 | uint8_t *p; 80 | 81 | p = pIdBuffer->b; 82 | for (unsigned i = 0; i < sizeof(idWords) / sizeof(idWords[0]); ++i) 83 | { 84 | uint32_t const * const pWord = (uint32_t *) idWords[i]; 85 | uint32_t idWord = *pWord; 86 | 87 | for (unsigned j = 0; j < 4; ++j) 88 | { 89 | *p++ = (uint8_t) idWord; 90 | idWord >>= 8; 91 | } 92 | } 93 | } 94 | 95 | #endif // ARDUINO_ARCH_SAMD 96 | -------------------------------------------------------------------------------- /src/lib/CatenaBase_SafePrintf.cpp: -------------------------------------------------------------------------------- 1 | /* CatenaBase_SafePrintf.cpp Wed Dec 06 2017 19:01:23 tmm */ 2 | 3 | /* 4 | 5 | Module: CatenaBase_SafePrintf.cpp 6 | 7 | Function: 8 | CatenaBase::SafePrintf() 9 | 10 | Version: 11 | V0.7.0 Wed Dec 06 2017 19:01:23 tmm Edit level 3 12 | 13 | Copyright notice: 14 | This file copyright (C) 2016-2017 by 15 | 16 | MCCI Corporation 17 | 3520 Krums Corners Road 18 | Ithaca, NY 14850 19 | 20 | An unpublished work. All rights reserved. 21 | 22 | This file is proprietary information, and may not be disclosed or 23 | copied without the prior permission of MCCI Corporation. 24 | 25 | Author: 26 | Terry Moore, MCCI Corporation October 2016 27 | 28 | Revision history: 29 | 0.1.0 Sat Oct 15 2016 22:38:20 tmm 30 | Module created. 31 | 32 | 0.7.0 Wed Dec 06 2017 19:01:23 tmm 33 | Rename file as part of refactoring. 34 | 35 | */ 36 | 37 | #include "CatenaBase.h" 38 | 39 | #include 40 | #include 41 | using namespace McciCatena; 42 | 43 | 44 | /****************************************************************************\ 45 | | 46 | | Manifest constants & typedefs. 47 | | 48 | | This is strictly for private types and constants which will not 49 | | be exported. 50 | | 51 | \****************************************************************************/ 52 | 53 | 54 | 55 | /****************************************************************************\ 56 | | 57 | | Read-only data. 58 | | 59 | | If program is to be ROM-able, these must all be tagged read-only 60 | | using the ROM storage class; they may be global. 61 | | 62 | \****************************************************************************/ 63 | 64 | 65 | 66 | /****************************************************************************\ 67 | | 68 | | VARIABLES: 69 | | 70 | | If program is to be ROM-able, these must be initialized 71 | | using the BSS keyword. (This allows for compilers that require 72 | | every variable to have an initializer.) Note that only those 73 | | variables owned by this module should be declared here, using the BSS 74 | | keyword; this allows for linkers that dislike multiple declarations 75 | | of objects. 76 | | 77 | \****************************************************************************/ 78 | 79 | 80 | void 81 | CatenaBase::SafePrintf( 82 | const char *fmt, 83 | ... 84 | ) 85 | { 86 | if (! Serial.dtr()) 87 | return; 88 | 89 | char buf[128]; 90 | va_list ap; 91 | 92 | va_start(ap, fmt); 93 | (void) vsnprintf(buf, sizeof(buf) - 1, fmt, ap); 94 | va_end(ap); 95 | 96 | // in case we overflowed: 97 | buf[sizeof(buf) - 1] = '\0'; 98 | if (Serial.dtr()) Serial.print(buf); 99 | } 100 | -------------------------------------------------------------------------------- /src/lib/stm32/catena480x/Catena4801_getPlatformTable.cpp: -------------------------------------------------------------------------------- 1 | /* Catena4801_getPlatformTable.cpp Mon Nov 26 2018 17:27:02 chwon */ 2 | 3 | /* 4 | 5 | Module: Catena4801_getPlatformTable.cpp 6 | 7 | Function: 8 | Catena4801::getPlatformTable() 9 | 10 | Version: 11 | V0.12.0 Mon Nov 26 2018 17:27:02 chwon Edit level 1 12 | 13 | Copyright notice: 14 | This file copyright (C) 2018 by 15 | 16 | MCCI Corporation 17 | 3520 Krums Corners Road 18 | Ithaca, NY 14850 19 | 20 | An unpublished work. All rights reserved. 21 | 22 | This file is proprietary information, and may not be disclosed or 23 | copied without the prior permission of MCCI Corporation 24 | 25 | Author: 26 | ChaeHee Won, MCCI Corporation November 2018 27 | 28 | Revision history: 29 | 0.12.0 Mon Nov 26 2018 17:27:02 chwon 30 | Module created. 31 | 32 | */ 33 | 34 | #ifdef ARDUINO_ARCH_STM32 35 | 36 | #include "Catena4801.h" 37 | 38 | #include "Catena_Log.h" 39 | #include "Catena_Platforms.h" 40 | #include "Catena_Guids.h" 41 | 42 | namespace McciCatena { 43 | 44 | const CATENA_PLATFORM gkPlatformCatena4801 = 45 | { 46 | Guid: GUID_HW_CATENA_4801_BASE(WIRE), 47 | pParent: &gkPlatformCatena4801, 48 | PlatformFlags: 49 | CatenaBase::fHasLoRa | 50 | CatenaBase::fHasTtnNycLoRa | 51 | CatenaBase::fHasFRAM | 52 | CatenaBase::fHasFlash | 53 | CatenaBase::fHasRS485 54 | }; 55 | 56 | const CATENA_PLATFORM (* const Catena4801::vPlatforms[]) = 57 | { 58 | // entry 0 is the default 59 | &gkPlatformCatena4801, 60 | }; 61 | 62 | const size_t Catena4801::nvPlatforms = sizeof(Catena4801::vPlatforms) / sizeof(Catena4801::vPlatforms[0]); 63 | 64 | /* 65 | 66 | Name: Catena4801::getPlatformTable() 67 | 68 | Function: 69 | Get the known platform table. 70 | 71 | Definition: 72 | public: virtual 73 | void Catena4801::getPlatformTable( 74 | const CATENA_PLATFORM * const * &vPlatforms, 75 | size_t &nvPlatforms 76 | ) override; 77 | 78 | Description: 79 | This override for getPlatformTable() returns the vector of platform 80 | GUIDs for this Catena. 81 | 82 | Returns: 83 | vPlatforms is set to the base of the array of pointers to platform 84 | stuctures; and nvPlatforms is set to the number of entries in 85 | the table. 86 | 87 | */ 88 | 89 | /* public virtual override */ 90 | void 91 | Catena4801::getPlatformTable( 92 | const CATENA_PLATFORM * const * &result_vPlatforms, 93 | size_t &result_nvPlatforms 94 | ) 95 | { 96 | result_vPlatforms = vPlatforms; 97 | result_nvPlatforms = nvPlatforms; 98 | } 99 | 100 | } /* namespace McciCatena */ 101 | 102 | #endif // ARDUINO_ARCH_STM32 103 | -------------------------------------------------------------------------------- /src/CatenaSamd21.h: -------------------------------------------------------------------------------- 1 | /* CatenaSamd21.h Wed Dec 05 2018 14:07:26 chwon */ 2 | 3 | /* 4 | 5 | Module: CatenaSamd21.h 6 | 7 | Function: 8 | class CatenaSamd21 9 | 10 | Version: 11 | V0.12.0 Wed Dec 05 2018 14:07:26 chwon Edit level 6 12 | 13 | Copyright notice: 14 | This file copyright (C) 2016-2018 by 15 | 16 | MCCI Corporation 17 | 3520 Krums Corners Road 18 | Ithaca, NY 14850 19 | 20 | An unpublished work. All rights reserved. 21 | 22 | This file is proprietary information, and may not be disclosed or 23 | copied without the prior permission of MCCI Corporation. 24 | 25 | Author: 26 | Terry Moore, MCCI Corporation October 2016 27 | 28 | Revision history: 29 | 0.1.0 Tue Oct 25 2016 02:00:28 tmm 30 | Module created. 31 | 32 | 0.3.0 Thu Oct 27 2016 22:53:12 tmm 33 | Eliminate array types. 34 | 35 | 0.4.0 Wed Mar 8 2017 17:29:54 tmm 36 | Add flags for new well-known sensors and mod-number provisions. 37 | 38 | 0.5.0 Sun Mar 19 2017 15:49:23 tmm 39 | Refactor to add support for USB command-line processing. 40 | 41 | 0.11.0 Wed Nov 21 2018 13:32:28 chwon 42 | Add Sleep() method and add CatenaRTC class. 43 | 44 | 0.12.0 Wed Dec 05 2018 14:07:26 chwon 45 | Move UniqueuID and CPUID_PLATFORM_MAP structure and related methods to 46 | CatenaBase class. 47 | 48 | */ 49 | 50 | #ifndef _CATENASAMD21_H_ /* prevent multiple includes */ 51 | #define _CATENASAMD21_H_ 52 | 53 | #pragma once 54 | 55 | #ifndef _CATENABASE_H_ 56 | # include "CatenaBase.h" 57 | #endif 58 | 59 | #ifndef _CATENARTC_H_ 60 | # include "CatenaRTC.h" 61 | #endif 62 | 63 | namespace McciCatena { 64 | 65 | /* the class for Samd21-based Catenas */ 66 | class CatenaSamd21 : public CatenaBase 67 | { 68 | public: 69 | using Super = CatenaBase; 70 | 71 | /* 72 | || Methods 73 | */ 74 | 75 | // start the Samd21 level 76 | virtual bool begin(void); 77 | bool begin(uint32_t uOverrideMask); 78 | bool begin(uint32_t uClearMask, uint32_t uSetMask); 79 | 80 | virtual void GetUniqueID( 81 | UniqueID_buffer_t *pIdBuffer 82 | ) override; 83 | 84 | virtual void Sleep(uint32_t howLongInSeconds) override; 85 | 86 | CatenaRTC::CalendarTime GetCalendarTime(void) 87 | { 88 | return this->m_Rtc.GetTime(); 89 | } 90 | 91 | bool SetCalendarTime(const CatenaRTC::CalendarTime &calendarTime) 92 | { 93 | return this->m_Rtc.SetTime(&calendarTime); 94 | } 95 | 96 | protected: 97 | virtual void registerCommands(void); 98 | 99 | /* 100 | || Class-level information 101 | */ 102 | private: 103 | CatenaRTC m_Rtc; 104 | }; 105 | 106 | } /* namespace McciCatena */ 107 | 108 | /**** end of CatenaSamd21.h ****/ 109 | #endif /* _CATENASAMD21_H_ */ 110 | -------------------------------------------------------------------------------- /src/lib/samd/CatenaSamd21_registerCommands.cpp: -------------------------------------------------------------------------------- 1 | /* CatenaSamd21_registerCommands.cpp Sun Mar 19 2017 14:53:33 tmm */ 2 | 3 | /* 4 | 5 | Module: CatenaSamd21_registerCommands.cpp 6 | 7 | Function: 8 | CatenaSamd21::registerCommands() 9 | 10 | Version: 11 | V0.5.0 Sun Mar 19 2017 14:53:33 tmm Edit level 1 12 | 13 | Copyright notice: 14 | This file copyright (C) 2017 by 15 | 16 | MCCI Corporation 17 | 3520 Krums Corners Road 18 | Ithaca, NY 14850 19 | 20 | An unpublished work. All rights reserved. 21 | 22 | This file is proprietary information, and may not be disclosed or 23 | copied without the prior permission of MCCI Corporation. 24 | 25 | Author: 26 | Terry Moore, MCCI Corporation March 2017 27 | 28 | Revision history: 29 | 0.5.0 Sun Mar 19 2017 14:53:33 tmm 30 | Module created. 31 | 32 | */ 33 | 34 | #ifdef ARDUINO_ARCH_SAMD 35 | 36 | #include "CatenaSamd21.h" 37 | 38 | #include "Catena_CommandStream.h" 39 | 40 | using namespace McciCatena; 41 | 42 | /****************************************************************************\ 43 | | 44 | | Manifest constants 45 | | 46 | \****************************************************************************/ 47 | 48 | static cCommandStream::CommandFn doCpuid; 49 | 50 | /****************************************************************************\ 51 | | 52 | | The command tables 53 | | 54 | \****************************************************************************/ 55 | 56 | static const cCommandStream::cEntry sDefaultEntries[] = 57 | { 58 | { "cpuid", doCpuid }, 59 | }; 60 | 61 | static cCommandStream::cDispatch 62 | sDispatch(sDefaultEntries, sizeof(sDefaultEntries)); 63 | 64 | /****************************************************************************\ 65 | | 66 | | The method function 67 | | 68 | \****************************************************************************/ 69 | 70 | /* protected virtual */ 71 | void 72 | CatenaSamd21::registerCommands() 73 | { 74 | this->Super::registerCommands(); 75 | 76 | this->addCommands(sDispatch, (void *) this); 77 | } 78 | 79 | /****************************************************************************\ 80 | | 81 | | The commands 82 | | 83 | \****************************************************************************/ 84 | 85 | static cCommandStream::CommandStatus 86 | doCpuid( 87 | cCommandStream *pThis, 88 | void *pContext, 89 | int argc, 90 | char **argv 91 | ) 92 | { 93 | CatenaSamd21 * const pCatena = static_cast(pContext); 94 | 95 | CatenaSamd21::UniqueID_string_t CpuIDstring; 96 | 97 | pThis->printf("%s\n", pCatena->GetUniqueIDstring(&CpuIDstring)); 98 | return pThis->kSuccess; 99 | } 100 | 101 | #endif // ARDUINO_ARCH_SAMD 102 | -------------------------------------------------------------------------------- /src/lib/stm32/CatenaStm32_registerCommands.cpp: -------------------------------------------------------------------------------- 1 | /* CatenaStm32_registerCommands.cpp Fri Oct 13 2017 15:19:30 chwon */ 2 | 3 | /* 4 | 5 | Module: CatenaStm32_registerCommands.cpp 6 | 7 | Function: 8 | CatenaStm32::registerCommands() 9 | 10 | Version: 11 | V0.5.0 Fri Oct 13 2017 15:19:30 chwon Edit level 1 12 | 13 | Copyright notice: 14 | This file copyright (C) 2017 by 15 | 16 | MCCI Corporation 17 | 3520 Krums Corners Road 18 | Ithaca, NY 14850 19 | 20 | An unpublished work. All rights reserved. 21 | 22 | This file is proprietary information, and may not be disclosed or 23 | copied without the prior permission of MCCI Corporation. 24 | 25 | Author: 26 | ChaeHee Won, MCCI Corporation October 2017 27 | 28 | Revision history: 29 | 0.5.0 Fri Oct 13 2017 15:19:30 chwon 30 | Module created. 31 | 32 | */ 33 | 34 | #ifdef ARDUINO_ARCH_STM32 35 | 36 | #include "CatenaStm32.h" 37 | 38 | #include "Catena_CommandStream.h" 39 | 40 | using namespace McciCatena; 41 | 42 | /****************************************************************************\ 43 | | 44 | | Manifest constants 45 | | 46 | \****************************************************************************/ 47 | 48 | static cCommandStream::CommandFn doCpuid; 49 | 50 | /****************************************************************************\ 51 | | 52 | | The command tables 53 | | 54 | \****************************************************************************/ 55 | 56 | static const cCommandStream::cEntry sDefaultEntries[] = 57 | { 58 | { "cpuid", doCpuid }, 59 | }; 60 | 61 | static cCommandStream::cDispatch 62 | sDispatch(sDefaultEntries, sizeof(sDefaultEntries)); 63 | 64 | /****************************************************************************\ 65 | | 66 | | The method function 67 | | 68 | \****************************************************************************/ 69 | 70 | /* protected virtual */ 71 | void 72 | CatenaStm32::registerCommands() 73 | { 74 | this->Super::registerCommands(); 75 | 76 | this->addCommands(sDispatch, (void *) this); 77 | } 78 | 79 | /****************************************************************************\ 80 | | 81 | | The commands 82 | | 83 | \****************************************************************************/ 84 | 85 | static cCommandStream::CommandStatus 86 | doCpuid( 87 | cCommandStream *pThis, 88 | void *pContext, 89 | int argc, 90 | char **argv 91 | ) 92 | { 93 | CatenaStm32 * const pCatena = static_cast(pContext); 94 | 95 | CatenaStm32::UniqueID_string_t CpuIDstring; 96 | 97 | pThis->printf("%s\n", pCatena->GetUniqueIDstring(&CpuIDstring)); 98 | return pThis->kSuccess; 99 | } 100 | 101 | #endif // ARDUINO_ARCH_STM32 102 | -------------------------------------------------------------------------------- /src/Catena455x.h: -------------------------------------------------------------------------------- 1 | /* Catena455x.h Mon Nov 26 2018 15:49:24 chwon */ 2 | 3 | /* 4 | 5 | Module: Catena455x.h 6 | 7 | Function: 8 | class Catena455x: CatenaBase Platform to represent a Catena 455x 9 | (4550, 4551, etc.) 10 | 11 | Version: 12 | V0.12.0 Mon Nov 26 2018 15:49:24 chwon Edit level 2 13 | 14 | Copyright notice: 15 | This file copyright (C) 2017-2018 by 16 | 17 | MCCI Corporation 18 | 3520 Krums Corners Road 19 | Ithaca, NY 14850 20 | 21 | An unpublished work. All rights reserved. 22 | 23 | This file is proprietary information, and may not be disclosed or 24 | copied without the prior permission of MCCI Corporation. 25 | 26 | Author: 27 | ChaeHee Won, MCCI Corporation October 2017 28 | 29 | Revision history: 30 | 0.6.0 Fri Oct 13 2017 15:19:30 chwon 31 | Module created. 32 | 33 | 0.12.0 Mon Nov 26 2018 15:49:24 chwon 34 | Change from CatenaStm32L0LoRa to CatenaStm32L0 class. 35 | 36 | */ 37 | 38 | #ifndef _CATENA455X_H_ /* prevent multiple includes */ 39 | #define _CATENA455X_H_ 40 | 41 | #pragma once 42 | 43 | #ifndef _CATENASTM32L0_H_ 44 | # include "CatenaStm32L0.h" 45 | #endif 46 | 47 | namespace McciCatena { 48 | 49 | class Catena455x : public CatenaStm32L0 50 | { 51 | public: 52 | using Super = CatenaStm32L0; 53 | 54 | // no specific constructor. 55 | Catena455x() {}; 56 | 57 | // uses default destructor 58 | 59 | // neither copyable nor movable 60 | Catena455x(const Catena455x&) = delete; 61 | Catena455x& operator=(const Catena455x&) = delete; 62 | Catena455x(const Catena455x&&) = delete; 63 | Catena455x& operator=(const Catena455x&&) = delete; 64 | 65 | // LoRaWAN binding 66 | class LoRaWAN /* forward */; 67 | 68 | enum ANALOG_PINS 69 | { 70 | APIN_VBAT_SENSE = A3, 71 | APIN_VBUS_SENSE = A4, 72 | }; 73 | 74 | enum DIGITAL_PINS 75 | { 76 | PIN_STATUS_LED = D13, 77 | PIN_SPI2_FLASH_SS = D19, 78 | PIN_SPI2_MOSI = D23, 79 | PIN_SPI2_MISO = D22, 80 | PIN_SPI2_SCK = D24, 81 | }; 82 | 83 | // methods 84 | virtual bool begin() override; 85 | virtual float ReadVbat(void) const override; 86 | virtual float ReadVbus(void) const override; 87 | 88 | protected: 89 | 90 | private: 91 | }; 92 | 93 | /* 94 | || The LoRaWAN class for the Catena 455x. Assumes The Things Network 95 | */ 96 | class Catena455x::LoRaWAN : public CatenaStm32L0::LoRaWAN 97 | { 98 | public: 99 | using Super = CatenaStm32L0::LoRaWAN; 100 | 101 | /* 102 | || the constructor. We don't do anything at this level, the 103 | || Super constructor does most of the work. 104 | */ 105 | LoRaWAN() {}; 106 | 107 | bool begin(Catena455x *pParent); 108 | 109 | protected: 110 | 111 | private: 112 | }; 113 | 114 | } // namespace McciCatena 115 | 116 | /**** end of Catena455x.h ****/ 117 | #endif /* _CATENA455X_H_ */ 118 | -------------------------------------------------------------------------------- /src/lib/stm32/CatenaStm32_GetUniqueID.cpp: -------------------------------------------------------------------------------- 1 | /* GetUniqueID.cpp Tue Oct 25 2016 02:20:03 tmm */ 2 | 3 | /* 4 | 5 | Module: GetUniqueID.cpp 6 | 7 | Function: 8 | Catena4410::GetUniqueID() 9 | 10 | Version: 11 | V0.1.0 Tue Oct 25 2016 02:20:03 tmm Edit level 2 12 | 13 | Copyright notice: 14 | This file copyright (C) 2016 by 15 | 16 | MCCI Corporation 17 | 3520 Krums Corners Road 18 | Ithaca, NY 14850 19 | 20 | An unpublished work. All rights reserved. 21 | 22 | This file is proprietary information, and may not be disclosed or 23 | copied without the prior permission of MCCI Corporation. 24 | 25 | Author: 26 | Terry Moore, MCCI Corporation October 2016 27 | 28 | Revision history: 29 | 0.1.0 Sat Oct 15 2016 22:35:27 tmm 30 | Module created. 31 | 32 | */ 33 | 34 | #ifdef ARDUINO_ARCH_STM32 35 | 36 | #include 37 | #include 38 | using namespace McciCatena; 39 | 40 | /****************************************************************************\ 41 | | 42 | | Manifest constants & typedefs. 43 | | 44 | | This is strictly for private types and constants which will not 45 | | be exported. 46 | | 47 | \****************************************************************************/ 48 | 49 | 50 | 51 | /****************************************************************************\ 52 | | 53 | | Read-only data. 54 | | 55 | | If program is to be ROM-able, these must all be tagged read-only 56 | | using the ROM storage class; they may be global. 57 | | 58 | \****************************************************************************/ 59 | 60 | 61 | 62 | /****************************************************************************\ 63 | | 64 | | VARIABLES: 65 | | 66 | | If program is to be ROM-able, these must be initialized 67 | | using the BSS keyword. (This allows for compilers that require 68 | | every variable to have an initializer.) Note that only those 69 | | variables owned by this module should be declared here, using the BSS 70 | | keyword; this allows for linkers that dislike multiple declarations 71 | | of objects. 72 | | 73 | \****************************************************************************/ 74 | 75 | void CatenaStm32::GetUniqueID( 76 | UniqueID_buffer_t *pIdBuffer 77 | ) 78 | { 79 | uint32_t idWords[4]; 80 | uint8_t *p; 81 | 82 | idWords[0] = HAL_GetDEVID() << 16 | HAL_GetREVID(); 83 | idWords[1] = LL_GetUID_Word0(); 84 | idWords[2] = LL_GetUID_Word1(); 85 | idWords[3] = LL_GetUID_Word2(); 86 | p = pIdBuffer->b; 87 | for (unsigned i = 0; i < sizeof(idWords) / sizeof(idWords[0]); ++i) 88 | { 89 | uint32_t idWord = idWords[i]; 90 | 91 | for (unsigned j = 0; j < 4; ++j) 92 | { 93 | *p++ = (uint8_t) idWord; 94 | idWord >>= 8; 95 | } 96 | } 97 | } 98 | 99 | #endif // ARDUINO_ARCH_STM32 100 | -------------------------------------------------------------------------------- /src/lib/CatenaBase_NetSave.cpp: -------------------------------------------------------------------------------- 1 | /* CatenaBase_NetSave.cpp Mon Dec 03 2018 13:21:28 chwon */ 2 | 3 | /* 4 | 5 | Module: CatenaBase_NetSave.cpp 6 | 7 | Function: 8 | Interface from LoRaWAN to FRAM. 9 | 10 | Version: 11 | V0.12.0 Mon Dec 03 2018 13:21:28 chwon Edit level 1 12 | 13 | Copyright notice: 14 | This file copyright (C) 2018 by 15 | 16 | MCCI Corporation 17 | 3520 Krums Corners Road 18 | Ithaca, NY 14850 19 | 20 | An unpublished work. All rights reserved. 21 | 22 | This file is proprietary information, and may not be disclosed or 23 | copied without the prior permission of MCCI Corporation 24 | 25 | Author: 26 | ChaeHee Won, MCCI Corporation December 2018 27 | 28 | Revision history: 29 | 0.12.0 Mon Dec 03 2018 13:21:28 chwon 30 | Module created. 31 | 32 | */ 33 | 34 | #include 35 | 36 | #include 37 | #include 38 | 39 | using namespace McciCatena; 40 | 41 | void 42 | CatenaBase::NetSaveSessionInfo( 43 | const Arduino_LoRaWAN::SessionInfo &Info, 44 | const uint8_t *pExtraInfo, 45 | size_t nExtraInfo 46 | ) 47 | { 48 | auto const pFram = this->getFram(); 49 | 50 | // note that the v1 header and the V2 header are identical in the 51 | // bytes belwow. 52 | if (pFram != nullptr && (Info.Header.Tag == Arduino_LoRaWAN::kSessionInfoTag_V1 || 53 | Info.Header.Tag == Arduino_LoRaWAN::kSessionInfoTag_V2)) 54 | { 55 | pFram->saveField(cFramStorage::kNetID, Info.V1.NetID); 56 | pFram->saveField(cFramStorage::kDevAddr, Info.V1.DevAddr); 57 | pFram->saveField(cFramStorage::kNwkSKey, Info.V1.NwkSKey); 58 | pFram->saveField(cFramStorage::kAppSKey, Info.V1.AppSKey); 59 | if (Info.Header.Tag == Arduino_LoRaWAN::kSessionInfoTag_V1) 60 | { 61 | pFram->saveField(cFramStorage::kFCntUp, Info.V1.FCntUp); 62 | pFram->saveField(cFramStorage::kFCntDown, Info.V1.FCntDown); 63 | } 64 | } 65 | 66 | gLog.printf( 67 | gLog.kInfo, 68 | "NwkID: %08x " 69 | "DevAddr: %08x\n", 70 | Info.V1.NetID, 71 | Info.V1.DevAddr 72 | ); 73 | } 74 | 75 | void 76 | CatenaBase::NetSaveSessionState( 77 | const Arduino_LoRaWAN::SessionState &State 78 | ) 79 | { 80 | auto const pFram = this->getFram(); 81 | 82 | // note that the v1 header and the V2 header are identical in the 83 | // bytes belwow. 84 | if (pFram != nullptr && (State.Header.Tag == Arduino_LoRaWAN::kSessionStateTag_V1)) 85 | { 86 | pFram->saveField(cFramStorage::kLmicSessionState, State); 87 | } 88 | } 89 | 90 | bool 91 | CatenaBase::NetGetSessionState( 92 | Arduino_LoRaWAN::SessionState &State 93 | ) 94 | { 95 | auto const pFram = this->getFram(); 96 | 97 | if (pFram == nullptr) 98 | return false; 99 | 100 | return pFram->getField(cFramStorage::kLmicSessionState, State); 101 | } 102 | 103 | /**** end of CatenaBase_NetSave.cpp ****/ 104 | -------------------------------------------------------------------------------- /src/CatenaRTC.h: -------------------------------------------------------------------------------- 1 | /* CatenaRTC.h Mon Nov 26 2018 15:01:32 chwon */ 2 | 3 | /* 4 | 5 | Module: CatenaRTC.h 6 | 7 | Function: 8 | RTC wrapper for Catena 9 | 10 | Version: 11 | V0.12.0 Mon Nov 26 2018 15:01:32 chwon Edit level 3 12 | 13 | Copyright notice: 14 | This file copyright (C) 2016, 2018 by 15 | 16 | MCCI Corporation 17 | 3520 Krums Corners Road 18 | Ithaca, NY 14850 19 | 20 | An unpublished work. All rights reserved. 21 | 22 | This file is proprietary information, and may not be disclosed or 23 | copied without the prior permission of MCCI Corporation. 24 | 25 | Author: 26 | Terry Moore, MCCI Corporation November 2016 27 | 28 | Revision history: 29 | 0.3.0 Tue Nov 1 2016 22:56:04 tmm 30 | Module created. 31 | 32 | 0.11.0 Mon Nov 19 2018 12:08:48 chwon 33 | Remove include CatenaSamd21.h. 34 | 35 | 0.12.0 Mon Nov 26 2018 15:01:32 chwon 36 | Remove RTCZero library. 37 | 38 | */ 39 | 40 | #ifndef _CATENARTC_H_ /* prevent multiple includes */ 41 | #define _CATENARTC_H_ 42 | 43 | #include 44 | 45 | /* the class for real-time calculations */ 46 | namespace McciCatena { 47 | 48 | class CatenaRTC 49 | { 50 | public: 51 | enum Alarm_Match: uint8_t 52 | { 53 | MATCH_OFF = RTC_MODE2_MASK_SEL_OFF_Val, // Never 54 | MATCH_SS = RTC_MODE2_MASK_SEL_SS_Val, // Every Minute 55 | MATCH_MMSS = RTC_MODE2_MASK_SEL_MMSS_Val, // Every Hour 56 | MATCH_HHMMSS = RTC_MODE2_MASK_SEL_HHMMSS_Val, // Every Day 57 | MATCH_DHHMMSS = RTC_MODE2_MASK_SEL_DDHHMMSS_Val, // Every Month 58 | MATCH_MMDDHHMMSS = RTC_MODE2_MASK_SEL_MMDDHHMMSS_Val, // Every Year 59 | MATCH_YYMMDDHHMMSS = RTC_MODE2_MASK_SEL_YYMMDDHHMMSS_Val // Once, on a specific date and a specific time 60 | }; 61 | 62 | struct JulianTime; 63 | struct CalendarTime; 64 | enum class SleepMode 65 | { 66 | IdleCpu = 0, 67 | IdleCpuAhb, 68 | IdleCpuAhbApb, 69 | SleepWalk, 70 | DeepSleep, 71 | }; 72 | 73 | struct CalendarTime 74 | { 75 | uint8_t Year, Month, Day; 76 | uint8_t Hour, Minute, Second; 77 | 78 | bool Advance(uint32_t delta); 79 | }; 80 | 81 | CatenaRTC() {}; 82 | bool begin(bool fResetTime = false); 83 | 84 | CalendarTime GetTime(); 85 | bool SetTime(const CalendarTime *pTime); 86 | void SetAlarm(uint32_t delta); 87 | 88 | void SetAlarm(const CalendarTime *pNow); 89 | 90 | void SleepForAlarm(Alarm_Match how = MATCH_HHMMSS, 91 | SleepMode howSleep = SleepMode::IdleCpu 92 | ); 93 | 94 | private: 95 | volatile uint32_t m_Alarm; 96 | static const uint16_t md[13]; 97 | }; 98 | 99 | } // namespace McciCatena 100 | 101 | 102 | /**** end of CatenaRTC.h ****/ 103 | #endif /* _CATENARTC_H_ */ 104 | -------------------------------------------------------------------------------- /src/lib/samd/featherm0/catenafeatherm0_lorawan_getabpprovisioninginfo.cpp: -------------------------------------------------------------------------------- 1 | /* catenafeatherm0_lorawan_getabpprovisioninginfo.cpp Mon Dec 5 2016 02:08:45 tmm */ 2 | 3 | /* 4 | 5 | Module: catenafeatherm0_lorawan_getabpprovisioninginfo.cpp 6 | 7 | Function: 8 | CatenaFeatherM0::LoRaWAN::GetAbpProvisioningInfo() 9 | 10 | Version: 11 | V0.4.0 Mon Dec 5 2016 02:08:45 tmm Edit level 2 12 | 13 | Copyright notice: 14 | This file copyright (C) 2016 by 15 | 16 | MCCI Corporation 17 | 3520 Krums Corners Road 18 | Ithaca, NY 14850 19 | 20 | An unpublished work. All rights reserved. 21 | 22 | This file is proprietary information, and may not be disclosed or 23 | copied without the prior permission of MCCI Corporation. 24 | 25 | Author: 26 | Terry Moore, MCCI Corporation October 2016 27 | 28 | Revision history: 29 | 0.3.0 Mon Oct 31 2016 17:59:43 tmm 30 | Module created. 31 | 32 | */ 33 | 34 | #ifdef ARDUINO_ARCH_SAMD 35 | 36 | #include 37 | 38 | #include 39 | using namespace McciCatena; 40 | 41 | 42 | /****************************************************************************\ 43 | | 44 | | Manifest constants & typedefs. 45 | | 46 | \****************************************************************************/ 47 | 48 | 49 | /****************************************************************************\ 50 | | 51 | | Read-only data. 52 | | 53 | \****************************************************************************/ 54 | 55 | 56 | /****************************************************************************\ 57 | | 58 | | VARIABLES: 59 | | 60 | \****************************************************************************/ 61 | 62 | 63 | bool 64 | CatenaFeatherM0::LoRaWAN::GetAbpProvisioningInfo( 65 | CatenaFeatherM0::LoRaWAN::AbpProvisioningInfo *pInfo 66 | ) 67 | { 68 | CatenaFeatherM0 * const pCatena = this->m_pCatena; 69 | const ProvisioningInfo * const pInstance = pCatena->GetProvisioningInfo(); 70 | 71 | if (! pInstance) 72 | ARDUINO_LORAWAN_PRINTF( 73 | LogVerbose, 74 | "%s: no provisioning info\n", 75 | __func__ 76 | ); 77 | 78 | if (! pInstance || 79 | pInstance->Style != ProvisioningStyle::kABP) 80 | { 81 | if (pInfo) 82 | { 83 | // ensure consistent behavior 84 | memset(pInfo, 0, sizeof(*pInfo)); 85 | } 86 | 87 | return false; 88 | } 89 | 90 | // got instance data 91 | if (pInfo) 92 | { 93 | *pInfo = pInstance->AbpInfo; 94 | } 95 | 96 | return true; 97 | } 98 | 99 | #endif // ARDUINO_ARCH_SAMD 100 | -------------------------------------------------------------------------------- /src/CatenaFeatherM0.h: -------------------------------------------------------------------------------- 1 | /* 2 | 3 | Module: CateenaFeatherM0.h 4 | 5 | Function: 6 | Class CatenaFeatherM0 7 | 8 | Copyright notice: 9 | See LICENSE file accompanying this project. 10 | 11 | Author: 12 | Terry Moore, MCCI Corporation December 2016 13 | 14 | */ 15 | 16 | #ifndef _CATENAFEATHERM0_H_ /* prevent multiple includes */ 17 | #define _CATENAFEATHERM0_H_ 18 | 19 | #pragma once 20 | 21 | #ifndef _CATENASAMD21_H_ 22 | # include "CatenaSamd21.h" 23 | #endif 24 | 25 | #include 26 | 27 | namespace McciCatena { 28 | 29 | class CatenaFeatherM0 : public CatenaSamd21 30 | { 31 | public: 32 | using Super = CatenaSamd21; 33 | 34 | CatenaFeatherM0() {}; 35 | virtual ~CatenaFeatherM0() {}; 36 | 37 | // forward reference 38 | class LoRaWAN; 39 | 40 | // all FeatherM0s put vbat on A7 41 | enum ANALOG_PINS 42 | { 43 | APIN_VBAT_SENSE = A7, 44 | }; 45 | 46 | enum DIGITAL_PINS 47 | { 48 | PIN_STATUS_LED = 13, 49 | }; 50 | 51 | // get system clock rate in Hz. Always fixed for Feathers. 52 | virtual uint64_t GetSystemClockRate(void) const override 53 | { 54 | return 48 * 1000 * 1000; 55 | } 56 | 57 | // methods 58 | virtual bool begin() override; 59 | 60 | // read the current battery voltage, in engineering units 61 | float ReadVbat(void) const; 62 | 63 | protected: 64 | // methods 65 | virtual const Arduino_LoRaWAN::ProvisioningInfo * 66 | GetProvisioningInfo(void); 67 | 68 | virtual const Arduino_LoRaWAN::ProvisioningTable * 69 | GetLoRaWANkeys(void) const 70 | { 71 | return nullptr; 72 | } 73 | 74 | private: 75 | }; 76 | 77 | class CatenaFeatherM0::LoRaWAN : public Arduino_LoRaWAN_network, 78 | public cPollableObject 79 | { 80 | public: 81 | using Super = Arduino_LoRaWAN_network; 82 | 83 | /* 84 | || the constructor. 85 | */ 86 | LoRaWAN() {}; 87 | 88 | /* 89 | || the begin function loads data from the local 90 | || platform's stable storage and initializes 91 | || the connection. 92 | */ 93 | virtual bool begin(CatenaFeatherM0 *pCatena); 94 | 95 | virtual void poll() { this->Super::loop(); }; 96 | 97 | protected: 98 | /* 99 | || we have to provide these for the lower level 100 | */ 101 | virtual ProvisioningStyle GetProvisioningStyle(void) override; 102 | 103 | virtual bool GetAbpProvisioningInfo( 104 | AbpProvisioningInfo *pProvisioningInfo 105 | ) override; 106 | 107 | virtual bool GetOtaaProvisioningInfo( 108 | OtaaProvisioningInfo *pProvisioningInfo 109 | ) override; 110 | 111 | // 112 | // TODO(tmm@mcci.com) -- the following are not used but are always 113 | // hanging around even when we have better ways to do things. 114 | // 115 | private: 116 | CatenaFeatherM0 *m_pCatena; 117 | }; 118 | 119 | } /* namespace McciCatena */ 120 | 121 | /**** end of CatenaFeatherM0.h ****/ 122 | #endif /* _CATENAFEATHERM0_H_ */ 123 | -------------------------------------------------------------------------------- /src/lib/stm32/catena461x/Catena4618_getPlatformTable.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | 3 | Module: Catena4618_getPlatformTable.cpp 4 | 5 | Function: 6 | Catena4618::getPlatformTable() 7 | 8 | Copyright notice: 9 | See accompanying LICENSE file. 10 | 11 | Author: 12 | Lakshmi Priya Natarajan, MCCI Corporation June 2019 13 | 14 | Revision history: 15 | See https://github.com/mcci-catena/Catena-Arduino-Platform 16 | 17 | */ 18 | 19 | #ifdef ARDUINO_ARCH_STM32 20 | 21 | #include "Catena4618.h" 22 | 23 | #include "Catena_Log.h" 24 | #include "Catena_Platforms.h" 25 | #include "Catena_Guids.h" 26 | 27 | /****************************************************************************\ 28 | | 29 | | Read-only data. 30 | | 31 | \****************************************************************************/ 32 | 33 | namespace McciCatena { 34 | 35 | const CATENA_PLATFORM gkPlatformCatena4618 = 36 | { 37 | Guid: GUID_HW_CATENA_4618_BASE(WIRE), 38 | pParent: &gkPlatformCatena4618, 39 | PlatformFlags: 40 | CatenaBase::fHasLoRa | 41 | CatenaBase::fHasTtnNycLoRa | 42 | CatenaBase::fHasSHT3x | 43 | CatenaBase::fHasLuxSi1133 | 44 | CatenaBase::fHasFRAM | 45 | CatenaBase::fHasFlash 46 | }; 47 | 48 | const CATENA_PLATFORM gkPlatformCatena4618_v2 = 49 | { 50 | Guid: GUID_HW_CATENA_4618_V2_BASE(WIRE), 51 | pParent: &gkPlatformCatena4618, 52 | PlatformFlags: 53 | CatenaBase::fHasLoRa | 54 | CatenaBase::fHasTtnNycLoRa | 55 | CatenaBase::fHasSHT3x | 56 | CatenaBase::fHasLuxLtr329 | 57 | CatenaBase::fHasFRAM | 58 | CatenaBase::fHasFlash 59 | }; 60 | 61 | const CATENA_PLATFORM (* const Catena4618::vPlatforms[]) = 62 | { 63 | // entry 0 is the default 64 | &gkPlatformCatena4618, 65 | &gkPlatformCatena4618_v2, 66 | }; 67 | 68 | const size_t Catena4618::nvPlatforms = sizeof(Catena4618::vPlatforms) / sizeof(Catena4618::vPlatforms[0]); 69 | 70 | /* 71 | 72 | Name: Catena4618::getPlatformTable() 73 | 74 | Function: 75 | Get the known platform table. 76 | 77 | Definition: 78 | public: virtual 79 | void Catena4618::getPlatformTable( 80 | const CATENA_PLATFORM * const * &vPlatforms, 81 | size_t &nvPlatforms 82 | ) override; 83 | 84 | Description: 85 | This override for getPlatformTable() returns the vector of platform 86 | GUIDs for this Catena. 87 | 88 | Returns: 89 | vPlatforms is set to the base of the array of pointers to platform 90 | stuctures; and nvPlatforms is set to the number of entries in 91 | the table. 92 | 93 | */ 94 | 95 | /* public virtual override */ 96 | void 97 | Catena4618::getPlatformTable( 98 | const CATENA_PLATFORM * const * &result_vPlatforms, 99 | size_t &result_nvPlatforms 100 | ) 101 | { 102 | result_vPlatforms = vPlatforms; 103 | result_nvPlatforms = nvPlatforms; 104 | } 105 | 106 | } /* namespace McciCatena */ 107 | 108 | #endif // ARDUINO_ARCH_STM32 109 | -------------------------------------------------------------------------------- /src/Catena_Totalizer.h: -------------------------------------------------------------------------------- 1 | /* Catena_Totalizer.h Mon Mar 27 2017 00:18:49 tmm */ 2 | 3 | /* 4 | 5 | Module: Catena_Totalizer.h 6 | 7 | Function: 8 | class McciCatena:cTotalizer. 9 | 10 | Version: 11 | V0.5.0 Mon Mar 27 2017 00:18:49 tmm Edit level 1 12 | 13 | Copyright notice: 14 | This file copyright (C) 2017 by 15 | 16 | MCCI Corporation 17 | 3520 Krums Corners Road 18 | Ithaca, NY 14850 19 | 20 | An unpublished work. All rights reserved. 21 | 22 | This file is proprietary information, and may not be disclosed or 23 | copied without the prior permission of MCCI Corporation. 24 | 25 | Author: 26 | Terry Moore, MCCI Corporation March 2017 27 | 28 | Revision history: 29 | 0.5.0 Mon Mar 27 2017 00:18:49 tmm 30 | Module created. 31 | 32 | */ 33 | 34 | #ifndef _CATENA_TOTALIZER_H_ /* prevent multiple includes */ 35 | #define _CATENA_TOTALIZER_H_ 36 | 37 | #pragma once 38 | 39 | #include 40 | 41 | #ifndef _CATENA_POLLABLEINTERFACE_H_ 42 | # include "Catena_PollableInterface.h" 43 | #endif 44 | 45 | namespace McciCatena { 46 | 47 | class cTotalizer : public cPollableObject 48 | { 49 | public: 50 | enum : uint8_t 51 | { 52 | kPinUndefined = 0xFFu, 53 | }; 54 | 55 | static constexpr uint16_t kDefault_msDebounce = 50; 56 | 57 | cTotalizer(uint8_t pin = kPinUndefined) 58 | : m_pin(pin) 59 | , m_msDebounce(kDefault_msDebounce) 60 | {}; 61 | 62 | // setup, passing in a pin 63 | bool begin(uint8_t pin = kPinUndefined); 64 | 65 | // totalize 66 | virtual void poll() override; 67 | 68 | // get the running total 69 | uint32_t getcurrent() const 70 | { return this->m_total; }; 71 | bool getDeltaCountAndTime(uint32_t &outCount, uint32_t &outDelta); 72 | void setReference(); 73 | 74 | // set the debounce time 75 | cTotalizer &setDebounce(uint16_t msDebounce) 76 | { 77 | this->m_msDebounce = msDebounce; 78 | return *this; 79 | } 80 | 81 | // get the debounce time 82 | uint16_t getDebounce() const 83 | { 84 | return this->m_msDebounce; 85 | } 86 | 87 | private: 88 | // total number of counts seen 89 | uint32_t m_total; 90 | // time of last change (from millis()) 91 | uint32_t m_tEdge; 92 | // time of last measurement 93 | uint32_t m_tLastMeasured; 94 | uint32_t m_nLastMeasured; 95 | // debounce time. Zero turns off. 96 | uint16_t m_msDebounce; 97 | // last bit value observed. 98 | bool m_last; 99 | // last debounced bit value observed 100 | bool m_lastStable; 101 | // value has stabilized 102 | bool m_fIsStable; 103 | // true if we have a valid previous measurement 104 | bool m_fHaveDelta; 105 | // counter is initialized 106 | bool m_initialized = false; 107 | // Arduino digital pin to be monitored. 108 | uint8_t m_pin; 109 | }; 110 | 111 | }; // namespace McciCatena 112 | 113 | /**** end of Catena_Totalizer.h ****/ 114 | #endif /* _CATENA_TOTALIZER_H_ */ 115 | -------------------------------------------------------------------------------- /src/lib/stm32/stm32l0/CatenaStm32L0_registerCommands.cpp: -------------------------------------------------------------------------------- 1 | /* CatenaStm32L0_registerCommands.cpp Wed Dec 05 2018 14:34:20 chwon */ 2 | 3 | /* 4 | 5 | Module: CatenaStm32L0_registerCommands.cpp 6 | 7 | Function: 8 | CatenaStm32L0::registerCommands() 9 | 10 | Version: 11 | V0.12.0 Wed Dec 05 2018 14:34:21 chwon Edit level 2 12 | 13 | Copyright notice: 14 | This file copyright (C) 2017-2018 by 15 | 16 | MCCI Corporation 17 | 3520 Krums Corners Road 18 | Ithaca, NY 14850 19 | 20 | An unpublished work. All rights reserved. 21 | 22 | This file is proprietary information, and may not be disclosed or 23 | copied without the prior permission of MCCI Corporation. 24 | 25 | Author: 26 | ChaeHee Won, MCCI Corporation October 2017 27 | 28 | Revision history: 29 | 0.6.0 Fri Oct 13 2017 15:19:30 chwon 30 | Module created. 31 | 32 | 0.12.0 Wed Dec 05 2018 14:34:21 chwon 33 | Move adding commands to CatenaBase class. 34 | 35 | */ 36 | 37 | #ifdef ARDUINO_ARCH_STM32 38 | 39 | #include "CatenaStm32L0.h" 40 | 41 | #include "Catena_CommandStream.h" 42 | #include "Catena_Log.h" 43 | 44 | using namespace McciCatena; 45 | 46 | /****************************************************************************\ 47 | | 48 | | Manifest constants 49 | | 50 | \****************************************************************************/ 51 | 52 | static cCommandStream::CommandFn doCalibration; 53 | 54 | static const cCommandStream::cEntry sStm32L0Entries[] = 55 | { 56 | { "calibrate", doCalibration }, 57 | }; 58 | 59 | static cCommandStream::cDispatch 60 | sStm32L0Dispatch(sStm32L0Entries, sizeof(sStm32L0Entries), "system"); 61 | 62 | /****************************************************************************\ 63 | | 64 | | The command tables 65 | | 66 | \****************************************************************************/ 67 | 68 | 69 | /****************************************************************************\ 70 | | 71 | | The method function 72 | | 73 | \****************************************************************************/ 74 | 75 | /* protected virtual */ 76 | void 77 | CatenaStm32L0::registerCommands() 78 | { 79 | this->Super::registerCommands(); 80 | if (this->usesLseClock()) 81 | { 82 | this->addCommands( 83 | sStm32L0Dispatch, 84 | static_cast(this) 85 | ); 86 | } 87 | } 88 | 89 | static cCommandStream::CommandStatus 90 | doCalibration( 91 | cCommandStream *pThis, 92 | void *pContext, 93 | int argc, 94 | char **argv 95 | ) 96 | { 97 | CatenaStm32L0 * const pCatena = static_cast(pContext); 98 | 99 | if (argc <= 1) 100 | { 101 | uint32_t Calib; 102 | 103 | Calib = pCatena->CalibrateSystemClock(); 104 | pThis->printf("calibration result: %u\n", Calib); 105 | 106 | return cCommandStream::CommandStatus::kSuccess; 107 | } 108 | else 109 | { 110 | return cCommandStream::CommandStatus::kInvalidParameter; 111 | } 112 | 113 | } 114 | 115 | #endif // ARDUINO_ARCH_STM32 116 | 117 | /**** end of CatenaStm32L0_registerCommands.cpp ****/ 118 | -------------------------------------------------------------------------------- /src/lib/stm32/stm32l0/CatenaStm32L0_LoRaWAN_getotaaprovisioninginfo.cpp: -------------------------------------------------------------------------------- 1 | /* CatenaStm32L0_LoRaWAN_getotaaprovisioninginfo.cpp Wed Dec 05 2018 14:36:22 chwon */ 2 | 3 | /* 4 | 5 | Module: CatenaStm32L0_LoRaWAN_getotaaprovisioninginfo.cpp 6 | 7 | Function: 8 | CatenaStm32L0::LoRaWAN::GetOtaaProvisioningInfo() 9 | 10 | Version: 11 | V0.12.0 Wed Dec 05 2018 14:36:22 chwon Edit level 2 12 | 13 | Copyright notice: 14 | This file copyright (C) 2017-2018 by 15 | 16 | MCCI Corporation 17 | 3520 Krums Corners Road 18 | Ithaca, NY 14850 19 | 20 | An unpublished work. All rights reserved. 21 | 22 | This file is proprietary information, and may not be disclosed or 23 | copied without the prior permission of MCCI Corporation. 24 | 25 | Author: 26 | ChaeHee Won, MCCI Corporation October 2017 27 | 28 | Revision history: 29 | 0.6.0 Fri Oct 13 2017 15:19:30 chwon 30 | Module created. 31 | 32 | 0.12.0 Wed Dec 05 2018 14:36:22 chwon 33 | Use Catena provisioning method. 34 | 35 | */ 36 | 37 | #ifdef ARDUINO_ARCH_STM32 38 | 39 | #include 40 | 41 | #include 42 | #include 43 | 44 | using namespace McciCatena; 45 | 46 | /****************************************************************************\ 47 | | 48 | | Manifest constants & typedefs. 49 | | 50 | \****************************************************************************/ 51 | 52 | 53 | /****************************************************************************\ 54 | | 55 | | Read-only data. 56 | | 57 | \****************************************************************************/ 58 | 59 | 60 | /****************************************************************************\ 61 | | 62 | | VARIABLES: 63 | | 64 | \****************************************************************************/ 65 | 66 | 67 | /* 68 | 69 | Name: CatenaStm32L0::LoRaWAN::GetOtaaProvisioningInfo() 70 | 71 | Function: 72 | Fetch OTAA provisioning info from FRAM (if availalbe) 73 | 74 | Definition: 75 | public: virtual bool 76 | CatenaStm32L0::LoRaWAN::GetOtaaProvisioningInfo( 77 | CatenaStm32L0::LoRaWAN::OtaaProvisioningInfo *pInfo 78 | ) override; 79 | 80 | Description: 81 | This routine fetches the OTAA provisioning info from FRAM if 82 | available, formatting it into *pInfo. For this to work, FRAM 83 | must be initialized and the AppKey, AppEUI and DevEUI must be 84 | available. 85 | 86 | If pInfo is nullptr, the routine simply checks whether the info 87 | is availalbe. 88 | 89 | Returns: 90 | This routine returns true if and only if the provisioning info 91 | is available. 92 | 93 | */ 94 | 95 | bool 96 | CatenaStm32L0::LoRaWAN::GetOtaaProvisioningInfo( 97 | CatenaStm32L0::LoRaWAN::OtaaProvisioningInfo *pInfo 98 | ) 99 | { 100 | CatenaStm32L0 * const pCatena = this->m_pCatena; 101 | 102 | return pCatena->GetOtaaProvisioningInfo(pInfo); 103 | } 104 | 105 | #endif // ARDUINO_ARCH_STM32 106 | 107 | /**** end of CatenaStm32L0_LoRaWAN_getotaaprovisioninginfo.cpp ****/ 108 | -------------------------------------------------------------------------------- /src/Catena_limits.h: -------------------------------------------------------------------------------- 1 | /* Catena_limits.h Sat Mar 18 2017 16:06:51 tmm */ 2 | 3 | /* 4 | 5 | Module: Catena_limits.h 6 | 7 | Function: 8 | Wrapper for when working with Arduino code. 9 | 10 | Version: 11 | V0.5.0 Sat Mar 18 2017 16:06:51 tmm Edit level 1 12 | 13 | Copyright notice: 14 | This file copyright (C) 2017 by 15 | 16 | MCCI Corporation 17 | 3520 Krums Corners Road 18 | Ithaca, NY 14850 19 | 20 | An unpublished work. All rights reserved. 21 | 22 | This file is proprietary information, and may not be disclosed or 23 | copied without the prior permission of MCCI Corporation. 24 | 25 | Author: 26 | Terry Moore, MCCI Corporation March 2017 27 | 28 | Revision history: 29 | 0.5.0 Sat Mar 18 2017 16:06:51 tmm 30 | Module created. 31 | 32 | */ 33 | 34 | #ifndef _CATENA_LIMITS_H_ /* prevent multiple includes */ 35 | #define _CATENA_LIMITS_H_ 36 | 37 | #pragma once 38 | 39 | // this is ugly. Arduino.h defines macros min() and max().... which clobber 40 | // . So we do some dark magic. 41 | #if defined(Arduino_h) 42 | # define CATENA_LIMITS_min_defined 1 43 | # define CATENA_LIMITS_max_defined 1 44 | #else 45 | # if defined(min) 46 | # define CATENA_LIMITS_min_defined 1 47 | # else 48 | # define CATENA_LIMITS_min_defined 0 49 | # endif 50 | # if defined(max) 51 | # define CATENA_LIMITS_max_defined 1 52 | # else 53 | # define CATENA_LIMITS_max_defined 0 54 | # endif 55 | #endif 56 | 57 | #if CATENA_LIMITS_min_defined 58 | # undef min 59 | #endif 60 | #if CATENA_LIMITS_max_defined 61 | # undef max 62 | #endif 63 | 64 | #include 65 | 66 | /* 67 | || Even more unfortunately -- if we re-instate min and max, we won't be 68 | || able to use numeric_limits<>::max and ::min. So first we have to 69 | || declare templates (in McciCatena namespace) for the things we 70 | || need to use. 71 | */ 72 | namespace McciCatena { 73 | 74 | template 75 | class cNumericLimits : public std::numeric_limits 76 | { 77 | public: 78 | static constexpr T numeric_limits_max() noexcept { return std::numeric_limits::max(); } 79 | 80 | static constexpr T numeric_limits_min() noexcept { return std::numeric_limits::min(); } 81 | 82 | // since `lowest` is mentally adjacent to `min`, we provide an alias for it, too. 83 | static constexpr T numeric_limits_lowest() noexcept { return std::numeric_limits::lowest; } 84 | }; 85 | 86 | } // namespace McciCatena 87 | 88 | /* 89 | || Now, we reinstate the Arduino.h values... I said it was ugly. 90 | || In an ideal world we'd be able to save and restore the below. Bear 91 | || in mind that there may be other words that Arduino.h steps on, 92 | || breaking C++ header files: it defines a number of lower-case macros with 93 | || commonly-used words. Since there are no namespaces for macros, it's 94 | || an unpleasant situation. 95 | */ 96 | #if CATENA_LIMITS_min_defined 97 | # define min(a,b) ((a)<(b)?(a):(b)) 98 | #endif 99 | 100 | #if CATENA_LIMITS_max_defined 101 | # define max(a,b) ((a)>(b)?(a):(b)) 102 | #endif 103 | 104 | /**** end of Catena_limits.h ****/ 105 | #endif /* _CATENA_LIMITS_H_ */ 106 | -------------------------------------------------------------------------------- /src/lib/samd/catenawingfram2k/CatenaWingFram2k_begin.cpp: -------------------------------------------------------------------------------- 1 | /* CatenaWingFram2k_begin.cpp Wed Dec 05 2018 14:26:50 chwon */ 2 | 3 | /* 4 | 5 | Module: CatenaWingFram2k_begin.cpp 6 | 7 | Function: 8 | CatenaWingFram2k::begin() 9 | 10 | Version: 11 | V0.12.0 Wed Dec 05 2018 14:26:50 chwon Edit level 2 12 | 13 | Copyright notice: 14 | This file copyright (C) 2017-2018 by 15 | 16 | MCCI Corporation 17 | 3520 Krums Corners Road 18 | Ithaca, NY 14850 19 | 20 | An unpublished work. All rights reserved. 21 | 22 | This file is proprietary information, and may not be disclosed or 23 | copied without the prior permission of MCCI Corporation. 24 | 25 | Author: 26 | Terry Moore, MCCI Corporation March 2017 27 | 28 | Revision history: 29 | 0.5.0 Sun Mar 12 2017 19:19:28 tmm 30 | Module created. 31 | 32 | 0.12.0 Wed Dec 05 2018 14:26:51 chwon 33 | Move common initialization code to CatenaBase class. 34 | 35 | */ 36 | 37 | #ifdef ARDUINO_ARCH_SAMD 38 | 39 | #include "CatenaWingFram2k.h" 40 | 41 | #include "Catena_Log.h" 42 | 43 | using namespace McciCatena; 44 | 45 | /* 46 | 47 | Name: CatenaWingFram2k::begin() 48 | 49 | Function: 50 | Set up all the well-known board peripherals. 51 | 52 | Definition: 53 | bool CatenaWingFram2k::begin(); 54 | 55 | Description: 56 | Issues begin() for all the CatenaWingFram2k things. 57 | 58 | Returns: 59 | true for success, false for failure. 60 | 61 | */ 62 | 63 | 64 | bool CatenaWingFram2k::begin() 65 | { 66 | delay(2000); 67 | gLog.printf(gLog.kTrace, "+CatenaWingFram2k::begin()\n"); 68 | 69 | // we must initialize the FRAM before we call our parent, 70 | // because FRAM is used for stable storage of platform info. 71 | 72 | // start the FRAM 73 | if (!this->m_Fram.begin()) 74 | return false; 75 | 76 | // check whether the FRAM is valid 77 | if (! this->m_Fram.isValid()) 78 | { 79 | gLog.printf( 80 | gLog.kError, 81 | "FRAM contents are not valid, resetting\n" 82 | ); 83 | this->m_Fram.initialize(); 84 | } 85 | 86 | // do the platform selection. 87 | if (! this->Super::begin()) 88 | { 89 | gLog.printf( 90 | gLog.kError, 91 | "?CatenaWingFram2k::begin:" 92 | " Super::begin() failed\n" 93 | ); 94 | return false; 95 | } 96 | 97 | // register all commands in this stack 98 | this->registerCommands(); 99 | 100 | // and register the FRAM commands 101 | if (!this->m_Fram.addCommands()) 102 | { 103 | gLog.printf( 104 | gLog.kError, 105 | "?CatenaWingFram2k::begin:" 106 | " m_Fram.addCommands() failed\n" 107 | ); 108 | return false; 109 | } 110 | 111 | this->m_Fram.getField( 112 | cFramStorage::StandardKeys::kBootCount, 113 | this->m_BootCount 114 | ); 115 | ++this->m_BootCount; 116 | this->m_Fram.saveField( 117 | cFramStorage::StandardKeys::kBootCount, 118 | this->m_BootCount 119 | ); 120 | return true; 121 | } 122 | 123 | #endif // ARDUINO_ARCH_SAMD 124 | -------------------------------------------------------------------------------- /src/lib/stm32/catena461x/Catena4610_ReadVoltage.cpp: -------------------------------------------------------------------------------- 1 | /* Catena4610_ReadAnalog.cpp Fri Dec 28 2018 14:01:42 chwon */ 2 | 3 | /* 4 | 5 | Module: Catena4610_ReadAnalog.cpp 6 | 7 | Function: 8 | Catena4610::ReadVbat() and Catena4610::ReadVbus() 9 | 10 | Version: 11 | V0.13.0 Fri Dec 28 2018 14:01:42 chwon Edit level 1 12 | 13 | Copyright notice: 14 | This file copyright (C) 2018 by 15 | 16 | MCCI Corporation 17 | 3520 Krums Corners Road 18 | Ithaca, NY 14850 19 | 20 | An unpublished work. All rights reserved. 21 | 22 | This file is proprietary information, and may not be disclosed or 23 | copied without the prior permission of MCCI Corporation 24 | 25 | Author: 26 | ChaeHee Won, MCCI Corporation December 2018 27 | 28 | Revision history: 29 | 0.13.0 Fri Dec 28 2018 14:01:42 chwon 30 | Module created. 31 | 32 | */ 33 | 34 | #ifdef ARDUINO_ARCH_STM32 35 | 36 | #include "Catena4610.h" 37 | #include "Catena_Log.h" 38 | 39 | #include 40 | using namespace McciCatena; 41 | 42 | /****************************************************************************\ 43 | | 44 | | Manifest constants & typedefs. 45 | | 46 | | This is strictly for private types and constants which will not 47 | | be exported. 48 | | 49 | \****************************************************************************/ 50 | 51 | 52 | 53 | /****************************************************************************\ 54 | | 55 | | Read-only data. 56 | | 57 | | If program is to be ROM-able, these must all be tagged read-only 58 | | using the ROM storage class; they may be global. 59 | | 60 | \****************************************************************************/ 61 | 62 | 63 | 64 | /****************************************************************************\ 65 | | 66 | | VARIABLES: 67 | | 68 | | If program is to be ROM-able, these must be initialized 69 | | using the BSS keyword. (This allows for compilers that require 70 | | every variable to have an initializer.) Note that only those 71 | | variables owned by this module should be declared here, using the BSS 72 | | keyword; this allows for linkers that dislike multiple declarations 73 | | of objects. 74 | | 75 | \****************************************************************************/ 76 | 77 | float 78 | Catena4610::ReadVbat(void) const 79 | { 80 | float volt = this->ReadAnalog(Catena461x::ANALOG_CHANNEL_VBAT, 1, 2); 81 | return volt / 1000; 82 | } 83 | 84 | float 85 | Catena4610::ReadVbus(void) const 86 | { 87 | float volt = this->ReadAnalog(Catena461x::ANALOG_CHANNEL_VBUS, 1, 3); 88 | return volt / 1000; 89 | } 90 | 91 | #if defined(ARDUINO_MCCI_CATENA_4610) && defined(USBD_LL_ConnectionState_WEAK) 92 | 93 | extern "C" { 94 | 95 | uint32_t USBD_LL_ConnectionState(void) 96 | { 97 | uint32_t vBus; 98 | bool fStatus; 99 | 100 | fStatus = CatenaStm32L0_ReadAnalog( 101 | Catena461x::ANALOG_CHANNEL_VBUS, 1, 3, &vBus 102 | ); 103 | return (fStatus && vBus < 3000) ? 0 : 1; 104 | } 105 | 106 | } 107 | 108 | #endif // ARDUINO_MCCI_CATENA_4610 109 | 110 | #endif // ARDUINO_ARCH_STM32 111 | 112 | /**** end of Catena4610_ReadAnalog.cpp ****/ 113 | -------------------------------------------------------------------------------- /src/lib/stm32/catena461x/Catena4611_ReadVoltage.cpp: -------------------------------------------------------------------------------- 1 | /* Catena4611_ReadAnalog.cpp Fri Dec 28 2018 14:01:42 chwon */ 2 | 3 | /* 4 | 5 | Module: Catena4611_ReadAnalog.cpp 6 | 7 | Function: 8 | Catena4611::ReadVbat() and Catena4611::ReadVbus() 9 | 10 | Version: 11 | V0.13.0 Fri Dec 28 2018 14:01:42 chwon Edit level 1 12 | 13 | Copyright notice: 14 | This file copyright (C) 2018 by 15 | 16 | MCCI Corporation 17 | 3520 Krums Corners Road 18 | Ithaca, NY 14850 19 | 20 | An unpublished work. All rights reserved. 21 | 22 | This file is proprietary information, and may not be disclosed or 23 | copied without the prior permission of MCCI Corporation 24 | 25 | Author: 26 | ChaeHee Won, MCCI Corporation December 2018 27 | 28 | Revision history: 29 | 0.13.0 Fri Dec 28 2018 14:01:42 chwon 30 | Module created. 31 | 32 | */ 33 | 34 | #ifdef ARDUINO_ARCH_STM32 35 | 36 | #include "Catena4611.h" 37 | #include "Catena_Log.h" 38 | 39 | #include 40 | using namespace McciCatena; 41 | 42 | /****************************************************************************\ 43 | | 44 | | Manifest constants & typedefs. 45 | | 46 | | This is strictly for private types and constants which will not 47 | | be exported. 48 | | 49 | \****************************************************************************/ 50 | 51 | 52 | 53 | /****************************************************************************\ 54 | | 55 | | Read-only data. 56 | | 57 | | If program is to be ROM-able, these must all be tagged read-only 58 | | using the ROM storage class; they may be global. 59 | | 60 | \****************************************************************************/ 61 | 62 | 63 | 64 | /****************************************************************************\ 65 | | 66 | | VARIABLES: 67 | | 68 | | If program is to be ROM-able, these must be initialized 69 | | using the BSS keyword. (This allows for compilers that require 70 | | every variable to have an initializer.) Note that only those 71 | | variables owned by this module should be declared here, using the BSS 72 | | keyword; this allows for linkers that dislike multiple declarations 73 | | of objects. 74 | | 75 | \****************************************************************************/ 76 | 77 | float 78 | Catena4611::ReadVbat(void) const 79 | { 80 | float volt = this->ReadAnalog(Catena461x::ANALOG_CHANNEL_VBAT, 1, 1); 81 | return volt / 1000; 82 | } 83 | 84 | float 85 | Catena4611::ReadVbus(void) const 86 | { 87 | float volt = this->ReadAnalog(Catena461x::ANALOG_CHANNEL_VBUS, 1, 3); 88 | return volt / 1000; 89 | } 90 | 91 | #if defined(ARDUINO_MCCI_CATENA_4611) && defined(USBD_LL_ConnectionState_WEAK) 92 | 93 | extern "C" { 94 | 95 | uint32_t USBD_LL_ConnectionState(void) 96 | { 97 | uint32_t vBus; 98 | bool fStatus; 99 | 100 | fStatus = CatenaStm32L0_ReadAnalog( 101 | Catena461x::ANALOG_CHANNEL_VBUS, 1, 3, &vBus 102 | ); 103 | return (fStatus && vBus < 3000) ? 0 : 1; 104 | } 105 | 106 | } 107 | 108 | #endif // ARDUINO_MCCI_CATENA_4611 109 | 110 | #endif // ARDUINO_ARCH_STM32 111 | 112 | /**** end of Catena4611_ReadAnalog.cpp ****/ 113 | -------------------------------------------------------------------------------- /src/lib/samd/CatenaSamd21_Sleep.cpp: -------------------------------------------------------------------------------- 1 | /* CatenaSamd21_Sleep.cpp Wed Oct 31 2018 11:46:53 chwon */ 2 | 3 | /* 4 | 5 | Module: CatenaSamd21_Sleep.cpp 6 | 7 | Function: 8 | Home for CatenaSamd21::Sleep() 9 | 10 | Version: 11 | V3.21h Wed Oct 31 2018 11:46:53 chwon Edit level 1 12 | 13 | Copyright notice: 14 | This file copyright (C) 2018 by 15 | 16 | MCCI Corporation 17 | 3520 Krums Corners Road 18 | Ithaca, NY 14850 19 | 20 | An unpublished work. All rights reserved. 21 | 22 | This file is proprietary information, and may not be disclosed or 23 | copied without the prior permission of MCCI Corporation 24 | 25 | Author: 26 | ChaeHee Won, MCCI Corporation October 2018 27 | 28 | Revision history: 29 | 3.21h Wed Oct 31 2018 11:46:53 chwon 30 | Module created. 31 | 32 | */ 33 | 34 | #ifdef ARDUINO_ARCH_SAMD 35 | 36 | #include "CatenaSamd21.h" 37 | 38 | #include 39 | using namespace McciCatena; 40 | 41 | /****************************************************************************\ 42 | | 43 | | Manifest constants & typedefs. 44 | | 45 | | This is strictly for private types and constants which will not 46 | | be exported. 47 | | 48 | \****************************************************************************/ 49 | 50 | 51 | 52 | /****************************************************************************\ 53 | | 54 | | Read-only data. 55 | | 56 | | If program is to be ROM-able, these must all be tagged read-only 57 | | using the ROM storage class; they may be global. 58 | | 59 | \****************************************************************************/ 60 | 61 | 62 | 63 | /****************************************************************************\ 64 | | 65 | | VARIABLES: 66 | | 67 | | If program is to be ROM-able, these must be initialized 68 | | using the BSS keyword. (This allows for compilers that require 69 | | every variable to have an initializer.) Note that only those 70 | | variables owned by this module should be declared here, using the BSS 71 | | keyword; this allows for linkers that dislike multiple declarations 72 | | of objects. 73 | | 74 | \****************************************************************************/ 75 | 76 | 77 | /* 78 | 79 | Name: CatenaSamd21::Sleep() 80 | 81 | Function: 82 | Put system in sleep mode 83 | 84 | Definition: 85 | void CatenaSamd21::Sleep(uint32_t howLongInSeconds); 86 | 87 | Description: 88 | This function sets the alarm with given howLongInSeconds and puts the 89 | system in low power sleep mode. The system will be wake up when alarm 90 | happen in howLongInSeconds. 91 | 92 | Returns: 93 | No explicit result. 94 | 95 | */ 96 | 97 | void CatenaSamd21::Sleep(uint32_t howLongInSeconds) 98 | { 99 | this->m_Rtc.SetAlarm(howLongInSeconds); 100 | this->m_Rtc.SleepForAlarm( 101 | this->m_Rtc.MATCH_HHMMSS, 102 | this->m_Rtc.SleepMode::DeepSleep 103 | ); 104 | 105 | // add the number of ms that we were asleep to the millisecond timer. 106 | // we don't need extreme accuracy. 107 | adjust_millis_forward(howLongInSeconds * 1000); 108 | } 109 | 110 | #endif // ARDUINO_ARCH_SAMD 111 | 112 | /**** end of CatenaSamd21_Sleep.cpp ****/ 113 | --------------------------------------------------------------------------------