mirror of https://github.com/rusefi/bldc.git
App adc button bitfield and cc disable support
This commit is contained in:
parent
73194ea4d2
commit
35d2dfcff2
|
@ -21,6 +21,7 @@
|
|||
* AS5x47 encoder support: https://github.com/vedderb/bldc/pull/511
|
||||
* Disable BMS limit options.
|
||||
* Added PT1000 temperature sensor support.
|
||||
* APP ADC button bitfield and CC disable support.
|
||||
|
||||
=== FW 5.03 ===
|
||||
* Fixed inductance measurement bug.
|
||||
|
|
|
@ -259,11 +259,11 @@ static THD_FUNCTION(adc_thread, arg) {
|
|||
bool rev_button = false;
|
||||
if (use_rx_tx_as_buttons) {
|
||||
cc_button = !palReadPad(HW_UART_TX_PORT, HW_UART_TX_PIN);
|
||||
if (config.cc_button_inverted) {
|
||||
if ((config.buttons >> 1) & 1) {
|
||||
cc_button = !cc_button;
|
||||
}
|
||||
rev_button = !palReadPad(HW_UART_RX_PORT, HW_UART_RX_PIN);
|
||||
if (config.rev_button_inverted) {
|
||||
if ((config.buttons >> 2) & 1) {
|
||||
rev_button = !rev_button;
|
||||
}
|
||||
} else {
|
||||
|
@ -274,29 +274,33 @@ static THD_FUNCTION(adc_thread, arg) {
|
|||
config.ctrl_type == ADC_CTRL_TYPE_DUTY_REV_BUTTON ||
|
||||
config.ctrl_type == ADC_CTRL_TYPE_PID_REV_BUTTON) {
|
||||
rev_button = !palReadPad(HW_ICU_GPIO, HW_ICU_PIN);
|
||||
if (config.rev_button_inverted) {
|
||||
if ((config.buttons >> 2) & 1) {
|
||||
rev_button = !rev_button;
|
||||
}
|
||||
} else {
|
||||
cc_button = !palReadPad(HW_ICU_GPIO, HW_ICU_PIN);
|
||||
if (config.cc_button_inverted) {
|
||||
if ((config.buttons >> 1) & 1) {
|
||||
cc_button = !cc_button;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Override button values, when used from LISP
|
||||
if(buttons_detached){
|
||||
if (buttons_detached) {
|
||||
cc_button = cc_override;
|
||||
rev_button = rev_override;
|
||||
if (config.cc_button_inverted) {
|
||||
if ((config.buttons >> 1) & 1) {
|
||||
cc_button = !cc_button;
|
||||
}
|
||||
if (config.cc_button_inverted) {
|
||||
cc_button = !cc_button;
|
||||
if ((config.buttons >> 2) & 1) {
|
||||
rev_button = !rev_button;
|
||||
}
|
||||
}
|
||||
|
||||
if (!((config.buttons >> 0) & 1)) {
|
||||
cc_button = false;
|
||||
}
|
||||
|
||||
// All pins and buttons are still decoded for debugging, even
|
||||
// when output is disabled.
|
||||
if (app_is_output_disabled()) {
|
||||
|
|
|
@ -176,6 +176,9 @@
|
|||
#ifndef APPCONF_ADC_SAFE_START
|
||||
#define APPCONF_ADC_SAFE_START true
|
||||
#endif
|
||||
#ifndef APPCONF_ADC_BUTTONS
|
||||
#define APPCONF_ADC_BUTTONS 0
|
||||
#endif
|
||||
#ifndef APPCONF_ADC_CC_BUTTON_INVERTED
|
||||
#define APPCONF_ADC_CC_BUTTON_INVERTED false
|
||||
#endif
|
||||
|
|
|
@ -24,7 +24,7 @@
|
|||
#define FW_VERSION_MAJOR 6
|
||||
#define FW_VERSION_MINOR 00
|
||||
// Set to 0 for building a release and iterate during beta test builds
|
||||
#define FW_TEST_VERSION_NUMBER 61
|
||||
#define FW_TEST_VERSION_NUMBER 62
|
||||
|
||||
#include "datatypes.h"
|
||||
|
||||
|
|
|
@ -255,8 +255,7 @@ int32_t confgenerator_serialize_appconf(uint8_t *buffer, const app_configuration
|
|||
buffer_append_float16(buffer, conf->app_adc_conf.voltage2_end, 1000, &ind);
|
||||
buffer[ind++] = conf->app_adc_conf.use_filter;
|
||||
buffer[ind++] = conf->app_adc_conf.safe_start;
|
||||
buffer[ind++] = conf->app_adc_conf.cc_button_inverted;
|
||||
buffer[ind++] = conf->app_adc_conf.rev_button_inverted;
|
||||
buffer[ind++] = conf->app_adc_conf.buttons;
|
||||
buffer[ind++] = conf->app_adc_conf.voltage_inverted;
|
||||
buffer[ind++] = conf->app_adc_conf.voltage2_inverted;
|
||||
buffer_append_float32_auto(buffer, conf->app_adc_conf.throttle_exp, &ind);
|
||||
|
@ -650,8 +649,7 @@ bool confgenerator_deserialize_appconf(const uint8_t *buffer, app_configuration
|
|||
conf->app_adc_conf.voltage2_end = buffer_get_float16(buffer, 1000, &ind);
|
||||
conf->app_adc_conf.use_filter = buffer[ind++];
|
||||
conf->app_adc_conf.safe_start = buffer[ind++];
|
||||
conf->app_adc_conf.cc_button_inverted = buffer[ind++];
|
||||
conf->app_adc_conf.rev_button_inverted = buffer[ind++];
|
||||
conf->app_adc_conf.buttons = buffer[ind++];
|
||||
conf->app_adc_conf.voltage_inverted = buffer[ind++];
|
||||
conf->app_adc_conf.voltage2_inverted = buffer[ind++];
|
||||
conf->app_adc_conf.throttle_exp = buffer_get_float32_auto(buffer, &ind);
|
||||
|
@ -1029,8 +1027,7 @@ void confgenerator_set_defaults_appconf(app_configuration *conf) {
|
|||
conf->app_adc_conf.voltage2_end = APPCONF_ADC_VOLTAGE2_END;
|
||||
conf->app_adc_conf.use_filter = APPCONF_ADC_USE_FILTER;
|
||||
conf->app_adc_conf.safe_start = APPCONF_ADC_SAFE_START;
|
||||
conf->app_adc_conf.cc_button_inverted = APPCONF_ADC_CC_BUTTON_INVERTED;
|
||||
conf->app_adc_conf.rev_button_inverted = APPCONF_ADC_REV_BUTTON_INVERTED;
|
||||
conf->app_adc_conf.buttons = APPCONF_ADC_BUTTONS;
|
||||
conf->app_adc_conf.voltage_inverted = APPCONF_ADC_VOLTAGE_INVERTED;
|
||||
conf->app_adc_conf.voltage2_inverted = APPCONF_ADC_VOLTAGE2_INVERTED;
|
||||
conf->app_adc_conf.throttle_exp = APPCONF_ADC_THROTTLE_EXP;
|
||||
|
|
|
@ -9,7 +9,7 @@
|
|||
|
||||
// Constants
|
||||
#define MCCONF_SIGNATURE 1990552441
|
||||
#define APPCONF_SIGNATURE 3494444161
|
||||
#define APPCONF_SIGNATURE 372136320
|
||||
|
||||
// Functions
|
||||
int32_t confgenerator_serialize_mcconf(uint8_t *buffer, const mc_configuration *conf);
|
||||
|
|
|
@ -644,8 +644,7 @@ typedef struct {
|
|||
float voltage2_end;
|
||||
bool use_filter;
|
||||
SAFE_START_MODE safe_start;
|
||||
bool cc_button_inverted;
|
||||
bool rev_button_inverted;
|
||||
uint8_t buttons;
|
||||
bool voltage_inverted;
|
||||
bool voltage2_inverted;
|
||||
float throttle_exp;
|
||||
|
|
Loading…
Reference in New Issue