I welcome you to my review of MAX31343 Shield. My review is split to multiple chapters linked in following table of contents. Main page of review (marked with yellow star in table of contents below this text) contains summary, final score, and description of all chapters. Most important chapters of review begin with “Review” in name and contains detailed description of thing under review. There are chapters reviewing RTC chip, evaluation shield, bundled PICO board and its MCU. There are also described projects which I have done for evaluating this shield and finally there one tutorial showing how to easily use roadtested shield with Arduino. In this part I will describe my Library for MAX31343 chip which I have made for gaining experiences with MAX31343 RTC chip and discovering its details.
Review Table of Contents
- Introduction, Overview of Table of Contents, Summary and Score
- Review of RTC Chip
- Review of Evaluation Shield
- Review of MAX32625 MCU and PICO Board
- Tutorial: Using Shield with Arduino
- Project 1: Platform Independent Library (this article)
- Project 2: Time Syncing over BLE
- Project 3: Linux Driver
Platform Independent MAX31343 Library
As part of review I have created my own library for MAX31343 chip. While Maxim provide official Arduino library this may looks like waste of time, but I had reasons for doing this. At first, I want to discover how RTC chip works and learn all its details for review purposes. Second reason is that I rarely use Arduino in my projects. Instead of Arduino I frequently use some more advanced microcontrollers. Porting Arduino libraries are quite complicated to platform without any Wire class. Lastly, I usually write my firmwares in C instead of C++. Maxim’s library also rely (you can eliminate this, but with global statically allocated object it did not worked to me most probably because of passing uninitialized Wire object) on dynamic memory allocations (which are common in C++ programs) but can cause hardly predictable runtime errors in case of memory fragmentation and memory allocation failure. This issue may become significant on chips with low amount of memory in comparison to programs running on computer with gigabytes of memory. So, I decided to write my own library.
I designed my library complexly and allow users to access all features of chip including reading current configuration from chip. Maxim’s library for example do not enable you to check if trickle charger is enabled. You can enable, disable, and configure it but library has no method to read current status and configuration. You usually do not need these methods, but I included and implemented them in my library.
Second design concept which I use in all my libraries is platform independency. As I mentioned above in this part, I use multiple MCUs and I need frequently port some code to another platform. My library is separated to two sources files (and related header files). One of them contains library logic but has no bindings to any platform and second file is platform specific file which in case of this library, contains platform specific logic for controlling I2C bus and configuring interrupt line. It has no binding to any MAX31343 related logic. I (or you) can migrate my library to new platform just by reimplementing platform specific file. Platform specific logic is just 5 functions which initialize I2C driver, uninitialize it, 2 functions for issuing read and write transaction to the chip and finally function used for configuring external interrupt on interrupt line. Implementation of I2C driver uninitialization function and function configuring interrupt line are optional in case when there is no need to uninitialize I2C driver (in case when library is initialized at beginning and never uninitialized) and when interrupt support is not needed.
Library is available at Github. Source codes consist of library, platform specific ports and examples. Not all examples are implemented yet and all examples are not ported to all platforms because making all of them is very time consuming. Currently library is ported to STM32 platform (default pinout matches NUCLEO-L552ZE-Q board and PSoC 62 platform (default pinout and project configuration matches previously RoadTested Cypress PSoC 62S2 Wi-Fi & BT5.0 Pioneer Dev Kit (CY8CKIT-062S2-43012). In the future I plan to port library to other platforms which I use. I plan support AVR and also MAX32625 MCU which is part of bundled PICO board.
Except examples as part of Github project I used my library in second project (Time Syncing over BLE) and I also used it to experiment with shield and chip. For example, testing project which checks that chip correctly handles end of February in leap years is based on this library. Project is downloadable at the end of Review of RTC Chip chapter.
You can download latest version of library from release page at Github. You need to expand Assets section and select which platform variant you want to download. Alternatively, you can clone whole repository.