Skip to content

Commit

Permalink
Upgrade stats, get 1mA back by disabling an LED
Browse files Browse the repository at this point in the history
  • Loading branch information
DeflateAwning committed Dec 29, 2023
1 parent 7df5c21 commit f5653ea
Show file tree
Hide file tree
Showing 5 changed files with 32 additions and 40 deletions.
23 changes: 9 additions & 14 deletions firmware/F103C8T6_DIGI_USB.ioc
Original file line number Diff line number Diff line change
Expand Up @@ -18,19 +18,18 @@ Mcu.Name=STM32F103C(8-B)Tx
Mcu.Package=LQFP48
Mcu.Pin0=PB10
Mcu.Pin1=PB11
Mcu.Pin10=PB3
Mcu.Pin11=PB4
Mcu.Pin12=PB5
Mcu.Pin13=VP_SYS_VS_Systick
Mcu.Pin10=PB4
Mcu.Pin11=PB5
Mcu.Pin12=VP_SYS_VS_Systick
Mcu.Pin2=PB13
Mcu.Pin3=PB14
Mcu.Pin4=PB15
Mcu.Pin5=PA8
Mcu.Pin6=PA11
Mcu.Pin7=PA12
Mcu.Pin8=PA13
Mcu.Pin9=PA14
Mcu.PinsNb=14
Mcu.Pin5=PA11
Mcu.Pin6=PA12
Mcu.Pin7=PA13
Mcu.Pin8=PA14
Mcu.Pin9=PB3
Mcu.PinsNb=13
Mcu.ThirdPartyNb=0
Mcu.UserConstants=
Mcu.UserName=STM32F103C8Tx
Expand Down Expand Up @@ -61,10 +60,6 @@ PA13.Signal=SYS_JTMS-SWDIO
PA14.Locked=true
PA14.Mode=Serial_Wire
PA14.Signal=SYS_JTCK-SWCLK
PA8.GPIOParameters=GPIO_Label
PA8.GPIO_Label=PIN_LED_D304
PA8.Locked=true
PA8.Signal=GPIO_Output
PB10.Locked=true
PB10.Mode=I2C
PB10.Signal=I2C2_SCL
Expand Down
2 changes: 0 additions & 2 deletions firmware/Inc/main.h
Original file line number Diff line number Diff line change
Expand Up @@ -81,8 +81,6 @@ void Error_Handler(void);
#define PIN_CCD_ICG_GPIO_Port GPIOB
#define PIN_CCD_SH_Pin GPIO_PIN_15
#define PIN_CCD_SH_GPIO_Port GPIOB
#define PIN_LED_D304_Pin GPIO_PIN_8
#define PIN_LED_D304_GPIO_Port GPIOA
#define PIN_DRA_ENABLE_Pin GPIO_PIN_11
#define PIN_DRA_ENABLE_GPIO_Port GPIOA
#define PIN_RFET_EN_OUT_Pin GPIO_PIN_12
Expand Down
21 changes: 11 additions & 10 deletions firmware/Src/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -135,13 +135,14 @@ int main(void)
Wdog_init(); //initialize watchdog

// flash code on-off-on-off for "boot complete"
HAL_GPIO_WritePin(PIN_LED_D304_GPIO_Port, PIN_LED_D304_Pin, GPIO_PIN_SET);
delay_ms(250);
HAL_GPIO_WritePin(PIN_LED_D304_GPIO_Port, PIN_LED_D304_Pin, GPIO_PIN_RESET);
delay_ms(250);
HAL_GPIO_WritePin(PIN_LED_D304_GPIO_Port, PIN_LED_D304_Pin, GPIO_PIN_SET);
delay_ms(250);
HAL_GPIO_WritePin(PIN_LED_D304_GPIO_Port, PIN_LED_D304_Pin, GPIO_PIN_RESET);
for (uint8_t i = 0; i < 2; i++) {
HAL_GPIO_WritePin(PIN_LED_SUCCESS_GPIO_Port, PIN_LED_SUCCESS_Pin, GPIO_PIN_SET);
HAL_GPIO_WritePin(PIN_LED_FAILURE_GPIO_Port, PIN_LED_FAILURE_Pin, GPIO_PIN_RESET);
delay_ms(250);
HAL_GPIO_WritePin(PIN_LED_SUCCESS_GPIO_Port, PIN_LED_SUCCESS_Pin, GPIO_PIN_RESET);
HAL_GPIO_WritePin(PIN_LED_FAILURE_GPIO_Port, PIN_LED_FAILURE_Pin, GPIO_PIN_SET);
delay_ms(250);
}

