10#include "pico/float.h"
11#include "pico/stdlib.h"
12#include "pico/multicore.h"
13#include "pico/printf.h"
14#include "hardware/pwm.h"
15#include "hardware/adc.h"
16#include "hardware/flash.h"
28#define LOG(level, ...) { if(level <= LOGLEVEL) {printf(__VA_ARGS__);}}
31#define _125M 125000000
34#define DCC_INPUT_PIN 21u
35#define MOTOR_FWD_PIN 23u
36#define MOTOR_REV_PIN 22u
37#define FWD_V_EMF_ADC_PIN 28u
38#define REV_V_EMF_ADC_PIN 29u
43 #define GPIO_OUTPUT_PIN_MASK (1u<<24) | (1u<<25) | (1u<<26) | (1u<<27) | (1u<<5) | (1u<<4) | (1u<<3) | (1u<<2)
46 #define GPIO_OUTPUT_PIN_MASK (1u<<24) | (1u<<25) | (1u<<26) | (1u<<27) | (1u<<5) | (1u<<4) | (1u<<3) | (1u<<2) | (1u<<1) | (1u<<0)
50#define GPIO_ILLEGAL_MASK (1u<<DCC_INPUT_PIN) | (1u<<MOTOR_FWD_PIN) | (1u<<MOTOR_REV_PIN) | (1u<<FWD_V_EMF_ADC_PIN) | (1u<<REV_V_EMF_ADC_PIN)
53#define GPIO_ALLOWED_OUTPUTS (GPIO_OUTPUT_PIN_MASK) & ~(GPIO_ILLEGAL_MASK)
56#define FLASH_TARGET_OFFSET (PICO_FLASH_SIZE_BYTES-FLASH_SECTOR_SIZE)
58extern repeating_timer_t pid_control_timer;
59extern repeating_timer_t speed_helper_timer;
60extern const uint8_t *CV_ARRAY_FLASH;
61extern uint8_t speed_step_target;
62extern uint8_t speed_step_target_prev;
66void write_cv_handler(uint16_t cv_index, uint8_t cv_data);
67float measure(uint8_t total_iterations,
68 uint8_t measurement_delay_us,
69 uint8_t l_side_arr_cutoff,
70 uint8_t r_side_arr_cutoff,
72uint32_t get_32bit_CV (uint16_t CV_start_index);
73uint16_t get_16bit_CV (uint16_t CV_start_index);
bool get_direction_of_speed_step(uint8_t speed_step)
Get direction Function calculates direction.Direction is based on speed_step byte....
Definition shared.c:67