Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
54 commits
Select commit Hold shift + click to select a range
4d65c17
rgb feature 1.0
SamDan13 Jan 17, 2023
b61b0f6
Merge branch 'feature/led_rgb_new_debug_code' of https://github.com/T…
dmrohrs Jan 17, 2023
d94c917
Merge branch 'feature/led_rgb_new_debug_code' of https://github.com/T…
dmrohrs Jan 17, 2023
8485fe9
new rgb function
SamDan13 Jan 24, 2023
210e6f9
Merge branch 'feature/led_rgb_new_debug_code' of https://github.com/T…
dmrohrs Jan 24, 2023
487ff66
new rgb function 1.1
SamDan13 Jan 26, 2023
5936a44
Merge branch 'feature/led_rgb_new_debug_code' of https://github.com/T…
dmrohrs Jan 26, 2023
4ad37d6
new rgb function 1.2
SamDan13 Feb 13, 2023
6c8abed
Merge branch 'feature/led_rgb_new_debug_code' of https://github.com/T…
dmrohrs Feb 14, 2023
e2c86f6
new rgb function 1.3
SamDan13 Feb 16, 2023
8f74fe6
Merge branch 'feature/led_rgb_new_debug_code' of https://github.com/T…
dmrohrs Feb 16, 2023
98b8764
new rgb function 1.4
SamDan13 Feb 23, 2023
ee7557f
new rgb function 1.4.2
SamDan13 Feb 23, 2023
432c438
Merge branch 'feature/led_rgb_new_debug_code' of https://github.com/T…
dmrohrs Feb 23, 2023
fa174a7
new rgb function 1.4.3
SamDan13 Feb 24, 2023
b60da98
Merge branch 'feature/led_rgb_new_debug_code' of https://github.com/T…
dmrohrs Feb 27, 2023
da7f5e8
possible solution
dmrohrs Feb 27, 2023
993b0e4
Merge branch 'develop' of https://github.com/Tesla-UFMG/ECU into feat…
dmrohrs Feb 27, 2023
f16376d
possible solution pt.2
dmrohrs Feb 27, 2023
578284e
possible solution pt.3
SamDan13 Feb 28, 2023
36a0b4a
possible changes
dmrohrs Mar 2, 2023
f549fc5
Merge branch 'develop' of https://github.com/Tesla-UFMG/ECU into feat…
dmrohrs Mar 3, 2023
badb618
test chages
dmrohrs Mar 3, 2023
d318228
possible solution pt.4
SamDan13 Mar 10, 2023
ba3b89b
Merge branch 'feature/led_rgb_new_debug_code' of https://github.com/T…
dmrohrs Mar 10, 2023
ad8148b
possible solution pt.4
SamDan13 Mar 14, 2023
48994bc
Merge branch 'feature/led_rgb_new_debug_code' of https://github.com/T…
dmrohrs Mar 14, 2023
fde458d
logic test changes & defines added
dmrohrs Mar 15, 2023
1bc9d91
Merge branch 'develop' of https://github.com/Tesla-UFMG/ECU into feat…
dmrohrs Mar 15, 2023
247157e
final solution
SamDan13 Mar 15, 2023
cdf0538
led final solution
SamDan13 Mar 16, 2023
096330c
led rgb final solution
SamDan13 Mar 16, 2023
5071aec
led rgb solution
SamDan13 Mar 16, 2023
c9b2f3e
led rgb solution
SamDan13 Mar 16, 2023
b3a7841
led rgb solution
SamDan13 Mar 19, 2023
3968d88
led rgb solution
SamDan13 Mar 19, 2023
2f99c7d
rgb_led_handler.c improvement
SamDan13 Apr 3, 2023
62a02c8
are_messages_available
SamDan13 Apr 5, 2023
ee00b1d
solved requested changes
SamDan13 Apr 5, 2023
59ed551
Merge branch 'develop' into feature/led_rgb_new_debug_code
SamDan13 Apr 12, 2023
372c961
some fixes
SamDan13 Apr 12, 2023
985d01d
some fixes
SamDan13 Apr 12, 2023
81a5b13
format fixes
SamDan13 Apr 12, 2023
438855b
correcting type of function 'are_messages_available'
SamDan13 Apr 12, 2023
2c1e397
resolved requests
SamDan13 May 6, 2023
673f50a
resolved requests -- formatting fix
SamDan13 May 6, 2023
7d36a36
resolved requests -- clang-tidy fix
SamDan13 May 6, 2023
04315a9
RTD.c requests
SamDan13 May 21, 2023
8db24a2
clang-format fixes
SamDan13 May 31, 2023
60052c9
Merge branch 'develop' of https://github.com/Tesla-UFMG/ECU into feat…
dmrohrs May 31, 2023
cef562b
updating .yml clang-format version
dmrohrs Jun 1, 2023
aa1c879
formatting global_definitions.h
dmrohrs Jun 1, 2023
c0f6038
test function
SamDan13 Jun 11, 2023
bfff9f2
Merge branch 'feature/led_rgb_new_debug_code' of https://github.com/T…
SamDan13 Jun 11, 2023
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 .github/workflows/clang-format-check.yml
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ jobs:
- name: Run clang-format style check.
uses: jidicula/clang-format-action@v4.10.2
with:
clang-format-version: '15'
clang-format-version: '16'
check-path: 'Core'
# In the following line all files exceptions should be defined
exclude-regex: '(freertos|main.c|main.h|stm32h7xx|syscalls.c|sysmem.c|FreeRTOSConfig.h)'
6 changes: 3 additions & 3 deletions Core/Inc/leds/debug_leds_handler.h
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
/*
* leds.h
*
* Created on: May 13, 2021
* Author: Felipe Telles
* Created on: May 21, 2023
* Author: Samuel Dantas
*/

