This code is written for the CDMRP ECMO project's Layer 2 (Critical Computing Unit), the layer interacting directly with the sensors and sending results to Layer 1 (Application Processing Unit) for monitoring and networking.
The firmware is organized in using a foreground-background architecture.
The foreground is an ISR which runs every 10ms when a hardware timer overflows. The ISR communicates via I2C with an adpd1080 chip onboard an optical sensor to read its data results. It also reads the on-chip SAR ADC conversion results once for every 10 times it runs. Once the ISR has read the SAR ADC conversion results it sets the dataReady flag.
This causes the background loop to capture the data stored in shared buffers between the foreground and background for processing, encryption, and transmission via UART to a receiver.
The firmware achieves 100 Hz optical sensor sampling rate, 10 Hz SAR ADC sampling rate, and 10 Hz results transmission rate.
Timing measurements:
- Timer ISR: periodic with 10ms period, 0.3-0.5ms duration
- dataReady loop iteration: periodic with 100ms period, 1.6ms duration
- UART packet transmission: periodic with 100ms period, 16ms duration
Debugging CRC check failures: The receiver occasionally fails its CRC check on incoming data packets, for around 3-5 packets for every 15-25 packets sent. Another way of viewing it is that every 1-10 seconds (varying), there will be 1-5 CRC check failures. This reliability issue could be on the transmitter side, receiver side, or due to bus issues, yet to be determined.
Cleaning up messy functions: Need to check whether calculateCRC8() : uint8_t is correct and make style updates to ADPD1080.c functions.
Credit code copied from PDL API: Need to cite PDL API examples for Crypto block initialization and usage.
Application/device drivers error checking and handling: Error checking and handling when PDL API calls or device driver API calls fail are currently inconsistent or unimplemented.
Additional features: Watchdog timer, additional sensors, state machine for new operation modes, foreground-background process synchronization, DFU module/bootloader, SMIF data storage, UI via BLE, adpd1080 data available interrupts, I2C multiword read, support for multiple adpd1080 devices on a single I2C bus.
- PSoC 6 evaluation board
- ESP32 receiver
- Establish common ground with PSoC
- Connect Rx port (pin 16, GPIO16, RX2) with Tx port of PSoC
- Osama's optical sensor (open with Altium online viewer)
- Connector clip color key
- Red - power (3.3V, ideally 5V)
- Black - ground
- Green - SDA (1.8V, 3.6V maximum)
- Yellow - SCL (1.8V, 3.6V maximum)
- Blue - GPIO0 (1.8V, 2.2V maximum), unused
- Purple - GPIO1 (1.8V, 2.2V maximum), unused
- Connector clip color key
- In PSoC Creator, open the workspace containing the PSoC base firmware project
- Make sure the I2C component libary PSoC_UDB_I2C user dependency is properly installed in Project > Dependencies
- Connect and program the PSoC 6 evaluation board with the PSoC base firmware project
- View debug output using a terminal app
- Open the sketch containing the ESP32 receiver code
- Select Node32s or ESP32 Dev Module for the board
- Connect and program the ESP32
- View results output using the Serial Monitor or another terminal app
Embedded team: Steven Zhang [email protected], Ching-Han Chou [email protected], Haoran Zheng [email protected], Zhaonan Shi [email protected], Thomas Li [email protected].
Device driver for optical sensor (adpd1080) ported over from Arduino script written by Osama Elgabori [email protected].
This repo forked from Steven Zhang's personal repo.
Miro Samek, Programming embedded systems: Foreground-background architecture (“superloop”)
Harigovind A and Rakshith M B, Securing UART communication interface in embedded IoT devices - EDN
PDL API Reference - PSoC 6 Peripheral Driver Library