From fa69200601ba8517dc81ec449c0633fb5a989631 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?O=C4=9Fuzhan=20B=C3=BCy=C3=BCksolak?= Date: Tue, 30 Jan 2024 12:09:16 +0300 Subject: [PATCH] clang format updates --- .../MAX78000/CNN/facial_recognition/main.c | 4 ++- .../CNN/facial_recognition/src/cnn_1.c | 8 ++++-- .../CNN/facial_recognition/src/cnn_2.c | 4 ++- .../facial_recognition/src/facedetection.c | 19 +++++++++---- .../CNN/facial_recognition/src/post_process.c | 24 ++++++++++++---- .../CNN/facial_recognition/src/utils.c | 4 ++- .../CNN/facial_recognition/include/cnn_3.h | 17 +++-------- .../MAX78002/CNN/facial_recognition/main.c | 4 ++- .../CNN/facial_recognition/src/cnn_1.c | 28 +++++++++++-------- .../CNN/facial_recognition/src/cnn_2.c | 24 ++++++++-------- .../CNN/facial_recognition/src/post_process.c | 24 ++++++++++++---- .../CNN/facial_recognition/src/utils.c | 4 ++- 12 files changed, 104 insertions(+), 60 deletions(-) diff --git a/Examples/MAX78000/CNN/facial_recognition/main.c b/Examples/MAX78000/CNN/facial_recognition/main.c index f289d61b7c2..99d820b1a1f 100644 --- a/Examples/MAX78000/CNN/facial_recognition/main.c +++ b/Examples/MAX78000/CNN/facial_recognition/main.c @@ -61,7 +61,9 @@ void init_names() char default_names[DEFAULT_EMBS_NUM][7] = DEFAULT_NAMES; #pragma GCC diagnostic push #pragma GCC diagnostic ignored "-Wstringop-truncation" - for (int i = 0; i < DEFAULT_EMBS_NUM; i++) { strncpy((char *)names[i], default_names[i], 7); } + for (int i = 0; i < DEFAULT_EMBS_NUM; i++) { + strncpy((char *)names[i], default_names[i], 7); + } #pragma GCC diagnostic pop } #ifdef TFT_ENABLE diff --git a/Examples/MAX78000/CNN/facial_recognition/src/cnn_1.c b/Examples/MAX78000/CNN/facial_recognition/src/cnn_1.c index 770b2e84d77..bc00c33e8f7 100644 --- a/Examples/MAX78000/CNN/facial_recognition/src/cnn_1.c +++ b/Examples/MAX78000/CNN/facial_recognition/src/cnn_1.c @@ -86,7 +86,9 @@ int cnn_stop(void) void memcpy32(uint32_t *dst, const uint32_t *src, int n) { - while (n-- > 0) { *dst++ = *src++; } + while (n-- > 0) { + *dst++ = *src++; + } } static const uint32_t kernels[] = KERNELS; @@ -113,7 +115,9 @@ static const uint8_t bias_3[] = BIAS_3; static void memcpy_8to32(uint32_t *dst, const uint8_t *src, int n) { - while (n-- > 0) { *dst++ = *src++; } + while (n-- > 0) { + *dst++ = *src++; + } } int cnn_1_load_bias(void) diff --git a/Examples/MAX78000/CNN/facial_recognition/src/cnn_2.c b/Examples/MAX78000/CNN/facial_recognition/src/cnn_2.c index 621d220abaf..ba473f0f502 100644 --- a/Examples/MAX78000/CNN/facial_recognition/src/cnn_2.c +++ b/Examples/MAX78000/CNN/facial_recognition/src/cnn_2.c @@ -82,7 +82,9 @@ static const uint8_t bias_3[] = BIAS_3; static void memcpy_8to32(uint32_t *dst, const uint8_t *src, int n) { - while (n-- > 0) { *dst++ = *src++; } + while (n-- > 0) { + *dst++ = *src++; + } } int cnn_2_load_bias(void) diff --git a/Examples/MAX78000/CNN/facial_recognition/src/facedetection.c b/Examples/MAX78000/CNN/facial_recognition/src/facedetection.c index f8f7b82f7df..a72c293399d 100644 --- a/Examples/MAX78000/CNN/facial_recognition/src/facedetection.c +++ b/Examples/MAX78000/CNN/facial_recognition/src/facedetection.c @@ -82,7 +82,10 @@ static void setup_dma_tft(uint32_t *src_ptr) static void start_tft_dma(uint32_t *src_ptr) { - while ((MXC_DMA->ch[g_dma_channel_tft].status & MXC_F_DMA_STATUS_STATUS)) { ; } + while ((MXC_DMA->ch[g_dma_channel_tft].status & MXC_F_DMA_STATUS_STATUS)) { + { + } + } if (MXC_DMA->ch[g_dma_channel_tft].status & MXC_F_DMA_STATUS_CTZ_IF) { MXC_DMA->ch[g_dma_channel_tft].status = MXC_F_DMA_STATUS_CTZ_IF; @@ -168,13 +171,19 @@ static void run_cnn_1(int x_offset, int y_offset) setup_dma_tft((uint32_t *)raw); start_tft_dma((uint32_t *)raw); // Wait for DMA to finish - while ((MXC_DMA->ch[g_dma_channel_tft].status & MXC_F_DMA_STATUS_STATUS)) { ; } + while ((MXC_DMA->ch[g_dma_channel_tft].status & MXC_F_DMA_STATUS_STATUS)) { + { + } + } setup_dma_tft((uint32_t *)(raw + IMAGE_XRES * IMAGE_YRES)); // Send a second half of captured image to TFT start_tft_dma((uint32_t *)(raw + IMAGE_XRES * IMAGE_YRES)); // Wait for DMA to finish - while ((MXC_DMA->ch[g_dma_channel_tft].status & MXC_F_DMA_STATUS_STATUS)) { ; } + while ((MXC_DMA->ch[g_dma_channel_tft].status & MXC_F_DMA_STATUS_STATUS)) { + { + } + } PR_DEBUG("DMA time : %d", utils_get_time_ms() - dma_time); //MXC_TFT_ShowImageCameraRGB565(X_START, Y_START, raw, w, h); @@ -206,8 +215,8 @@ static void run_cnn_1(int x_offset, int y_offset) r = ur - 128; // Loading data into the CNN fifo - while (((*((volatile uint32_t *)0x50000004) & 1)) != 0) - ; // Wait for FIFO 0 + while (((*((volatile uint32_t *)0x50000004) & 1)) != 0) {} + // Wait for FIFO 0 number = 0x00FFFFFF & ((((uint8_t)b) << 16) | (((uint8_t)g) << 8) | ((uint8_t)r)); diff --git a/Examples/MAX78000/CNN/facial_recognition/src/post_process.c b/Examples/MAX78000/CNN/facial_recognition/src/post_process.c index e1a5c583cee..0777bc0d6f3 100644 --- a/Examples/MAX78000/CNN/facial_recognition/src/post_process.c +++ b/Examples/MAX78000/CNN/facial_recognition/src/post_process.c @@ -51,7 +51,9 @@ int get_prior_idx(int ar_idx, int scale_idx, int rel_idx) { int prior_idx = 0; - for (int s = 0; s < scale_idx; ++s) { prior_idx += NUM_ARS * MULT(dims[s][0], dims[s][1]); } + for (int s = 0; s < scale_idx; ++s) { + prior_idx += NUM_ARS * MULT(dims[s][0], dims[s][1]); + } prior_idx += NUM_ARS * rel_idx + ar_idx; return prior_idx; @@ -74,7 +76,9 @@ void get_indices(int *ar_idx, int *scale_idx, int *rel_idx, int prior_idx) int in_scale_idx = prior_idx; - for (s = 0; s < *scale_idx; ++s) { in_scale_idx -= (NUM_ARS * MULT(dims[s][0], dims[s][1])); } + for (s = 0; s < *scale_idx; ++s) { + in_scale_idx -= (NUM_ARS * MULT(dims[s][0], dims[s][1])); + } *ar_idx = in_scale_idx % NUM_ARS; *rel_idx = in_scale_idx / NUM_ARS; @@ -214,7 +218,9 @@ void gcxgcy_to_cxcy(float *cxcy, int prior_idx, float *priors_cxcy) { float gcxgcy[4]; - for (int i = 0; i < 4; i++) { gcxgcy[i] = (float)prior_locs[4 * prior_idx + i] / 128.0; } + for (int i = 0; i < 4; i++) { + gcxgcy[i] = (float)prior_locs[4 * prior_idx + i] / 128.0; + } cxcy[0] = priors_cxcy[0] + gcxgcy[0] * priors_cxcy[2] / 10; cxcy[1] = priors_cxcy[1] + gcxgcy[1] * priors_cxcy[3] / 10; @@ -236,7 +242,9 @@ void insert_val(uint16_t val, uint16_t *arr, int arr_len, int idx) arr[arr_len] = arr[arr_len - 1]; } - for (int j = (arr_len - 1); j > idx; --j) { arr[j] = arr[j - 1]; } + for (int j = (arr_len - 1); j > idx; --j) { + arr[j] = arr[j - 1]; + } arr[idx] = val; } @@ -247,7 +255,9 @@ void insert_idx(uint16_t val, uint16_t *arr, int arr_len, int idx) arr[arr_len] = arr[arr_len - 1]; } - for (int j = (arr_len - 1); j > idx; --j) { arr[j] = arr[j - 1]; } + for (int j = (arr_len - 1); j > idx; --j) { + arr[j] = arr[j - 1]; + } arr[idx] = val; } @@ -457,7 +467,9 @@ void localize_objects(void) area = calculate_area(xy); if (area > max_area) { max_area = area; - for (int i = 0; i < 4; ++i) { max_xy[i] = xy[i]; } + for (int i = 0; i < 4; ++i) { + max_xy[i] = xy[i]; + } } #else diff --git a/Examples/MAX78000/CNN/facial_recognition/src/utils.c b/Examples/MAX78000/CNN/facial_recognition/src/utils.c index 1bb93f07df4..46354ffeb0d 100644 --- a/Examples/MAX78000/CNN/facial_recognition/src/utils.c +++ b/Examples/MAX78000/CNN/facial_recognition/src/utils.c @@ -50,7 +50,9 @@ void utils_send_bytes(mxc_uart_regs_t *uart, uint8_t *ptr, int length) { int i; - for (i = 0; i < length; i++) { utils_send_byte(uart, ptr[i]); } + for (i = 0; i < length; i++) { + utils_send_byte(uart, ptr[i]); + } } #pragma GCC optimize("-O0") diff --git a/Examples/MAX78002/CNN/facial_recognition/include/cnn_3.h b/Examples/MAX78002/CNN/facial_recognition/include/cnn_3.h index 9709275cd21..87b79ac151e 100644 --- a/Examples/MAX78002/CNN/facial_recognition/include/cnn_3.h +++ b/Examples/MAX78002/CNN/facial_recognition/include/cnn_3.h @@ -38,15 +38,10 @@ typedef int16_t q15_t; #define Threshold 64 /* Stopwatch - holds the runtime when accelerator finishes */ -extern volatile uint32_t cnn_time; - - - +extern volatile uint32_t cnn_time; /* Enable clocks and power to accelerator, enable interrupt */ -int cnn_3_enable(uint32_t clock_source, uint32_t clock_divider); - - +int cnn_3_enable(uint32_t clock_source, uint32_t clock_divider); /* Perform minimum accelerator initialization so it can be configured */ int cnn_3_init(void); @@ -64,13 +59,9 @@ int cnn_3_verify_weights(void); int cnn_3_load_bias(void); /* Start accelerator processing */ -int cnn_3_start(void); - - +int cnn_3_start(void); /* Unload results from accelerator */ -int cnn_3_unload(uint32_t *out_buf); - - +int cnn_3_unload(uint32_t *out_buf); #endif // __CNN_3_H__ diff --git a/Examples/MAX78002/CNN/facial_recognition/main.c b/Examples/MAX78002/CNN/facial_recognition/main.c index b3b8a7f789b..11343018fbe 100644 --- a/Examples/MAX78002/CNN/facial_recognition/main.c +++ b/Examples/MAX78002/CNN/facial_recognition/main.c @@ -201,7 +201,9 @@ void init_names() char default_names[DEFAULT_EMBS_NUM][7] = DEFAULT_NAMES; #pragma GCC diagnostic push #pragma GCC diagnostic ignored "-Wstringop-truncation" - for (int i = 0; i < DEFAULT_EMBS_NUM; i++) { strncpy((char *)names[i], default_names[i], 7); } + for (int i = 0; i < DEFAULT_EMBS_NUM; i++) { + strncpy((char *)names[i], default_names[i], 7); + } #pragma GCC diagnostic pop } diff --git a/Examples/MAX78002/CNN/facial_recognition/src/cnn_1.c b/Examples/MAX78002/CNN/facial_recognition/src/cnn_1.c index 3f6762174b8..816bcbc2132 100644 --- a/Examples/MAX78002/CNN/facial_recognition/src/cnn_1.c +++ b/Examples/MAX78002/CNN/facial_recognition/src/cnn_1.c @@ -100,7 +100,9 @@ int cnn_stop(void) void memcpy32(uint32_t *dst, const uint32_t *src, int n) { - while (n-- > 0) { *dst++ = *src++; } + while (n-- > 0) { + *dst++ = *src++; + } } static const uint32_t kernels_1[] = KERNELS_1; @@ -127,7 +129,9 @@ static const uint8_t bias_3[] = BIAS_3; static void memcpy_8to32(uint32_t *dst, const uint8_t *src, int n) { - while (n-- > 0) { *dst++ = *src++; } + while (n-- > 0) { + *dst++ = *src++; + } } int cnn_1_load_bias(void) @@ -155,14 +159,14 @@ int cnn_1_init(void) *((volatile uint32_t *)0x5200000c) = 0x00001c80; // Clear registers *((volatile uint32_t *)0x5300000c) = 0x00001c80; // Clear registers *((volatile uint32_t *)0x5400000c) = 0x00001c80; // Clear registers - while ((*((volatile uint32_t *)0x5100000c) & 0x2000000) != 0x2000000) - ; // Wait for clear - while ((*((volatile uint32_t *)0x5200000c) & 0x2000000) != 0x2000000) - ; // Wait for clear - while ((*((volatile uint32_t *)0x5300000c) & 0x2000000) != 0x2000000) - ; // Wait for clear - while ((*((volatile uint32_t *)0x5400000c) & 0x2000000) != 0x2000000) - ; // Wait for clear + while ((*((volatile uint32_t *)0x5100000c) & 0x2000000) != 0x2000000) {} + // Wait for clear + while ((*((volatile uint32_t *)0x5200000c) & 0x2000000) != 0x2000000) {} + // Wait for clear + while ((*((volatile uint32_t *)0x5300000c) & 0x2000000) != 0x2000000) {} + // Wait for clear + while ((*((volatile uint32_t *)0x5400000c) & 0x2000000) != 0x2000000) {} + // Wait for clear *((volatile uint32_t *)0x5100000c) = 0x00000000; // Reset BIST *((volatile uint32_t *)0x5200000c) = 0x00000000; // Reset BIST *((volatile uint32_t *)0x5300000c) = 0x00000000; // Reset BIST @@ -1293,8 +1297,8 @@ int cnn_1_enable(uint32_t clock_source, uint32_t clock_divider) MXC_GCFR->reg3 = 0x0; // Reset if (clock_source == MXC_S_GCR_PCLKDIV_CNNCLKSEL_IPLL) - while ((MXC_GCR->ipll_ctrl & MXC_F_GCR_IPLL_CTRL_RDY) != MXC_F_GCR_IPLL_CTRL_RDY) - ; // Wait for PLL + while ((MXC_GCR->ipll_ctrl & MXC_F_GCR_IPLL_CTRL_RDY) != MXC_F_GCR_IPLL_CTRL_RDY) {} + // Wait for PLL MXC_GCR->pclkdiv = (MXC_GCR->pclkdiv & ~(MXC_F_GCR_PCLKDIV_CNNCLKDIV | MXC_F_GCR_PCLKDIV_CNNCLKSEL)) | diff --git a/Examples/MAX78002/CNN/facial_recognition/src/cnn_2.c b/Examples/MAX78002/CNN/facial_recognition/src/cnn_2.c index 198e40db012..c012ba57145 100644 --- a/Examples/MAX78002/CNN/facial_recognition/src/cnn_2.c +++ b/Examples/MAX78002/CNN/facial_recognition/src/cnn_2.c @@ -164,7 +164,9 @@ static const uint8_t bias_3[] = BIAS_7; static void memcpy_8to32(uint32_t *dst, const uint8_t *src, int n) { - while (n-- > 0) { *dst++ = *src++; } + while (n-- > 0) { + *dst++ = *src++; + } } int cnn_2_load_bias(void) @@ -192,14 +194,14 @@ int cnn_2_init(void) *((volatile uint32_t *)0x5200000c) = 0x00001c80; // Clear registers *((volatile uint32_t *)0x5300000c) = 0x00001c80; // Clear registers *((volatile uint32_t *)0x5400000c) = 0x00001c80; // Clear registers - while ((*((volatile uint32_t *)0x5100000c) & 0x2000000) != 0x2000000) - ; // Wait for clear - while ((*((volatile uint32_t *)0x5200000c) & 0x2000000) != 0x2000000) - ; // Wait for clear - while ((*((volatile uint32_t *)0x5300000c) & 0x2000000) != 0x2000000) - ; // Wait for clear - while ((*((volatile uint32_t *)0x5400000c) & 0x2000000) != 0x2000000) - ; // Wait for clear + while ((*((volatile uint32_t *)0x5100000c) & 0x2000000) != 0x2000000) {} + // Wait for clear + while ((*((volatile uint32_t *)0x5200000c) & 0x2000000) != 0x2000000) {} + // Wait for clear + while ((*((volatile uint32_t *)0x5300000c) & 0x2000000) != 0x2000000) {} + // Wait for clear + while ((*((volatile uint32_t *)0x5400000c) & 0x2000000) != 0x2000000) {} + // Wait for clear *((volatile uint32_t *)0x5100000c) = 0x00000000; // Reset BIST *((volatile uint32_t *)0x5200000c) = 0x00000000; // Reset BIST *((volatile uint32_t *)0x5300000c) = 0x00000000; // Reset BIST @@ -5140,8 +5142,8 @@ int cnn_2_enable(uint32_t clock_source, uint32_t clock_divider) MXC_GCFR->reg3 = 0x0; // Reset if (clock_source == MXC_S_GCR_PCLKDIV_CNNCLKSEL_IPLL) - while ((MXC_GCR->ipll_ctrl & MXC_F_GCR_IPLL_CTRL_RDY) != MXC_F_GCR_IPLL_CTRL_RDY) - ; // Wait for PLL + while ((MXC_GCR->ipll_ctrl & MXC_F_GCR_IPLL_CTRL_RDY) != MXC_F_GCR_IPLL_CTRL_RDY) {} + // Wait for PLL MXC_GCR->pclkdiv = (MXC_GCR->pclkdiv & ~(MXC_F_GCR_PCLKDIV_CNNCLKDIV | MXC_F_GCR_PCLKDIV_CNNCLKSEL)) | diff --git a/Examples/MAX78002/CNN/facial_recognition/src/post_process.c b/Examples/MAX78002/CNN/facial_recognition/src/post_process.c index ef980f360f7..e093e695d59 100644 --- a/Examples/MAX78002/CNN/facial_recognition/src/post_process.c +++ b/Examples/MAX78002/CNN/facial_recognition/src/post_process.c @@ -63,7 +63,9 @@ int get_prior_idx(int ar_idx, int scale_idx, int rel_idx) { int prior_idx = 0; - for (int s = 0; s < scale_idx; ++s) { prior_idx += NUM_ARS * MULT(dims[s][0], dims[s][1]); } + for (int s = 0; s < scale_idx; ++s) { + prior_idx += NUM_ARS * MULT(dims[s][0], dims[s][1]); + } prior_idx += NUM_ARS * rel_idx + ar_idx; return prior_idx; @@ -86,7 +88,9 @@ void get_indices(int *ar_idx, int *scale_idx, int *rel_idx, int prior_idx) int in_scale_idx = prior_idx; - for (s = 0; s < *scale_idx; ++s) { in_scale_idx -= (NUM_ARS * MULT(dims[s][0], dims[s][1])); } + for (s = 0; s < *scale_idx; ++s) { + in_scale_idx -= (NUM_ARS * MULT(dims[s][0], dims[s][1])); + } *ar_idx = in_scale_idx % NUM_ARS; *rel_idx = in_scale_idx / NUM_ARS; @@ -230,7 +234,9 @@ void gcxgcy_to_cxcy(float *cxcy, int prior_idx, float *priors_cxcy) { float gcxgcy[4]; - for (int i = 0; i < 4; i++) { gcxgcy[i] = (float)prior_locs[4 * prior_idx + i] / 128.0; } + for (int i = 0; i < 4; i++) { + gcxgcy[i] = (float)prior_locs[4 * prior_idx + i] / 128.0; + } cxcy[0] = priors_cxcy[0] + gcxgcy[0] * priors_cxcy[2] / 10; cxcy[1] = priors_cxcy[1] + gcxgcy[1] * priors_cxcy[3] / 10; @@ -252,7 +258,9 @@ void insert_val(uint16_t val, uint16_t *arr, int arr_len, int idx) arr[arr_len] = arr[arr_len - 1]; } - for (int j = (arr_len - 1); j > idx; --j) { arr[j] = arr[j - 1]; } + for (int j = (arr_len - 1); j > idx; --j) { + arr[j] = arr[j - 1]; + } arr[idx] = val; } @@ -263,7 +271,9 @@ void insert_idx(uint16_t val, uint16_t *arr, int arr_len, int idx) arr[arr_len] = arr[arr_len - 1]; } - for (int j = (arr_len - 1); j > idx; --j) { arr[j] = arr[j - 1]; } + for (int j = (arr_len - 1); j > idx; --j) { + arr[j] = arr[j - 1]; + } arr[idx] = val; } @@ -430,7 +440,9 @@ void localize_objects(void) area = calculate_area(xy); if (area > max_area) { max_area = area; - for (int i = 0; i < 4; ++i) { max_xy[i] = xy[i]; } + for (int i = 0; i < 4; ++i) { + max_xy[i] = xy[i]; + } } #else diff --git a/Examples/MAX78002/CNN/facial_recognition/src/utils.c b/Examples/MAX78002/CNN/facial_recognition/src/utils.c index 1bb93f07df4..59d227b790e 100644 --- a/Examples/MAX78002/CNN/facial_recognition/src/utils.c +++ b/Examples/MAX78002/CNN/facial_recognition/src/utils.c @@ -50,7 +50,9 @@ void utils_send_bytes(mxc_uart_regs_t *uart, uint8_t *ptr, int length) { int i; - for (i = 0; i < length; i++) { utils_send_byte(uart, ptr[i]); } + for (i = 0; i < length; i++) { + utils_send_byte(uart, ptr[i]); + } } #pragma GCC optimize("-O0")