#ifndef INC_DEBUGLEDS_H_
Expand All @@ -19,7 +19,7 @@
typedef enum { ON, OFF, TOGGLE, BLINK, FASTBLINK } ControlDebugLED_e;

typedef struct {
uint16_t lednumber;
uint16_t led_number;
ControlDebugLED_e control;
uint8_t amount;
} debug_led_message_t;
Expand Down
50 changes: 37 additions & 13 deletions Core/Inc/leds/rgb_led_handler.h
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
/*
* leds.h
*
* Created on: May 13, 2021
* Created on: May 21, 2023
* Author: Felipe Telles
*/

Expand All @@ -13,30 +13,53 @@
#include "stdint.h"
#include "util/global_definitions.h"

#define RGB_BLINK_DELAY 200
#define RGB_TIMEOUT 200
#define RGB_BLINK_200_DELAY 200
#define RGB_BLINK_1000_DELAY 1000
#define ONE_COLOR_PATTERN_POS 0
#define ONE_COLOR_PATTERN_SIZE 1
#define SOFT_ERROR_COLORS_PATTERN_SIZE 2
#define HARD_ERROR_COLORS_PATTERN_SIZE 3

#define RGB_BLACK \
(rgb_t) { 0, 0, 0 }
(rgb_t) { \
0, 0, 0 \
}
#define RGB_RED \
(rgb_t) { 1, 0, 0 }
(rgb_t) { \
1, 0, 0 \
}
#define RGB_GREEN \
(rgb_t) { 0, 1, 0 }
(rgb_t) { \
0, 1, 0 \
}
#define RGB_BLUE \
(rgb_t) { 0, 0, 1 }
(rgb_t) { \
0, 0, 1 \
}
#define RGB_YELLOW \
(rgb_t) { 1, 1, 0 }
(rgb_t) { \
1, 1, 0 \
}
#define RGB_PURBLE \
(rgb_t) { 1, 0, 1 }
(rgb_t) { \
1, 0, 1 \
}
#define RGB_CYAN \
(rgb_t) { 0, 1, 1 }
(rgb_t) { \
0, 1, 1 \
}
#define RGB_WHITE \
(rgb_t) { 1, 1, 1 }
(rgb_t) { \
1, 1, 1 \
}

typedef enum { FIXED, BLINK200, NO_CHANGE } control_rgb_led_e;
typedef enum { FIXED, BLINK200 } control_rgb_led_e;

typedef struct {
cores_t color;
colors_t pattern[3];
control_rgb_led_e control;
uint8_t size_of_pattern;
} rgb_led_message_t;

typedef struct {
Expand All @@ -45,6 +68,7 @@ typedef struct {
GPIO_PinState blue;
} rgb_t;

osStatus_t set_rgb_led(cores_t color, control_rgb_led_e control);
osStatus_t set_rgb_led(const colors_t* pattern, uint8_t size_of_pattern,
control_rgb_led_e control);

#endif /* INC_RGB_LED_H_ */
2 changes: 1 addition & 1 deletion Core/Inc/util/CMSIS_extra/global_variables_handler.h
Original file line number Diff line number Diff line change
Expand Up @@ -162,4 +162,4 @@ void set_global_var(global_vars_e type, void* message);
type##_var; \
})