//set some initial values in case there is no configuration saved in memory
uart1.baudrate = DEFAULT_UART1_BAUD_RATE;
Expand Down Expand Up @@ -341,7 +342,7 @@ static void MX_GPIO_Init(void)
|PIN_LED_FAILURE_Pin|PIN_LED_DCD_Pin, GPIO_PIN_RESET);

/*Configure GPIO pin Output Level */
HAL_GPIO_WritePin(GPIOA, PIN_LED_D304_Pin|PIN_DRA_ENABLE_Pin|PIN_RFET_EN_OUT_Pin, GPIO_PIN_RESET);
HAL_GPIO_WritePin(GPIOA, PIN_DRA_ENABLE_Pin|PIN_RFET_EN_OUT_Pin, GPIO_PIN_RESET);

/*Configure GPIO pins : PIN_CCD_PHI_M_Pin PIN_CCD_ICG_Pin PIN_CCD_SH_Pin PIN_LED_SUCCESS_Pin
PIN_LED_FAILURE_Pin PIN_LED_DCD_Pin */
Expand All @@ -352,8 +353,8 @@ static void MX_GPIO_Init(void)
GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_LOW;
HAL_GPIO_Init(GPIOB, &GPIO_InitStruct);

/*Configure GPIO pins : PIN_LED_D304_Pin PIN_DRA_ENABLE_Pin PIN_RFET_EN_OUT_Pin */
GPIO_InitStruct.Pin = PIN_LED_D304_Pin|PIN_DRA_ENABLE_Pin|PIN_RFET_EN_OUT_Pin;
/*Configure GPIO pins : PIN_DRA_ENABLE_Pin PIN_RFET_EN_OUT_Pin */
GPIO_InitStruct.Pin = PIN_DRA_ENABLE_Pin|PIN_RFET_EN_OUT_Pin;
GPIO_InitStruct.Mode = GPIO_MODE_OUTPUT_PP;
GPIO_InitStruct.Pull = GPIO_NOPULL;
GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_LOW;
Expand Down
20 changes: 9 additions & 11 deletions firmware/Src/mboss_handler.c
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
#include "frame_handler.h"
#include "dra_system.h"
#include "ax25.h"
#include "main.h"

