Skip to content

Commit

Permalink
firmware: app: tasks: Syncing the implementation of the main function…
Browse files Browse the repository at this point in the history
… with the OBDH 2.0 repository
  • Loading branch information
mgm8 committed Oct 26, 2021
1 parent 56eab08 commit 271148d
Show file tree
Hide file tree
Showing 22 changed files with 233 additions and 136 deletions.
6 changes: 3 additions & 3 deletions firmware/app/tasks/beacon.c
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with TTC 2.0. If not, see <http://www.gnu.org/licenses/>.
* along with TTC 2.0. If not, see <http:/\/www.gnu.org/licenses/>.
*
*/

Expand All @@ -25,7 +25,7 @@
*
* \author Gabriel Mariano Marcelino <[email protected]>
*
* \version 0.0.9
* \version 0.1.10
*
* \date 2019/10/27
*
Expand All @@ -42,7 +42,7 @@

xTaskHandle xTaskBeaconHandle;

void vTaskBeacon(void *pvParameters)
void vTaskBeacon(void)
{
/* Wait startup task to finish */
xEventGroupWaitBits(task_startup_status, TASK_STARTUP_DONE, pdFALSE, pdTRUE, pdMS_TO_TICKS(TASK_BEACON_INIT_TIMEOUT_MS));
Expand Down
6 changes: 2 additions & 4 deletions firmware/app/tasks/beacon.h
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
*
* \author Gabriel Mariano Marcelino <[email protected]>
*
* \version 0.0.9
* \version 0.1.10
*
* \date 2019/10/27
*
Expand Down Expand Up @@ -55,11 +55,9 @@ extern xTaskHandle xTaskBeaconHandle;
/**
* \brief Beacon task.
*
* \param[in] pvParameters is a value that will passed as the task's parameter.
*
* \return None.
*/
void vTaskBeacon(void *pvParameters);
void vTaskBeacon(void);

#endif /* BEACON_H_ */

Expand Down
18 changes: 12 additions & 6 deletions firmware/app/tasks/csp_server.c
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with TTC 2.0. If not, see <http://www.gnu.org/licenses/>.
* along with TTC 2.0. If not, see <http:/\/www.gnu.org/licenses/>.
*
*/

Expand All @@ -25,7 +25,7 @@
*
* \author Gabriel Mariano Marcelino <[email protected]>
*
* \version 0.0.9
* \version 0.1.10
*
* \date 2020/04/04
*
Expand All @@ -42,7 +42,7 @@

xTaskHandle xTaskCSPServerHandle;

void vTaskCSPServer(void *pvParameters)
void vTaskCSPServer(void)
{
/* Wait startup task to finish */
xEventGroupWaitBits(task_startup_status, TASK_STARTUP_DONE, pdFALSE, pdTRUE, pdMS_TO_TICKS(TASK_CSP_SERVER_INIT_TIMEOUT_MS));
Expand All @@ -63,18 +63,24 @@ void vTaskCSPServer(void *pvParameters)
while(1)
{
/* Wait for connection until reach timeout */
if ((conn = csp_accept(sock, CONFIG_CSP_WAIT_CONN_TIMEOUT_MS)) == NULL)
conn = csp_accept(sock, CONFIG_CSP_WAIT_CONN_TIMEOUT_MS);
if (conn == NULL)
{
continue;
}

/* Read packets until reach timeout */
while((packet = csp_read(conn, CONFIG_CSP_READ_PKT_TIMEOUT_MS)) != NULL)
packet = csp_read(conn, CONFIG_CSP_READ_PKT_TIMEOUT_MS);
while(packet != NULL)
{
switch(csp_conn_dport(conn))
{
case CONFIG_CSP_PORT:
case CONFIG_CSP_PRIMARY_PORT:
/* TODO: Process packet here */
break;
case CONFIG_CSP_SECONDARY_PORT:
/* TODO: Process packet here */
break;
default:
/* Let the service handler reply pings, buffer use, etc. */
csp_service_handler(conn, packet);
Expand Down
6 changes: 2 additions & 4 deletions firmware/app/tasks/csp_server.h
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
*
* \author Gabriel Mariano Marcelino <[email protected]>
*
* \version 0.0.9
* \version 0.1.10
*
* \date 2020/04/04
*
Expand Down Expand Up @@ -54,11 +54,9 @@ extern xTaskHandle xTaskCSPServerHandle;
/**
* \brief CSP server task.
*
* \param[in] pvParameters is a value that will passed as the task's parameter.
*
* \return None.
*/
void vTaskCSPServer(void *pvParameters);
void vTaskCSPServer(void);

#endif /* CSP_SERVER_H_ */

Expand Down
6 changes: 3 additions & 3 deletions firmware/app/tasks/heartbeat.c
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with TTC 2.0. If not, see <http://www.gnu.org/licenses/>.
* along with TTC 2.0. If not, see <http:/\/www.gnu.org/licenses/>.
*
*/

Expand All @@ -25,7 +25,7 @@
*
* \author Gabriel Mariano Marcelino <[email protected]>
*
* \version 0.0.9
* \version 0.1.10
*
* \date 2020/01/20
*
Expand All @@ -40,7 +40,7 @@

xTaskHandle xTaskHeartbeatHandle;

void vTaskHeartbeat(void *pvParameters)
void vTaskHeartbeat(void)
{
/* Wait startup task to finish */
xEventGroupWaitBits(task_startup_status, TASK_STARTUP_DONE, pdFALSE, pdTRUE, pdMS_TO_TICKS(TASK_HEARTBEAT_INIT_TIMEOUT_MS));
Expand Down
8 changes: 3 additions & 5 deletions firmware/app/tasks/heartbeat.h
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
*
* \author Gabriel Mariano Marcelino <[email protected]>
*
* \version 0.0.9
* \version 0.1.10
*
* \date 2020/01/20
*
Expand All @@ -41,7 +41,7 @@
#include <task.h>

#define TASK_HEARTBEAT_NAME "Heartbeat" /**< Task name. */
#define TASK_HEARTBEAT_STACK_SIZE 128 /**< Memory stack size in bytes. */
#define TASK_HEARTBEAT_STACK_SIZE 160 /**< Memory stack size in bytes. */
#define TASK_HEARTBEAT_PRIORITY 1 /**< Priority. */
#define TASK_HEARTBEAT_PERIOD_MS 500 /**< Period in milliseconds. */
#define TASK_HEARTBEAT_INIT_TIMEOUT_MS 2000 /**< Wait time to initialize the task in milliseconds. */
Expand All @@ -54,11 +54,9 @@ extern xTaskHandle xTaskHeartbeatHandle;
/**
* \brief System heartbeat task.
*
* \param[in] pvParameters is a value that will passed as the task's parameter.
*
* \return None.
*/
void vTaskHeartbeat(void *pvParameters);
void vTaskHeartbeat(void);

#endif /* HEARTBEAT_H_ */

Expand Down
6 changes: 3 additions & 3 deletions firmware/app/tasks/radio_reset.c
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with TTC 2.0. If not, see <http://www.gnu.org/licenses/>.
* along with TTC 2.0. If not, see <http:/\/www.gnu.org/licenses/>.
*
*/

Expand All @@ -25,7 +25,7 @@
*
* \author Gabriel Mariano Marcelino <[email protected]>
*
* \version 0.0.9
* \version 0.1.10
*
* \date 2020/01/29
*
Expand All @@ -37,7 +37,7 @@

xTaskHandle xTaskRadioResetHandle;

void vTaskRadioReset(void *pvParameters)
void vTaskRadioReset(void)
{
/* Delay before the first cycle */
vTaskDelay(pdMS_TO_TICKS(TASK_RADIO_RESET_INITIAL_DELAY_MS));
Expand Down
8 changes: 3 additions & 5 deletions firmware/app/tasks/radio_reset.h
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with TTC 2.0. If not, see <http://www.gnu.org/licenses/>.
* along with TTC 2.0. If not, see <http:/\/www.gnu.org/licenses/>.
*
*/

Expand All @@ -25,7 +25,7 @@
*
* \author Gabriel Mariano Marcelino <[email protected]>
*
* \version 0.0.9
* \version 0.1.10
*
* \date 2020/01/29
*
Expand Down Expand Up @@ -54,11 +54,9 @@ extern xTaskHandle xTaskRadioResetHandle;
/**
* \brief Periodic radio reset task.
*
* \param[in] pvParameters is a value that will passed as the task's parameter.
*
* \return None.
*/
void vTaskRadioReset(void *pvParameters);
void vTaskRadioReset(void);

#endif /* RADIO_RESET_H_ */

Expand Down
6 changes: 3 additions & 3 deletions firmware/app/tasks/read_sensors.c
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with TTC 2.0. If not, see <http://www.gnu.org/licenses/>.
* along with TTC 2.0. If not, see <http:/\/www.gnu.org/licenses/>.
*
*/

Expand All @@ -25,7 +25,7 @@
*
* \author Gabriel Mariano Marcelino <[email protected]>
*
* \version 0.0.25
* \version 0.1.10
*
* \date 2020/07/12
*
Expand All @@ -43,7 +43,7 @@

xTaskHandle xTaskReadSensorsHandle;

void vTaskReadSensors(void *pvParameters)
void vTaskReadSensors(void)
{
/* Wait startup task to finish */
xEventGroupWaitBits(task_startup_status, TASK_STARTUP_DONE, pdFALSE, pdTRUE, pdMS_TO_TICKS(TASK_READ_SENSORS_INIT_TIMEOUT_MS));
Expand Down
6 changes: 2 additions & 4 deletions firmware/app/tasks/read_sensors.h
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
*
* \author Gabriel Mariano Marcelino <[email protected]>
*
* \version 0.0.9
* \version 0.1.10
*
* \date 2020/07/12
*
Expand Down Expand Up @@ -54,11 +54,9 @@ extern xTaskHandle xTaskReadSensorsHandle;
/**
* \brief Read onboard sensors task.
*
* \param[in] pvParameters is a value that will passed as the task's parameter.
*
* \return None.
*/
void vTaskReadSensors(void *pvParameters);
void vTaskReadSensors(void);

#endif /* READ_SENSORS_H_ */

Expand Down
59 changes: 29 additions & 30 deletions firmware/app/tasks/startup.c
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with TTC 2.0. If not, see <http://www.gnu.org/licenses/>.
* along with TTC 2.0. If not, see <http:/\/www.gnu.org/licenses/>.
*
*/

Expand All @@ -25,7 +25,7 @@
*
* \author Gabriel Mariano Marcelino <[email protected]>
*
* \version 0.0.9
* \version 0.1.10
*
* \date 2019/12/04
*
Expand Down Expand Up @@ -59,7 +59,7 @@ xTaskHandle xTaskStartupHandle;

EventGroupHandle_t task_startup_status;

void vTaskStartup(void *pvParameters)
void vTaskStartup(void)
{
unsigned int error_counter = 0;

Expand Down Expand Up @@ -144,7 +144,7 @@ void vTaskStartup(void *pvParameters)
error_counter++;
}

if (error_counter > 0)
if (error_counter > 0U)
{
sys_log_print_event_from_module(SYS_LOG_ERROR, TASK_STARTUP_NAME, "Boot completed with ");
sys_log_print_uint(error_counter);
Expand All @@ -167,38 +167,37 @@ void vTaskStartup(void *pvParameters)
vTaskSuspend(xTaskStartupHandle);
}

int startup_init_csp()
int startup_init_csp(void)
{
#if CONFIG_CSP_ENABLED == 1
/* CSP initialization */
if (csp_init(CONFIG_CSP_MY_ADDRESS) != CSP_ERR_NONE)
{
return -1; /* Error during CSP initialization */
}
#if defined(CONFIG_CSP_ENABLED) && (CONFIG_CSP_ENABLED == 1)
int err = CSP_ERR_NONE;

/* Buffer initialization */
if (csp_buffer_init(CONFIG_CSP_BUFFER_MAX_PKTS, CONFIG_CSP_BUFFER_MAX_SIZE) != CSP_ERR_NONE)
{
return -1; /* Error during the CSP buffer initialization */
}

if (csp_route_set(CONFIG_CSP_TTC_ADDRESS, &csp_if_spi, CSP_NODE_MAC) != CSP_ERR_NONE)
{
return -1;
}

if (csp_route_set(CONFIG_CSP_EPS_ADDRESS, &csp_if_i2c, CSP_NODE_MAC) != CSP_ERR_NONE)
{
return -1;
}
/* CSP initialization */
err = csp_init(CONFIG_CSP_MY_ADDRESS);

/* CSP router task initialization */
if (csp_route_start_task(CONFIG_CSP_ROUTER_WORD_STACK, CONFIG_CSP_ROUTER_TASK_PRIORITY) != CSP_ERR_NONE)
if (err == CSP_ERR_NONE)
{
return -1; /* Error during CSP router task initialization! */
/* Buffer initialization */
err = csp_buffer_init(CONFIG_CSP_BUFFER_MAX_PKTS, CONFIG_CSP_BUFFER_MAX_SIZE);

if (err == CSP_ERR_NONE)
{
err = csp_route_set(CONFIG_CSP_TTC_ADDRESS, &csp_if_spi, CSP_NODE_MAC);

if (err == CSP_ERR_NONE)
{
err = csp_route_set(CONFIG_CSP_EPS_ADDRESS, &csp_if_i2c, CSP_NODE_MAC);

if (err == CSP_ERR_NONE)
{
/* CSP router task initialization */
err = csp_route_start_task(CONFIG_CSP_ROUTER_WORD_STACK, CONFIG_CSP_ROUTER_TASK_PRIORITY);
}
}
}
}

return CSP_ERR_NONE;
return err;
#else
sys_log_print_event_from_module(SYS_LOG_WARNING, TASK_STARTUP_NAME, "libcsp disabled!");
sys_log_new_line();
Expand Down
Loading

0 comments on commit 271148d

Please sign in to comment.