#endif /* INC_CMSIS_EXTRA_GLOBAL_VARIABLES_HANDLER_H_ */
#endif /* INC_CMSIS_EXTRA_GLOBAL_VARIABLES_HANDLER_H_ */
6 changes: 3 additions & 3 deletions Core/Inc/util/global_definitions.h
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
typedef enum { FRONT_RIGHT = 0, FRONT_LEFT, REAR_RIGHT, REAR_LEFT } speed_pin_e;

// cores do LED da ECU
typedef enum { PRETO = 0, VERMELHO, VERDE, AZUL, AMARELO, ROXO, CIANO, BRANCO } cores_t;
typedef enum { BLACK = 0, RED, GREEN, BLUE, YELLOW, PURPLE, CYAN, WHITE } colors_t;

typedef enum modos_desempenho {
ERRO = 0,
Expand All @@ -28,7 +28,7 @@ typedef enum modos_desempenho {
AUTOX
} race_mode_t;

typedef struct // struct de modo
typedef struct // struct de modo
{
int tor_max; // torque maximo (de 0 a 4000)
int vel_max; // velocidade maxima (de 0 a 9000)
Expand All @@ -43,7 +43,7 @@ typedef struct // struct de modo
int torq_gain; // ganho de torque, aconselhavel q seja proporcional ao torque maximo (
// de 0 a 40)
race_mode_t mode; // 1 enduro, 2 aceleracao, 3 skidpad, 4 autox
cores_t cor;
colors_t rgb_colors[1];
} modos;

#define R_MOTOR 0
Expand Down
19 changes: 10 additions & 9 deletions Core/Src/driver_settings/RTD.c
Original file line number Diff line number Diff line change
Expand Up @@ -23,31 +23,31 @@ static void set_RTD();
void RTD(void* argument) {
UNUSED(argument);

// seta o led rgb no primeira execucao do codigo
set_rgb_led(get_global_var_value(SELECTED_MODE).cor, BLINK200);
// set the rgb led on the first execution of the code
set_rgb_led(get_global_var_value(SELECTED_MODE).rgb_colors, ONE_COLOR_PATTERN_SIZE,
BLINK200);

for (;;) {

// espera receber flag q o botao de RTD foi pressionado
// waits to receive flag that the RTD button was pressed
osThreadFlagsWait(RTD_BTN_PRESSED_THREAD_FLAG, osFlagsWaitAny, osWaitForever);

if (!is_RTD_active()) {
if (can_RTD_be_enabled()) {
set_RTD();
} else {
// envia uma mensagem de alerta caso n seja possivel acionar RTD
// sends an alert message if it is not possible to trigger RTD
set_debugleds(DEBUGLED1, BLINK, 2);
}
}
}
}

void exit_RTD() {
// seta modo_selecionado como erro
// set the mode_selected as error
set_global_var_value(SELECTED_MODE, erro);
Comment thread
SamDan13 marked this conversation as resolved.
set_global_var_value(RACE_MODE, ERRO);
set_rgb_led(get_global_var_value(SELECTED_MODE).cor, BLINK200);
// limpa flag de RTD
// clear RTD flag
osEventFlagsClear(e_ECU_control_flagsHandle, RTD_FLAG);
osThreadFlagsSet(t_odometer_saveHandle, ODOMETER_SAVE_THREAD_FLAG);
}
Expand Down Expand Up @@ -81,7 +81,7 @@ void exit_RTD() {
* TODO: Allow RTD activation from the status check of the AIRs.
*/
static bool can_RTD_be_enabled() {
// obtem todas as flags e filtra apenas flags de erros severos, ignorando as outras
// get all flags and filter only severe error flags, ignoring others
uint32_t error_flags = osEventFlagsGet(e_ECU_control_flagsHandle);
error_flags &= ALL_SEVERE_ERROR_FLAG;
BRAKE_STATUS_t is_brake_active = get_global_var_value(BRAKE_STATUS);
Expand All @@ -100,7 +100,8 @@ static bool can_RTD_be_enabled() {

static void set_RTD() {
osEventFlagsSet(e_ECU_control_flagsHandle, RTD_FLAG);
set_rgb_led(get_global_var_value(SELECTED_MODE).cor, FIXED);
set_rgb_led(get_global_var_value(SELECTED_MODE).rgb_colors, FIXED,
ONE_COLOR_PATTERN_SIZE);
activate_RTDS();
}

Expand Down
4 changes: 2 additions & 2 deletions Core/Src/driver_settings/modo.c
Original file line number Diff line number Diff line change
Expand Up @@ -37,8 +37,8 @@ void seleciona_modo(void* argument) {
case AUTOX: set_global_var_value(SELECTED_MODE, autox); break;
default: set_global_var_value(SELECTED_MODE, erro); break;
}

set_rgb_led(get_global_var_value(SELECTED_MODE).cor, BLINK200);
set_rgb_led(get_global_var_value(SELECTED_MODE).rgb_colors,
ONE_COLOR_PATTERN_SIZE, BLINK200);
osEventFlagsClear(e_ECU_control_flagsHandle, DYNAMIC_CONTROL_FLAG);
}
// todo: dataloggar modos
Expand Down
34 changes: 18 additions & 16 deletions Core/Src/leds/debug_leds_handler.c
Original file line number Diff line number Diff line change
@@ -1,13 +1,15 @@
/*
* leds.c
*
* Created on: May 12, 2021
* Author: Felipe Telles
* Created on: May 21, 2023
* Author: Samuel Dantas
*/

#include "leds/debug_leds_handler.h"

#include "cmsis_os.h"
#include "util/CMSIS_extra/cmsis_extra.h"
#include "util/CMSIS_extra/global_variables_handler.h"
#include "util/global_definitions.h"
#include "util/global_variables.h"
#include "util/util.h"
Expand All @@ -16,7 +18,7 @@ extern osMessageQueueId_t q_debug_leds_messageHandle;

osStatus_t set_debugleds(uint16_t lednumber, ControlDebugLED_e control, uint8_t amount) {
debug_led_message_t message = {lednumber, control, amount};
return osMessageQueuePut(q_debug_leds_messageHandle, &message, 0, 0U);
return osMessageQueuePutOverwrite(q_debug_leds_messageHandle, &message, 0);
}

void debug_leds(void* argument) {
Expand All @@ -27,36 +29,36 @@ void debug_leds(void* argument) {
for (;;) {
ECU_ENABLE_BREAKPOINT_DEBUG();

// espera ate alguma mensagem chegar
// wait until some message arrives
osMessageQueueGet(q_debug_leds_messageHandle, &message, NULL, osWaitForever);
switch (message.control) {
case ON:
// acende o led escolhido
HAL_GPIO_WritePin(GPIOE, message.lednumber, GPIO_PIN_RESET);
// lights up the chosen led
HAL_GPIO_WritePin(GPIOE, message.led_number, GPIO_PIN_RESET);
break;
case OFF:
// apaga o led escolhido
HAL_GPIO_WritePin(GPIOE, message.lednumber, GPIO_PIN_SET);
// turn off the chosen led
HAL_GPIO_WritePin(GPIOE, message.led_number, GPIO_PIN_SET);
break;
case TOGGLE:
// toggle o led escolhido
HAL_GPIO_TogglePin(GPIOE, message.lednumber);
// toggle the chosen led
HAL_GPIO_TogglePin(GPIOE, message.led_number);
break;
case BLINK:
// pisca o led escolhido, pelo valor de vezes escolhido
// delays garante que eh possivel contar quantas vezes piscou
// blink the chosen led, by the chosen value of times
// delays ensures that it is possible to count how many times it blinked
for (uint8_t i = 0; i < message.amount; i++) {
HAL_GPIO_WritePin(GPIOE, message.lednumber, GPIO_PIN_RESET);
HAL_GPIO_WritePin(GPIOE, message.led_number, GPIO_PIN_RESET);
osDelay(300);
HAL_GPIO_WritePin(GPIOE, message.lednumber, GPIO_PIN_SET);
HAL_GPIO_WritePin(GPIOE, message.led_number, GPIO_PIN_SET);
osDelay(300);
}
osDelay(500);
break;
case FASTBLINK:
HAL_GPIO_WritePin(GPIOE, message.lednumber, GPIO_PIN_RESET);
HAL_GPIO_WritePin(GPIOE, message.led_number, GPIO_PIN_RESET);
osDelay(message.amount);
HAL_GPIO_WritePin(GPIOE, message.lednumber, GPIO_PIN_SET);
HAL_GPIO_WritePin(GPIOE, message.led_number, GPIO_PIN_SET);
osDelay(message.amount / 2);
break;
}
Expand Down
Loading