feat: add mode_complete to allow mode to stop automatically for controller

This commit is contained in:
Roy_01
2025-03-18 11:41:05 +08:00
parent 92859cd662
commit ee99ff121b
2 changed files with 35 additions and 8 deletions
+29 -2
View File
@@ -177,6 +177,7 @@ typedef struct
{
uint32_t count;
uint32_t drop;
bool the_last_record_flag;
void (*complete_cb)(void);
} notify_setting_t;
@@ -257,8 +258,12 @@ static void pel_scan_mode_notify(scan_mode_notify_packet_t *packet_buf, uint32_t
packet_buf->resis_pattern_id = load_config.resistor.pattern_index;
packet_buf->resis_bitsmask = load_config.resistor.resistor_mask;
packet_buf->resis_g_value = load_config.resistor.resistor_conductance;
packet_buf->val_1 = 0xFFFFFFFF;
packet_buf->val_2 = 0xFFFFFFFF;
packet_buf->val_3 = 0xFFFF;
ret_code_t ret = le_event_async_notify((void *)packet_buf, packet_len, pdMS_TO_TICKS(5));
// NRF_LOG_HEXDUMP_INFO(packet_buf,packet_len);
{
char str[128];
snprintf(str, sizeof(str), "{%3d, %3d, %10lu, %10lu, %10lu, %10lu, %2.7f, %2.7f, %2.7f, %5d, 0x%04X, %.7f, %d}", packet_buf->mem_board_id, packet_buf->packet_seq, packet_buf->notify_time, packet_buf->output_vo_raw, packet_buf->output_vc_raw, packet_buf->output_ve_raw, packet_buf->hold_OUT_v, packet_buf->hold_VCC_v, packet_buf->hold_VEE_v, packet_buf->resis_pattern_id, packet_buf->resis_bitsmask, packet_buf->resis_g_value, packet_buf->mode_complete);
@@ -444,6 +449,7 @@ static void pel_pulse_stop(void *p_arg)
stop_adc_pulse();
}
#define MODE_COMPLETE (0xA)
static void pel_pulse_notify(void *p_arg)
{
NRF_LOG_INFO("%s()", __FUNCTION__);
@@ -462,6 +468,16 @@ static void pel_pulse_notify(void *p_arg)
for (uint32_t i = 0; i < p_setting->count; i++)
{
xSemaphoreTake(adc_convt_cplt_sem, pdMS_TO_TICKS(1000));
if (p_setting->the_last_record_flag && (i == p_setting->count - 1))
{
packet_buf.mode_complete |= MODE_COMPLETE;
}
else
{
packet_buf.mode_complete &= ~MODE_COMPLETE;
}
nrf_gpio_pin_set(TP2_PIN);
pel_scan_mode_notify(&packet_buf, sizeof(packet_buf));
nrf_gpio_pin_clear(TP2_PIN);
@@ -640,8 +656,9 @@ static void auto_scan_mode(uint8_t *ins, uint16_t size)
case 0x01: {
// auto_scan_mode start
// 30 00 02 01 00 1C 00 01 00 0A 00 05
uint16_t pattern_max = u8_to_u16(p_ins->param[0], p_ins->param[1]);
uint16_t pattern_min = u8_to_u16(p_ins->param[2], p_ins->param[3]);
uint16_t pattern_max = u8_to_u16(p_ins->param[0], p_ins->param[1]);
uint16_t pattern_min = u8_to_u16(p_ins->param[2], p_ins->param[3]);
pel_scan_msg.notify_setting.the_last_record_flag = false;
send_start_package((void *)&packet_buf, sizeof(packet_buf));
@@ -656,6 +673,10 @@ static void auto_scan_mode(uint8_t *ins, uint16_t size)
pel_scan_msg.notify_setting.drop = u8_to_u16(p_ins->param[4], p_ins->param[5]);
pel_scan_msg.notify_setting.count = u8_to_u16(p_ins->param[6], p_ins->param[7]);
pel_scan_msg.notify_setting.complete_cb = auto_scan_complete;
if (i == pattern_min)
{
pel_scan_msg.notify_setting.the_last_record_flag = true;
}
ASSERT(xMessageBufferSend(pel_scan_msqQ, &pel_scan_msg, sizeof(pel_scan_msg.opcode) + sizeof(pel_scan_msg.notify_setting), pdMS_TO_TICKS(500)));
wait_auto_scan_complete();
@@ -730,6 +751,8 @@ static void R_external_calibration_mode(uint8_t *ins, uint16_t size)
case 0x01: {
// R_external_calibration_mode start with drop n * 10ms
// 30 00 03 01 00 0A 00 05
pel_scan_msg.notify_setting.the_last_record_flag = false;
send_start_package((void *)&packet_buf, sizeof(packet_buf));
for (uint16_t i = 0; i < COUNTOF(calibration_bits_pattern_tab); i++)
@@ -743,6 +766,10 @@ static void R_external_calibration_mode(uint8_t *ins, uint16_t size)
pel_scan_msg.notify_setting.drop = u8_to_u16(p_ins->param[0], p_ins->param[1]);
pel_scan_msg.notify_setting.count = u8_to_u16(p_ins->param[2], p_ins->param[3]);
pel_scan_msg.notify_setting.complete_cb = auto_scan_complete;
if (i == COUNTOF(calibration_bits_pattern_tab) - 1)
{
pel_scan_msg.notify_setting.the_last_record_flag = true;
}
ASSERT(xMessageBufferSend(pel_scan_msqQ, &pel_scan_msg, sizeof(pel_scan_msg.opcode) + sizeof(pel_scan_msg.notify_setting), pdMS_TO_TICKS(500)));
wait_auto_scan_complete();
+6 -6
View File
@@ -12,9 +12,9 @@ extern "C"
#define VERSION_DATE_YEAR 25
#define VERSION_DATE_MONTH 3
#define VERSION_DATE_DAY 17
#define VERSION_DATE_HOUR 16
#define VERSION_DATE_MINUTE 36
#define VERSION_DATE_DAY 18
#define VERSION_DATE_HOUR 11
#define VERSION_DATE_MINUTE 41
#define PEL_0P5R_MASK (0x01 << 0)
#define PEL_1P0R_MASK (0x01 << 1)
@@ -45,9 +45,9 @@ extern "C"
float resis_g_value;
uint32_t mode_complete : 4;
uint32_t rsvd : 28;
int32_t val_1;
int32_t val_2;
int16_t val_3;
uint32_t val_1;
uint32_t val_2;
uint16_t val_3;
} scan_mode_notify_packet_t;
const elite_instance_t *pel_init(void);