implemented write syscall for printf, added float-support for printf, serial tx does not need an interrupt anymore, replaced consoleLog and consoleScope with printf, changed debug output: every comment starts with "# " now, added lots of debug messages, added welcome message with gcc version and build date

This commit is contained in:
larsm 2020-11-22 21:54:59 +01:00
parent ad8c2a552a
commit c57e1a0e4e
7 changed files with 134 additions and 186 deletions

View File

@ -1,33 +0,0 @@
/*
* 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

@ -1,81 +0,0 @@
#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];
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

@ -26,7 +26,6 @@
#include "setup.h"
#include "config.h"
#include "util.h"
#include "comms.h"
#include "BLDC_controller.h" /* BLDC's header file */
#include "rtwtypes.h"
@ -52,6 +51,8 @@ extern volatile adc_buf_t adc_buffer;
extern UART_HandleTypeDef huart2;
extern UART_HandleTypeDef huart3;
volatile uint8_t uart_buf[200];
// Matlab defines - from auto-code generation
//---------------
extern P rtP_Left; /* Block parameters (auto storage) */
@ -191,6 +192,10 @@ 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;
@ -212,7 +217,7 @@ int main(void) {
shortBeep(4); HAL_Delay(100);
steerFixdt = speedFixdt = 0; // reset filters
enable = 1; // enable motors
consoleLog("-- Motors enabled --\r\n");
printf("# -- Motors enabled --\n");
}
// ####### VARIANT_HOVERCAR #######
@ -410,15 +415,16 @@ 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
setScopeChannel(0, (int16_t)input1); // 1: INPUT1
setScopeChannel(1, (int16_t)input2); // 2: INPUT2
setScopeChannel(2, (int16_t)speedR); // 3: output command: [-1000, 1000]
setScopeChannel(3, (int16_t)speedL); // 4: output command: [-1000, 1000]
setScopeChannel(4, (int16_t)adc_buffer.batt1); // 5: for battery voltage calibration
setScopeChannel(5, (int16_t)(batVoltage * BAT_CALIB_REAL_VOLTAGE / BAT_CALIB_ADC)); // 6: for verifying battery voltage calibration
setScopeChannel(6, (int16_t)board_temp_adcFilt); // 7: for board temperature calibration
setScopeChannel(7, (int16_t)board_temp_deg_c); // 8: for verifying board temperature calibration
consoleScope();
printf("1:%i 2:%i 3:%i 4:%i 5:%i 6:%i 7:%i 8:%i\r\n",
input1, // 1: INPUT1
input2, // 2: INPUT2
speedR, // 3: output command: [-1000, 1000]
speedL, // 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
board_temp_deg_c); // 8: for verifying board temperature calibration
printf("# Battery empty: %4.2fV: power off\n", batVoltage * BAT_CALIB_REAL_VOLTAGE / BAT_CALIB_ADC / 100.0);
}
#endif
@ -459,21 +465,31 @@ 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) { // disable motors and beep in case of Motor error - fast beep
enable = 0;
if (rtY_Left.z_errCode) printf("# Warning: rtY_Left.z_errCode: %i\n", rtY_Left.z_errCode);
if (rtY_Right.z_errCode) printf("# Warning: rtY_Right.z_errCode: %i\n", rtY_Right.z_errCode);
buzzerFreq = 8;
buzzerPattern = 1;
} else if (timeoutFlagADC || timeoutFlagSerial || timeoutCnt > TIMEOUT) { // beep in case of ADC timeout, Serial timeout or General timeout - fast beep
if (timeoutFlagADC) printf("# Warning: ADC timeout\n");
if (timeoutFlagSerial) printf("# Warning: Serial timeout\n");
if (timeoutCnt > TIMEOUT) printf("# Warning: General timeout\n");
buzzerFreq = 24;
buzzerPattern = 1;
} else if (TEMP_WARNING_ENABLE && board_temp_deg_c >= TEMP_WARNING) { // beep if mainboard gets hot
printf("# Warning: STM32 is getting hot: %4.1f°C\n", board_temp_deg_c / 10.0);
buzzerFreq = 4;
buzzerPattern = 1;
} else if (BAT_LVL1_ENABLE && batVoltage < BAT_LVL1) { // low bat 1: fast beep
printf("# Warning: Battery is getting empty 1: %4.2fV\n", batVoltage * BAT_CALIB_REAL_VOLTAGE / BAT_CALIB_ADC / 100.0);
buzzerFreq = 5;
buzzerPattern = 6;
} else if (BAT_LVL2_ENABLE && batVoltage < BAT_LVL2) { // low bat 2: slow beep
printf("# Warning: Battery is getting empty 2: %4.2fV\n", batVoltage * BAT_CALIB_REAL_VOLTAGE / BAT_CALIB_ADC / 100.0);
buzzerFreq = 5;
buzzerPattern = 42;
} else if (BEEPS_BACKWARD && ((speed < -50 && speedAvg < 0) || MultipleTapBrake.b_multipleTap)) { // backward beep
@ -494,6 +510,7 @@ 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,16 +149,22 @@ 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);
// 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;
/* USART2 interrupt Init */
HAL_NVIC_SetPriority(USART2_IRQn, 0, 0);
@ -204,16 +210,22 @@ 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);
// 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;
/* USART3 interrupt Init */
HAL_NVIC_SetPriority(USART3_IRQn, 0, 0);

