Skip to content

Commit

Permalink
firmware: devices: payload: Add enable/disable implementations for px
Browse files Browse the repository at this point in the history
  • Loading branch information
c-porto committed Aug 14, 2024
1 parent 32ec644 commit 19cdc80
Showing 1 changed file with 25 additions and 10 deletions.
35 changes: 25 additions & 10 deletions firmware/devices/payload/payload.c
Original file line number Diff line number Diff line change
Expand Up @@ -47,10 +47,10 @@

#define PAYLOAD_UNIX_TO_J2000_EPOCH(x) ((x) - 946684800) /* Unix to J2000 epoch conversion */

static edc_config_t edc_0_conf = {0};
static edc_config_t edc_1_conf = {0};
static edc_config_t edc_0_conf;
static edc_config_t edc_1_conf;

static px_config_t px_conf = {0};
static px_config_t px_conf;

int payload_init(payload_t pl)
{
Expand Down Expand Up @@ -160,8 +160,9 @@ int payload_init(payload_t pl)
{
px_conf.port = I2C_PORT_0;
px_conf.bitrate = 400000UL;
px_conf.en_pin = GPIO_PIN_37;

if (px_init(px_conf) == 0)
if (px_init(&px_conf) == 0)
{
err = 0;

Expand Down Expand Up @@ -217,8 +218,15 @@ int payload_enable(payload_t pl)

break;
case PAYLOAD_X:
sys_log_print_event_from_module(SYS_LOG_ERROR, PAYLOAD_MODULE_NAME, "Payload-X: enable() routine not implemented yet!");
sys_log_new_line();
if (px_enable(&px_conf) == 0)
{
err = 0;
}
else
{
sys_log_print_event_from_module(SYS_LOG_ERROR, PAYLOAD_MODULE_NAME, "Payload X: Error enabling!");
sys_log_new_line();
}

break;
default:
Expand Down Expand Up @@ -262,8 +270,15 @@ int payload_disable(payload_t pl)

break;
case PAYLOAD_X:
sys_log_print_event_from_module(SYS_LOG_ERROR, PAYLOAD_MODULE_NAME, "Payload-X: disable() routine not implemented yet!");
sys_log_new_line();
if (px_disable(&px_conf) == 0)
{
err = 0;
}
else
{
sys_log_print_event_from_module(SYS_LOG_ERROR, PAYLOAD_MODULE_NAME, "Payload X: Error enabling!");
sys_log_new_line();
}

break;
default:
Expand Down Expand Up @@ -303,7 +318,7 @@ int payload_write_cmd(payload_t pl, payload_cmd_t cmd)

break;
case PAYLOAD_X:
if (px_write(px_conf, &cmd, 1U) == 0)
if (px_write(&px_conf, &cmd, 1U) == 0)
{
sys_log_print_event_from_module(SYS_LOG_INFO, PAYLOAD_MODULE_NAME, "Payload-X: ");
sys_log_print_hex(cmd);
Expand Down Expand Up @@ -644,7 +659,7 @@ int payload_get_data(payload_t pl, payload_data_id_t id, uint8_t *data, int32_t
break;
}
case PAYLOAD_X:
if (px_read(px_conf, data, *len) == 0)
if (px_read(&px_conf, data, *len) == 0)
{
sys_log_print_event_from_module(SYS_LOG_INFO, PAYLOAD_MODULE_NAME, "Payload-X: ");
/*
Expand Down

0 comments on commit 19cdc80

Please sign in to comment.