mirror of
https://github.com/betaflight/betaflight.git
synced 2025-07-23 16:25:31 +03:00
CF/BF - First cut of MSP current sensor.
How it works: 1. Current Meter Source on FC is set to MSP/OSD Slave by user. 2. On reboot FC sends MSP_ANALOG to OSD Slave. 3. OSD Slave listens for incoming MSP as usual. 4. OSD responds to MSP as usual. 6. The FC recevies the data from the OSD Slave and updates the MSP Current Meter.
This commit is contained in:
parent
3e56bb75cf
commit
22147105fb
17 changed files with 166 additions and 15 deletions
|
@ -17,6 +17,7 @@
|
|||
|
||||
#pragma once
|
||||
|
||||
#include "common/time.h"
|
||||
#include "current_ids.h"
|
||||
|
||||
typedef enum {
|
||||
|
@ -24,6 +25,7 @@ typedef enum {
|
|||
CURRENT_METER_ADC,
|
||||
CURRENT_METER_VIRTUAL,
|
||||
CURRENT_METER_ESC,
|
||||
CURRENT_METER_MSP,
|
||||
CURRENT_METER_MAX = CURRENT_METER_ESC
|
||||
} currentMeterSource_e;
|
||||
|
||||
|
@ -48,6 +50,7 @@ typedef enum {
|
|||
CURRENT_SENSOR_VIRTUAL = 0,
|
||||
CURRENT_SENSOR_ADC,
|
||||
CURRENT_SENSOR_ESC,
|
||||
CURRENT_SENSOR_MSP
|
||||
} currentSensor_e;
|
||||
|
||||
|
||||
|
@ -93,6 +96,21 @@ typedef struct currentMeterESCState_s {
|
|||
int32_t amperage; // current read by current sensor in centiampere (1/100th A)
|
||||
} currentMeterESCState_t;
|
||||
|
||||
|
||||
//
|
||||
// MSP
|
||||
//
|
||||
|
||||
typedef struct currentMeterMSPState_s {
|
||||
int32_t mAhDrawn; // milliampere hours drawn from the battery since start
|
||||
int32_t amperage; // current read by current sensor in centiampere (1/100th A)
|
||||
} currentMeterMSPState_t;
|
||||
|
||||
|
||||
//
|
||||
// Current Meter API
|
||||
//
|
||||
|
||||
void currentMeterReset(currentMeter_t *meter);
|
||||
|
||||
void currentMeterADCInit(void);
|
||||
|
@ -108,6 +126,11 @@ void currentMeterESCRefresh(int32_t lastUpdateAt);
|
|||
void currentMeterESCReadCombined(currentMeter_t *meter);
|
||||
void currentMeterESCReadMotor(uint8_t motorNumber, currentMeter_t *meter);
|
||||
|
||||
void currentMeterMSPInit(void);
|
||||
void currentMeterMSPRefresh(timeUs_t currentTimeUs);
|
||||
void currentMeterMSPRead(currentMeter_t *meter);
|
||||
void currentMeterMSPSet(uint16_t amperage, uint16_t mAhDrawn);
|
||||
|
||||
//
|
||||
// API for reading current meters by id.
|
||||
//
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue