Skip to content

Commit

Permalink
added TCP interface for testing
Browse files Browse the repository at this point in the history
  • Loading branch information
ClemensElflein committed Nov 13, 2024
1 parent 4ffb40a commit f32a6ac
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 6 deletions.
16 changes: 11 additions & 5 deletions src/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@
#include <SEGGER_RTT_streams.h>
#endif
#include <boot_service_discovery.h>
#include <drivers/gps/gps_driver.h>
#include <drivers/gps/ublox_gps_driver.h>
#include <etl/to_string.h>
#include <heartbeat.h>
#include <id_eeprom.h>
Expand All @@ -18,26 +20,28 @@
#include <xbot-service/Io.hpp>
#include <xbot-service/portable/system.hpp>

#include "services/diff_drive_service/diff_drive_service.hpp"
#include "services/emergency_service/emergency_service.hpp"
#include "services/imu_service/imu_service.hpp"
#include "services/power_service/power_service.hpp"
#include "services/diff_drive_service/diff_drive_service.hpp"
#include "services/mower_service/mower_service.hpp"
#include "services/power_service/power_service.hpp"
EmergencyService emergency_service{1};
DiffDriveService diff_drive{2};
MowerService mower_service{3};
ImuService imu_service{4};
PowerService power_service{5};

xbot::driver::gps::UbxGpsDriver ubx_gps_driver{};
DebugTCPInterface gps_debug{1000, &ubx_gps_driver};
uint8_t id[6]{};
/*
* Application entry point.
*/
int main() {
#ifdef RELEASE_BUILD
// Reset the boot register for a release build, so that the chip
// resets to bootloader
MODIFY_REG(SYSCFG->UR2, SYSCFG_UR2_BOOT_ADD0,
(0x8000000 >> 16) << SYSCFG_UR2_BOOT_ADD0_Pos);
MODIFY_REG(SYSCFG->UR2, SYSCFG_UR2_BOOT_ADD0, (0x8000000 >> 16) << SYSCFG_UR2_BOOT_ADD0_Pos);
#endif

// Need to disable D-Cache for the Ethernet MAC to work properly
Expand All @@ -58,6 +62,7 @@ int main() {
SYSVIEW_ChibiOS_Start(STM32_SYS_CK, STM32_SYS_CK, "I#15=SysTick");
#endif


/*
* InitGlobals() sets up global variables shared by threads. (e.g. mutex)
* InitHeartbeat() starts the heartbeat timer to blink an LED as long as the
Expand Down Expand Up @@ -95,7 +100,8 @@ int main() {
diff_drive.start();
mower_service.start();


ubx_gps_driver.StartDriver(&UARTD6, 921600);
gps_debug.Start();

// Subscribe to global events and dispatch to our services
event_listener_t event_listener;
Expand Down
5 changes: 4 additions & 1 deletion src/services/mower_service/mower_service.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,10 @@ bool MowerService::Configure() {
// No configuration needed
return true;
}
void MowerService::OnCreate() { mower_driver_.StartDriver(&UARTD2, 115200); }
void MowerService::OnCreate() {
mower_driver_.StartDriver(&UARTD2, 115200);
mower_esc_driver_interface_.Start();
}
void MowerService::OnStart() { mower_duty_ = 0; }
void MowerService::OnStop() { mower_duty_ = 0; }

Expand Down
2 changes: 2 additions & 0 deletions src/services/mower_service/mower_service.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
#include <drivers/vesc/VescDriver.h>

#include <MowerServiceBase.hpp>
#include <debug/debug_tcp_interface.hpp>

class MowerService : public MowerServiceBase {
public:
Expand All @@ -35,6 +36,7 @@ class MowerService : public MowerServiceBase {
float mower_duty_ = 0;
bool duty_sent_ = false;
xbot::driver::esc::VescDriver mower_driver_{};
DebugTCPInterface mower_esc_driver_interface_{65103,&mower_driver_};
};

#endif // MOWER_SERVICE_HPP

0 comments on commit f32a6ac

Please # to comment.