diff --git a/lib/pc_firm/parser.c b/lib/pc_firm/parser.c index 5a4f079..e880701 100644 --- a/lib/pc_firm/parser.c +++ b/lib/pc_firm/parser.c @@ -28,8 +28,12 @@ extern void pressure_all_level_meas(void); extern void tmp235_voltage_level_meas(void); +/* AGC functions */ +extern void full_agc_mesurement_start(void); +extern bool is_power_up_done(void); + /* Device control functions */ -extern int device_activated(void); +extern int device_activated(void); extern int device_sleep_mode(void); /* Error handling */ @@ -260,6 +264,9 @@ static bool dr_parse_cmd(const uint8_t *buffer, uint8_t length, ParsedCmd *out) /* A. Device Status */ static int Cmd_mta(const ParsedCmd *cmd); static int Cmd_sta(const ParsedCmd *cmd); + +/* B. AGC / Gain Measurement */ +static int Cmd_mag(const ParsedCmd *cmd); static int Cmd_str(const ParsedCmd *cmd); /* F. PD-ADC M48 Full Measurement Series */ @@ -314,6 +321,9 @@ static CmdEntry g_cmd_table[] = { { "mta?", true, Cmd_mta }, { "sta?", true, Cmd_sta }, { "str?", false, Cmd_str }, + /* B. AGC / Gain Measurement */ + { "mag?", true, Cmd_mag }, + { "sag?", true, Cmd_mag }, /* F. PD-ADC M48 Full Measurement Series */ { "mcj?", true, Cmd_mcj }, { "scj?", true, Cmd_mcj }, @@ -488,6 +498,36 @@ static int Cmd_sta(const ParsedCmd *cmd) } +/* B. AGC / Gain Measurement */ +static int Cmd_mag(const ParsedCmd *cmd) +{ + (void)cmd; + + if (g_plat.log && g_log_enable) { + g_plat.log("[Cmd_mag] Full AGC measurement request\r\n"); + } + + if (device_status != true || !is_power_up_done()) { + if (g_plat.log && g_log_enable) { + g_plat.log("[Cmd_mag] ERROR: Device not activated or power-up not done\r\n"); + } + if (g_plat.tx_bin) { + param_error("mag?"); + } + return 1; + } + + processing = true; + + if (g_plat.log && g_log_enable) { + g_plat.log("[Cmd_mag] full_agc_mesurement_start()\r\n"); + } + + full_agc_mesurement_start(); + + return 1; +} + static int Cmd_str(const ParsedCmd *cmd) { (void)cmd;