Fixed printf - works with default UART settings

- still some clean up to do
This commit is contained in:
EmanuelFeru 2020-12-09 20:35:26 +01:00
parent 31f0f915cf
commit d1286e246b
8 changed files with 198 additions and 105 deletions

33
Inc/comms.h Normal file
View File

@ -0,0 +1,33 @@
/*
* This file is part of the hoverboard-firmware-hack project.
*
* Copyright (C) 2017-2018 Rene Hopf <renehopf@mac.com>
* Copyright (C) 2017-2018 Nico Stute <crinq@crinq.de>
* Copyright (C) 2017-2018 Niklas Fauth <niklas.fauth@kit.fail>
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
// Define to prevent recursive inclusion
#ifndef COMMS_H
#define COMMS_H
#include "stm32f1xx_hal.h"
void setScopeChannel(uint8_t ch, int16_t val);
void consoleScope(void);
void consoleLog(char *message);
#endif

View File

@ -34,6 +34,7 @@
#endif
#define TIMEOUT 20 // number of wrong / missing input commands before emergency off
#define A2BIT_CONV 50 // A to bit for current conversion on ADC. Example: 1 A = 50, 2 A = 100, etc
// #define PRINTF_FLOAT_SUPPORT // [-] Uncomment this for printf to support float on Serial Debug. It will increase code size! Better to avoid it!
// ADC conversion time definitions
#define ADC_CONV_TIME_1C5 (14) //Total ADC clock cycles / conversion = ( 1.5+12.5)
@ -256,7 +257,7 @@
* After calibration you can optionally write the values to the following defines
* Procedure:
* - connect gnd, rx and tx of a usb-uart converter in 3.3V mode to the right sensor board cable (do NOT use the red 15V wire!)
* - readout values using a serial terminal in 38400 boud
* - readout values using a serial terminal in 115200 baud rate
* - turn the potis to minimum position, write value 1 to INPUT1_MIN and value 2 to INPUT2_MIN
* - turn the potis to maximum position, write value 1 to INPUT1_MAX and value 2 to INPUT2_MAX
* - for middle resting potis: Let the potis in the middle resting position, write value 1 to INPUT1_MID and value 2 to INPUT2_MID

View File

@ -183,6 +183,10 @@
#define ARRAY_LEN(x) (uint32_t)(sizeof(x) / sizeof(*(x)))
#define MAP(x, in_min, in_max, out_min, out_max) (((((x) - (in_min)) * ((out_max) - (out_min))) / ((in_max) - (in_min))) + (out_min))
#if defined(PRINTF_FLOAT_SUPPORT) && (defined(DEBUG_SERIAL_USART2) || defined(DEBUG_SERIAL_USART3)) && defined(__GNUC__)
asm(".global _printf_float"); // this is the magic trick for printf to support float. Warning: It will increase code considerably! Better to avoid!
#endif
typedef struct {
uint16_t dcr;

106
Src/comms.c Normal file
View File

@ -0,0 +1,106 @@
#include <stdio.h>
#include <string.h>
#include "stm32f1xx_hal.h"
#include "defines.h"
#include "setup.h"
#include "config.h"
#include "comms.h"
extern UART_HandleTypeDef huart2;
extern UART_HandleTypeDef huart3;
static volatile uint8_t uart_buf[100];
static volatile int16_t ch_buf[8];
//volatile char char_buf[300];
/* retarget the C library printf function to the USART */
#if defined(DEBUG_SERIAL_USART2) || defined(DEBUG_SERIAL_USART3)
#ifdef __GNUC__
#define PUTCHAR_PROTOTYPE int __io_putchar(int ch)
#else
#define PUTCHAR_PROTOTYPE int fputc(int ch, FILE *f)
#endif
PUTCHAR_PROTOTYPE {
#if defined(DEBUG_SERIAL_USART2)
HAL_UART_Transmit(&huart2, (uint8_t *)&ch, 1, 1000);
#elif defined(DEBUG_SERIAL_USART3)
HAL_UART_Transmit(&huart3, (uint8_t *)&ch, 1, 1000);
#endif
return ch;
}
#ifdef __GNUC__
int _write(int file, char *data, int len) {
int i;
for (i = 0; i < len; i++) { __io_putchar( *data++ );}
return len;
}
#endif
#endif
void setScopeChannel(uint8_t ch, int16_t val) {
ch_buf[ch] = val;
}
void consoleScope(void) {
#if defined DEBUG_SERIAL_SERVOTERM && (defined DEBUG_SERIAL_USART2 || defined DEBUG_SERIAL_USART3)
uart_buf[0] = 0xff;
uart_buf[1] = CLAMP(ch_buf[0]+127, 0, 255);
uart_buf[2] = CLAMP(ch_buf[1]+127, 0, 255);
uart_buf[3] = CLAMP(ch_buf[2]+127, 0, 255);
uart_buf[4] = CLAMP(ch_buf[3]+127, 0, 255);
uart_buf[5] = CLAMP(ch_buf[4]+127, 0, 255);
uart_buf[6] = CLAMP(ch_buf[5]+127, 0, 255);
uart_buf[7] = CLAMP(ch_buf[6]+127, 0, 255);
uart_buf[8] = CLAMP(ch_buf[7]+127, 0, 255);
uart_buf[9] = '\n';
#ifdef DEBUG_SERIAL_USART2
if(__HAL_DMA_GET_COUNTER(huart2.hdmatx) == 0) {
HAL_UART_Transmit_DMA(&huart2, (uint8_t *)uart_buf, strLength);
}
#endif
#ifdef DEBUG_SERIAL_USART3
if(__HAL_DMA_GET_COUNTER(huart3.hdmatx) == 0) {
HAL_UART_Transmit_DMA(&huart3, (uint8_t *)uart_buf, strLength);
}
#endif
#endif
#if defined DEBUG_SERIAL_ASCII && (defined DEBUG_SERIAL_USART2 || defined DEBUG_SERIAL_USART3)
// memset((void *)(uintptr_t)uart_buf, 0, sizeof(uart_buf));
int strLength;
strLength = sprintf((char *)(uintptr_t)uart_buf,
"1:%i 2:%i 3:%i 4:%i 5:%i 6:%i 7:%i 8:%i\r\n",
ch_buf[0], ch_buf[1], ch_buf[2], ch_buf[3], ch_buf[4], ch_buf[5], ch_buf[6], ch_buf[7]);
#ifdef DEBUG_SERIAL_USART2
if(__HAL_DMA_GET_COUNTER(huart2.hdmatx) == 0) {
HAL_UART_Transmit_DMA(&huart2, (uint8_t *)uart_buf, strLength);
}
#endif
#ifdef DEBUG_SERIAL_USART3
if(__HAL_DMA_GET_COUNTER(huart3.hdmatx) == 0) {
HAL_UART_Transmit_DMA(&huart3, (uint8_t *)uart_buf, strLength);
}
#endif
#endif
}
void consoleLog(char *message)
{
#if defined DEBUG_SERIAL_ASCII && (defined DEBUG_SERIAL_USART2 || defined DEBUG_SERIAL_USART3)
#ifdef DEBUG_SERIAL_USART2
if(__HAL_DMA_GET_COUNTER(huart2.hdmatx) == 0) {
HAL_UART_Transmit_DMA(&huart2, (uint8_t *)message, strlen((char *)(uintptr_t)message));
}
#endif
#ifdef DEBUG_SERIAL_USART3
if(__HAL_DMA_GET_COUNTER(huart3.hdmatx) == 0) {
HAL_UART_Transmit_DMA(&huart3, (uint8_t *)message, strlen((char *)(uintptr_t)message));
}
#endif
#endif
}

