- Updated CMakeLists.txt and board config .h files
- Refactored core0.c to most functions are now static functions. - Introduced new structures (`dcc_packet_t` and `dcc_ring_buffer_t`) for DCC packet data handling and packet detection. - DCC pin interrupt now only does packet detection and no evaluation, evaluation is now done inside the main loop. - Refactor message evaluation logic. - Implemented hard fault handler, now rebooting when hardfault is encountered. - Optimized initialization sequence in main(). - Controller and speed helper functions now run outside the timer interrupts, instead flags are set, which are checked inside the core1 main loop. - Added enumeration for speed steps to improve readability. (However they are yet to be used) - Added various documentation comments. - Added various LOG() messages. - Added python script for generating speed_step typedef definition.
This commit is contained in:
1 parent
acdbf3cffe
commit
d970170795
10 files changed
+847
-300
No files matched your search
+19
-4
@@ -6,9 +6,10 @@
|
||||
|
||||
#include "shared.h"
|
||||
|
||||
// TODO: Implement enum typedef for speed steps, also getter and setter functions checking validity of speed step values.
|
||||
uint8_t speed_step_target = 0;
|
||||
uint8_t speed_step_target_prev = 0;
|
||||
uint32_t error_state = 0;
|
||||
static error_t error_state = 0;
|
||||
|
||||
// Functions in shared.c are accessed by both cores
|
||||
|
||||
@@ -36,13 +37,27 @@ direction_t get_direction_of_speed_step(uint8_t speed_step){
|
||||
|
||||
void set_error(error_t err){
|
||||
error_state |= err;
|
||||
gpio_put(RP2040_DECODER_DEFAULT_LED_PIN, true);
|
||||
#ifdef RP2040_DECODER_DEFAULT_LED_PIN
|
||||
gpio_put(RP2040_DECODER_DEFAULT_LED_PIN, true);
|
||||
#endif
|
||||
}
|
||||
|
||||
void clear_error(error_t err){
|
||||
error_state & (~err);
|
||||
error_state &= (~err);
|
||||
if (error_state == 0){
|
||||
#ifdef RP2040_DECODER_DEFAULT_LED_PIN
|
||||
gpio_put(RP2040_DECODER_DEFAULT_LED_PIN, false);
|
||||
#endif
|
||||
}
|
||||
}
|
||||
|
||||
uint32_t get_error_state(){
|
||||
void clear_all_errors(){
|
||||
error_state = 0;
|
||||
#ifdef RP2040_DECODER_DEFAULT_LED_PIN
|
||||
gpio_put(RP2040_DECODER_DEFAULT_LED_PIN, false);
|
||||
#endif
|
||||
}
|
||||
|
||||
error_t get_error_state(){
|
||||
return error_state;
|
||||
}
|
||||
Reference in new issue
Block a user