Skip to content
Open
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
4 changes: 3 additions & 1 deletion .vscode/settings.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@
"stm32_hal_legacy.h": "c",
"stm32f3xx.h": "c",
"stm32f303xe.h": "c",
"robotpins.h": "c"
"robotpins.h": "c",
"stm32f3xx_it.h": "c",
"communicationstructs.h": "c"
}
}
131 changes: 0 additions & 131 deletions app/inc/CanBusTask.h

This file was deleted.

27 changes: 22 additions & 5 deletions app/inc/CommunicationStructs.h
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@

#pragma once

#include "main.h"
#include "cmsis_os.h"
#include "main.h"

/**
* @brief Represents a CAN bus message splitted into the velocity
Expand All @@ -35,10 +35,27 @@ typedef struct {
uint8_t vMotor_pitch;
} GimballControlMessage;


// Message queues from protocols
/**
* @brief Represents a Control Data Message
*/
#pragma pack(push, 1)
typedef struct control_data {
uint8_t joystickA;
uint8_t joystickB;
uint8_t knobA;
uint8_t knobB;
uint8_t switchA;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

El packed te sirve cuando tienes arrays de datos de diferentes tamaños... en este caso, todos son de 8 bit... no hay necesidad de hacerlo packed
Realmente ocupas 8 bits para los switches?

uint8_t switchB;
uint8_t switchC;
uint8_t switchD;
} control_data;
#pragma pack(pop)

// Message queues from protocols
extern osPoolId can_rx_mpool;
extern osPoolId can_tx_mpool;

extern osMessageQId outputQueueChassis;
extern osMessageQId inputQueueChassis;
extern osMessageQId outputQueueChassis;
extern osMessageQId inputQueueChassis;

extern osMessageQId remoteQueue;
55 changes: 0 additions & 55 deletions app/inc/RobomasterCanProtocol.h

This file was deleted.

37 changes: 37 additions & 0 deletions app/src/remote_control.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
#include <stm32f3xx_hal.h>
#include <stm32f3xx_it.h>
#include <string.h>

#include "CommunicationStructs.h"
#include "cmsis_os.h"
#include "usart.h"

control_data control1;
UART_HandleTypeDef huart1;
uint8_t UART1_rxBuffer;

osMessageQDef(remoteQueue, 16, unsigned int);

void UART_Init(void) {}

void sbus_translate(control_data* _control, uint8_t* _buffer) {
_control->joystickA = (_buffer[0] >> 1) & 0x7F; // 7bits
_control->joystickB = ((_buffer[0] & 0x01) << 6) | ((_buffer[1] >> 2) & 0x3F); // 7bits
_control->switchA = (_buffer[1] >> 1) & 0x01; // 2bits
_control->switchB = _buffer[1] & 0x01; // 2bits
_control->switchC = (_buffer[2] >> 6) & 0x03; // 4bits
_control->switchD = (_buffer[2] >> 4) & 0x03; // 4bits
_control->knobA = _buffer[3]; // 8bits
_control->knobB = _buffer[4]; // 8bits
}

void UART_Task(void* argument) {
HAL_UART_Receive_IT(&huart1, &UART1_rxBuffer, 12);
remoteQueue = osMessageCreate(osMessageQ(remoteQueue), NULL);
for (;;) {
sbus_translate(&control1, &UART1_rxBuffer);
osMessagePut(remoteQueue, (unsigned int)&control1, osWaitForever);
}
}

void HAL_UART_RxCpltCallback(UART_HandleTypeDef* uart) { HAL_UART_Receive_IT(&huart1, &UART1_rxBuffer, 12); }
Empty file added test.txt
Empty file.