Skip to content

Commit

Permalink
firmware: drivers: uart_interrupt: Updating UART buffer and size vari…
Browse files Browse the repository at this point in the history
…ables name #76 #140
  • Loading branch information
andrempmattos committed Aug 2, 2021
1 parent 20145c5 commit bfb3e6a
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 17 deletions.
10 changes: 5 additions & 5 deletions firmware/devices/ttc/ttc.c
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
* \author André M. P. de Mattos <andre.mattos@spacelab.ufsc.br>
* \author Augusto Cezar Boldori Vassoler <augustovassoler@gmail.com>
*
* \version 0.2.4
* \version 0.2.6
*
* \date 22/04/2021
*
Expand Down Expand Up @@ -100,16 +100,16 @@ int ttc_init(void)

int ttc_decode(uint8_t *adr, uint32_t *val, uint8_t *cmd)
{
uint8_t buf[received_data_size];
uint8_t buf[uart_received_data_size];

for (int i = 0; i < received_data_size; i++)
for (int i = 0; i < uart_received_data_size; i++)
{
buf[i] = uart_rx_buffer[i];
}

if(ttc_check_crc(buf, received_data_size, buf[received_data_size-1]) == true)
if(ttc_check_crc(buf, uart_received_data_size, buf[uart_received_data_size-1]) == true)
{
switch(received_data_size)
switch(uart_received_data_size)
{
case TTC_COMMAND_WRITE_SIZE:
*adr = buf[0];
Expand Down
4 changes: 2 additions & 2 deletions firmware/devices/ttc/ttc.h
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
* \author André M. P. de Mattos <andre.mattos@spacelab.ufsc.br>
* \author Augusto Cezar Boldori Vassoler <augustovassoler@gmail.com>
*
* \version 0.2.4
* \version 0.2.6
*
* \date 22/04/2020
*
Expand All @@ -48,7 +48,7 @@
#define TTC_COMMAND_WRITE_SIZE 6

/**
* \brief UART ports.
* \brief TTC command types.
*/
typedef enum
{
Expand Down
16 changes: 8 additions & 8 deletions firmware/drivers/uart_interrupt/uart_interrupt.c
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
* \author Gabriel Mariano Marcelino <gabriel.mm8@gmail.com>
* \author André M. P. de Mattos <andre.mattos@spacelab.ufsc.br>
*
* \version 0.2.4
* \version 0.2.6
*
* \date 2021/08/01
*
Expand All @@ -45,8 +45,8 @@
#include "uart_interrupt.h"

uint8_t uart_rx_buffer[UART_RX_BUFFER_MAX_SIZE];
uint8_t received_data_size = 0;
uint8_t index = 0;
uint8_t uart_received_data_size = 0;
uint8_t uart_buffer_index = 0;

int uart_interrupt_init(uart_interrupt_port_t port, uart_interrupt_config_t config)
{
Expand Down Expand Up @@ -272,17 +272,17 @@ void USCI_A0_ISR(void)
if (USCI_A_UART_queryStatusFlags(USCI_A0_BASE, USCI_A_UART_BREAK_DETECT) == USCI_A_UART_BREAK_DETECT)
{
#if CONFIG_DRIVERS_DEBUG_ENABLED == 1
sys_log_print_event_from_module(SYS_LOG_ERROR, UART_MODULE_NAME, "Received data: ");
for (int i = 0; i < index; i++)
sys_log_print_event_from_module(SYS_LOG_INFO, UART_MODULE_NAME, "Received data: ");
for (int i = 0; i < uart_buffer_index; i++)
{
sys_log_print_hex(uart_rx_buffer[i]);
sys_log_print_msg(",");
}
sys_log_new_line();
#endif /* CONFIG_DRIVERS_DEBUG_ENABLED */

received_data_size = index;
index = 0;
uart_received_data_size = uart_buffer_index;
uart_buffer_index = 0;

/* xHigherPriorityTaskWoken must be initialised to pdFALSE. If calling
xTaskNotifyFromISR() unblocks the handling task, and the priority of
Expand All @@ -297,7 +297,7 @@ void USCI_A0_ISR(void)
}
else
{
uart_rx_buffer[index++] = USCI_A_UART_receiveData(USCI_A0_BASE);
uart_rx_buffer[uart_buffer_index++] = USCI_A_UART_receiveData(USCI_A0_BASE);
}
break;
default:
Expand Down
4 changes: 2 additions & 2 deletions firmware/drivers/uart_interrupt/uart_interrupt.h
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
* \author Gabriel Mariano Marcelino <gabriel.mm8@gmail.com>
* \author André M. P. de Mattos <andre.mattos@spacelab.ufsc.br>
*
* \version 0.2.4
* \version 0.2.6
*
* \date 2021/08/01
*
Expand All @@ -49,7 +49,7 @@
* \brief UART interrupt RX buffer and size.
*/
extern uint8_t uart_rx_buffer[UART_RX_BUFFER_MAX_SIZE];
extern uint8_t received_data_size;
extern uint8_t uart_received_data_size;

/**
* \brief UART ports.
Expand Down

0 comments on commit bfb3e6a

Please sign in to comment.