36
Src/syscalls.c Normal file
View File

@ -0,0 +1,36 @@
#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

@ -24,7 +24,6 @@
#include "defines.h"
#include "setup.h"
#include "config.h"
#include "comms.h"
#include "eeprom.h"
#include "util.h"
#include "BLDC_controller.h"
@ -458,26 +457,26 @@ 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;
consoleLog("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;
consoleLog("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;
consoleLog("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
if ((min + INPUT_MARGIN - ADC_PROTECT_THRESH) > 0 && (max - INPUT_MARGIN + ADC_PROTECT_THRESH) < 4095) {
consoleLog(" and protected");
printf(" and protected");
longBeep(2); // Indicate protection by a beep
}
#endif
}
HAL_Delay(10);
consoleLog("\n");
printf("\n");
HAL_Delay(10);
return type;
@ -499,7 +498,10 @@ void adcCalibLim(void) {
}
#if !defined(VARIANT_HOVERBOARD) && !defined(VARIANT_TRANSPOTTER)
consoleLog("Input calibration started...\n");
printf("# Input calibration started...\n");
printf("# move the potentiometers freely to the min and max limits repeatedly\n");
printf("# release potentiometers to the resting postion\n");
printf("# press the power button to confirm or wait for the 20 sec timeout\n");
readInput();
// Inititalization: MIN = a high value, MAX = a low value
@ -533,10 +535,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;
consoleLog("Input1 OK\n"); HAL_Delay(10);
printf("# Input1 OK\n"); HAL_Delay(10);
} else {
INPUT1_TYP_CAL = 0; // Disable input
consoleLog("Input1 Fail\n"); HAL_Delay(10);
printf("# Input1 Fail\n"); HAL_Delay(10);
}
INPUT2_TYP_CAL = checkInputType(INPUT2_MIN_temp, INPUT2_MID_temp, INPUT2_MAX_temp);
@ -544,23 +546,14 @@ 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;
consoleLog("Input2 OK\n"); HAL_Delay(10);
printf("# Input2 OK\n"); HAL_Delay(10);
} else {
INPUT2_TYP_CAL = 0; // Disable input
consoleLog("Input2 Fail\n"); HAL_Delay(10);
printf("# Input2 Fail\n"); HAL_Delay(10);
}
inp_cal_valid = 1; // Mark calibration to be saved in Flash at shutdown
consoleLog("Limits: "); HAL_Delay(10);
setScopeChannel(0, (int16_t)INPUT1_TYP_CAL);
setScopeChannel(1, (int16_t)INPUT1_MIN_CAL);
setScopeChannel(2, (int16_t)INPUT1_MID_CAL);
setScopeChannel(3, (int16_t)INPUT1_MAX_CAL);
setScopeChannel(4, (int16_t)INPUT2_TYP_CAL);
setScopeChannel(5, (int16_t)INPUT2_MIN_CAL);
setScopeChannel(6, (int16_t)INPUT2_MID_CAL);
setScopeChannel(7, (int16_t)INPUT2_MAX_CAL);
consoleScope();
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);
#endif
}
/*
@ -576,7 +569,9 @@ void updateCurSpdLim(void) {
}
#if !defined(VARIANT_HOVERBOARD) && !defined(VARIANT_TRANSPOTTER)
consoleLog("Torque and Speed limits update started...\n");
printf("# Torque and Speed limits update started...\n");
printf("# move and hold the pots to a desired limit position for Current and Speed\n");
printf("# press the power button to confirm or wait for the 10 sec timeout\n");
int32_t input1_fixdt = input1 << 16;
int32_t input2_fixdt = input2 << 16;
@ -608,17 +603,9 @@ void updateCurSpdLim(void) {
cur_spd_valid += 2; // Mark update to be saved in Flash at shutdown
}
consoleLog("Limits: "); HAL_Delay(10);
setScopeChannel(0, (int16_t)cur_spd_valid); // 0 = No limit changed, 1 = Current limit changed, 2 = Speed limit changed, 3 = Both limits changed
setScopeChannel(1, (int16_t)input1_fixdt);
setScopeChannel(2, (int16_t)cur_factor);
setScopeChannel(3, (int16_t)rtP_Left.i_max);
setScopeChannel(4, (int16_t)0);
setScopeChannel(5, (int16_t)input2_fixdt);
setScopeChannel(6, (int16_t)spd_factor);
setScopeChannel(7, (int16_t)rtP_Left.n_max);
consoleScope();
// 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);
#endif
}
@ -752,7 +739,7 @@ void cruiseControl(uint8_t button) {
void poweroff(void) {
buzzerPattern = 0;
enable = 0;
consoleLog("-- Motors disabled --\r\n");
printf("# -- Motors disabled --\n");
for (int i = 0; i < 8; i++) {
buzzerFreq = (uint8_t)i;
HAL_Delay(100);
@ -1107,7 +1094,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
consoleLog("-- Command received --\r\n");
printf("# -- Command received --\n");
// handle_input(*userCommand); // -> Create this function to handle the user commands
}
}

View File

@ -37,6 +37,7 @@ monitor_speed = 38400
build_flags =
-DUSE_HAL_DRIVER
-DSTM32F103xE
-Wl,-u,_printf_float ; enable float for printf
-Wl,-T./STM32F103RCTx_FLASH.ld
-Wl,-lc
-Wl,-lm
@ -60,6 +61,7 @@ monitor_speed = 38400
build_flags =
-DUSE_HAL_DRIVER
-DSTM32F103xE
-Wl,-u,_printf_float ; enable float for printf
-Wl,-T./STM32F103RCTx_FLASH.ld
-Wl,-lc
-Wl,-lm
@ -79,6 +81,7 @@ upload_protocol = stlink
build_flags =
-DUSE_HAL_DRIVER
-DSTM32F103xE
-Wl,-u,_printf_float ; enable float for printf
-Wl,-T./STM32F103RCTx_FLASH.ld
-Wl,-lc
-Wl,-lm
@ -98,6 +101,7 @@ upload_protocol = stlink
build_flags =
-DUSE_HAL_DRIVER
-DSTM32F103xE
-Wl,-u,_printf_float ; enable float for printf
-Wl,-T./STM32F103RCTx_FLASH.ld
-Wl,-lc
-Wl,-lm
@ -117,6 +121,7 @@ upload_protocol = stlink
build_flags =
-DUSE_HAL_DRIVER
-DSTM32F103xE
-Wl,-u,_printf_float ; enable float for printf
-Wl,-T./STM32F103RCTx_FLASH.ld
-Wl,-lc
-Wl,-lm
@ -136,6 +141,7 @@ upload_protocol = stlink
build_flags =
-DUSE_HAL_DRIVER
-DSTM32F103xE
-Wl,-u,_printf_float ; enable float for printf
-Wl,-T./STM32F103RCTx_FLASH.ld
-Wl,-lc
-Wl,-lm
@ -159,6 +165,7 @@ monitor_speed = 38400
build_flags =
-DUSE_HAL_DRIVER
-DSTM32F103xE
-Wl,-u,_printf_float ; enable float for printf
-Wl,-T./STM32F103RCTx_FLASH.ld
-Wl,-lc
-Wl,-lm
@ -182,6 +189,7 @@ monitor_speed = 38400
build_flags =
-DUSE_HAL_DRIVER
-DSTM32F103xE
-Wl,-u,_printf_float ; enable float for printf
-Wl,-T./STM32F103RCTx_FLASH.ld
-Wl,-lc
-Wl,-lm
@ -201,6 +209,7 @@ upload_protocol = stlink
build_flags =
-DUSE_HAL_DRIVER
-DSTM32F103xE
-Wl,-u,_printf_float ; enable float for printf
-Wl,-T./STM32F103RCTx_FLASH.ld
-Wl,-lc
-Wl,-lm
@ -221,6 +230,7 @@ upload_protocol = stlink
build_flags =
-DUSE_HAL_DRIVER
-DSTM32F103xE
-Wl,-u,_printf_float ; enable float for printf
-Wl,-T./STM32F103RCTx_FLASH.ld
-Wl,-lc
-Wl,-lm