From 123b877ac25f728e8f1db6a3014c67c688f02853 Mon Sep 17 00:00:00 2001 From: Gustavo de Souza dos Reis Date: Wed, 17 May 2023 09:18:55 -0300 Subject: [PATCH] Remove BENCH_TEST macro --- CMakeLists.txt | 5 ---- modules/ipmb.h | 5 ++++ modules/main.c | 4 ---- modules/sensors/hotswap.c | 38 +++++++++++++++++++------------ port/board/afc-bpm/v3_1/payload.c | 14 ++++++++---- port/board/afc-timing/payload.c | 17 ++++++++++---- 6 files changed, 52 insertions(+), 31 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index bf2bf565f..b6a914a97 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -70,11 +70,6 @@ include_directories( ${UCONTROLLER_HDRS} ${PROJ_HDRS} ) set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -DTARGET_CONTROLLER=${TARGET_CONTROLLER} -DTARGET_BOARD_NAME=\"${TARGET_BOARD_NAME}\" ") -if(BENCH_TEST) - set(MODULES_FLAGS "${MODULES_FLAGS} -DBENCH_TEST") - message( STATUS "${Magenta}Bench mode activated! ${ColourReset}") -endif() - # Get Git information git_describe(GIT_TAG "--tags") get_git_head_revision(GIT_REFSPEC GIT_SHA1) diff --git a/modules/ipmb.h b/modules/ipmb.h index dcc29dbbd..b67f78e3c 100644 --- a/modules/ipmb.h +++ b/modules/ipmb.h @@ -37,6 +37,11 @@ #include "board_ipmb.h" +/** + * @brief Address out of range of the MicroTCA Carrier's AMC Slot ID + */ +#define IPMB_ADDR_DISCONNECTED 0xA2 + /** * @brief Maximum count of messages to be sent */ diff --git a/modules/main.c b/modules/main.c index e2e9322d5..0590f1a27 100755 --- a/modules/main.c +++ b/modules/main.c @@ -64,10 +64,6 @@ int main( void ) printf("Version: %s\n", g_GIT_TAG); printf("SHA1: %s\n", g_GIT_SHA1); -#ifdef BENCH_TEST - printf("BENCH_TEST mode activated! This will enable some debug functions, be careful!\n"); -#endif - #ifdef MODULE_WATCHDOG watchdog_init(); #endif diff --git a/modules/sensors/hotswap.c b/modules/sensors/hotswap.c index 262aef713..b3e3587d9 100644 --- a/modules/sensors/hotswap.c +++ b/modules/sensors/hotswap.c @@ -137,7 +137,12 @@ void vTaskHotSwap( void *Parameters ) continue; } - if ( new_state_amc ^ old_state_amc ) { + bool standalone_mode = false; + if (get_ipmb_addr() == 0xA2) { + standalone_mode = true; + } + + if ( new_state_amc ^ old_state_amc ) { if ( new_state_amc == 0 ) { printf("AMC Hotswap handle pressed!\n"); } else { @@ -148,9 +153,9 @@ void vTaskHotSwap( void *Parameters ) hotswap_clear_mask_bit( HOTSWAP_AMC, 1 << (!new_state_amc) ); old_state_amc = new_state_amc; } -#ifdef BENCH_TEST - old_state_amc = new_state_amc; -#endif + if (!standalone_mode){ + old_state_amc = new_state_amc; + } } #ifdef MODULE_RTM @@ -167,23 +172,28 @@ void vTaskHotSwap( void *Parameters ) if ( new_state_rtm ^ old_state_rtm ) { if ( new_state_rtm == 0 ) { printf("RTM Hotswap handle pressed!\n"); -#ifdef BENCH_TEST - payload_send_message(FRU_RTM, PAYLOAD_MESSAGE_RTM_ENABLE); -#endif + + if (!standalone_mode){ + payload_send_message(FRU_RTM, PAYLOAD_MESSAGE_RTM_ENABLE); + } } else { - printf("RTM Hotswap handle released!\n"); -#ifdef BENCH_TEST - payload_send_message(FRU_RTM, PAYLOAD_MESSAGE_QUIESCE); -#endif + printf("RTM Hotswap handle released!\n"); + + if (!standalone_mode){ + payload_send_message(FRU_RTM, PAYLOAD_MESSAGE_QUIESCE); + } + } if ( hotswap_send_event( hotswap_rtm_sensor, new_state_rtm ) == ipmb_error_success ) { hotswap_set_mask_bit( HOTSWAP_RTM, 1 << new_state_rtm ); hotswap_clear_mask_bit( HOTSWAP_RTM, 1 << (!new_state_rtm) ); old_state_rtm = new_state_rtm; } -#ifdef BENCH_TEST - old_state_rtm = new_state_rtm; -#endif + + if(!standalone_mode) { + old_state_rtm = new_state_rtm; + } + } #endif } diff --git a/port/board/afc-bpm/v3_1/payload.c b/port/board/afc-bpm/v3_1/payload.c index 2f6f7fa03..e4c8e9a9d 100644 --- a/port/board/afc-bpm/v3_1/payload.c +++ b/port/board/afc-bpm/v3_1/payload.c @@ -178,11 +178,17 @@ TaskHandle_t vTaskPayload_Handle; void payload_init( void ) { + /* Set standalone mode if the module is disconnected from a create*/ + bool standalone_mode = false; -#ifndef BENCH_TEST - /* Wait until ENABLE# signal is asserted ( ENABLE == 0) */ - while ( gpio_read_pin( PIN_PORT(GPIO_MMC_ENABLE), PIN_NUMBER(GPIO_MMC_ENABLE) ) == 1 ) {}; -#endif + if(get_ipmb_addr() == IPMB_ADDR_DISCONNECTED){ + standalone_mode = true; + } + + if(!standalone_mode) { + /* Wait until ENABLE# signal is asserted ( ENABLE == 0) */ + while ( gpio_read_pin( PIN_PORT(GPIO_MMC_ENABLE), PIN_NUMBER(GPIO_MMC_ENABLE) ) == 1 ) {}; + } xTaskCreate( vTaskPayload, "Payload", 120, NULL, tskPAYLOAD_PRIORITY, &vTaskPayload_Handle ); diff --git a/port/board/afc-timing/payload.c b/port/board/afc-timing/payload.c index c693c7f4f..e97fe0896 100644 --- a/port/board/afc-timing/payload.c +++ b/port/board/afc-timing/payload.c @@ -179,10 +179,19 @@ TaskHandle_t vTaskPayload_Handle; void payload_init( void ) { -#ifndef BENCH_TEST - /* Wait until ENABLE# signal is asserted ( ENABLE == 0) */ - while ( gpio_read_pin( PIN_PORT(GPIO_MMC_ENABLE), PIN_NUMBER(GPIO_MMC_ENABLE) ) == 1 ) {}; -#endif + + /* Set standalone mode if the module is disconnected from a create*/ + bool standalone_mode = false; + + if(get_ipmp_addr() == IPMB_ADDR_DISCONNECTED) { + standalone_mode = true; + } + + if(!standalone_mode) { + /* Wait until ENABLE# signal is asserted ( ENABLE == 0) */ + while ( gpio_read_pin( PIN_PORT(GPIO_MMC_ENABLE), PIN_NUMBER(GPIO_MMC_ENABLE) ) == 1 ) {}; + } + xTaskCreate( vTaskPayload, "Payload", 120, NULL, tskPAYLOAD_PRIORITY, &vTaskPayload_Handle );