#include "drivers/temperature_sensors.h"
#include "drivers/modem.h"
Expand Down Expand Up @@ -36,7 +37,7 @@ BossCommandEntry boss_command_table[] = {

// 0x20-0x2F namespace: APRS-related and status-related commands
{0x20, boss_cmd_run_power_on_self_test},
{0x21, boss_cmd_get_stored_aprs_packets_stats},
// {0x21, boss_cmd_get_stored_aprs_packets_stats},
{0x22, boss_cmd_beacon_right_now},
{0x23, boss_cmd_force_reboot_system},
{0x24, boss_cmd_set_beacon_period},
Expand All @@ -46,20 +47,14 @@ BossCommandEntry boss_command_table[] = {
{0x31, boss_cmd_set_unix_timestamp},
{0x32, boss_cmd_exp_set_ccd_config},
{0x33, boss_cmd_exp_get_radfet_values},
{0x34, boss_cmd_exp_ccd_do_debug_convert}, // for plotting

// 0xC0-0xCF namespace: RADFET experiment debugging
// TODO

// 0xD0-0xDF namespace: CCD experiment debugging
// TODO

// 0x90-0x9F namespace: other debugging commands
// {0x90, boss_cmd_echo_command},
{0x91, boss_cmd_clear_aprs_packet_store},
// {0x91, boss_cmd_clear_aprs_packet_store},
{0x92, boss_cmd_exit_mission_boss_mode}, // CRITICAL!
// {0x93, boss_cmd_test_delay_ms},
// {0x95, boss_cmd_exp_get_radfet_values_on_loop},
{0x96, boss_cmd_exp_ccd_do_debug_convert}, // for plotting

#ifdef ENABLE_boss_cmd_cycle_ccd_pin_options
// {0x97, boss_cmd_cycle_ccd_pin_options},
Expand Down Expand Up @@ -369,7 +364,7 @@ void boss_cmd_transfer_data_packets(uint8_t *cmd, Terminal_stream src) {
}

// just send the frame as-is
char msg[255];
char msg[250];
sprintf(
msg,
"%sRESP: idx=%lu, len=%d, frame=%s%s",
Expand Down Expand Up @@ -630,13 +625,16 @@ void boss_cmd_get_uptime_and_status(uint8_t *cmd, Terminal_stream src) {
char msg[200];
sprintf(
msg,
"%sRESP: ut_ms=%lu, ut_sec=%lu, ts_sec_at_boot=%lu, ts_sec_now=%lu, reset_cause=%s(%d), aprs_mode=%d, temp_k=%d,%d,%d,%d,%d%s",
"%sRESP: ut_ms=%lu, ut_sec=%lu, ts_sec_at_boot=%lu, ts_sec_now=%lu, reset_cause=%s(%d), aprs_mode=%d, temp_k=%d,%d,%d,%d,%d,%d-%d, fullpct=%d, rx%ld, tx%ld%s",
MBOSS_RESPONSE_START_STR,
system_uptime_ms, get_system_uptime_sec(),
timestamp_sec_at_boot, get_unix_timestamp_sec_now(),
reset_cause_get_name(reset_cause), (uint8_t)reset_cause,
(uint8_t) current_aprs_mode,
get_external_temperature_k(0), get_external_temperature_k(1), get_external_temperature_k(2), get_external_temperature_k(3), get_external_temperature_k(4),
min_sensor_temp_k, max_sensor_temp_k,
(uint8_t)(sf_buffer_wr_idx/STORE_AND_FORWARD_BUFFER_SIZE*100),
frame_rx_count_since_boot, beacon_count_since_boot,
MBOSS_RESPONSE_END_STR
);
term_sendToMode((uint8_t*)msg, strlen(msg), MODE_BOSS);
Expand Down
6 changes: 3 additions & 3 deletions python_mboss_emulator/emulate_mboss.py
Original file line number Diff line number Diff line change
Expand Up @@ -112,8 +112,8 @@ def add_to_command_table(cmd_df: pd.DataFrame) -> pd.DataFrame:
# [0x27, '255 packets', [0xE0, 0x27, 0x00, 0x00, 0, 0, 0, 255, 0xED]],

# CCD experiment
[0x96, 'CCD1', [0xE0, 0x96, 0x00, 0x00, 0, 0, 0, 0x01, 0xED]], # CCD1
[0x96, 'CCD2', [0xE0, 0x96, 0x00, 0x00, 0, 0, 0, 0x02, 0xED]], # CCD2
[0x34, 'CCD1', [0xE0, 0x34, 0x00, 0x00, 0, 0, 0, 0x01, 0xED]], # CCD1
[0x34, 'CCD2', [0xE0, 0x34, 0x00, 0x00, 0, 0, 0, 0x02, 0xED]], # CCD2

# CCD config
[0x32, 'CCD Config - Defaults', [0xE0, 0x32, 10, 0x00, 50, 0x00, 120, 15, 0xED]],
Expand Down Expand Up @@ -301,7 +301,7 @@ def update_plots(plot_data: dict[int, list[int]]) -> None:
logger.info(f"Plotting CCD{ccd_num} data.")

# send the bytes
serial_send_bytes(ser, [0xE0, 0x96, 0, 0, 0, 0, how_many_bytes_times_16, ccd_num, 0xED], '0x96 - CCD data')
serial_send_bytes(ser, [0xE0, 0x34, 0, 0, 0, 0, how_many_bytes_times_16, ccd_num, 0xED], '0x34 - CCD data')
resp = read_response(ser)

# interpret the bytes
Expand Down

0 comments on commit f5653ea

Please sign in to comment.