Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion stm32h753iitx/boardfiles/drivers/rc/rc_crsf.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -85,4 +85,4 @@ void CRSFReceiver::parse() {

UART_HandleTypeDef * CRSFReceiver::getHUART() {
return uart_;
}
}
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#include <cmath>
#include <cstring>
#include <cstdio>
#include "rc.hpp"
#include "rc_sbus.hpp"

DataChunk_t channelMappings[SBUS_CHANNEL_COUNT][SBUS_MAX_BTYES_PER_CHANNEL] = {
{ //channel 1
Expand Down Expand Up @@ -54,31 +54,31 @@ DataChunk_t channelMappings[SBUS_CHANNEL_COUNT][SBUS_MAX_BTYES_PER_CHANNEL] = {
}
};

RCReceiver::RCReceiver(UART_HandleTypeDef* uart) : uart(uart) {
SBUSReceiver::SBUSReceiver(UART_HandleTypeDef* uart) : uart(uart) {
memset((void*)rawSbus, 0, SBUS_PACKET_SIZE);
}


UART_HandleTypeDef* RCReceiver::getHUART() {
UART_HandleTypeDef* SBUSReceiver::getHUART() {
return uart;
}

RCControl RCReceiver::getRCData() {
RCControl SBUSReceiver::getRCData() {
RCControl tmp = rcData;
rcData.isDataNew = false;
return tmp;
}

void RCReceiver::init() {
void SBUSReceiver::init() {
rcData.isDataNew = false;
HAL_UARTEx_ReceiveToIdle_DMA(uart, (uint8_t*)rawSbus, SBUS_PACKET_SIZE);
}

void RCReceiver::startDMA() {
void SBUSReceiver::startDMA() {
HAL_UARTEx_ReceiveToIdle_DMA(uart, (uint8_t*)rawSbus, SBUS_PACKET_SIZE);
}

void RCReceiver::parse() {
void SBUSReceiver::parse() {

uint8_t *buf = (uint8_t*)rawSbus;

Expand All @@ -92,7 +92,7 @@ void RCReceiver::parse() {
}
}

float RCReceiver::sbusToRCControl(uint8_t *buf, int channelMappingIdx) {
float SBUSReceiver::sbusToRCControl(uint8_t *buf, int channelMappingIdx) {
uint16_t res = 0;

for (int i = 0; i < SBUS_MAX_BTYES_PER_CHANNEL; i++) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,9 @@ typedef struct {
int bitshift;
} DataChunk_t;

class RCReceiver : public IRCReceiver {
class SBUSReceiver : public IRCReceiver {
public:
RCReceiver(UART_HandleTypeDef *uart);
SBUSReceiver(UART_HandleTypeDef *uart);

RCControl getRCData() override;

Expand Down
1 change: 1 addition & 0 deletions stm32h753iitx/boardfiles/model/inc/drivers.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
#include "logger.hpp"
#include "motor.hpp"
#include "motor_datatype.hpp"
#include "rc_sbus.hpp"
#include "rc_crsf.hpp"
#include "rc_motor_control.hpp"
#include "tm_queue.hpp"
Expand Down
2 changes: 1 addition & 1 deletion stm32l552xx/boardfiles/drivers/rc/rc_crsf.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,6 @@ void CRSFReceiver::parse() {
rcData.isDataNew = true;
}

UART_HandleTypeDef * CRSFReceiver::getUart() {
UART_HandleTypeDef * CRSFReceiver::getHUART() {
return uart;
}
2 changes: 1 addition & 1 deletion stm32l552xx/boardfiles/drivers/rc/rc_crsf.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ class CRSFReceiver : public IRCReceiver {
void startDMA();

void parse();
UART_HandleTypeDef * getUart();
UART_HandleTypeDef * getHUART();

private:
UART_HandleTypeDef *uart;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#include <cmath>
#include <cstring>
#include <cstdio>
#include "rc.hpp"
#include "rc_sbus.hpp"

DataChunk_t channelMappings[SBUS_CHANNEL_COUNT][SBUS_MAX_BTYES_PER_CHANNEL] = {
{ //channel 1
Expand Down Expand Up @@ -54,31 +54,31 @@ DataChunk_t channelMappings[SBUS_CHANNEL_COUNT][SBUS_MAX_BTYES_PER_CHANNEL] = {
}
};

RCReceiver::RCReceiver(UART_HandleTypeDef* uart) : uart(uart) {
SBUSReceiver::SBUSReceiver(UART_HandleTypeDef* uart) : uart(uart) {
memset(rawSbus, 0, SBUS_PACKET_SIZE);
}


UART_HandleTypeDef* RCReceiver::getHUART() {
UART_HandleTypeDef* SBUSReceiver::getHUART() {
return uart;
}

RCControl RCReceiver::getRCData() {
RCControl SBUSReceiver::getRCData() {
RCControl tmp = rcData;
rcData.isDataNew = false;
return tmp;
}

void RCReceiver::init() {
void SBUSReceiver::init() {
rcData.isDataNew = false;
HAL_UARTEx_ReceiveToIdle_DMA(uart, rawSbus, SBUS_PACKET_SIZE);
}

void RCReceiver::startDMA() {
void SBUSReceiver::startDMA() {
HAL_UARTEx_ReceiveToIdle_DMA(uart, rawSbus, SBUS_PACKET_SIZE);
}

void RCReceiver::parse() {
void SBUSReceiver::parse() {

uint8_t *buf = rawSbus;

Expand All @@ -92,7 +92,7 @@ void RCReceiver::parse() {
}
}

float RCReceiver::sbusToRCControl(uint8_t *buf, int channelMappingIdx) {
float SBUSReceiver::sbusToRCControl(uint8_t *buf, int channelMappingIdx) {
uint16_t res = 0;

for (int i = 0; i < SBUS_MAX_BTYES_PER_CHANNEL; i++) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,9 @@ typedef struct {
int bitshift;
} DataChunk_t;

class RCReceiver : public IRCReceiver {
class SBUSReceiver : public IRCReceiver {
public:
RCReceiver(UART_HandleTypeDef *uart);
SBUSReceiver(UART_HandleTypeDef *uart);

RCControl getRCData() override;

Expand Down
2 changes: 1 addition & 1 deletion stm32l552xx/boardfiles/model/inc/drivers.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
#include "logger.hpp"
#include "motor.hpp"
#include "motor_datatype.hpp"
#include "rc.hpp"
#include "rc_sbus.hpp"
#include "rc_crsf.hpp"
#include "rc_motor_control.hpp"
#include "tm_queue.hpp"
Expand Down
4 changes: 2 additions & 2 deletions stm32l552xx/boardfiles/override.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ void HAL_Delay(uint32_t Delay) {


void HAL_UARTEx_RxEventCallback(UART_HandleTypeDef *huart, uint16_t Size) {
if (huart == rcHandle->getUart()){
if (huart == rcHandle->getHUART()){
rcHandle->parse();
rcHandle->startDMA();
} else if (huart == rfdHandle->getHuart()) {
Expand All @@ -61,7 +61,7 @@ void HAL_UARTEx_RxEventCallback(UART_HandleTypeDef *huart, uint16_t Size) {
}

void HAL_UART_ErrorCallback(UART_HandleTypeDef *huart) {
if(huart == rcHandle->getUart()){
if(huart == rcHandle->getHUART()){
uint32_t error = HAL_UART_GetError(huart);

if (error & HAL_UART_ERROR_PE) {
Expand Down