New 4-Layer Board with USB; Update gitignore; Change Speed Table Comment;
This commit is contained in:
1 parent
d417235df5
commit
9240e5b1a7
33 files changed
+42809
-62833
No files matched your search
@@ -15,14 +15,14 @@ float measure(uint8_t total_iterations,
|
||||
uint8_t measurement_delay_us,
|
||||
uint8_t l_side_arr_cutoff,
|
||||
uint8_t r_side_arr_cutoff,
|
||||
bool direction) {
|
||||
bool direction){
|
||||
uint32_t sum = 0;
|
||||
uint16_t adc_val[total_iterations];
|
||||
int32_t j = 0;
|
||||
uint16_t key;
|
||||
pwm_set_gpio_level(MOTOR_FWD_PIN, 0);
|
||||
pwm_set_gpio_level(MOTOR_REV_PIN, 0);
|
||||
adc_select_input((!direction) + 2);
|
||||
adc_select_input((!direction)+2);
|
||||
busy_wait_us(measurement_delay_us);
|
||||
adc_run(true);
|
||||
for (int32_t i = 0; i < total_iterations; ++i) {
|
||||
@@ -39,32 +39,32 @@ float measure(uint8_t total_iterations,
|
||||
adc_run(false);
|
||||
//discard x entries beginning from the lowest entry of the array (counting up); x = msr.l_side_arr_cutoff
|
||||
//discard y entries beginning from the highest index of the array (counting down); y = msr.r_side_arr_cutoff
|
||||
for (int32_t i = l_side_arr_cutoff; i < total_iterations - r_side_arr_cutoff; ++i) {
|
||||
for (int32_t i = l_side_arr_cutoff; i < total_iterations - r_side_arr_cutoff ; ++i) {
|
||||
sum += adc_val[i];
|
||||
}
|
||||
float res = (float) sum / (float) (total_iterations - (l_side_arr_cutoff + r_side_arr_cutoff));
|
||||
float res = (float)sum / (float)( total_iterations - (l_side_arr_cutoff + r_side_arr_cutoff) );
|
||||
// return true to keep the repeating timer active
|
||||
return res;
|
||||
}
|
||||
|
||||
// retrieve 4Bytes from CV_ARRAY_FLASH at once and return 32-Bit value
|
||||
uint32_t get_32bit_CV(uint16_t CV_start_index) {
|
||||
uint32_t get_32bit_CV (uint16_t CV_start_index){
|
||||
uint8_t byte_3 = CV_ARRAY_FLASH[CV_start_index];
|
||||
uint8_t byte_2 = CV_ARRAY_FLASH[CV_start_index + 1];
|
||||
uint8_t byte_1 = CV_ARRAY_FLASH[CV_start_index + 2];
|
||||
uint8_t byte_0 = CV_ARRAY_FLASH[CV_start_index + 3];
|
||||
return (byte_0) + (byte_1 << 8) + (byte_2 << 16) + (byte_3 << 24);
|
||||
uint8_t byte_2 = CV_ARRAY_FLASH[CV_start_index+1];
|
||||
uint8_t byte_1 = CV_ARRAY_FLASH[CV_start_index+2];
|
||||
uint8_t byte_0 = CV_ARRAY_FLASH[CV_start_index+3];
|
||||
return (byte_0) + (byte_1<<8) + (byte_2<<16) + (byte_3<<24);
|
||||
}
|
||||
|
||||
|
||||
// retrieve 2Bytes from CV_ARRAY_FLASH at once and return 16-Bit value
|
||||
uint16_t get_16bit_CV(uint16_t CV_start_index) {
|
||||
uint16_t get_16bit_CV (uint16_t CV_start_index){
|
||||
uint8_t byte_1 = CV_ARRAY_FLASH[CV_start_index];
|
||||
uint8_t byte_0 = CV_ARRAY_FLASH[CV_start_index + 1];
|
||||
return (byte_0) + (byte_1 << 8);
|
||||
uint8_t byte_0 = CV_ARRAY_FLASH[CV_start_index+1];
|
||||
return (byte_0) + (byte_1<<8);
|
||||
}
|
||||
|
||||
bool get_direction_of_speed_step(uint8_t speed_step) {
|
||||
bool get_direction_of_speed_step(uint8_t speed_step){
|
||||
// Shift by 7 Bytes to move bit7 into bit0 position and return
|
||||
return speed_step >> 7;
|
||||
}
|
||||
Reference in new issue
Block a user