more debug printfs, disabled function usage of gpio0/1, disabled usb interface to save some 25kb in the firmware image

This commit is contained in:
questor/Inter committed 2023-05-08 22:50:19 +02:00
1 parent 23b69d6823
commit 995dca15c8
4 files changed
+43 -14

No files matched your search

+21 -5
View File
@@ -16,14 +16,18 @@ void update_speed_dir(pid_params *pid, uint32_t speed_step_target){
// Forward
if(speed_step_target > 127) {
pid->direction = true^reverse_dir;
if (pid->speed_step_target == 128) pid->end_target_index = 0;
else pid->end_target_index = (pid->speed_step_target-129);
if (pid->speed_step_target == 128)
pid->end_target_index = 0;
else
pid->end_target_index = (pid->speed_step_target-129);
}
// Reverse
else {
pid->direction = false^reverse_dir;
if (pid->speed_step_target == 0) pid->end_target_index = 0;
else pid->end_target_index = (pid->speed_step_target-1);
if (pid->speed_step_target == 0)
pid->end_target_index = 0;
else
pid->end_target_index = (pid->speed_step_target-1);
}
}
@@ -192,6 +196,15 @@ bool pid_control(struct repeating_timer *t){
if (output < 0 || !pid->setpoint) output = 0.0f;
else if (output > pid->max_output) output = pid->max_output;
if(LOGLEVEL >= 1) {
static int counter = 0;
counter++;
if(counter > 100) {
LOG(1, "pid error(%f) output(%f)\n", e, output);
counter = 0;
}
}
// Set PWM Level and discard results in adc fifo
adjust_pwm_level((uint16_t)roundf(output),pid);
adc_fifo_drain();
@@ -226,6 +239,9 @@ void init_pid(pid_params *pid){
double v_min = (double)CV_ARRAY_FLASH[1];
double v_mid = (double)CV_ARRAY_FLASH[5]*16;
double v_max = (double)CV_ARRAY_FLASH[4]*16;
LOG(1, "speedtable min(%f) mid(%f) max(%f)\n", v_min, v_mid, v_max);
double delta_x = 63;
double m_1 = (v_mid-v_min)/delta_x;
double m_2 = (v_max-v_mid)/delta_x;
@@ -305,7 +321,7 @@ void core1_entry() {
multicore_fifo_push_blocking((uint32_t) &(pid->direction));
uint64_t packet_timeout_threshold_in_us = CV_ARRAY_FLASH[10]*1000000;
absolute_time_t time_last_update = get_absolute_time();
printf("core1 done\n");
// printf("core1 done\n");
while (1){
// Check for time difference between last packet and current time (Packet Timeout)
absolute_time_t current_time = get_absolute_time();