Skip to content

Commit d96b1be

Browse files
wip VESC implementation
1 parent a0af0e2 commit d96b1be

File tree

16 files changed

+2726
-16
lines changed

16 files changed

+2726
-16
lines changed

CMakeLists.txt

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -59,8 +59,13 @@ target_sources(${CMAKE_PROJECT_NAME} PRIVATE
5959
src/services/imu_service/imu_service.hpp
6060
src/services/power_service/power_service.cpp
6161
src/services/power_service/power_service.hpp
62+
# BQ2567 driver
6263
src/drivers/bq_2576/bq_2576.cpp
6364
src/drivers/bq_2576/bq_2576.hpp
65+
# VESC driver
66+
src/drivers/vesc/buffer.cpp
67+
src/drivers/vesc/VescUart.cpp
68+
src/drivers/vesc/crc.cpp
6469
)
6570

6671
# Add include paths

boards/XCORE/mcuconf.h

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -361,7 +361,7 @@
361361
*/
362362
#define STM32_SERIAL_USE_USART1 FALSE
363363
#define STM32_SERIAL_USE_USART2 FALSE
364-
#define STM32_SERIAL_USE_USART3 TRUE
364+
#define STM32_SERIAL_USE_USART3 FALSE
365365
#define STM32_SERIAL_USE_UART4 FALSE
366366
#define STM32_SERIAL_USE_UART5 FALSE
367367
#define STM32_SERIAL_USE_USART6 FALSE
@@ -435,14 +435,14 @@
435435
/*
436436
* UART driver system settings.
437437
*/
438-
#define STM32_UART_USE_USART1 FALSE
439-
#define STM32_UART_USE_USART2 FALSE
438+
#define STM32_UART_USE_USART1 TRUE
439+
#define STM32_UART_USE_USART2 TRUE
440440
#define STM32_UART_USE_USART3 FALSE
441-
#define STM32_UART_USE_UART4 FALSE
441+
#define STM32_UART_USE_UART4 TRUE
442442
#define STM32_UART_USE_UART5 FALSE
443-
#define STM32_UART_USE_USART6 FALSE
444-
#define STM32_UART_USE_UART7 FALSE
445-
#define STM32_UART_USE_UART8 FALSE
443+
#define STM32_UART_USE_USART6 TRUE
444+
#define STM32_UART_USE_UART7 TRUE
445+
#define STM32_UART_USE_UART8 TRUE
446446
#define STM32_UART_USE_UART9 FALSE
447447
#define STM32_UART_USE_USART10 FALSE
448448
#define STM32_UART_USART1_RX_DMA_STREAM STM32_DMA_STREAM_ID_ANY

cfg/chconf.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -105,7 +105,7 @@ extern volatile uint32_t last_idle_tick;
105105
* this value.
106106
*/
107107
#if !defined(CH_CFG_ST_TIMEDELTA)
108-
#define CH_CFG_ST_TIMEDELTA 2
108+
#define CH_CFG_ST_TIMEDELTA 10
109109
#endif
110110

111111
/** @} */

cfg/halconf.h

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -142,7 +142,7 @@
142142
* @brief Enables the SERIAL subsystem.
143143
*/
144144
#if !defined(HAL_USE_SERIAL) || defined(__DOXYGEN__)
145-
#define HAL_USE_SERIAL TRUE
145+
#define HAL_USE_SERIAL FALSE
146146
#endif
147147

148148
/**
@@ -177,7 +177,7 @@
177177
* @brief Enables the UART subsystem.
178178
*/
179179
#if !defined(HAL_USE_UART) || defined(__DOXYGEN__)
180-
#define HAL_USE_UART FALSE
180+
#define HAL_USE_UART TRUE
181181
#endif
182182

183183
/**
@@ -505,15 +505,15 @@
505505
* @note Disabling this option saves both code and data space.
506506
*/
507507
#if !defined(UART_USE_WAIT) || defined(__DOXYGEN__)
508-
#define UART_USE_WAIT FALSE
508+
#define UART_USE_WAIT TRUE
509509
#endif
510510

511511
/**
512512
* @brief Enables the @p uartAcquireBus() and @p uartReleaseBus() APIs.
513513
* @note Disabling this option saves both code and data space.
514514
*/
515515
#if !defined(UART_USE_MUTUAL_EXCLUSION) || defined(__DOXYGEN__)
516-
#define UART_USE_MUTUAL_EXCLUSION FALSE
516+
#define UART_USE_MUTUAL_EXCLUSION TRUE
517517
#endif
518518

519519
/*===========================================================================*/

cfg/lwipopts.h

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -38,8 +38,7 @@
3838
#ifndef __LWIPOPT_H__
3939
#define __LWIPOPT_H__
4040

41-
// LWIP_LINK_POLL_INTERVAL is set low here in order to have quicker startup time.
42-
#define LWIP_LINK_POLL_INTERVAL TIME_MS2I(1000)
41+
#define LWIP_LINK_POLL_INTERVAL TIME_S2I(5000)
4342

4443
/*
4544
-----------------------------------------------

main.cpp

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
#include <SEGGER_RTT_streams.h>
88
#include <boot_service_discovery.h>
99
#include <chprintf.h>
10+
#include <drivers/vesc/VescUart.h>
1011
#include <globals.h>
1112
#include <heartbeat.h>
1213
#include <id_eeprom.h>
@@ -20,6 +21,23 @@
2021
#include "services/power_service/power_service.hpp"
2122
ImuService imu_service{4};
2223
PowerService power_service{5};
24+
25+
static THD_WORKING_AREA(waTestThread, 500);
26+
27+
static void test_thread(void *p) {
28+
static VescUart vesc_uart(&UARTD2);
29+
while (1) {
30+
SEGGER_SYSVIEW_Print("keepalive");
31+
vesc_uart.sendKeepalive();
32+
SEGGER_SYSVIEW_Print("request");
33+
vesc_uart.requestVescValues();
34+
SEGGER_SYSVIEW_Print("parse");
35+
vesc_uart.parseVescValues();
36+
SEGGER_SYSVIEW_Print("wait");
37+
chThdSleepMilliseconds(50);
38+
}
39+
}
40+
2341
/*
2442
* Application entry point.
2543
*/
@@ -82,5 +100,9 @@ int main(void) {
82100
xbot::service::Io::start();
83101
imu_service.start();
84102
power_service.start();
103+
104+
chThdCreateStatic(waTestThread, sizeof(waTestThread), NORMALPRIO, test_thread,
105+
NULL);
106+
85107
chThdSleep(TIME_INFINITE);
86108
}

src/boot_service_discovery.c

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,6 @@
1313

1414
#include "chprintf.h"
1515
#include "lwip/sockets.h"
16-
1716
static char boardAdvertisementBuffer[1000];
1817
static char boardAdvertisementRequestBuffer[1000];
1918
static THD_WORKING_AREA(waServiceDiscovery, 500);
@@ -64,7 +63,6 @@ static void multicast_sender_thread(void *p) {
6463
multicast_addr.sin_family = AF_INET;
6564
multicast_addr.sin_addr.s_addr = inet_addr(SD_MULTICAST_GROUP);
6665
multicast_addr.sin_port = htons(SD_MULTICAST_PORT);
67-
6866
while (true) {
6967
int received =
7068
recvfrom(sockfd, boardAdvertisementRequestBuffer,

0 commit comments

Comments
 (0)