From 1b35552b4f5ef3cc4650c272ad37e732618833fd Mon Sep 17 00:00:00 2001 From: VocalFan <45863583+VocalFan@users.noreply.github.com> Date: Sat, 18 May 2024 00:30:09 -0400 Subject: [PATCH] Put a switch on those things. --- fw/application/src/hal/hal_spi_flash.c | 66 +++++++++++++++----------- fw/application/src/i18n/language.c | 57 +++++++++++----------- 2 files changed, 67 insertions(+), 56 deletions(-) diff --git a/fw/application/src/hal/hal_spi_flash.c b/fw/application/src/hal/hal_spi_flash.c index 5a93aa1c..b077cc32 100644 --- a/fw/application/src/hal/hal_spi_flash.c +++ b/fw/application/src/hal/hal_spi_flash.c @@ -149,38 +149,48 @@ ret_code_t hal_spi_flash_info(flash_info_t *info) { memory_type_capacity = rx[1]; memory_type_capacity = (memory_type_capacity << 8) | rx[2]; - if (memory_type_capacity == MTC_MX25L25645_GM2I) { - NRF_LOG_INFO("MX25L25645GM2I-10G detection"); - info->block_count = 8192; - } else if (memory_type_capacity == MTC_W25Q128_BV) { - NRF_LOG_INFO("W25Q128BV detection"); - info->block_count = 4096; - } else if (memory_type_capacity == MTC_W25Q64_BV_CV) { - NRF_LOG_INFO("W25Q64BV or W25Q64CV detection"); - info->block_count = 2048; - } else if (memory_type_capacity == MTC_W25Q64_DW) { - NRF_LOG_INFO("W25Q64DW detection"); - info->block_count = 2048; - } else if (memory_type_capacity == MTC_W25Q32_BV) { - NRF_LOG_INFO("W25Q32BV detection"); - info->block_count = 1024; - } else if (memory_type_capacity == MTC_W25Q32_DW) { - NRF_LOG_INFO("W25Q32DW detection"); - info->block_count = 1024; - } else if (memory_type_capacity == MTC_W25Q16_BV_CL_CV) { - NRF_LOG_INFO("W25Q16BV or W25Q16CL or W25Q16CV detection"); - info->block_count = 512; - } else if (memory_type_capacity == MTC_W25Q16_DW) { - NRF_LOG_INFO("W25Q16DW detection"); - info->block_count = 512; - } else { - NRF_LOG_INFO("Memory Capacity error! %d", memory_type_capacity); - info->block_count = 0; - return NRF_ERROR_INVALID_PARAM; + switch (memory_type_capacity) { + case MTC_MX25L25645_GM2I: + NRF_LOG_INFO("MX25L25645GM2I-10G detection"); + info->block_count = 8192; + break; + case MTC_W25Q128_BV: + NRF_LOG_INFO("W25Q128BV detection"); + info->block_count = 4096; + break; + case MTC_W25Q64_BV_CV: + NRF_LOG_INFO("W25Q64BV or W25Q64CV detection"); + info->block_count = 2048; + break; + case MTC_W25Q64_DW: + NRF_LOG_INFO("W25Q64DW detection"); + info->block_count = 2048; + break; + case MTC_W25Q32_BV: + NRF_LOG_INFO("W25Q32BV detection"); + info->block_count = 1024; + break; + case MTC_W25Q32_DW: + NRF_LOG_INFO("W25Q32DW detection"); + info->block_count = 1024; + break; + case MTC_W25Q16_BV_CL_CV: + NRF_LOG_INFO("W25Q16BV or W25Q16CL or W25Q16CV detection"); + info->block_count = 512; + break; + case MTC_W25Q16_DW: + NRF_LOG_INFO("W25Q16DW detection"); + info->block_count = 512; + break; + default: + NRF_LOG_INFO("Memory Capacity error! %d", memory_type_capacity); + info->block_count = 0; + return NRF_ERROR_INVALID_PARAM; } return NRF_SUCCESS; } + ret_code_t hal_spi_flash_read(uint32_t address, void *buffer, size_t size) { uint8_t tx[4]; diff --git a/fw/application/src/i18n/language.c b/fw/application/src/i18n/language.c index 0c1c0be3..3b49b9b7 100644 --- a/fw/application/src/i18n/language.c +++ b/fw/application/src/i18n/language.c @@ -32,34 +32,35 @@ const char *getLangString(L_StringID stringID) { void setLanguage(Language lang) { currentLanguage = lang; } const char *getLangDesc(Language lang) { - if (lang == LANGUAGE_ZH_HANS) { - return "简体中文"; - } else if (lang == LANGUAGE_EN_US) { - return "English"; - } else if (lang == LANGUAGE_ZH_TW) { - return "繁體中文(臺灣)"; - } else if (lang == LANGUAGE_ES_ES) { - return "Español"; - } else if (lang == LANGUAGE_IT_IT) { - return "Italiano"; - } else if (lang == LANGUAGE_HU_HU) { - return "Magyar"; - } else if (lang == LANGUAGE_DE_DE) { - return "Deutsch"; - } else if (lang == LANGUAGE_FR_FR) { - return "Français"; - } else if (lang == LANGUAGE_NL_NL) { - return "Dutch (Nederlands)"; - } else if (lang == LANGUAGE_PT_BR) { - return "Português(Brazil)"; - } else if (lang == LANGUAGE_JA_JP) { - return "日本語"; - } else if (lang == LANGUAGE_PT_PT) { - return "Português(Portugal)"; - } else if (lang == LANGUAGE_RU_RU) { - return "Русский"; - } else { - return "@@LANG@@"; + switch (lang) { + case LANGUAGE_ZH_HANS: + return "简体中文"; + case LANGUAGE_EN_US: + return "English"; + case LANGUAGE_ZH_TW: + return "繁體中文(臺灣)"; + case LANGUAGE_ES_ES: + return "Español"; + case LANGUAGE_IT_IT: + return "Italiano"; + case LANGUAGE_HU_HU: + return "Magyar"; + case LANGUAGE_DE_DE: + return "Deutsch"; + case LANGUAGE_FR_FR: + return "Français"; + case LANGUAGE_NL_NL: + return "Dutch (Nederlands)"; + case LANGUAGE_PT_BR: + return "Português(Brazil)"; + case LANGUAGE_JA_JP: + return "日本語"; + case LANGUAGE_PT_PT: + return "Português(Portugal)"; + case LANGUAGE_RU_RU: + return "Русский"; + default: + return "@@LANG@@"; } }