View File

@ -20,12 +20,14 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#include <stdio.h>
#include <stdlib.h> // for abs()
#include "stm32f1xx_hal.h"
#include "defines.h"
#include "setup.h"
#include "config.h"
#include "util.h"
#include "comms.h"
#include "BLDC_controller.h" /* BLDC's header file */
#include "rtwtypes.h"
@ -189,10 +191,6 @@ int main(void) {
poweronMelody();
HAL_GPIO_WritePin(LED_PORT, LED_PIN, GPIO_PIN_SET);
printf("\n# hoverboard-firmware-hack-FOC\n");
printf("# GCC Version: %s\n",__VERSION__);
printf("# Build Date: %s\n\n",__DATE__);
int16_t speedL = 0, speedR = 0;
int16_t lastSpeedL = 0, lastSpeedR = 0;
@ -214,7 +212,7 @@ int main(void) {
beepShort(4); HAL_Delay(100);
steerFixdt = speedFixdt = 0; // reset filters
enable = 1; // enable motors
printf("# -- Motors enabled --\n");
printf("-- Motors enabled --\r\n");
}
// ####### VARIANT_HOVERCAR #######
@ -412,11 +410,11 @@ int main(void) {
// ####### DEBUG SERIAL OUT #######
#if defined(DEBUG_SERIAL_USART2) || defined(DEBUG_SERIAL_USART3)
if (main_loop_counter % 25 == 0) { // Send data periodically every 125 ms
printf("1:%i 2:%i 3:%i 4:%i 5:%i 6:%i 7:%i 8:%i\r\n",
printf("in1:%i in2:%i spdL:%i spdR:%i adcBat:%i BatV:%i adcTemp:%i Temp:%i\r\n",
input1, // 1: INPUT1
input2, // 2: INPUT2
speedR, // 3: output command: [-1000, 1000]
speedL, // 4: output command: [-1000, 1000]
speedL, // 3: output command: [-1000, 1000]
speedR, // 4: output command: [-1000, 1000]
adc_buffer.batt1, // 5: for battery voltage calibration
batVoltage * BAT_CALIB_REAL_VOLTAGE / BAT_CALIB_ADC, // 6: for verifying battery voltage calibration
board_temp_adcFilt, // 7: for board temperature calibration
@ -461,31 +459,29 @@ int main(void) {
// ####### BEEP AND EMERGENCY POWEROFF #######
if ((TEMP_POWEROFF_ENABLE && board_temp_deg_c >= TEMP_POWEROFF && speedAvgAbs < 20) || (batVoltage < BAT_DEAD && speedAvgAbs < 20)) { // poweroff before mainboard burns OR low bat 3
if (board_temp_deg_c >= TEMP_POWEROFF) printf("# Error: STM32 overtemp: %4.1f°C: power off\n", board_temp_deg_c / 10.0);
if (batVoltage < BAT_DEAD) printf("# Battery empty: %4.2fV: power off\n", batVoltage * BAT_CALIB_REAL_VOLTAGE / BAT_CALIB_ADC / 100.0);
poweroff();
} else if (rtY_Left.z_errCode || rtY_Right.z_errCode) { // 1 beep (low pitch): Motor error, disable motors
enable = 0;
beepCount(1, 24, 1);
printf("# Warning: Left_err: %i Right_err: %i\n", rtY_Left.z_errCode);
printf("#ErrL: %i ErrR: %i\r\n", rtY_Left.z_errCode, rtY_Right.z_errCode);
} else if (timeoutFlagADC) { // 2 beeps (low pitch): ADC timeout
beepCount(2, 24, 1);
printf("# Warning: ADC timeout\n");
printf("#ADC timeout\r\n");
} else if (timeoutFlagSerial) { // 3 beeps (low pitch): Serial timeout
beepCount(3, 24, 1);
printf("# Warning: Serial timeout\n");
printf("#Serial timeout\r\n");
} else if (timeoutCnt > TIMEOUT) { // 4 beeps (low pitch): General timeout (PPM, PWM, Nunchuck)
beepCount(4, 24, 1);
printf("# Warning: General timeout\n");
printf("#General timeout\r\n");
} else if (TEMP_WARNING_ENABLE && board_temp_deg_c >= TEMP_WARNING) { // 5 beeps (low pitch): Mainboard temperature warning
beepCount(5, 24, 1);
printf("# Warning: STM32 is getting hot: %4.1f°C\n", board_temp_deg_c / 10.0);
printf("#STM32 hot: %i\r\n", board_temp_deg_c);
} else if (BAT_LVL1_ENABLE && batVoltage < BAT_LVL1) { // 1 beep fast (medium pitch): Low bat 1
beepCount(0, 10, 6);
printf("# Warning: Battery is getting empty 1: %4.2fV\n", batVoltage * BAT_CALIB_REAL_VOLTAGE / BAT_CALIB_ADC / 100.0);
printf("#Battery empty: %i\r\n", batVoltage * BAT_CALIB_REAL_VOLTAGE / BAT_CALIB_ADC);
} else if (BAT_LVL2_ENABLE && batVoltage < BAT_LVL2) { // 1 beep slow (medium pitch): Low bat 2
beepCount(0, 10, 30);
printf("# Warning: Battery is getting empty 2: %4.2fV\n", batVoltage * BAT_CALIB_REAL_VOLTAGE / BAT_CALIB_ADC / 100.0);
printf("#Battery empty: %i\r\n", batVoltage * BAT_CALIB_REAL_VOLTAGE / BAT_CALIB_ADC);
} else if (BEEPS_BACKWARD && ((speed < -50 && speedAvg < 0) || MultipleTapBrake.b_multipleTap)) { // 1 beep fast (high pitch): Backward spinning motors
beepCount(0, 5, 1);
backwardDrive = 1;
@ -502,7 +498,6 @@ int main(void) {
inactivity_timeout_counter++;
}
if (inactivity_timeout_counter > (INACTIVITY_TIMEOUT * 60 * 1000) / (DELAY_IN_MAIN_LOOP + 1)) { // rest of main loop needs maybe 1ms
printf("# inactivity timeout: power off\n");
poweroff();
}

View File

@ -89,11 +89,11 @@ void UART3_Init(void)
/* DMA interrupt init */
/* DMA1_Channel2_IRQn interrupt configuration */
// HAL_NVIC_SetPriority(DMA1_Channel2_IRQn, 0, 0);
// HAL_NVIC_EnableIRQ(DMA1_Channel2_IRQn);
HAL_NVIC_SetPriority(DMA1_Channel2_IRQn, 0, 0);
HAL_NVIC_EnableIRQ(DMA1_Channel2_IRQn);
/* DMA1_Channel3_IRQn interrupt configuration */
// HAL_NVIC_SetPriority(DMA1_Channel3_IRQn, 0, 0);
// HAL_NVIC_EnableIRQ(DMA1_Channel3_IRQn);
HAL_NVIC_SetPriority(DMA1_Channel3_IRQn, 0, 0);
HAL_NVIC_EnableIRQ(DMA1_Channel3_IRQn);
huart3.Instance = USART3;
huart3.Init.BaudRate = USART3_BAUD;
@ -149,22 +149,16 @@ void HAL_UART_MspInit(UART_HandleTypeDef* uartHandle)
__HAL_LINKDMA(uartHandle,hdmarx,hdma_usart2_rx);
/* USART2_TX Init */
// hdma_usart2_tx.Instance = DMA1_Channel7;
// hdma_usart2_tx.Init.Direction = DMA_MEMORY_TO_PERIPH;
// hdma_usart2_tx.Init.PeriphInc = DMA_PINC_DISABLE;
// hdma_usart2_tx.Init.MemInc = DMA_MINC_ENABLE;
// hdma_usart2_tx.Init.PeriphDataAlignment = DMA_PDATAALIGN_BYTE;
// hdma_usart2_tx.Init.MemDataAlignment = DMA_MDATAALIGN_BYTE;
// hdma_usart2_tx.Init.Mode = DMA_NORMAL;
// hdma_usart2_tx.Init.Priority = DMA_PRIORITY_LOW;
// HAL_DMA_Init(&hdma_usart2_tx);
// __HAL_LINKDMA(uartHandle,hdmatx,hdma_usart2_tx);
USART2->CR3 |= USART_CR3_DMAT; // | USART_CR3_DMAR | USART_CR3_OVRDIS;
DMA1_Channel7->CCR = 0;
DMA1_Channel7->CPAR = (uint32_t) & (USART3->DR);
DMA1_Channel7->CNDTR = 0;
DMA1_Channel7->CCR = DMA_CCR_MINC | DMA_CCR_DIR;
DMA1->IFCR = DMA_IFCR_CTCIF2 | DMA_IFCR_CHTIF2 | DMA_IFCR_CGIF2;
hdma_usart2_tx.Instance = DMA1_Channel7;
hdma_usart2_tx.Init.Direction = DMA_MEMORY_TO_PERIPH;
hdma_usart2_tx.Init.PeriphInc = DMA_PINC_DISABLE;
hdma_usart2_tx.Init.MemInc = DMA_MINC_ENABLE;
hdma_usart2_tx.Init.PeriphDataAlignment = DMA_PDATAALIGN_BYTE;
hdma_usart2_tx.Init.MemDataAlignment = DMA_MDATAALIGN_BYTE;
hdma_usart2_tx.Init.Mode = DMA_NORMAL;
hdma_usart2_tx.Init.Priority = DMA_PRIORITY_LOW;
HAL_DMA_Init(&hdma_usart2_tx);
__HAL_LINKDMA(uartHandle,hdmatx,hdma_usart2_tx);
/* USART2 interrupt Init */
HAL_NVIC_SetPriority(USART2_IRQn, 0, 0);
@ -210,22 +204,16 @@ void HAL_UART_MspInit(UART_HandleTypeDef* uartHandle)
__HAL_LINKDMA(uartHandle,hdmarx,hdma_usart3_rx);
/* USART3_TX Init */
// hdma_usart3_tx.Instance = DMA1_Channel2;
// hdma_usart3_tx.Init.Direction = DMA_MEMORY_TO_PERIPH;
// hdma_usart3_tx.Init.PeriphInc = DMA_PINC_DISABLE;
// hdma_usart3_tx.Init.MemInc = DMA_MINC_ENABLE;
// hdma_usart3_tx.Init.PeriphDataAlignment = DMA_PDATAALIGN_BYTE;
// hdma_usart3_tx.Init.MemDataAlignment = DMA_MDATAALIGN_BYTE;
// hdma_usart3_tx.Init.Mode = DMA_NORMAL;
// hdma_usart3_tx.Init.Priority = DMA_PRIORITY_LOW;
// HAL_DMA_Init(&hdma_usart3_tx);
// __HAL_LINKDMA(uartHandle,hdmatx,hdma_usart3_tx);
USART3->CR3 |= USART_CR3_DMAT; // | USART_CR3_DMAR | USART_CR3_OVRDIS;
DMA1_Channel2->CCR = 0;
DMA1_Channel2->CPAR = (uint32_t) & (USART3->DR);
DMA1_Channel2->CNDTR = 0;
DMA1_Channel2->CCR = DMA_CCR_MINC | DMA_CCR_DIR;
DMA1->IFCR = DMA_IFCR_CTCIF2 | DMA_IFCR_CHTIF2 | DMA_IFCR_CGIF2;
hdma_usart3_tx.Instance = DMA1_Channel2;
hdma_usart3_tx.Init.Direction = DMA_MEMORY_TO_PERIPH;
hdma_usart3_tx.Init.PeriphInc = DMA_PINC_DISABLE;
hdma_usart3_tx.Init.MemInc = DMA_MINC_ENABLE;
hdma_usart3_tx.Init.PeriphDataAlignment = DMA_PDATAALIGN_BYTE;
hdma_usart3_tx.Init.MemDataAlignment = DMA_MDATAALIGN_BYTE;
hdma_usart3_tx.Init.Mode = DMA_NORMAL;
hdma_usart3_tx.Init.Priority = DMA_PRIORITY_LOW;
HAL_DMA_Init(&hdma_usart3_tx);
__HAL_LINKDMA(uartHandle,hdmatx,hdma_usart3_tx);
/* USART3 interrupt Init */
HAL_NVIC_SetPriority(USART3_IRQn, 0, 0);

View File

@ -1,36 +0,0 @@
#include <reent.h>
#include <stdlib.h>
#include <stdio.h>
#include <errno.h>
#include <sys/stat.h>
#include <sys/time.h>
#include <string.h>
#include "stm32f1xx_hal.h"
#include "config.h"
extern volatile uint8_t uart_buf[200];
/*
* printf sends its output to this function, this function sends it to the uart dma output buffer
*/
__attribute__((__used__)) int _write(int fd, const char *ptr, int len){
#if defined DEBUG_SERIAL_ASCII && (defined DEBUG_SERIAL_USART2 || defined DEBUG_SERIAL_USART3)
#ifdef DEBUG_SERIAL_USART2
while(DMA1_Channel7->CNDTR != 0); // wait
memcpy(uart_buf,ptr,len); // copy to buffer
DMA1_Channel7->CCR &= ~DMA_CCR_EN;
DMA1_Channel7->CNDTR = len; // set number of bytes to read
DMA1_Channel7->CMAR = (uint32_t)uart_buf; // set buffer to read from
DMA1_Channel7->CCR |= DMA_CCR_EN;
#endif
#ifdef DEBUG_SERIAL_USART3
while(DMA1_Channel2->CNDTR != 0); // wait
memcpy(uart_buf,ptr,len); // copy to buffer
DMA1_Channel2->CCR &= ~DMA_CCR_EN;
DMA1_Channel2->CNDTR = len; // set number of bytes to read
DMA1_Channel2->CMAR = (uint32_t)uart_buf; // set buffer to read from
DMA1_Channel2->CCR |= DMA_CCR_EN;
#endif
#endif
return len;
}

View File

@ -18,6 +18,7 @@
*/
// Includes
#include <stdio.h>
#include <stdlib.h> // for abs()
#include <string.h>
#include "stm32f1xx_hal.h"
@ -467,14 +468,14 @@ int checkInputType(int16_t min, int16_t mid, int16_t max){
HAL_Delay(10);
if ((min / threshold) == (max / threshold) || (mid / threshold) == (max / threshold) || min > max || mid > max) {
type = 0;
printf("# Input is ignored"); // (MIN and MAX) OR (MID and MAX) are close, disable input
printf("Input is ignored"); // (MIN and MAX) OR (MID and MAX) are close, disable input
} else {
if ((min / threshold) == (mid / threshold)){
type = 1;
printf("# Input is a normal pot"); // MIN and MID are close, it's a normal pot
printf("Input is a normal pot"); // MIN and MID are close, it's a normal pot
} else {
type = 2;
printf("# Input is a mid-resting pot"); // it's a mid resting pot
printf("Input is a mid-resting pot"); // it's a mid resting pot
}
HAL_Delay(10);
#ifdef CONTROL_ADC
@ -486,7 +487,7 @@ int checkInputType(int16_t min, int16_t mid, int16_t max){
}
HAL_Delay(10);
printf("\n");
printf("\r\n");
HAL_Delay(10);
return type;
@ -542,10 +543,10 @@ void adcCalibLim(void) {
INPUT1_MIN_CAL = INPUT1_MIN_temp + INPUT_MARGIN;
INPUT1_MID_CAL = INPUT1_MID_temp;
INPUT1_MAX_CAL = INPUT1_MAX_temp - INPUT_MARGIN;
printf("# Input1 OK\r\n"); HAL_Delay(10);
printf("Input1 OK\r\n"); HAL_Delay(10);
} else {
INPUT1_TYP_CAL = 0; // Disable input
printf("# Input1 Fail\r\n"); HAL_Delay(10);
printf("Input1 Fail\r\n"); HAL_Delay(10);
}
INPUT2_TYP_CAL = checkInputType(INPUT2_MIN_temp, INPUT2_MID_temp, INPUT2_MAX_temp);
@ -553,14 +554,15 @@ void adcCalibLim(void) {
INPUT2_MIN_CAL = INPUT2_MIN_temp + INPUT_MARGIN;
INPUT2_MID_CAL = INPUT2_MID_temp;
INPUT2_MAX_CAL = INPUT2_MAX_temp - INPUT_MARGIN;
printf("# Input2 OK\r\n"); HAL_Delay(10);
printf("Input2 OK\r\n"); HAL_Delay(10);
} else {
INPUT2_TYP_CAL = 0; // Disable input
printf("# Input2 Fail\r\n"); HAL_Delay(10);
printf("Input2 Fail\r\n"); HAL_Delay(10);
}
inp_cal_valid = 1; // Mark calibration to be saved in Flash at shutdown
printf("# Limits: INPUT1_TYP_CAL:%i INPUT1_MIN_CAL:%i INPUT1_MID_CAL:%i INPUT1_MAX_CAL:%i INPUT2_TYP_CAL:%i INPUT2_MIN_CAL:%i INPUT2_MID_CAL:%i INPUT2_MAX_CAL:%i\n",
INPUT1_TYP_CAL, INPUT1_MIN_CAL, INPUT1_MID_CAL, INPUT1_MAX_CAL, INPUT2_TYP_CAL, INPUT2_MIN_CAL, INPUT2_MID_CAL, INPUT2_MAX_CAL);
printf("Limits Input1: TYP:%i MIN:%i MID:%i MAX:%i\r\nLimits Input2: TYP:%i MIN:%i MID:%i MAX:%i\r\n",
INPUT1_TYP_CAL, INPUT1_MIN_CAL, INPUT1_MID_CAL, INPUT1_MAX_CAL,
INPUT2_TYP_CAL, INPUT2_MIN_CAL, INPUT2_MID_CAL, INPUT2_MAX_CAL);
#endif
}
/*
@ -609,8 +611,8 @@ void updateCurSpdLim(void) {
}
// cur_spd_valid: 0 = No limit changed, 1 = Current limit changed, 2 = Speed limit changed, 3 = Both limits changed
printf("# Limits: cur_spd_valid:%i input1_fixdt:%li cur_factor:%i rtP_Left.i_max:%i input2_fixdt:%li spd_factor:%i rtP_Left.n_max:%i\n",
cur_spd_valid, input1_fixdt, cur_factor, rtP_Left.i_max, input2_fixdt, spd_factor, rtP_Left.n_max);
printf("Limits (%i)\r\nCurrent: fixdt:%li factor%i i_max:%i \r\nSpeed: fixdt:%li factor:%i n_max:%i\r\n",
cur_spd_valid, input1_fixdt, cur_factor, rtP_Left.i_max, input2_fixdt, spd_factor, rtP_Left.n_max);
#endif
}
@ -1100,7 +1102,7 @@ void usart_process_debug(uint8_t *userCommand, uint32_t len)
{
for (; len > 0; len--, userCommand++) {
if (*userCommand != '\n' && *userCommand != '\r') { // Do not accept 'new line' and 'carriage return' commands
printf("# -- Command received --\n");
printf("Command = %c\r\n", *userCommand);
// handle_input(*userCommand); // -> Create this function to handle the user commands
}
}