-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
firmware: app: tasks: param_server: Adding TTC communication handling #…
- Loading branch information
1 parent
95c3ffc
commit 20145c5
Showing
3 changed files
with
64 additions
and
127 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -24,8 +24,9 @@ | |
* \brief Parameter server task implementation. | ||
* | ||
* \author Gabriel Mariano Marcelino <[email protected]> | ||
* \author André M. P. de Mattos <[email protected]> | ||
* | ||
* \version 0.2.2 | ||
* \version 0.2.6 | ||
* | ||
* \date 2021/07/24 | ||
* | ||
|
@@ -36,150 +37,85 @@ | |
#include <system/sys_log/sys_log.h> | ||
#include <structs/eps2_data.h> | ||
|
||
#include <devices/ttc/ttc.h> | ||
#include <devices/obdh/obdh.h> | ||
|
||
#include "param_server.h" | ||
#include "startup.h" | ||
|
||
xTaskHandle xTaskParamServerHandle; | ||
|
||
void vTaskParamServer(void *pvParameters) | ||
{ | ||
const TickType_t xMaxBlockTime = pdMS_TO_TICKS( 500 ); /*< Use portMAX_DELAY instead to block indefinitely. */ | ||
BaseType_t xResult; | ||
uint32_t ulNotifiedValue; | ||
|
||
/* Delay before the first cycle */ | ||
vTaskDelay(pdMS_TO_TICKS(TASK_PARAM_SERVER_INITIAL_DELAY_MS)); | ||
|
||
uint8_t adr = 0; | ||
uint32_t val = 0; | ||
uint8_t cmd = 0; | ||
|
||
/* Wait startup task to finish */ | ||
xEventGroupWaitBits(task_startup_status, TASK_STARTUP_DONE, pdFALSE, pdTRUE, pdMS_TO_TICKS(TASK_PARAM_SERVER_INIT_TIMEOUT_MS)); | ||
|
||
while(1) | ||
{ | ||
xResult = xTaskNotifyWait(0UL, 0xFFFFFFFFUL, &ulNotifiedValue, xMaxBlockTime); | ||
xResult = xTaskNotifyWait(0UL, 0xFFFFFFFFUL, &ulNotifiedValue, pdMS_TO_TICKS(TASK_PARAM_SERVER_MAX_BLOCK_TIME_MS)); | ||
|
||
if (xResult == pdPASS) | ||
{ | ||
if ( (ulNotifiedValue & NOTIFICATION_VALUE_FROM_I2C_SLAVE_ISR) != 0) | ||
/* Process interrupt from UART ISR. */ | ||
if ( (ulNotifiedValue & NOTIFICATION_VALUE_FROM_I2C_ISR) != 0) | ||
{ | ||
/* TO DO. */ | ||
/* Process interrupt from i2c_slave ISR. */ | ||
} | ||
if ( (ulNotifiedValue & NOTIFICATION_VALUE_FROM_UART) != 0) | ||
|
||
/* Process interrupt from UART ISR. */ | ||
if ( (ulNotifiedValue & NOTIFICATION_VALUE_FROM_UART_ISR) != 0) | ||
{ | ||
/* TO DO. */ | ||
ttc_decode(&adr, &val, &cmd); | ||
|
||
sys_log_print_event_from_module(SYS_LOG_INFO, TASK_PARAM_SERVER_NAME, "TTC command received: "); | ||
sys_log_print_msg("cmd="); | ||
sys_log_print_int(cmd); | ||
sys_log_new_line(); | ||
|
||
switch(cmd) | ||
{ | ||
case TTC_COMMAND_WRITE: | ||
if (eps_buffer_write(adr, &val) != 0) | ||
{ | ||
sys_log_print_event_from_module(SYS_LOG_ERROR, TASK_PARAM_SERVER_NAME, "TTC write command has failed to complete!"); | ||
sys_log_new_line(); | ||
} | ||
break; | ||
case TTC_COMMAND_READ: | ||
if (eps_buffer_read(adr, &val) != 0) | ||
{ | ||
sys_log_print_event_from_module(SYS_LOG_ERROR, TASK_PARAM_SERVER_NAME, "TTC read command has failed to complete!"); | ||
sys_log_new_line(); | ||
} | ||
else | ||
{ | ||
if (ttc_answer(adr, val) != 0) | ||
{ | ||
sys_log_print_event_from_module(SYS_LOG_ERROR, TASK_PARAM_SERVER_NAME, "TTC read command has failed to complete!"); | ||
sys_log_new_line(); | ||
} | ||
} | ||
break; | ||
default: | ||
break; | ||
} | ||
} | ||
} | ||
else | ||
{ | ||
/* xTaskNotifyWait timed out. */ | ||
sys_log_print_event_from_module(SYS_LOG_WARNING, TASK_PARAM_SERVER_NAME, "Any command request received in the last minute"); | ||
sys_log_new_line(); | ||
} | ||
|
||
// TickType_t last_cycle = xTaskGetTickCount(); | ||
|
||
// eps2_param_id_t req_id = UINT8_MAX; | ||
|
||
// switch(req_id) | ||
// { | ||
// case EPS2_PARAM_ID_TIME_COUNTER: | ||
// break; | ||
// case EPS2_PARAM_ID_MCU_TEMP: | ||
// break; | ||
// case EPS2_PARAM_ID_EPS_CURRENT: | ||
// break; | ||
// case EPS2_PARAM_ID_LAST_RESET_CAUSE: | ||
// break; | ||
// case EPS2_PARAM_ID_RESET_COUNTER: | ||
// break; | ||
// case EPS2_PARAM_ID_SP_MY_PX_VOLTAGE: | ||
// break; | ||
// case EPS2_PARAM_ID_SP_MX_PZ_VOLTAGE: | ||
// break; | ||
// case EPS2_PARAM_ID_SP_MZ_PY_VOLTAGE: | ||
// break; | ||
// case EPS2_PARAM_ID_SP_MY_CURRENT: | ||
// break; | ||
// case EPS2_PARAM_ID_SP_PY_CURRENT: | ||
// break; | ||
// case EPS2_PARAM_ID_SP_MX_CURRENT: | ||
// break; | ||
// case EPS2_PARAM_ID_SP_PX_CURRENT: | ||
// break; | ||
// case EPS2_PARAM_ID_SP_MZ_CURRENT: | ||
// break; | ||
// case EPS2_PARAM_ID_SP_PZ_CURRENT: | ||
// break; | ||
// case EPS2_PARAM_ID_MPPT_1_DUTY_CYCLE: | ||
// break; | ||
// case EPS2_PARAM_ID_MPPT_2_DUTY_CYCLE: | ||
// break; | ||
// case EPS2_PARAM_ID_MPPT_3_DUTY_CYCLE: | ||
// break; | ||
// case EPS2_PARAM_ID_SP_VOLTAGE_MPPT: | ||
// break; | ||
// case EPS2_PARAM_ID_MAIN_POWER_BUS_VOLTAGE: | ||
// break; | ||
// case EPS2_PARAM_ID_RTD_0_TEMP: | ||
// break; | ||
// case EPS2_PARAM_ID_RTD_1_TEMP: | ||
// break; | ||
// case EPS2_PARAM_ID_RTD_2_TEMP: | ||
// break; | ||
// case EPS2_PARAM_ID_RTD_3_TEMP: | ||
// break; | ||
// case EPS2_PARAM_ID_RTD_4_TEMP: | ||
// break; | ||
// case EPS2_PARAM_ID_RTD_5_TEMP: | ||
// break; | ||
// case EPS2_PARAM_ID_RTD_6_TEMP: | ||
// break; | ||
// case EPS2_PARAM_ID_BAT_VOLTAGE: | ||
// break; | ||
// case EPS2_PARAM_ID_BAT_CURRENT: | ||
// break; | ||
// case EPS2_PARAM_ID_BAT_AVERAGE_CURRENT: | ||
// break; | ||
// case EPS2_PARAM_ID_BAT_ACC_CURRENT: | ||
// break; | ||
// case EPS2_PARAM_ID_BAT_CHARGE: | ||
// break; | ||
// case EPS2_PARAM_ID_BAT_MONITOR_TEMP: | ||
// break; | ||
// case EPS2_PARAM_ID_BAT_MONITOR_STATUS: | ||
// break; | ||
// case EPS2_PARAM_ID_BAT_MONITOR_PROTECT: | ||
// break; | ||
// case EPS2_PARAM_ID_BAT_MONITOR_CYCLE_COUNTER: | ||
// break; | ||
// case EPS2_PARAM_ID_BAT_MONITOR_RAAC: | ||
// break; | ||
// case EPS2_PARAM_ID_BAT_MONITOR_RSAC: | ||
// break; | ||
// case EPS2_PARAM_ID_BAT_MONITOR_RARC: | ||
// break; | ||
// case EPS2_PARAM_ID_BAT_MONITOR_RSRC: | ||
// break; | ||
// case EPS2_PARAM_ID_BAT_HEATER_1_DUTY_CYCLE: | ||
// break; | ||
// case EPS2_PARAM_ID_BAT_HEATER_2_DUTY_CYCLE: | ||
// break; | ||
// case EPS2_PARAM_ID_HW_VERSION: | ||
// break; | ||
// case EPS2_PARAM_ID_FW_VERSION: | ||
// break; | ||
// case EPS2_PARAM_ID_MPPT_1_MODE: | ||
// break; | ||
// case EPS2_PARAM_ID_MPPT_2_MODE: | ||
// break; | ||
// case EPS2_PARAM_ID_MPPT_3_MODE: | ||
// break; | ||
// case EPS2_PARAM_ID_BAT_HEATER_1_MODE: | ||
// break; | ||
// case EPS2_PARAM_ID_BAT_HEATER_2_MODE: | ||
// break; | ||
// case EPS2_PARAM_ID_DEVICE_ID: | ||
// break; | ||
// default: | ||
// sys_log_print_event_from_module(SYS_LOG_ERROR, TASK_PARAM_SERVER_NAME, "Unknown parameter ID!"); | ||
// sys_log_new_line(); | ||
// } | ||
|
||
// vTaskDelayUntil(&last_cycle, pdMS_TO_TICKS(TASK_PARAM_SERVER_PERIOD_MS)); | ||
|
||
} | ||
} | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -24,8 +24,9 @@ | |
* \brief Parameter server task definition. | ||
* | ||
* \author Gabriel Mariano Marcelino <[email protected]> | ||
* \author André M. P. de Mattos <[email protected]> | ||
* | ||
* \version 0.2.1 | ||
* \version 0.2.6 | ||
* | ||
* \date 2021/07/24 | ||
* | ||
|
@@ -43,11 +44,11 @@ | |
#define TASK_PARAM_SERVER_NAME "Param Server" /**< Task name. */ | ||
#define TASK_PARAM_SERVER_STACK_SIZE 300 /**< Stack size in bytes. */ | ||
#define TASK_PARAM_SERVER_PRIORITY 4 /**< Task priority. */ | ||
#define TASK_PARAM_SERVER_PERIOD_MS 50 /**< Task period in milliseconds. */ | ||
#define TASK_PARAM_SERVER_INITIAL_DELAY_MS 1000 /**< Delay, in milliseconds, before the first execution. */ | ||
#define TASK_PARAM_SERVER_INIT_TIMEOUT_MS 1000 /**< Wait time to initialize the task in milliseconds. */ | ||
#define TASK_PARAM_SERVER_MAX_BLOCK_TIME_MS 60*1000 /**< Maximum block time in milliseconds. */ | ||
|
||
#define NOTIFICATION_VALUE_FROM_I2C_SLAVE_ISR (1UL << 0UL) /**< Bit to set on i2c_slave ISR notification. */ | ||
#define NOTIFICATION_VALUE_FROM_UART (1UL << 1UL) /**< Bit to set on uart notification. */ | ||
#define NOTIFICATION_VALUE_FROM_I2C_ISR (1UL << 0UL) /**< Bit to set on i2c_slave ISR notification. */ | ||
#define NOTIFICATION_VALUE_FROM_UART_ISR (1UL << 1UL) /**< Bit to set on uart ISR notification. */ | ||
|
||
/** | ||
* \brief Parameter server handle. | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -25,7 +25,7 @@ | |
* | ||
* \author Gabriel Mariano Marcelino <[email protected]> | ||
* | ||
* \version 0.2.5 | ||
* \version 0.2.6 | ||
* | ||
* \date 2020/10/21 | ||
* | ||
|
@@ -36,7 +36,7 @@ | |
#ifndef VERSION_H_ | ||
#define VERSION_H_ | ||
|
||
#define FIRMWARE_VERSION "0.2.5" | ||
#define FIRMWARE_VERSION "0.2.6" | ||
|
||
#define FIRMWARE_STATUS "Development" | ||
|
||
|