Browse Source

Optimization

old-version
gudae 1 month ago
parent
commit
592e0faa24
  1. BIN
      DefaultBuild/app_cmd_parser.obj
  2. BIN
      DefaultBuild/app_owi_service.obj
  3. BIN
      DefaultBuild/app_result.obj
  4. BIN
      DefaultBuild/app_scheduler.obj
  5. BIN
      DefaultBuild/gatectrl.obj
  6. BIN
      DefaultBuild/multical.abs
  7. 678
      DefaultBuild/multical.map
  8. 3343
      DefaultBuild/multical.mot
  9. BIN
      DefaultBuild/owi.obj
  10. BIN
      DefaultBuild/r_main.obj
  11. BIN
      DefaultBuild/uart.obj
  12. 16
      QualityReport(multical,DefaultBuild).txt
  13. 50
      app_owi_service.c
  14. 7
      app_scheduler.c
  15. 1
      app_scheduler.h
  16. 1
      multical.mtpj
  17. 123
      multical.temp.mtud
  18. 15
      owi.c
  19. 190
      r_main.c
  20. 2
      uart.c

BIN
DefaultBuild/app_cmd_parser.obj

Binary file not shown.

BIN
DefaultBuild/app_owi_service.obj

Binary file not shown.

BIN
DefaultBuild/app_result.obj

Binary file not shown.

BIN
DefaultBuild/app_scheduler.obj

Binary file not shown.

BIN
DefaultBuild/gatectrl.obj

Binary file not shown.

BIN
DefaultBuild/multical.abs

Binary file not shown.

678
DefaultBuild/multical.map

File diff suppressed because it is too large

3343
DefaultBuild/multical.mot

File diff suppressed because it is too large

BIN
DefaultBuild/owi.obj

Binary file not shown.

BIN
DefaultBuild/r_main.obj

Binary file not shown.

BIN
DefaultBuild/uart.obj

Binary file not shown.

16
QualityReport(multical,DefaultBuild).txt

@ -1,13 +1,13 @@
QualityReport
2026년 3월 16일 월요일 오후 3:34:34
2026년 3월 18일 수요일 오후 2:04:39
------ Start build(multical, DefaultBuild) ------
------ Build ended(Error:0, Warning:0)(multical, DefaultBuild) ------
--- SHA1 hash value of output files ---
C:\Users\temp\Desktop\new_fw\DefaultBuild\multical.abs: f11e23a50a4b42ef052d2effc091d61f3c612086
C:\Users\temp\Desktop\new_fw\DefaultBuild\multical.mot: 630d25b191142533d214fb10f07cdcb7601c85c6
C:\Users\temp\Desktop\new_fw\DefaultBuild\multical.abs: a1f673f43efd9df3d36b8b83716e9d0420974ff2
C:\Users\temp\Desktop\new_fw\DefaultBuild\multical.mot: f708d9433ec20c9933cc70dcdfe65f331310e129
--- System Information ---
@ -18,7 +18,7 @@ C:\Users\temp\Desktop\new_fw\DefaultBuild\multical.mot: 630d25b191142533d214fb10
*.NET Framework Version
Microsoft .NET Framework 4 [.NET 4.8 or later] (533325)
*WebView2 Version
145.0.3800.97
146.0.3856.62
--- Application Information ---
*Product Name
@ -35,13 +35,13 @@ C:\Users\temp\Desktop\new_fw\DefaultBuild\multical.mot: 630d25b191142533d214fb10
C:\Program Files (x86)\Renesas Electronics\CS+\CC
*Memory Usage
*Private Working Set
254 MB
320 MB
*Number of GDI Objects
2747
2739
*Number of USER Objects
1491
1526
*Opened Files
32 editors, 32 files, 236 KB
33 editors, 33 files, 239 KB
--- Build Tool Plug-in Information ---
RH850 Build tool CC-RH Plug-in

50
app_owi_service.c

