-
Notifications
You must be signed in to change notification settings - Fork 4
Nucleo f303re enhnancements #12
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from all commits
7d8681c
85437a8
d5694a8
a562a34
667c692
42f7ae7
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
This file was deleted.
This file was deleted.
| 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; | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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); | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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); } | ||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Falta el message pool