|
@@ -36,7 +36,9 @@ static samples_t mos_temp1;
|
|
|
#ifdef ACC_V_CHAN
|
|
#ifdef ACC_V_CHAN
|
|
|
static samples_t acc_vol;
|
|
static samples_t acc_vol;
|
|
|
#endif
|
|
#endif
|
|
|
-
|
|
|
|
|
|
|
+#ifdef VBUS_I_CHAN
|
|
|
|
|
+static samples_t _ibus;
|
|
|
|
|
+#endif
|
|
|
void samples_init(void){
|
|
void samples_init(void){
|
|
|
_vbus.filted_value = (CONFIG_RATED_DC_VOL);
|
|
_vbus.filted_value = (CONFIG_RATED_DC_VOL);
|
|
|
_vbus.value = (CONFIG_RATED_DC_VOL);
|
|
_vbus.value = (CONFIG_RATED_DC_VOL);
|
|
@@ -65,20 +67,24 @@ void samples_init(void){
|
|
|
#endif
|
|
#endif
|
|
|
#ifdef MOTOR_TEMP_ADC_CHAN
|
|
#ifdef MOTOR_TEMP_ADC_CHAN
|
|
|
motor_temp.value = motor_temp.filted_value = 0;
|
|
motor_temp.value = motor_temp.filted_value = 0;
|
|
|
- motor_temp.lowpass = 0.01;
|
|
|
|
|
|
|
+ motor_temp.lowpass = 0.01f;
|
|
|
sample_motor_temp();
|
|
sample_motor_temp();
|
|
|
#endif
|
|
#endif
|
|
|
#ifdef MOS_TEMP_ADC_CHAN
|
|
#ifdef MOS_TEMP_ADC_CHAN
|
|
|
mos_temp.value = mos_temp.filted_value = 0;
|
|
mos_temp.value = mos_temp.filted_value = 0;
|
|
|
- mos_temp.lowpass = 0.01;
|
|
|
|
|
|
|
+ mos_temp.lowpass = 0.01f;
|
|
|
sample_mos_temp();
|
|
sample_mos_temp();
|
|
|
#endif
|
|
#endif
|
|
|
#ifdef MOS_TEMP1_ADC_CHAN
|
|
#ifdef MOS_TEMP1_ADC_CHAN
|
|
|
mos_temp1.value = mos_temp1.filted_value = 0;
|
|
mos_temp1.value = mos_temp1.filted_value = 0;
|
|
|
- mos_temp1.lowpass = 0.01;
|
|
|
|
|
|
|
+ mos_temp1.lowpass = 0.01f;
|
|
|
sample_mos_temp();
|
|
sample_mos_temp();
|
|
|
#endif
|
|
#endif
|
|
|
-
|
|
|
|
|
|
|
+#ifdef VBUS_I_CHAN
|
|
|
|
|
+ _ibus.value = _ibus.filted_value = 0;
|
|
|
|
|
+ _ibus.lowpass = 0.01f;
|
|
|
|
|
+ sample_ibus();
|
|
|
|
|
+#endif
|
|
|
shark_task_create(sample_task, NULL);
|
|
shark_task_create(sample_task, NULL);
|
|
|
}
|
|
}
|
|
|
|
|
|
|
@@ -105,6 +111,14 @@ int get_acc_vol(void) {
|
|
|
#endif
|
|
#endif
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
+float get_vbus_current(void) {
|
|
|
|
|
+#ifdef VBUS_I_CHAN
|
|
|
|
|
+ return _ibus.filted_value;
|
|
|
|
|
+#else
|
|
|
|
|
+ return 0;
|
|
|
|
|
+#endif
|
|
|
|
|
+}
|
|
|
|
|
+
|
|
|
s16 get_motor_temp(void) {
|
|
s16 get_motor_temp(void) {
|
|
|
return motor_temp.filted_value;
|
|
return motor_temp.filted_value;
|
|
|
}
|
|
}
|
|
@@ -129,6 +143,7 @@ float get_throttle_float(void) {
|
|
|
}
|
|
}
|
|
|
static u32 sample_task(void *param) {
|
|
static u32 sample_task(void *param) {
|
|
|
sample_vbus();
|
|
sample_vbus();
|
|
|
|
|
+ sample_ibus();
|
|
|
sample_throttle();
|
|
sample_throttle();
|
|
|
sample_uvw_phase();
|
|
sample_uvw_phase();
|
|
|
sample_motor_temp();
|
|
sample_motor_temp();
|
|
@@ -150,6 +165,14 @@ void sample_vbus(void){
|
|
|
#endif
|
|
#endif
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
+void sample_ibus(void) {
|
|
|
|
|
+#ifdef VBUS_I_CHAN
|
|
|
|
|
+ s16 vadc = adc_get_ibus();
|
|
|
|
|
+ _ibus.value = (float)vadc * VBUS_I_CEOF;
|
|
|
|
|
+ LowPass_Filter(_ibus.filted_value, _ibus.value, _ibus.lowpass);
|
|
|
|
|
+#endif
|
|
|
|
|
+}
|
|
|
|
|
+
|
|
|
void sample_throttle(void){
|
|
void sample_throttle(void){
|
|
|
#ifdef THROTTLE_CHAN
|
|
#ifdef THROTTLE_CHAN
|
|
|
s16 vadc = adc_get_throttle();
|
|
s16 vadc = adc_get_throttle();
|