@ -1,5 +1,6 @@
#include "app_owi_service.h"
#include "owi.h"
#include "delay.h"
#include <string.h>
static app_owi_result_t app_owi_from_raw(const owi_io_result_t *io)
@ -27,10 +28,59 @@ static app_owi_result_t app_owi_from_raw(const owi_io_result_t *io)
return r;
}
static uint8_t is_long_owi_read(int length)
{
return (length == 119 || length == 127) ? 1u : 0u;
}
static uint8_t looks_bad_tail(const owi_io_result_t *io)
{
uint16_t i;
uint8_t zero_run = 0;
uint8_t ff_run = 0;
if (!io) return 1u;
if (io->read_len < 24u) return 1u;
for (i = (uint16_t)(io->read_len - 24u); i < io->read_len; i++) {
uint8_t b = io->data[i];
if (b == 0x00u) zero_run++;
else zero_run = 0;
if (b == 0xFFu) ff_run++;
else ff_run = 0;
/* 진짜 이상한 경우만 */
if (zero_run >= 8u || ff_run >= 8u) {
return 1u;
}
}
return 0u;
}
app_owi_result_t app_owi_read_basic(uint8_t id, int length)
{
owi_io_result_t io;
OWI_ReadBytesRaw(length, id, &io);
if (is_long_owi_read(length)) {
if (!io.ok || io.timeout || io.read_len < (uint16_t)length || looks_bad_tail(&io)) {
delay_us(3000u);
OWI_ReadBytesRaw(length, id, &io);
/* 재시도 후에도 bad면 실패 처리 */
if (!io.ok || io.timeout || io.read_len < (uint16_t)length || looks_bad_tail(&io)) {
io.ok = 0u;
io.timeout = 1u;
io.timeout_byte_index = 0xFFFEu;
io.timeout_bit_index = 0xFEu;
}
}
}
return app_owi_from_raw(&io);
}

7
app_scheduler.c

@ -42,3 +42,10 @@ int app_scheduler_is_empty(void)
{
return (g_count == 0U);
}
void app_scheduler_clear(void)
{
g_head = 0;
g_tail = 0;
g_count = 0;
memset(g_queue, 0, sizeof(g_queue));
}

1
app_scheduler.h

@ -7,5 +7,6 @@ void app_scheduler_init(void);
int app_scheduler_push(const app_job_t *job);
int app_scheduler_pop(app_job_t *job);
int app_scheduler_is_empty(void);
void app_scheduler_clear(void);
#endif

1
multical.mtpj

@ -2061,7 +2061,6 @@ C:\Program Files (x86)\Renesas Electronics\CS+\CC\FAA\V1.05.00
<DebuggerProperty-HookProperty-HookTransaction-Broke-Length>0</DebuggerProperty-HookProperty-HookTransaction-Broke-Length>
<DebuggerProperty-HookProperty-HookTransaction-Connected-Length>0</DebuggerProperty-HookProperty-HookTransaction-Connected-Length>
<DebuggerProperty-HookProperty-HookTransaction-Disconnecting-Length>0</DebuggerProperty-HookProperty-HookTransaction-Disconnecting-Length>
<DebuggerProperty-EssentialProperty-EmulatorConnect-SerialNumber />
</Instance>
</Class>
<Class Guid="9f7af90c-526c-4f28-af29-524df208b9e0">

123
multical.temp.mtud

File diff suppressed because one or more lines are too long

15
owi.c

