mirror of https://github.com/rusefi/bldc.git
Fix shadowed variables. Add -Wshadow.
Signed-off-by: Marcos Chaparro <mchaparro@powerdesigns.ca>
This commit is contained in:
parent
884f626e63
commit
c59dd2b2fc
|
@ -73,7 +73,7 @@ static char *ch_ltoa(char *p, long num, unsigned radix) {
|
|||
}
|
||||
|
||||
#if CHPRINTF_USE_FLOAT
|
||||
static const long pow10[FLOAT_PRECISION] = {
|
||||
static const long ch_pow10[FLOAT_PRECISION] = {
|
||||
10, 100, 1000, 10000, 100000, 1000000, 10000000, 100000000, 1000000000
|
||||
};
|
||||
|
||||
|
@ -82,7 +82,7 @@ static char *ftoa(char *p, double num, unsigned long precision) {
|
|||
|
||||
if ((precision == 0) || (precision > FLOAT_PRECISION))
|
||||
precision = FLOAT_PRECISION;
|
||||
precision = pow10[precision - 1];
|
||||
precision = ch_pow10[precision - 1];
|
||||
|
||||
l = (long)num;
|
||||
p = long_to_string_with_divisor(p, l, 10, 0);
|
||||
|
|
2
Makefile
2
Makefile
|
@ -222,7 +222,7 @@ AOPT =
|
|||
TOPT = -mthumb -DTHUMB
|
||||
|
||||
# Define C warning options here
|
||||
CWARN = -Wall -Wextra -Wundef -Wstrict-prototypes
|
||||
CWARN = -Wall -Wextra -Wundef -Wstrict-prototypes -Wshadow
|
||||
|
||||
# Define C++ warning options here
|
||||
CPPWARN = -Wall -Wextra -Wundef
|
||||
|
|
|
@ -281,13 +281,13 @@ static THD_FUNCTION(ppm_thread, arg) {
|
|||
}
|
||||
|
||||
if (send_current && config.multi_esc) {
|
||||
float current = mc_interface_get_tot_current_directional_filtered();
|
||||
float current_filtered = mc_interface_get_tot_current_directional_filtered();
|
||||
|
||||
for (int i = 0;i < CAN_STATUS_MSGS_TO_STORE;i++) {
|
||||
can_status_msg *msg = comm_can_get_status_msg_index(i);
|
||||
|
||||
if (msg->id >= 0 && UTILS_AGE_S(msg->rx_time) < MAX_CAN_AGE) {
|
||||
comm_can_set_current(msg->id, current);
|
||||
comm_can_set_current(msg->id, current_filtered);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -736,7 +736,7 @@ bool conf_general_measure_flux_linkage(float current, float duty, float erpm_per
|
|||
float vd_avg = 0.0;
|
||||
float iq_avg = 0.0;
|
||||
float id_avg = 0.0;
|
||||
float samples = 0.0;
|
||||
samples = 0.0;
|
||||
|
||||
for (int i = 0;i < 1000;i++) {
|
||||
vq_avg += mcpwm_foc_get_vq();
|
||||
|
|
|
@ -74,8 +74,8 @@ static THD_FUNCTION(led_thread, arg) {
|
|||
for (int i = 0;i < 50;i++) {
|
||||
scale -= 0.02;
|
||||
uint32_t color = scale_color(COLOR_RED, scale);
|
||||
for (int i = 0;i < (int)fault;i++) {
|
||||
set_led_wrapper(i, color);
|
||||
for (int j = 0;j < (int)fault;j++) {
|
||||
set_led_wrapper(j, color);
|
||||
}
|
||||
chThdSleepMilliseconds(10);
|
||||
}
|
||||
|
|
4
main.c
4
main.c
|
@ -176,10 +176,12 @@ static THD_FUNCTION(timer_thread, arg) {
|
|||
}
|
||||
}
|
||||
|
||||
/* When assertions enabled halve PWM frequency. The control loop ISR runs 40% slower */
|
||||
void assert_failed(uint8_t* file, uint32_t line) {
|
||||
commands_printf("Wrong parameters value: file %s on line %d\r\n", file, line);
|
||||
mc_interface_release_motor();
|
||||
while(1)
|
||||
;
|
||||
chThdSleepMilliseconds(1);
|
||||
}
|
||||
|
||||
int main(void) {
|
||||
|
|
32
mcpwm_foc.c
32
mcpwm_foc.c
|
@ -1002,9 +1002,9 @@ void mcpwm_foc_encoder_detect(float current, bool print, float *offset, float *r
|
|||
for (int i = 0; i < it_rat; i++) {
|
||||
float phase_old = m_phase_now_encoder;
|
||||
float phase_ovr_tmp = m_phase_now_override;
|
||||
for (float i = phase_ovr_tmp; i < phase_ovr_tmp + (2.0 / 3.0) * M_PI;
|
||||
i += (2.0 * M_PI) / 500.0) {
|
||||
m_phase_now_override = i;
|
||||
for (float j = phase_ovr_tmp; j < phase_ovr_tmp + (2.0 / 3.0) * M_PI;
|
||||
j += (2.0 * M_PI) / 500.0) {
|
||||
m_phase_now_override = j;
|
||||
chThdSleepMilliseconds(1);
|
||||
}
|
||||
utils_norm_angle_rad((float*)&m_phase_now_override);
|
||||
|
@ -1030,9 +1030,9 @@ void mcpwm_foc_encoder_detect(float current, bool print, float *offset, float *r
|
|||
for (int i = 0; i < it_rat; i++) {
|
||||
float phase_old = m_phase_now_encoder;
|
||||
float phase_ovr_tmp = m_phase_now_override;
|
||||
for (float i = phase_ovr_tmp; i > phase_ovr_tmp - (2.0 / 3.0) * M_PI;
|
||||
i -= (2.0 * M_PI) / 500.0) {
|
||||
m_phase_now_override = i;
|
||||
for (float j = phase_ovr_tmp; j > phase_ovr_tmp - (2.0 / 3.0) * M_PI;
|
||||
j -= (2.0 * M_PI) / 500.0) {
|
||||
m_phase_now_override = j;
|
||||
chThdSleepMilliseconds(1);
|
||||
}
|
||||
utils_norm_angle_rad((float*)&m_phase_now_override);
|
||||
|
@ -1084,14 +1084,14 @@ void mcpwm_foc_encoder_detect(float current, bool print, float *offset, float *r
|
|||
m_phase_now_override = ((float)i * 2.0 * M_PI * m_conf->foc_encoder_ratio) / ((float)it_ofs);
|
||||
chThdSleepMilliseconds(500);
|
||||
|
||||
float diff = utils_angle_difference_rad(m_phase_now_encoder, m_phase_now_override);
|
||||
float angle_diff = utils_angle_difference_rad(m_phase_now_encoder, m_phase_now_override);
|
||||
float s, c;
|
||||
sincosf(diff, &s, &c);
|
||||
sincosf(angle_diff, &s, &c);
|
||||
s_sum += s;
|
||||
c_sum += c;
|
||||
|
||||
if (print) {
|
||||
commands_printf("%.2f", (double)(diff * 180.0 / M_PI));
|
||||
commands_printf("%.2f", (double)(angle_diff * 180.0 / M_PI));
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1099,14 +1099,14 @@ void mcpwm_foc_encoder_detect(float current, bool print, float *offset, float *r
|
|||
m_phase_now_override = ((float)i * 2.0 * M_PI * m_conf->foc_encoder_ratio) / ((float)it_ofs);
|
||||
chThdSleepMilliseconds(500);
|
||||
|
||||
float diff = utils_angle_difference_rad(m_phase_now_encoder, m_phase_now_override);
|
||||
float angle_diff = utils_angle_difference_rad(m_phase_now_encoder, m_phase_now_override);
|
||||
float s, c;
|
||||
sincosf(diff, &s, &c);
|
||||
sincosf(angle_diff, &s, &c);
|
||||
s_sum += s;
|
||||
c_sum += c;
|
||||
|
||||
if (print) {
|
||||
commands_printf("%.2f", (double)(diff * 180.0 / M_PI));
|
||||
commands_printf("%.2f", (double)(angle_diff * 180.0 / M_PI));
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1376,8 +1376,8 @@ bool mcpwm_foc_hall_detect(float current, uint8_t *hall_table) {
|
|||
|
||||
// Forwards
|
||||
for (int i = 0;i < 3;i++) {
|
||||
for (int i = 0;i < 360;i++) {
|
||||
m_phase_now_override = (float)i * M_PI / 180.0;
|
||||
for (int j = 0;j < 360;j++) {
|
||||
m_phase_now_override = (float)j * M_PI / 180.0;
|
||||
chThdSleepMilliseconds(5);
|
||||
|
||||
int hall = read_hall();
|
||||
|
@ -1391,8 +1391,8 @@ bool mcpwm_foc_hall_detect(float current, uint8_t *hall_table) {
|
|||
|
||||
// Reverse
|
||||
for (int i = 0;i < 3;i++) {
|
||||
for (int i = 360;i >= 0;i--) {
|
||||
m_phase_now_override = (float)i * M_PI / 180.0;
|
||||
for (int j = 360;j >= 0;j--) {
|
||||
m_phase_now_override = (float)j * M_PI / 180.0;
|
||||
chThdSleepMilliseconds(5);
|
||||
|
||||
int hall = read_hall();
|
||||
|
|
Loading…
Reference in New Issue