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.

28 changes: 24 additions & 4 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,30 @@ typedef struct {
uint8_t vMotor_pitch;
} GimballControlMessage;

/**
* @brief Represents a Control Data Message
*/
#pragma pack(push, 1)
typedef struct control_data {
uint8_t joystickAx;
uint8_t joystickAy;
uint8_t joystickBx;
uint8_t joystickBy;
uint8_t knobA;
uint8_t knobB;
uint8_t switchA;
uint8_t switchB;
uint8_t switchC;
uint8_t switchD;
} control_data;
#pragma pack(pop)

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

extern osMessageQId outputQueueChassis;
extern osMessageQId inputQueueChassis;

extern osMessageQId outputQueueChassis;
extern osMessageQId inputQueueChassis;
extern osMessageQId remoteQueue;
Copy link
Contributor

Choose a reason for hiding this comment

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

Falta el message pool

55 changes: 0 additions & 55 deletions app/inc/RobomasterCanProtocol.h

This file was deleted.

40 changes: 40 additions & 0 deletions app/src/remote_control.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
#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;
Copy link
Contributor

Choose a reason for hiding this comment

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

Este, en teoría debe de estar declarado en el robot config... no hay necesidad de redeclararlo.

uint8_t UART1_rxBuffer;

osMessageQDef(remoteQueue, 16, unsigned int);
Copy link
Contributor

Choose a reason for hiding this comment

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

Faltan los message pools


void UART_Init(void) {}

void sbus_translate(control_data* _control, uint8_t* _buffer) {
_control->joystickAx = ((_buffer[1] >> 3) | (_buffer[2] << 5)) & 0xff;
_control->joystickAy = ((_buffer[2] >> 6) | (_buffer[3] << 2) | (_buffer[4] << 10)) & 0xff;
_control->joystickBx = ((_buffer[4] >> 1) | (_buffer[5] << 7)) & 0x0ff;
_control->joystickBy = ((_buffer[5] >> 1) | (_buffer[6] << 7)) & 0x0ff;
_control->knobA = ((_buffer[6] >> 7) | (_buffer[7] << 1)) & 0xff;
_control->knobB = ((_buffer[7]) | (_buffer[8])) & 0xff;
_control->switchA = (_buffer[9] & 0x07) >> 2;
_control->switchB = (_buffer[10] & 0x20) >> 5;
_control->switchC = ((_buffer[12] >> 3) & 0x03);
_control->switchD = ((_buffer[13] & 0x08) >> 3);
}

void UART_Task(void* argument) {
HAL_UART_Receive_IT(&huart1, &UART1_rxBuffer, 12);
osPoolDef(remote_pool, 16, control_data);
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.