-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #152 from spacelab-ufsc/radio_rx_feature
Merge pull request from radio_rx_feature
- Loading branch information
Showing
31 changed files
with
1,196 additions
and
269 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 |
---|---|---|
|
@@ -26,9 +26,9 @@ | |
* \author Gabriel Mariano Marcelino <[email protected]> | ||
* \author Miguel Boing <[email protected]> | ||
* | ||
* \version 0.4.5 | ||
* \version 0.5.1 | ||
* | ||
* \date 2021/04/14 | ||
* \date 2024/04/22 | ||
* | ||
* \addtogroup ttc_data | ||
* \{ | ||
|
@@ -42,46 +42,49 @@ ttc_data_t ttc_data_buf; | |
|
||
void downlink_add_packet(uint8_t *packet, uint16_t packet_size) | ||
{ | ||
uint16_t i = 0; | ||
uint16_t i = 0U; | ||
|
||
ttc_data_buf.down_buf.packet_sizes[ttc_data_buf.down_buf.position_to_write] = packet_size; | ||
|
||
for(i = 0; i <ttc_data_buf.down_buf.packet_sizes[ttc_data_buf.down_buf.position_to_write]; i++) | ||
for(i = 0U; i <ttc_data_buf.down_buf.packet_sizes[ttc_data_buf.down_buf.position_to_write]; i++) | ||
{ | ||
ttc_data_buf.down_buf.packet_array[ttc_data_buf.down_buf.position_to_write][i] = packet[i]; | ||
} | ||
|
||
ttc_data_buf.radio.tx_fifo_counter++; | ||
ttc_data_buf.radio.tx_packet_counter++; | ||
|
||
if (++ttc_data_buf.down_buf.position_to_write >= 5) | ||
if (++ttc_data_buf.down_buf.position_to_write >= 5U) | ||
{ | ||
ttc_data_buf.down_buf.position_to_write = 0; | ||
ttc_data_buf.down_buf.position_to_write = 0U; | ||
} | ||
} | ||
|
||
void downlink_pop_packet(uint8_t *packet, uint16_t *packet_size) | ||
{ | ||
uint16_t i = 0; | ||
uint16_t i = 0U; | ||
|
||
*packet_size = ttc_data_buf.down_buf.packet_sizes[ttc_data_buf.down_buf.position_to_read]; | ||
|
||
for(i = 0; i < ttc_data_buf.down_buf.packet_sizes[ttc_data_buf.down_buf.position_to_read]; i++) | ||
if (ttc_data_buf.radio.tx_fifo_counter > 0U) | ||
{ | ||
packet[i] = ttc_data_buf.down_buf.packet_array[ttc_data_buf.down_buf.position_to_read][i]; | ||
} | ||
*packet_size = ttc_data_buf.down_buf.packet_sizes[ttc_data_buf.down_buf.position_to_read]; | ||
|
||
ttc_data_buf.radio.tx_fifo_counter--; | ||
for(i = 0U; i < ttc_data_buf.down_buf.packet_sizes[ttc_data_buf.down_buf.position_to_read]; i++) | ||
{ | ||
packet[i] = ttc_data_buf.down_buf.packet_array[ttc_data_buf.down_buf.position_to_read][i]; | ||
} | ||
|
||
if (++ttc_data_buf.down_buf.position_to_read >= 5) | ||
{ | ||
ttc_data_buf.down_buf.position_to_read = 0; | ||
ttc_data_buf.radio.tx_fifo_counter--; | ||
|
||
if (++ttc_data_buf.down_buf.position_to_read >= 5U) | ||
{ | ||
ttc_data_buf.down_buf.position_to_read = 0U; | ||
} | ||
} | ||
} | ||
|
||
void uplink_add_packet(uint8_t *packet, uint16_t packet_size) | ||
{ | ||
uint16_t i = 0; | ||
uint16_t i = 0U; | ||
|
||
ttc_data_buf.up_buf.packet_sizes[ttc_data_buf.up_buf.position_to_write] = packet_size; | ||
|
||
|
@@ -103,26 +106,25 @@ void uplink_pop_packet(uint8_t *packet, uint16_t *packet_size) | |
{ | ||
uint16_t i = 0; | ||
|
||
*packet_size = ttc_data_buf.up_buf.packet_sizes[ttc_data_buf.up_buf.position_to_read]; | ||
|
||
for(i = 0; i < ttc_data_buf.up_buf.packet_sizes[ttc_data_buf.up_buf.position_to_read]; i++) | ||
if (ttc_data_buf.radio.rx_fifo_counter > 0U) | ||
{ | ||
packet[i] = ttc_data_buf.up_buf.packet_array[ttc_data_buf.up_buf.position_to_read][i]; | ||
ttc_data_buf.up_buf.packet_array[ttc_data_buf.up_buf.position_to_read][i] = 0xFF; /* Remove packet after a read */ | ||
} | ||
|
||
ttc_data_buf.up_buf.packet_sizes[ttc_data_buf.up_buf.position_to_read] = 0xFF; /* 0xFF means that there is no package in this position */ | ||
*packet_size = ttc_data_buf.up_buf.packet_sizes[ttc_data_buf.up_buf.position_to_read]; | ||
|
||
ttc_data_buf.radio.rx_fifo_counter--; | ||
for(i = 0; i < ttc_data_buf.up_buf.packet_sizes[ttc_data_buf.up_buf.position_to_read]; i++) | ||
{ | ||
packet[i] = ttc_data_buf.up_buf.packet_array[ttc_data_buf.up_buf.position_to_read][i]; | ||
ttc_data_buf.up_buf.packet_array[ttc_data_buf.up_buf.position_to_read][i] = 0xFF; /* Remove packet after a read */ | ||
} | ||
|
||
if (++ttc_data_buf.up_buf.position_to_read >= 5) | ||
{ | ||
ttc_data_buf.up_buf.position_to_read = 0; | ||
} | ||
ttc_data_buf.up_buf.packet_sizes[ttc_data_buf.up_buf.position_to_read] = 0x00; /* 0x00 means that there is no package in this position */ | ||
|
||
/* Update rx packet bytes */ | ||
ttc_data_buf.radio.last_rx_packet_bytes = &(ttc_data_buf.up_buf.packet_sizes[ttc_data_buf.up_buf.position_to_read]); | ||
ttc_data_buf.radio.rx_fifo_counter--; | ||
|
||
if (++ttc_data_buf.up_buf.position_to_read >= 5) | ||
{ | ||
ttc_data_buf.up_buf.position_to_read = 0; | ||
} | ||
} | ||
} | ||
|
||
/** \} End of ttc_data group */ |
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,9 +25,9 @@ | |
* | ||
* \author Miguel Boing <[email protected]> | ||
* | ||
* \version 0.4.3 | ||
* \version 0.5.1 | ||
* | ||
* \date 2023/03/03 | ||
* \date 2024/04/22 | ||
* | ||
* \addtogroup eps_server | ||
* \{ | ||
|
@@ -74,15 +74,7 @@ void vTaskEpsServer(void) | |
sys_log_new_line(); | ||
|
||
sys_log_print_str("Packet: "); | ||
|
||
uint16_t i = 0; | ||
|
||
for(i = 0; i < eps_request.data.data_packet.len; i++) | ||
{ | ||
sys_log_print_hex(eps_request.data.data_packet.packet[i]); | ||
sys_log_print_str("|"); | ||
} | ||
|
||
sys_log_dump_hex(eps_request.data.data_packet.packet, eps_request.data.data_packet.len); | ||
sys_log_new_line(); | ||
|
||
downlink_add_packet(eps_request.data.data_packet.packet, eps_request.data.data_packet.len); | ||
|
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,9 +25,9 @@ | |
* | ||
* \author Miguel Boing <[email protected]> | ||
* | ||
* \version 0.3.5 | ||
* \version 0.5.1 | ||
* | ||
* \date 2023/03/03 | ||
* \date 2024/04/22 | ||
* | ||
* \defgroup eps EPS | ||
* \ingroup tasks | ||
|
@@ -41,9 +41,9 @@ | |
#include <task.h> | ||
|
||
#define TASK_EPS_SERVER_NAME "EPS Server" /**< Task name. */ | ||
#define TASK_EPS_SERVER_STACK_SIZE 2000 /**< Stack size in bytes. */ | ||
#define TASK_EPS_SERVER_PRIORITY 4 /**< Task priority. */ | ||
#define TASK_EPS_SERVER_PERIOD_MS 250 /**< Task period in milliseconds. */ | ||
#define TASK_EPS_SERVER_STACK_SIZE 1000 /**< Stack size in bytes. */ | ||
#define TASK_EPS_SERVER_PRIORITY 3 /**< Task priority. */ | ||
#define TASK_EPS_SERVER_PERIOD_MS 750 /**< Task period in milliseconds. */ | ||
#define TASK_EPS_SERVER_INITIAL_DELAY_MS 1000 /**< Delay, in milliseconds, before the first execution. */ | ||
#define TASK_EPS_SERVER_INIT_TIMEOUT_MS 10000 /**< Wait time to initialize the task in milliseconds. */ | ||
|
||
|
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,9 +25,9 @@ | |
* | ||
* \author Miguel Boing <[email protected]> | ||
* | ||
* \version 0.4.5 | ||
* \version 0.5.1 | ||
* | ||
* \date 2023/03/03 | ||
* \date 2024/04/22 | ||
* | ||
* \addtogroup obdh_server | ||
* \{ | ||
|
@@ -62,13 +62,6 @@ void vTaskObdhServer(void) | |
obdh_response_t obdh_response = {0}; | ||
obdh_request.command = 0x00U; /* No command */ | ||
|
||
uint8_t buffer1[7] = {0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}; | ||
uint8_t buffer2[7] = {0x22, 0x22, 0x33, 0x44, 0x55, 0x66, 0x77}; | ||
uint8_t buffer3[10] = {0x11, 0x11, 0x11, 0x11, 0x11, 0x11, 0x11, 0x11, 0x11, 0x11}; | ||
|
||
uplink_add_packet(buffer2, 6); | ||
uplink_add_packet(buffer3, 10); | ||
|
||
while(1) | ||
{ | ||
TickType_t last_cycle = xTaskGetTickCount(); | ||
|
@@ -91,19 +84,19 @@ void vTaskObdhServer(void) | |
|
||
break; | ||
case CMDPR_CMD_WRITE_PARAM: | ||
obdh_write_read_bytes(6); | ||
obdh_write_read_bytes(7); | ||
|
||
sys_log_print_event_from_module(SYS_LOG_INFO, TASK_OBDH_SERVER_NAME, "TX is now "); | ||
|
||
switch(obdh_request.data.param_8) | ||
{ | ||
case 0x00: | ||
sys_log_print_msg("Turned on."); | ||
sys_log_print_msg("Turned off."); | ||
ttc_data_buf.radio.tx_enable = obdh_request.data.param_8; | ||
|
||
break; | ||
case 0x01: | ||
sys_log_print_msg("Turned off."); | ||
sys_log_print_msg("Turned on."); | ||
ttc_data_buf.radio.tx_enable = obdh_request.data.param_8; | ||
|
||
break; | ||
|
@@ -117,9 +110,9 @@ void vTaskObdhServer(void) | |
|
||
break; | ||
case CMDPR_CMD_TRANSMIT_PACKET: | ||
obdh_write_read_bytes(6); | ||
obdh_write_read_bytes(7); | ||
|
||
downlink_add_packet(obdh_request.data.data_packet.packet, (obdh_request.data.data_packet.len)+3); | ||
downlink_add_packet(obdh_request.data.data_packet.packet, obdh_request.data.data_packet.len); | ||
|
||
break; | ||
case CMDPR_CMD_READ_FIRST_PACKET: | ||
|
@@ -129,10 +122,13 @@ void vTaskObdhServer(void) | |
|
||
obdh_send_response(&obdh_response); | ||
|
||
obdh_write_read_bytes(7U); | ||
|
||
break; | ||
case 0x00: | ||
/* Read mode */ | ||
obdh_write_read_bytes(6); | ||
obdh_write_read_bytes(7U); | ||
|
||
break; | ||
default: | ||
break; | ||
|
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,9 +25,9 @@ | |
* | ||
* \author Miguel Boing <[email protected]> | ||
* | ||
* \version 0.4.5 | ||
* \version 0.5.1 | ||
* | ||
* \date 2023/03/03 | ||
* \date 2024/04/22 | ||
* | ||
* \defgroup obdh OBDH | ||
* \ingroup tasks | ||
|
@@ -41,7 +41,7 @@ | |
#include <task.h> | ||
|
||
#define TASK_OBDH_SERVER_NAME "OBDH Server" /**< Task name. */ | ||
#define TASK_OBDH_SERVER_STACK_SIZE 4000 /**< Stack size in bytes. */ | ||
#define TASK_OBDH_SERVER_STACK_SIZE 2000 /**< Stack size in bytes. */ | ||
#define TASK_OBDH_SERVER_PRIORITY 5 /**< Task priority. */ | ||
#define TASK_OBDH_SERVER_PERIOD_MS 100 /**< Task period in milliseconds. */ | ||
#define TASK_OBDH_SERVER_INITIAL_DELAY_MS 200 /**< Delay, in milliseconds, before the first execution. */ | ||
|
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,9 +25,9 @@ | |
* | ||
* \author Gabriel Mariano Marcelino <[email protected]> | ||
* | ||
* \version 0.1.10 | ||
* \version 0.5.1 | ||
* | ||
* \date 2020/01/12 | ||
* \date 2024/04/22 | ||
* | ||
* \addtogroup system_reset | ||
* \{ | ||
|
@@ -38,13 +38,15 @@ | |
|
||
#include "system_reset.h" | ||
|
||
#define pdMS_TO_TICKS_LONG( xTimeInMs ) ( ( TickType_t ) ( ( ( uint64_t ) ( xTimeInMs ) * ( uint64_t ) configTICK_RATE_HZ ) / ( TickType_t ) 1000 ) ) | ||
|
||
xTaskHandle xTaskSystemResetHandle; | ||
|
||
void vTaskSystemReset(void) | ||
{ | ||
while(1) | ||
{ | ||
vTaskDelay(pdMS_TO_TICKS(TASK_SYSTEM_RESET_PERIOD_MS)); | ||
vTaskDelay(pdMS_TO_TICKS_LONG(TASK_SYSTEM_RESET_PERIOD_MS)); | ||
|
||
sys_log_print_event_from_module(SYS_LOG_INFO, TASK_SYSTEM_RESET_NAME, "Restarting the system..."); | ||
sys_log_new_line(); | ||
|
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,9 +25,9 @@ | |
* | ||
* \author Miguel Boing <[email protected]> | ||
* | ||
* \version 0.4.5 | ||
* \version 0.5.1 | ||
* | ||
* \date 2023/04/03 | ||
* \date 2024/04/22 | ||
* | ||
* \addtogroup uplink_manager | ||
* \{ | ||
|
@@ -36,7 +36,7 @@ | |
#include <system/sys_log/sys_log.h> | ||
#include <devices/radio/radio.h> | ||
#include <structs/ttc_data.h> | ||
|
||
#include <ngham/ngham.h> | ||
#include "uplink_manager.h" | ||
#include "startup.h" | ||
|
||
|
@@ -53,22 +53,30 @@ void vTaskUplinkManager(void) | |
sys_log_print_event_from_module(SYS_LOG_INFO, TASK_UPLINK_MANAGER_NAME, "Initializing the Uplink Manager..."); | ||
sys_log_new_line(); | ||
|
||
ttc_data_buf.radio.rx_fifo_counter = 0; | ||
ttc_data_buf.radio.rx_packet_counter = 0; | ||
ttc_data_buf.radio.last_rx_packet_bytes = &(ttc_data_buf.up_buf.packet_sizes); | ||
ttc_data_buf.radio.rx_fifo_counter = 0U; | ||
ttc_data_buf.radio.rx_packet_counter = 0U; | ||
ttc_data_buf.radio.last_rx_packet_bytes = 0U; | ||
|
||
ttc_data_buf.up_buf.position_to_read = 0; | ||
ttc_data_buf.up_buf.position_to_write = 0; | ||
ttc_data_buf.up_buf.position_to_read = 0U; | ||
ttc_data_buf.up_buf.position_to_write = 0U; | ||
|
||
uint16_t rx_size = 230; | ||
uint8_t rx_packet[230]; | ||
uint8_t pop_rx_packet[230]; | ||
uint8_t rx_packet[230] = {0}; | ||
|
||
while(1) | ||
{ | ||
TickType_t last_cycle = xTaskGetTickCount(); | ||
|
||
/* TODO */ | ||
if (radio_available() == 0U) | ||
{ | ||
radio_recv(rx_packet, 80U, 100U); | ||
sys_log_print_event_from_module(SYS_LOG_INFO, TASK_UPLINK_MANAGER_NAME, "Received a new package:"); | ||
sys_log_dump_hex(rx_packet, 230U); | ||
sys_log_new_line(); | ||
|
||
/*TODO ngham_decode(rx_packet);*/ | ||
|
||
uplink_add_packet(rx_packet, 220U); | ||
} | ||
|
||
vTaskDelayUntil(&last_cycle, pdMS_TO_TICKS(TASK_UPLINK_MANAGER_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,10 +24,11 @@ | |
* \brief Configuration parameters definition. | ||
* | ||
* \author Gabriel Mariano Marcelino <[email protected]> | ||
* \author Miguel Boing <[email protected]> | ||
* | ||
* \version 0.4.5 | ||
* \version 0.5.1 | ||
* | ||
* \date 2019/10/26 | ||
* \date 2024/04/22 | ||
* | ||
* \defgroup config Configuration | ||
* \{ | ||
|
@@ -36,6 +37,9 @@ | |
#ifndef CONFIG_H_ | ||
#define CONFIG_H_ | ||
|
||
/* Targets the radio module, it can be '0' or '1'*/ | ||
#define RADIO_MODULE 1 | ||
|
||
/* Tasks */ | ||
#define CONFIG_TASK_STARTUP_ENABLED 1 | ||
#define CONFIG_TASK_WATCHDOG_RESET_ENABLED 1 | ||
|
File renamed without changes.
Oops, something went wrong.