| software:firmware
    MakAir Firmware | 
Mass Flow meter management. More...
#include "../includes/mass_flow_meter.h"#include <Arduino.h>#include <HardwareSerial.h>#include <IWatchdog.h>#include <OneButton.h>#include <Wire.h>#include <math.h>#include "../includes/buzzer_control.h"#include "../includes/config.h"#include "../includes/parameters.h"#include "../includes/screen.h"Go to the source code of this file.
| Macros | |
| #define | MASS_FLOW_TIMER_FREQ 10000 | 
| #define | MASS_FLOW_PERIOD 100 | 
| #define | MFM_MEAN_SAMPLES 40 | 
| #define | MFM_WAIT_RESET_PERIODS 13 | 
| #define | MFM_WAIT_WARMUP_PERIODS 8 | 
| #define | MFM_WAIT_SOFTRESET_PERIODS 3 | 
| #define | MFM_WAIT_READSERIALR1_PERIODS 1 | 
| Functions | |
| void | MFM_Timer_Callback (HardwareTimer *) | 
| bool | MFM_init (void) | 
| Initialize Mass Flow Meter.  More... | |
| int32_t | MFM_read_airflow (void) | 
| Read instant air flow.  More... | |
| int32_t | MFM_expi_read_airflow (void) | 
| Read instant air flow.  More... | |
| void | MFM_reset (void) | 
| Reset the volume counter.  More... | |
| void | MFM_expi_reset (void) | 
| uint32_t | MFM_read_serial_number (void) | 
| Get the serial number of the inspiratory flow meter.  More... | |
| uint32_t | MFM_expi_read_serial_number (void) | 
| return the serial number of the expiratory flow meter  More... | |
| int8_t | MFM_calibrateZero (void) | 
| If the massflow meter needs to be calibrated, this function will be usefull.  More... | |
| int32_t | MFM_getOffset (void) | 
| Get massflow meter offset.  More... | |
| int32_t | MFM_read_milliliters (bool reset_after_read) | 
| Get the number of milliliters since last reset.  More... | |
| int32_t | MFM_expi_read_milliliters (bool reset_after_read) | 
| Get the number of milliliters since last reset for expiratory sensor.  More... | |
Mass Flow meter management.
SFM3300-D sensirion mass flow meter is connected on I2C bus. To perform the integral of the mass flow, I2C polling must be done in a high priority timer.
Definition in file mass_flow_meter.cpp.
| #define MASS_FLOW_PERIOD 100 | 
Definition at line 42 of file mass_flow_meter.cpp.
| #define MASS_FLOW_TIMER_FREQ 10000 | 
Definition at line 39 of file mass_flow_meter.cpp.
| #define MFM_MEAN_SAMPLES 40 | 
Definition at line 66 of file mass_flow_meter.cpp.
| #define MFM_WAIT_READSERIALR1_PERIODS 1 | 
Definition at line 83 of file mass_flow_meter.cpp.
| #define MFM_WAIT_RESET_PERIODS 13 | 
Definition at line 80 of file mass_flow_meter.cpp.
| #define MFM_WAIT_SOFTRESET_PERIODS 3 | 
Definition at line 82 of file mass_flow_meter.cpp.
| #define MFM_WAIT_WARMUP_PERIODS 8 | 
Definition at line 81 of file mass_flow_meter.cpp.
| int8_t MFM_calibrateZero | ( | void | ) | 
If the massflow meter needs to be calibrated, this function will be usefull.
Calibrate the zero of the sensor.
Definition at line 604 of file mass_flow_meter.cpp.
| int32_t MFM_expi_read_airflow | ( | void | ) | 
Read instant air flow.
Definition at line 566 of file mass_flow_meter.cpp.
| int32_t MFM_expi_read_milliliters | ( | bool | reset_after_read | ) | 
Get the number of milliliters since last reset for expiratory sensor.
| reset_after_read | If true, performs the volume reset in the same atomic operation | 
Definition at line 654 of file mass_flow_meter.cpp.
| uint32_t MFM_expi_read_serial_number | ( | void | ) | 
return the serial number of the expiratory flow meter
Get the serial number of the expiratory flow meter.
Definition at line 597 of file mass_flow_meter.cpp.
| void MFM_expi_reset | ( | void | ) | 
Definition at line 578 of file mass_flow_meter.cpp.
| int32_t MFM_getOffset | ( | void | ) | 
| bool MFM_init | ( | void | ) | 
Initialize Mass Flow Meter.
Definition at line 321 of file mass_flow_meter.cpp.
| int32_t MFM_read_airflow | ( | void | ) | 
Read instant air flow.
Definition at line 555 of file mass_flow_meter.cpp.
| int32_t MFM_read_milliliters | ( | bool | reset_after_read | ) | 
Get the number of milliliters since last reset.
| reset_after_read | If true, performs the volume reset in the same atomic operation | 
Definition at line 637 of file mass_flow_meter.cpp.
| uint32_t MFM_read_serial_number | ( | void | ) | 
Get the serial number of the inspiratory flow meter.
0 if before init or if init failed Definition at line 581 of file mass_flow_meter.cpp.
| void MFM_reset | ( | void | ) | 
| void MFM_Timer_Callback | ( | HardwareTimer * | ) | 
Definition at line 102 of file mass_flow_meter.cpp.
| unsigned char c[2] | 
Definition at line 93 of file mass_flow_meter.cpp.
| uint16_t i | 
Definition at line 91 of file mass_flow_meter.cpp.
| HardwareTimer* massFlowTimer = NULL | 
Definition at line 48 of file mass_flow_meter.cpp.
| volatile uint16_t MFM_force_release_I2C = MFM_FORCE_RELEASE_I2C_FALSE | 
Definition at line 32 of file mass_flow_meter.cpp.
| volatile int32_t mfmExpiratoryAirVolumeSumMilliliters = 0 | 
Definition at line 61 of file mass_flow_meter.cpp.
| volatile int32_t mfmExpiratoryCalibrationOffset = 0 | 
Definition at line 60 of file mass_flow_meter.cpp.
| volatile int32_t mfmExpiratoryInstantAirFlow = 0 | 
Definition at line 63 of file mass_flow_meter.cpp.
| volatile int32_t mfmExpiratoryLastValueFixedFloat = 0 | 
Definition at line 75 of file mass_flow_meter.cpp.
| volatile int32_t mfmExpiratorySensorDetected = 0 | 
Definition at line 62 of file mass_flow_meter.cpp.
| uint16_t mfmExpiSFM3300FailCounter = 0 | 
Definition at line 87 of file mass_flow_meter.cpp.
| volatile bool mfmFaultCondition = false | 
Definition at line 50 of file mass_flow_meter.cpp.
| uint32_t mfmHoneywellHafSerialNumber = 0 | 
Definition at line 44 of file mass_flow_meter.cpp.
| volatile int32_t mfmInspiratoryAirVolumeSumMilliliters = 0 | 
Definition at line 56 of file mass_flow_meter.cpp.
| volatile int32_t mfmInspiratoryCalibrationOffset = 0 | 
Definition at line 55 of file mass_flow_meter.cpp.
| volatile int32_t mfmInspiratoryInstantAirFlow = 0 | 
Definition at line 58 of file mass_flow_meter.cpp.
| volatile int32_t mfmInspiratoryInstantAirFlowLastValues[MFM_MEAN_SAMPLES] | 
Definition at line 68 of file mass_flow_meter.cpp.
| volatile int16_t mfmInspiratoryInstantAirFlowLastValuesIndex = 0 | 
Definition at line 70 of file mass_flow_meter.cpp.
| volatile bool mfmInspiratoryInstantAirFlowRecord = false | 
Definition at line 67 of file mass_flow_meter.cpp.
| int32_t mfmInspiratoryLastValue = 0 | 
Definition at line 72 of file mass_flow_meter.cpp.
| volatile int32_t mfmInspiratoryLastValueFixedFloat = 0 | 
Definition at line 73 of file mass_flow_meter.cpp.
| volatile int32_t mfmInspiratorySensorDetected = 0 | 
Definition at line 57 of file mass_flow_meter.cpp.
| union { ... } mfmLastData | 
| int32_t mfmResetStateMachine = MFM_WAIT_RESET_PERIODS | 
Definition at line 85 of file mass_flow_meter.cpp.
| uint32_t mfmSfm3019SerialNumber = 0 | 
Definition at line 47 of file mass_flow_meter.cpp.
| uint32_t mfmSfm3300SerialNumberExpi = 0 | 
Definition at line 46 of file mass_flow_meter.cpp.
| int16_t si | 
Definition at line 92 of file mass_flow_meter.cpp.