- added shared.c file containing functions that can be accessed from both cores

- revised CV programming especially writing
- Core 1 is only started when valid package with correct address is received
- Extended addresses are now correctly verified and implemented
- Base PWM measurement is now done on core0 and checked for automatically in cv_setup_check()
- Moved Motor PWM, GPIO, ADC to core0
- Implemented inverted direction mode (CV_29) according to DCC-Standards
- Limited feed-forward parameters y_2 to max_output/y_1
- k_p gain slopes are now calculated on initialization
- k_p gain parameters are also in pid parameter struct now
- Revised init_pid()
- Implemented Packet timeout check (CV_11)
- 16Bit and 32Bit CVs now always have the highest bytes as the lowest array index to accommodate get_XXbit_CV() functions
This commit is contained in:
1nct committed 2022-08-01 17:20:05 +02:00
1 parent f09c4ff136
commit fd017ea685
8 files changed
+820 -601

No files matched your search

+10 -8
View File
@@ -7,7 +7,6 @@
#pragma once
#include "shared.h"
#include "CV.h"
#include "pico/float.h"
#define SIZE_BYTE_ARRAY 5
#define PACKAGE_3_BYTES 0b11111111110000000000000000000000000001
#define PACKAGE_MASK_3_BYTES 0b11111111111000000001000000001000000001
@@ -23,15 +22,15 @@ const uint32_t clr_bit_arr[6] = {
0b11100000000111111111111111111111, // Clear Bits 21-28 (F21-F28)
0b00011111111111111111111111111111, // Clear Bits 29-31 (F29-F31)
};
uint16_t two_sigma(const uint16_t arr[], uint8_t length);
void adc_offset_adjustment(uint8_t length);
float two_std_dev(const float arr[], uint32_t length);
void adc_offset_adjustment(uint32_t length);
void acknowledge();
void verify_cv_bit(uint16_t cv_address,bool bit_val, uint8_t bit_pos);
void verify_cv_byte(uint16_t cv_address, uint8_t cv_data);
void write_cv_byte(uint16_t cv_index, uint8_t cv_data);
void program_mode(uint8_t number_of_bytes, const uint8_t byte_array[]);
uint32_t get_32bit_CV (uint16_t CV_start_index);
uint16_t get_16bit_CV (uint16_t CV_start_index);
void regular_cv_write(uint16_t cv_index, uint8_t cv_data);
void write_cv_handler(uint16_t cv_index, uint8_t cv_data);
void program_mode(uint8_t number_of_bytes, const uint8_t byte_array[], bool restart_core1);
void set_outputs(uint32_t functions_to_set_bitmask);
void update_active_functions(uint32_t byte, uint8_t clr_bit_ind,bool direction_change);
bool error_detection(int8_t number_of_bytes, const uint8_t byte_array[]);
@@ -45,5 +44,8 @@ void evaluation();
void track_signal_rise(unsigned int gpio, long unsigned int events);
void track_signal_fall(unsigned int gpio, long unsigned int events);
void init_outputs();
uint16_t measure_base_pwm(bool direction, uint8_t iterations);
void cv_setup_check();
bool get_direction(bool *direction_ptr);
bool get_direction(bool *direction_ptr);
void init_motor_pwm(uint8_t gpio);
void init_main();