5#include "33BLE_digitalWriteFast.hpp"
6using namespace nano33BLE_digitalWriteFast;
9constexpr int ENABLE = 7;
10constexpr int ENABLE_MD_A = 2;
11constexpr int ENABLE_MD_B = 3;
15 constexpr int MISO = 12;
16 constexpr int MOSI = 11;
17 constexpr int SCK = 13;
19constexpr int SS_MD_A = 15;
20constexpr int SS_MD_B = 6;
21constexpr int SS_INC_ENC = 20;
22constexpr int SS_ABS_ENC = 1;
23constexpr int SS_ADC_A = 21;
24constexpr int SS_ADC_B = 10;
26constexpr int SS_MD_SS_A0 = 16;
27constexpr int SS_MD_SS_A1 = 17;
28constexpr int SS_MD_SS_A2 = 18;
29constexpr int SS_MD_SS_A3 = 19;
30constexpr int SS_MD_SS_B0 = 4;
31constexpr int SS_MD_SS_B1 = 5;
32constexpr int SS_MD_SS_B2 = 8;
33constexpr int SS_MD_SS_B3 = 9;
36constexpr int SPI_FREQ = 4000000;
37constexpr int ADC_SPI_FREQ = 1000000;
40constexpr int DC_MOTOR_NUM = 8;
41constexpr int INC_ENC_NUM = 8;
42constexpr int ABS_ENC_NUM = 8;
43constexpr int SOL_SUB_NUM = 4;
46constexpr int DC_MOTOR_BYTES = 2;
47constexpr int INC_ENC_BYTES = 4;
48constexpr int ABS_ENC_BYTES = 2;
51constexpr int DUTY_SPI_MAX = 32766;
54constexpr float CURRENT_MAX = 30.0;
56constexpr float CURRENT_RES = 2048;
59constexpr float ABS_ENC_MAX = 16383;
61constexpr int ABS_ENC_ERR_RP2040 = 0x7fff;
63constexpr int ABS_ENC_ERR = 0xffff;
66constexpr int INC_ENC_RESET = 0;
69constexpr float SOL_TIME_MIN = 10.0;
71constexpr int MICROS_MAX = 0xffffffff;
79 static void begin(
bool use_B =
false);
87 static void put(uint8_t num, int16_t duty, uint16_t duty_max = 1000);
91 static int16_t get(uint8_t num);
94 static void send(
void);
98 static void print(
bool new_line =
false);
103 static int16_t buf[(DC_MOTOR_NUM+SOL_SUB_NUM)*2];
116 static void begin(
bool use_B =
false);
120 static void put(uint8_t num,
bool state);
123 static int8_t get(uint8_t num);
126 static void print(
bool new_line =
false);
130 static unsigned long time_prev[SOL_SUB_NUM*2];
139 static void begin(
void);
143 static int32_t get(uint8_t num);
147 static int16_t get_diff(uint8_t num);
150 static void receive(
void);
153 static void reset(
void);
156 static void print(
bool new_line =
false);
159 static void print_diff(
bool new_line =
false);
163 static uint8_t buf[INC_ENC_NUM*INC_ENC_BYTES*2];
166 static int32_t val_prev[INC_ENC_NUM];
169 static void save_val(
void);
175 static void begin(
void);
179 static uint16_t get(uint8_t num);
182 static void receive(
void);
185 static void print(
bool new_line =
false);
189 static uint8_t buf[ABS_ENC_NUM*ABS_ENC_BYTES];
192 static bool parity_check(uint16_t);
195 static uint16_t remove_parity_bit(uint16_t);
201 static void begin(
void);
204 static float get(uint8_t num);
207 static void receive(
void);
210 static void print(
bool new_line =
false);
214 static float buf[DC_MOTOR_NUM];
217 static const uint8_t ch[DC_MOTOR_NUM];
220 static float bias[DC_MOTOR_NUM];
223 static float buf_prev[DC_MOTOR_NUM];
233 static void begin(
bool use_B =
false,
float current_limit = 2.0);
236 static void update(
unsigned int us = 4000);
240 static unsigned long time_prev;
243 static float _current_limit;
Definition cubic_arduino.h:172
Definition cubic_arduino.h:198
Definition cubic_arduino.h:226
static void begin(bool use_B=false, float current_limit=2.0)
Definition cubic_arduino.cpp:376
Definition cubic_arduino.h:73
static void put(uint8_t num, int16_t duty, uint16_t duty_max=1000)
Definition cubic_arduino.cpp:57
static void begin(bool use_B=false)
Definition cubic_arduino.cpp:23
Definition cubic_arduino.h:136
Definition cubic_arduino.h:110
static void begin(bool use_B=false)
Definition cubic_arduino.cpp:133