forked from EFeru/hoverboard-firmware-hack-FOC
UART with sideboards works + major refactoring
► the mainboard can now send and receive Serial data from the sideboards ► heavy refactored the `main.c`. It was becoming too large to manage... Therefore, `util.c` and `util.h` was created ► added new functionality for `VARIANT_HOVERCAR` and variants with `CONTROL_ADC` in general: - ADC limits auto-calibration mode (long press of the power button) - calibration will not be lost at power-off - Max Current and Max Speed adjustment mode (long press followed by a short press of the power button) - calibration will not be lost at power-off - added one sideboard functionality: - LEDs are used to display battery level, Motor Enable, Errors, Reverse driving, Braking. - Photo sensors are used as push buttons: One for changing Control Mode, One for Activating/Deactivating the Field Weakening on the fly
This commit is contained in:
30
Src/comms.c
30
Src/comms.c
@@ -30,11 +30,11 @@ void consoleScope(void) {
|
||||
uart_buf[8] = CLAMP(ch_buf[7]+127, 0, 255);
|
||||
uart_buf[9] = '\n';
|
||||
|
||||
if(UART_DMA_CHANNEL->CNDTR == 0) {
|
||||
UART_DMA_CHANNEL->CCR &= ~DMA_CCR_EN;
|
||||
UART_DMA_CHANNEL->CNDTR = 10;
|
||||
UART_DMA_CHANNEL->CMAR = (uint32_t)uart_buf;
|
||||
UART_DMA_CHANNEL->CCR |= DMA_CCR_EN;
|
||||
if(UART_DMA_CHANNEL_TX->CNDTR == 0) {
|
||||
UART_DMA_CHANNEL_TX->CCR &= ~DMA_CCR_EN;
|
||||
UART_DMA_CHANNEL_TX->CNDTR = 10;
|
||||
UART_DMA_CHANNEL_TX->CMAR = (uint32_t)uart_buf;
|
||||
UART_DMA_CHANNEL_TX->CCR |= DMA_CCR_EN;
|
||||
}
|
||||
#endif
|
||||
|
||||
@@ -45,11 +45,11 @@ void consoleScope(void) {
|
||||
"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]);
|
||||
|
||||
if(UART_DMA_CHANNEL->CNDTR == 0) {
|
||||
UART_DMA_CHANNEL->CCR &= ~DMA_CCR_EN;
|
||||
UART_DMA_CHANNEL->CNDTR = strLength;
|
||||
UART_DMA_CHANNEL->CMAR = (uint32_t)uart_buf;
|
||||
UART_DMA_CHANNEL->CCR |= DMA_CCR_EN;
|
||||
if(UART_DMA_CHANNEL_TX->CNDTR == 0) {
|
||||
UART_DMA_CHANNEL_TX->CCR &= ~DMA_CCR_EN;
|
||||
UART_DMA_CHANNEL_TX->CNDTR = strLength;
|
||||
UART_DMA_CHANNEL_TX->CMAR = (uint32_t)uart_buf;
|
||||
UART_DMA_CHANNEL_TX->CCR |= DMA_CCR_EN;
|
||||
}
|
||||
#endif
|
||||
}
|
||||
@@ -57,11 +57,11 @@ void consoleScope(void) {
|
||||
void consoleLog(char *message)
|
||||
{
|
||||
#if defined DEBUG_SERIAL_ASCII && (defined DEBUG_SERIAL_USART2 || defined DEBUG_SERIAL_USART3)
|
||||
if(UART_DMA_CHANNEL->CNDTR == 0) {
|
||||
UART_DMA_CHANNEL->CCR &= ~DMA_CCR_EN;
|
||||
UART_DMA_CHANNEL->CNDTR = strlen((char *)(uintptr_t)message);
|
||||
UART_DMA_CHANNEL->CMAR = (uint32_t)message;
|
||||
UART_DMA_CHANNEL->CCR |= DMA_CCR_EN;
|
||||
if(UART_DMA_CHANNEL_TX->CNDTR == 0) {
|
||||
UART_DMA_CHANNEL_TX->CCR &= ~DMA_CCR_EN;
|
||||
UART_DMA_CHANNEL_TX->CNDTR = strlen((char *)(uintptr_t)message);
|
||||
UART_DMA_CHANNEL_TX->CMAR = (uint32_t)message;
|
||||
UART_DMA_CHANNEL_TX->CCR |= DMA_CCR_EN;
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
Reference in New Issue
Block a user