@ -445,6 +445,7 @@ void OWI_ReadBytesRaw(int length, uint8_t id, owi_io_result_t *r)
{
int i;
int max_len;
uint8_t is_long_read;
if (!r) return;
@ -464,13 +465,15 @@ void OWI_ReadBytesRaw(int length, uint8_t id, owi_io_result_t *r)
r->read_len = (uint16_t)length;
OWI_ClearTimeout();
is_long_read = (length >= 119) ? 1u : 0u;
OWI_SecureStop();
OWI_WriteByte((uint8_t)((id << 1) | 1u));
/* read 응답 준비 시간 */
/* 기존 잘 되던 값 유지 */
delay_us(100u);
/* 첫 falling edge를 한 번 잡는다 */
/* 첫 falling edge를 한 번 잡는다 */
if (!OWI_WaitForFallingEdge(0u, 0u)) {
owi_result_latch_timeout(r);
OWI_StopRead();
@ -478,6 +481,14 @@ void OWI_ReadBytesRaw(int length, uint8_t id, owi_io_result_t *r)
}
for (i = 0; i < length; i++) {
/* long read만 주기적 재동기화 */
if (is_long_read && i == (length - 50)) {
if (!OWI_WaitForFallingEdge((uint16_t)i, 0u)) {
owi_result_latch_timeout(r);
break;
}
}
r->data[i] = OWI_ReadByte_StreamSynced((uint16_t)i);
if (OWI_HasTimeout()) {

190
r_main.c

@ -61,6 +61,9 @@ Includes
#define BRIDGE_IDLE_DONE_US 2500000U /* sweep 중 성공 라인 사이 최대 무응답 허용 시간 */
#define BRIDGE_TOTAL_WAIT_US 30000000U /* sweep 전체 브리지 최대 대기 시간 */
#define OWI_LONG_READ_SETTLE_US 30000U
#define OWI_LONG_READ_RETRY_US 10000U
/* =========================
* UART RX Buffers
* ========================= */
@ -125,6 +128,43 @@ static void RS485_Bridge_ResetFifo(void)
g_rs485_bridge_done = 0;
}
typedef struct {
uint8_t active;
uint8_t scan_started;
uint8_t current_scan_addr;
app_job_t job;
} app_runtime_job_t;
static app_runtime_job_t g_app_runtime_job;
static void app_runtime_reset(void)
{
memset(&g_app_runtime_job, 0, sizeof(g_app_runtime_job));
}
static void rs485_abort_and_reset_pipeline(void)
{
/* bridge 정리 */
g_rs485_bridge_active = 0;
g_rs485_bridge_done = 0;
RS485_Bridge_ResetFifo();
/* RX 상태 정리 */
rs485_rx_done = 0;
rs485_rx_index = 0;
rs485_rx_length = 0;
memset((void*)rs485_rx_buffer, 0, sizeof(rs485_rx_buffer));
/* 현재 job 중단 */
app_runtime_reset();
/* 대기 queue 비우기 */
app_scheduler_clear();
/* UART0 recover 요청 */
g_rs485_need_recover = 1;
}
static int RS485_Bridge_ReadLine(char *out, int out_sz, uint32_t timeout_us)
{
int n = 0;
@ -252,6 +292,29 @@ static unsigned char hex2byte(char h, char l)
return (unsigned char)((hi << 4) | lo);
}
static uint8_t is_long_owi_read_len(uint8_t len)
{
return (len == 119u || len == 127u);
}
static app_owi_result_t do_stable_owi_read(uint8_t id, uint8_t read_len)
{
app_owi_result_t r;
if (is_long_owi_read_len(read_len)) {
delay_us(OWI_LONG_READ_SETTLE_US);
}
r = app_owi_read_basic(id, (int)read_len);
if ((!r.ok || r.timeout || r.read_len < read_len) && is_long_owi_read_len(read_len)) {
delay_us(OWI_LONG_READ_RETRY_US);
r = app_owi_read_basic(id, (int)read_len);
}
return r;
}
/* =========================
* Prefix mode
* ========================= */
@ -263,15 +326,6 @@ typedef enum {
static PrefixMode s_prefix_mode = PREFIX_NONE;
typedef struct {
uint8_t active;
uint8_t scan_started;
uint8_t current_scan_addr;
app_job_t job;
} app_runtime_job_t;
static app_runtime_job_t g_app_runtime_job;
/* =========================
* parse x-prefix: xNNc_001011:...
* ========================= */
@ -718,23 +772,20 @@ static int run_connect_verify_one_channel(const app_job_t *job, uint8_t ch)
/* 재시도 전 OFF 처리 */
if (attempt > 0) {
Cal_Init();
delay_us(30000);
}
/* prefix / gate */
if (job->mode == 'C') {
s_prefix_mode = PREFIX_CAL;
Cal_Init();
} else {
s_prefix_mode = PREFIX_EOL;
Eol_Init();
}
/* prefix / gate */
if (job -> mode == 'C') {
s_prefix_mode = PREFIX_CAL;
Cal_Init();
}else{
s_prefix_mode = PREFIX_EOL;
Eol_Init();
}
/* 현재 채널만 선택 */
Gate_SetByNum(ch, job->hash_on, job->anaout_on, job->check_on);
GateCtrl_SelectChannel(ch);
delay_us(30000);
/* 1) OWT 28 003 + first3 */
r_write1 = app_owi_write_t_basic(0x28u, write1_data, 3);
if (!r_write1.ok || r_write1.timeout) {
@ -797,11 +848,12 @@ static int execute_connect_verify_sequence(CmdSource src, const app_job_t *job)
/* 000 이면 1~20 sweep */
if (job->channel == 0u) {
for (ch = 1; ch <= 20; ch++) {
uint8_t ok = (uint8_t)run_connect_verify_one_channel(job, ch);
if (ok) {
print_connect_sweep_result(src, ch, 1);
print_connect_sweep_result(src, ch, 1);
success_count++;
}
}
@ -809,6 +861,7 @@ static int execute_connect_verify_sequence(CmdSource src, const app_job_t *job)
if (success_count == 0u) {
OUT_PRINT(src, "Fail\r\n");
}
send_end_response(src);
return 1;
}
@ -825,7 +878,6 @@ static int execute_connect_verify_sequence(CmdSource src, const app_job_t *job)
} else {
OUT_PRINT(src, "Fail\r\n");
}
delay_us(30000);
send_end_response(src);
return 1;
}
@ -838,16 +890,15 @@ static int execute_direct_read_sequence(CmdSource src, const app_job_t *job)
if (!job) return 0;
/* 일반 OW 패턴만 처리 */
if (job->type != APP_JOB_PROTO_OW) return 0;
if (job->proto != APP_PROTO_OWIW) return 0;
if (job->proto != APP_PROTO_OWIW) return 0;
if (job->id != 0x28u) return 0;
if (job->len != 3u) return 0;
if (job->addr != g_fixed_addr) return 0;
if (job->channel < 1 || job->channel > 20) {
OUT_PRINT(src, "Fail\r\n");
send_end_response(src);
send_end_response(src);
return 1;
}
@ -861,41 +912,38 @@ static int execute_direct_read_sequence(CmdSource src, const app_job_t *job)
Gate_SetByNum(job->channel, job->hash_on, job->anaout_on, job->check_on);
GateCtrl_SelectChannel(job->channel);
//delay_us(30000);
/* payload 3바이트 패턴으로 read 길이 결정 */
if (job->payload[0] == 0x2E && job->payload[1] == 0x00 && job->payload[2] == 0x1F) {
read_len = 65; /* outmem */
read_len = 65;
}
else if (job->payload[0] == 0x22 && job->payload[1] == 0x00 && job->payload[2] == 0x3A) {
read_len = 119; /* shadow */
read_len = 119;
}
else if (job->payload[0] == 0x26 && job->payload[1] == 0x00 && job->payload[2] == 0x3E) {
read_len = 127; /* nvm */
read_len = 127;
}
else if (job->payload[0] == 0x0B && job->payload[1] == 0x04 && job->payload[2] == 0x06) {
read_len = 23; /* acquiredata */
read_len = 23;
}
else {
return 0; /* 일반 ow는 기존 처리로 넘김 */
return 0;
}
/* 1) GUI에서 보낸 ow 명령 그대로 write */
r_write = app_owi_write_basic(0x28u, job->payload, 3);
if (!r_write.ok || r_write.timeout) {
OUT_PRINT(src, "Fail\r\n");
send_end_response(src);
send_end_response(src);
return 1;
}
/* 2) 대응되는 read 수행 */
r_read = app_owi_read_basic(0x28u, read_len);
r_read = do_stable_owi_read(0x28u, read_len);
if (!r_read.ok || r_read.timeout || r_read.read_len < read_len) {
OUT_PRINT(src, "Fail\r\n");
send_end_response(src);
send_end_response(src);
return 1;
}
/* 3) 읽은 값만 출력 */
print_owi_read_result(src, &r_read);
send_end_response(src);
return 1;
@ -968,6 +1016,7 @@ static int execute_write_coeff_sequence(CmdSource src, const app_job_t *job)
Gate_SetByNum(job->channel, job->hash_on, job->anaout_on, job->check_on);
GateCtrl_SelectChannel(job->channel);
//delay_us(30000);
coeff_data = &job->payload[3];
@ -1001,8 +1050,10 @@ static int execute_write_coeff_sequence(CmdSource src, const app_job_t *job)
return 1;
}
delay_us(30000);
/* 4) or28127 */
r_read2 = app_owi_read_basic(0x28u, 127);
r_read2 = do_stable_owi_read(0x28u, 127u);
if (!r_read2.ok || r_read2.timeout || r_read2.read_len < 127) {
OUT_PRINT(src, "Fail\r\n");
send_end_response(src);
@ -1075,6 +1126,7 @@ static int execute_shadow_write_copy_nvm_sequence(CmdSource src, const app_job_t
return 1;
}
if (job->channel < 1 || job->channel > 20) {
OUT_PRINT(src, "Fail\r\n");
send_end_response(src);
@ -1091,6 +1143,7 @@ static int execute_shadow_write_copy_nvm_sequence(CmdSource src, const app_job_t
Gate_SetByNum(job->channel, job->hash_on, job->anaout_on, job->check_on);
GateCtrl_SelectChannel(job->channel);
//delay_us(30000);
/* 마지막 2바이트를 GUI CRC로 사용 */
gui_crc = &job->payload[119];
@ -1208,7 +1261,7 @@ static int execute_shadow_write_copy_nvm_sequence(CmdSource src, const app_job_t
break;
}
delay_us(5000);
//delay_us(5000);
}
if (poll_count >= 50u) {
@ -1299,7 +1352,7 @@ static int execute_shadow_write_copy_nvm_sequence(CmdSource src, const app_job_t
}
/* 17) or28127 */
r_read = app_owi_read_basic(0x28u, 127);
r_read = do_stable_owi_read(0x28u, 127u);
if (!r_read.ok || r_read.timeout || r_read.read_len < 127) {
OUT_PRINT(src, "Fail\r\n");
send_end_response(src);
@ -1322,29 +1375,31 @@ static int execute_owi_service_from_job(CmdSource src, const app_job_t *job)
if (!job) return 0;
// connect
/* connect */
if (execute_connect_verify_sequence(src, job)) {
return 1;
}
// nvm, shadow, outmem
/* nvm, shadow, outmem direct read */
if (execute_direct_read_sequence(src, job)) {
return 1;
}
// write_coefficient
/* write coefficient */
if (execute_write_coeff_sequence(src, job)) {
return 1;
}
// shadow_write to copy nvm
/* shadow_write -> copy nvm */
if (execute_shadow_write_copy_nvm_sequence(src, job)) {
return 1;
return 1;
}
if (job->addr != g_fixed_addr) return 0;
if (job->channel < 1 || job->channel > 20) {
OUT_PRINT(src, "Err:ch_range\r\n");
send_end_response(src);
return 1;
}
@ -1365,17 +1420,22 @@ static int execute_owi_service_from_job(CmdSource src, const app_job_t *job)
} else {
r = app_owi_write_basic(job->id, job->payload, (uint8_t)job->len);
}
print_owi_write_result(src, &r);
send_end_response(src);
return 1;
}
if (job->type == APP_JOB_PROTO_OR) {
r = app_owi_read_basic(job->id, (int)job->len);
print_owi_read_result(src, &r);
send_end_response(src);
return 1;
}
return 0;
OUT_PRINT(src, "Err:job_exec\r\n");
send_end_response(src);
return 1;
}
static void forward_line_rs485_and_bridge(const char *line)
@ -1485,22 +1545,25 @@ static void forward_line_rs485_and_bridge(const char *line)
}
if (!got_any_line) {
OUT_PRINT(CMD_SRC_PC, "Err:rs485_no_response\r\n");
} else {
char dbg[128];
if (line_len > 0) {
sprintf(dbg, "Err:rs485_no_end partial=%s\r\n", linebuf);
} else {
sprintf(dbg, "Err:rs485_no_end partial=<none>\r\n");
}
OUT_PRINT(CMD_SRC_PC, dbg);
}
OUT_PRINT(CMD_SRC_PC, "Err:rs485_no_response\r\n");
rs485_abort_and_reset_pipeline();
return;
} else {
char dbg[128];
if (line_len > 0) {
sprintf(dbg, "Err:rs485_no_end partial=%s\r\n", linebuf);
} else {
sprintf(dbg, "Err:rs485_no_end partial=<none>\r\n");
}
g_rs485_bridge_active = 0;
OUT_PRINT(CMD_SRC_PC, dbg);
rs485_abort_and_reset_pipeline();
return;
}
}
static int execute_owi_service_from_line(CmdSource src, const char *line)
{
uint8_t addr = 0, ch = 0;
@ -1555,6 +1618,7 @@ static int execute_owi_service_from_line(CmdSource src, const char *line)
if (payload_pos >= len) {
if (mode == 'E') {
OUT_PRINT(src, "<ACK>XE51\r\n");
send_end_response(src);
return 1;
} else {
OUT_PRINT(src, "Err:CAL_need_payload\r\n");
@ -1839,6 +1903,7 @@ static void process_one_line_now(CmdSource src, const char *input_line)
if (rem <= 0) {
if (mode == 'E') {
OUT_PRINT(src, "<ACK>XE51\r\n");
send_end_response(src);
return;
} else {
OUT_PRINT(src, "Err:CAL_need_payload\r\n");
@ -1958,11 +2023,6 @@ static void process_one_line(CmdSource src, const volatile uint8_t *rx_buf, uint
}
}
static void app_runtime_reset(void)
{
memset(&g_app_runtime_job, 0, sizeof(g_app_runtime_job));
}
static void app_runtime_try_start(void)
{
if (g_app_runtime_job.active) return;

2
uart.c

@ -56,7 +56,7 @@ void rs485_recover(void)
/* UART1 송신용 내부 버퍼(스택 포인터 안전) */
static uint8_t s_uart1_txbuf[1024];
static uint8_t s_uart0_txbuf[256];
static uint8_t s_uart0_txbuf[270];
static volatile uint16_t s_uart0_tx_len = 0;

Loading…
Cancel
Save