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"
17#include "hardware/gpio.h"
29#define LOG(level, ...) { if(level <= LOGLEVEL) {printf(__VA_ARGS__);}}
32#define _125M 125000000
35#define DCC_INPUT_PIN 21u
36#define MOTOR_FWD_PIN 23u
37#define MOTOR_REV_PIN 22u
38#define FWD_V_EMF_ADC_PIN 28u
39#define REV_V_EMF_ADC_PIN 29u
44 #define GPIO_OUTPUT_PIN_MASK (1u<<24) | (1u<<25) | (1u<<26) | (1u<<27) | (1u<<5) | (1u<<4) | (1u<<3) | (1u<<2)
47 #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)
51#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)
54#define GPIO_ALLOWED_OUTPUTS (GPIO_OUTPUT_PIN_MASK) & ~(GPIO_ILLEGAL_MASK)
57#define FLASH_TARGET_OFFSET (PICO_FLASH_SIZE_BYTES-FLASH_SECTOR_SIZE)
59extern repeating_timer_t pid_control_timer;
60extern repeating_timer_t speed_helper_timer;
61extern const uint8_t *CV_ARRAY_FLASH;
62extern uint8_t speed_step_target;
63extern uint8_t speed_step_target_prev;
67void write_cv_handler(uint16_t cv_index, uint8_t cv_data);
68float measure(uint8_t total_iterations,
69 uint8_t measurement_delay_us,
70 uint8_t l_side_arr_cutoff,
71 uint8_t r_side_arr_cutoff,
73uint32_t get_32bit_CV (uint16_t CV_start_index);
74uint16_t get_16bit_CV (uint16_t CV_start_index);
bool get_direction_of_speed_step(uint8_t speed_step)
Calculates the direction based on a speed step byte.
Definition shared.c:67