Skip to content

Base device driver layer firmware for ECMO PSoC 6 to collect and transmit sensor data

Notifications You must be signed in to change notification settings

biorobotics/ecmo_psoc6_ws

 
 

Repository files navigation

Base device driver layer firmware for ECMO PSoC 6

Description

Overview

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.

Features

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

TODOs

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.

Getting Started

Hardware required

  • 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

PSoC Creator

Arduino IDE

Credits

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.

References

Miro Samek, Programming embedded systems: Foreground-background architecture (“superloop”)

Harigovind A and Rakshith M B, Securing UART communication interface in embedded IoT devices - EDN

APIs

PDL API Reference - PSoC 6 Peripheral Driver Library

Arduino Cryptography Library: AESCommon Class Reference

Arduino HardwareSerial Library

About

Base device driver layer firmware for ECMO PSoC 6 to collect and transmit sensor data

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • C 47.2%
  • Assembly 31.1%
  • Pawn 14.4%
  • OpenEdge ABL 2.8%
  • Visual Basic 6.0 2.6%
  • HTML 0.7%
  • Other 1.2%