diff --git a/emBODY/eBcode/arch-arm/board/ems004/appl/v2/cfg/eoemsappl/EOMtheEMSapplCfg_cfg.h b/emBODY/eBcode/arch-arm/board/ems004/appl/v2/cfg/eoemsappl/EOMtheEMSapplCfg_cfg.h index 9f3d968b39..1e6f6ebf00 100644 --- a/emBODY/eBcode/arch-arm/board/ems004/appl/v2/cfg/eoemsappl/EOMtheEMSapplCfg_cfg.h +++ b/emBODY/eBcode/arch-arm/board/ems004/appl/v2/cfg/eoemsappl/EOMtheEMSapplCfg_cfg.h @@ -81,7 +81,7 @@ extern "C" { #define EOMTHEEMSAPPLCFG_VERSION_MAJOR (VERSION_MAJOR_OFFSET+3) // minor <0-255> // minor <0-255> -#define EOMTHEEMSAPPLCFG_VERSION_MINOR 60 +#define EOMTHEEMSAPPLCFG_VERSION_MINOR 61 // version @@ -89,13 +89,13 @@ extern "C" { // year <2010-2030> #define EOMTHEEMSAPPLCFG_BUILDDATE_YEAR 2023 // month <1-12> -#define EOMTHEEMSAPPLCFG_BUILDDATE_MONTH 1 +#define EOMTHEEMSAPPLCFG_BUILDDATE_MONTH 2 // day <1-31> -#define EOMTHEEMSAPPLCFG_BUILDDATE_DAY 25 +#define EOMTHEEMSAPPLCFG_BUILDDATE_DAY 21 // hour <0-23> -#define EOMTHEEMSAPPLCFG_BUILDDATE_HOUR 12 +#define EOMTHEEMSAPPLCFG_BUILDDATE_HOUR 14 // minute <0-59> -#define EOMTHEEMSAPPLCFG_BUILDDATE_MIN 11 +#define EOMTHEEMSAPPLCFG_BUILDDATE_MIN 30 // build date // Info diff --git a/emBODY/eBcode/arch-arm/board/ems004/appl/v2/src/eoappservices/EOtheEncoderReader.h b/emBODY/eBcode/arch-arm/board/ems004/appl/v2/src/eoappservices/EOtheEncoderReader.h index 7dbfd1a4e6..70685bfb76 100644 --- a/emBODY/eBcode/arch-arm/board/ems004/appl/v2/src/eoappservices/EOtheEncoderReader.h +++ b/emBODY/eBcode/arch-arm/board/ems004/appl/v2/src/eoappservices/EOtheEncoderReader.h @@ -80,7 +80,8 @@ typedef enum encreader_err_NOTCONNECTED = 15, /* this error happens when the encoder type is none or encoder is not local, for example it is connected to 2foc board */ encreader_err_AKSIM2_INVALID_DATA = 16, encreader_err_AKSIM2_CLOSE_TO_LIMITS= 17, - encreader_err_AKSIM2_CRC_ERROR = 18 + encreader_err_AKSIM2_CRC_ERROR = 18, + encreader_err_AKSIM2_GENERIC = 19 } eOencoderreader_errortype_t; diff --git a/emBODY/eBcode/arch-arm/board/mc2plus/appl/v2/cfg/eoemsappl/EOMtheEMSapplCfg_cfg.h b/emBODY/eBcode/arch-arm/board/mc2plus/appl/v2/cfg/eoemsappl/EOMtheEMSapplCfg_cfg.h index 9952278e0f..ecf598aa65 100644 --- a/emBODY/eBcode/arch-arm/board/mc2plus/appl/v2/cfg/eoemsappl/EOMtheEMSapplCfg_cfg.h +++ b/emBODY/eBcode/arch-arm/board/mc2plus/appl/v2/cfg/eoemsappl/EOMtheEMSapplCfg_cfg.h @@ -75,20 +75,20 @@ extern "C" { #define EOMTHEEMSAPPLCFG_VERSION_MAJOR 3 // minor <0-255> // minor <0-255> -#define EOMTHEEMSAPPLCFG_VERSION_MINOR 42 +#define EOMTHEEMSAPPLCFG_VERSION_MINOR 43 // version // build date // year <2010-2030> #define EOMTHEEMSAPPLCFG_BUILDDATE_YEAR 2023 // month <1-12> -#define EOMTHEEMSAPPLCFG_BUILDDATE_MONTH 1 +#define EOMTHEEMSAPPLCFG_BUILDDATE_MONTH 2 // day <1-31> -#define EOMTHEEMSAPPLCFG_BUILDDATE_DAY 25 +#define EOMTHEEMSAPPLCFG_BUILDDATE_DAY 21 // hour <0-23> -#define EOMTHEEMSAPPLCFG_BUILDDATE_HOUR 12 +#define EOMTHEEMSAPPLCFG_BUILDDATE_HOUR 14 // minute <0-59> -#define EOMTHEEMSAPPLCFG_BUILDDATE_MIN 12 +#define EOMTHEEMSAPPLCFG_BUILDDATE_MIN 30 // build date // Info diff --git a/emBODY/eBcode/arch-arm/board/mc4plus/appl/v2/cfg/eoemsappl/EOMtheEMSapplCfg_cfg.h b/emBODY/eBcode/arch-arm/board/mc4plus/appl/v2/cfg/eoemsappl/EOMtheEMSapplCfg_cfg.h index 7a7a9d64e8..8ec0b813ac 100644 --- a/emBODY/eBcode/arch-arm/board/mc4plus/appl/v2/cfg/eoemsappl/EOMtheEMSapplCfg_cfg.h +++ b/emBODY/eBcode/arch-arm/board/mc4plus/appl/v2/cfg/eoemsappl/EOMtheEMSapplCfg_cfg.h @@ -87,7 +87,7 @@ extern "C" { // minor <0-255> -#define EOMTHEEMSAPPLCFG_VERSION_MINOR 61 +#define EOMTHEEMSAPPLCFG_VERSION_MINOR 62 // version @@ -96,13 +96,13 @@ extern "C" { // year <2010-2030> #define EOMTHEEMSAPPLCFG_BUILDDATE_YEAR 2023 // month <1-12> -#define EOMTHEEMSAPPLCFG_BUILDDATE_MONTH 1 +#define EOMTHEEMSAPPLCFG_BUILDDATE_MONTH 2 // day <1-31> -#define EOMTHEEMSAPPLCFG_BUILDDATE_DAY 27 +#define EOMTHEEMSAPPLCFG_BUILDDATE_DAY 21 // hour <0-23> -#define EOMTHEEMSAPPLCFG_BUILDDATE_HOUR 13 +#define EOMTHEEMSAPPLCFG_BUILDDATE_HOUR 14 // minute <0-59> -#define EOMTHEEMSAPPLCFG_BUILDDATE_MIN 28 +#define EOMTHEEMSAPPLCFG_BUILDDATE_MIN 30 // build date diff --git a/emBODY/eBcode/arch-arm/embobj/plus/board/EOappEncodersReader.c b/emBODY/eBcode/arch-arm/embobj/plus/board/EOappEncodersReader.c index fd1664a016..8b676b5596 100644 --- a/emBODY/eBcode/arch-arm/embobj/plus/board/EOappEncodersReader.c +++ b/emBODY/eBcode/arch-arm/embobj/plus/board/EOappEncodersReader.c @@ -657,9 +657,18 @@ extern eOresult_t eo_appEncReader_GetValue(EOappEncReader *p, uint8_t jomo, eOen } } else - { // we dont even have a valid reading from hal - prop.valueinfo->errortype = encreader_err_AEA_READING; - errorparam = 0xffff; + { // we dont even have a valid reading from hal or the encoder is not properly connected to the board + prop.valueinfo->errortype = encreader_err_AKSIM2_GENERIC ; + errorparam = 0; + + // notify the error (check and re-check) + eOerrmanDescriptor_t errdes = {0}; + errdes.sourcedevice = eo_errman_sourcedevice_localboard; + errdes.sourceaddress = 0; + errdes.par16 = 0; + errdes.par64 = (uint64_t) (diagn.info.aksim2_status_crc) << 32; + errdes.code = eoerror_code_get(eoerror_category_HardWare, eoerror_value_HW_encoder_not_connected); + eo_errman_Error(eo_errman_GetHandle(), eo_errortype_error, NULL, NULL, &errdes); } } break; @@ -869,7 +878,7 @@ extern eOresult_t eo_appEncReader_GetValue(EOappEncReader *p, uint8_t jomo, eOen // in par16[1] and par64[1] we put info of the 4 secondary encoders. // so far we use prop.valueinfo->errortype but we may use also diagn for the amo - eObool_t filldiagnostics = eo_common_byte_bitcheck(p->diagnostics.config.jomomask, jomo); + eObool_t filldiagnostics = eo_common_byte_bitcheck(p->diagnostics.config.jomomask, jomo); if(eobool_true == filldiagnostics) { if(eomc_enc_amo == prop.descriptor->type) @@ -882,11 +891,11 @@ extern eOresult_t eo_appEncReader_GetValue(EOappEncReader *p, uint8_t jomo, eOen // select only 2 bytes: 1 from from diagn.type and one from diagn.info.value uint64_t word = (0x0ff & diagn.type) | ((0xff & diagn.info.value) << 8); // copy the word in correct position so that we have [word-enc3 | word-enc2 | word-enc1 | word-enc0] - p->diagnostics.par64[i] |= (word << (16*jomo)); + p->diagnostics.par64[i] |= (word << (16*jomo)); } } else - { + { switch(prop.valueinfo->errortype) { case encreader_err_NONE: @@ -897,10 +906,14 @@ extern eOresult_t eo_appEncReader_GetValue(EOappEncReader *p, uint8_t jomo, eOen default: case encreader_err_GENERIC: { // we dont know what is happening ... we just set the flag in par16[i]. - p->diagnostics.par16[i] |= (encreader_err_GENERIC<<(4*jomo)); // shift by nibbles .. + p->diagnostics.par16[i] |= (encreader_err_GENERIC<<(4*jomo)); // shift by nibbles .. } break; - case encreader_err_AEA_READING: + case encreader_err_AKSIM2_CLOSE_TO_LIMITS: + case encreader_err_AKSIM2_CRC_ERROR: + case encreader_err_AKSIM2_INVALID_DATA: + case encreader_err_AKSIM2_GENERIC: + case encreader_err_AEA_READING: case encreader_err_AEA_PARITY: case encreader_err_AEA_CHIP: case encreader_err_QENC_GENERIC: @@ -909,17 +922,14 @@ extern eOresult_t eo_appEncReader_GetValue(EOappEncReader *p, uint8_t jomo, eOen case encreader_err_PSC_GENERIC: case encreader_err_POS_GENERIC: case encreader_err_AMO_GENERIC: - case encreader_err_AKSIM2_CLOSE_TO_LIMITS: - case encreader_err_AKSIM2_CRC_ERROR: - case encreader_err_AKSIM2_INVALID_DATA: case encreader_err_SPICHAINOF2_GENERIC: case encreader_err_SPICHAINOF3_GENERIC: { // in such cases, we report the errortype and the errorparam that someone has prepared p->diagnostics.par16[i] |= (prop.valueinfo->errortype<<(4*jomo)); // shift by nibbles .. - p->diagnostics.par64[i] &= (errorparam<<(16*jomo)); // shift by two bytes - } break; + p->diagnostics.par64[i] &= (errorparam<<(16*jomo)); // shift by two bytes + } break; } - } + } } // ok, we now go to next encoder or ... we terminate the for() loop @@ -927,7 +937,7 @@ extern eOresult_t eo_appEncReader_GetValue(EOappEncReader *p, uint8_t jomo, eOen } // for() - // now the return value. we return always OK + // now the return value. we return always OK return eores_OK; } @@ -1332,7 +1342,7 @@ static eObool_t s_eo_appEncReader_IsValidValue_AEA(uint32_t *valueraw, eOencoder static eObool_t s_eo_appEncReader_IsValidValue_AEA3(uint32_t *valueraw, eOencoderreader_errortype_t *error) { - // TODO: there are no way to check the validity when using the AEA3 in SSI mode + // TODO: there is no way to check the validity when using the AEA3 in SSI mode // if((*valueraw & 0x01) != 0x00) // { // *error = encreader_err_AEA_CHIP; @@ -1343,19 +1353,44 @@ static eObool_t s_eo_appEncReader_IsValidValue_AEA3(uint32_t *valueraw, eOencode static eObool_t s_eo_appEncReader_IsValidValue_AKSIM2(hal_spiencoder_diagnostic_t* diag, eOencoderreader_errortype_t *error) { - switch(diag->type) - { - case hal_spiencoder_diagnostic_type_aksim2_invalid_data: - *error = encreader_err_AKSIM2_INVALID_DATA; - return eobool_false; - case hal_spiencoder_diagnostic_type_aksim2_crc_error: - *error = encreader_err_AKSIM2_CRC_ERROR; - return eobool_false; - case hal_spiencoder_diagnostic_type_aksim2_close_to_limits: - *error = encreader_err_AKSIM2_CLOSE_TO_LIMITS; - break; - default: - *error = encreader_err_NONE; +// switch(diag->type) +// { +// case hal_spiencoder_diagnostic_type_aksim2_invalid_data: +// *error = encreader_err_AKSIM2_INVALID_DATA; +// return eobool_false; +// case hal_spiencoder_diagnostic_type_aksim2_crc_error: +// *error = encreader_err_AKSIM2_CRC_ERROR; +// return eobool_false; +// case hal_spiencoder_diagnostic_type_aksim2_close_to_limits: +// *error = encreader_err_AKSIM2_CLOSE_TO_LIMITS; +// break; +// default: +// *error = encreader_err_NONE; +// } +// + // TODO: check and re-check + eOerrmanDescriptor_t errdes = {0}; + errdes.sourcedevice = eo_errman_sourcedevice_localboard; + errdes.sourceaddress = 0; + errdes.par16 = 0; + errdes.par64 = (uint64_t) (diag->info.aksim2_status_crc) << 32; + + if(0x04 == (0x04 & diag->info.aksim2_status_crc)) + { + errdes.code = eoerror_code_get(eoerror_category_HardWare, eoerror_value_HW_encoder_invalid_value); + eo_errman_Error(eo_errman_GetHandle(), eo_errortype_error, NULL, NULL, &errdes); + } + + if(0x02 == (0x02 & diag->info.aksim2_status_crc)) + { + errdes.code = eoerror_code_get(eoerror_category_HardWare, eoerror_value_HW_encoder_close_to_limits); + eo_errman_Error(eo_errman_GetHandle(), eo_errortype_error, NULL, NULL, &errdes); + } + + if(0x01 == (0x01 & diag->info.aksim2_status_crc)) + { + errdes.code = eoerror_code_get(eoerror_category_HardWare, eoerror_value_HW_encoder_crc); + eo_errman_Error(eo_errman_GetHandle(), eo_errortype_error, NULL, NULL, &errdes); } return eobool_true; diff --git a/emBODY/eBcode/arch-arm/libs/highlevel/abslayer/hal2/api/hal_spiencoder.h b/emBODY/eBcode/arch-arm/libs/highlevel/abslayer/hal2/api/hal_spiencoder.h index 3f60b4585a..8907333c55 100644 --- a/emBODY/eBcode/arch-arm/libs/highlevel/abslayer/hal2/api/hal_spiencoder.h +++ b/emBODY/eBcode/arch-arm/libs/highlevel/abslayer/hal2/api/hal_spiencoder.h @@ -126,6 +126,7 @@ typedef enum hal_spiencoder_diagnostic_type_aksim2_invalid_data = 5, hal_spiencoder_diagnostic_type_aksim2_close_to_limits = 6, hal_spiencoder_diagnostic_type_aksim2_crc_error = 7, + hal_spiencoder_diagnostic_type_aksim2_not_connected = 8, } hal_spiencoder_diagnostic_type_t; typedef struct diff --git a/emBODY/eBcode/arch-arm/libs/highlevel/abslayer/hal2/lib/hal2.ems4rd.ethdbg.lib b/emBODY/eBcode/arch-arm/libs/highlevel/abslayer/hal2/lib/hal2.ems4rd.ethdbg.lib index 2d2b6b5613..37833f9de0 100644 Binary files a/emBODY/eBcode/arch-arm/libs/highlevel/abslayer/hal2/lib/hal2.ems4rd.ethdbg.lib and b/emBODY/eBcode/arch-arm/libs/highlevel/abslayer/hal2/lib/hal2.ems4rd.ethdbg.lib differ diff --git a/emBODY/eBcode/arch-arm/libs/highlevel/abslayer/hal2/lib/hal2.mc2plus.ethdbg.lib b/emBODY/eBcode/arch-arm/libs/highlevel/abslayer/hal2/lib/hal2.mc2plus.ethdbg.lib index 75e64195fe..84cd37a27c 100644 Binary files a/emBODY/eBcode/arch-arm/libs/highlevel/abslayer/hal2/lib/hal2.mc2plus.ethdbg.lib and b/emBODY/eBcode/arch-arm/libs/highlevel/abslayer/hal2/lib/hal2.mc2plus.ethdbg.lib differ diff --git a/emBODY/eBcode/arch-arm/libs/highlevel/abslayer/hal2/lib/hal2.mc4plus.ethdbg.lib b/emBODY/eBcode/arch-arm/libs/highlevel/abslayer/hal2/lib/hal2.mc4plus.ethdbg.lib index 3c6bcc23b1..fce8d56fcc 100644 Binary files a/emBODY/eBcode/arch-arm/libs/highlevel/abslayer/hal2/lib/hal2.mc4plus.ethdbg.lib and b/emBODY/eBcode/arch-arm/libs/highlevel/abslayer/hal2/lib/hal2.mc4plus.ethdbg.lib differ diff --git a/emBODY/eBcode/arch-arm/libs/highlevel/abslayer/hal2/src/extra/devices/hal_spiencoder.c b/emBODY/eBcode/arch-arm/libs/highlevel/abslayer/hal2/src/extra/devices/hal_spiencoder.c index 4a514aaf9c..6df289ab70 100644 --- a/emBODY/eBcode/arch-arm/libs/highlevel/abslayer/hal2/src/extra/devices/hal_spiencoder.c +++ b/emBODY/eBcode/arch-arm/libs/highlevel/abslayer/hal2/src/extra/devices/hal_spiencoder.c @@ -832,6 +832,16 @@ extern hal_result_t hal_spiencoder_get_value2(hal_spiencoder_t id, hal_spiencode diagn->info.aksim2_status_crc |= 0x01; } + + // Check for SPI reading errors: if all data are FF then the encoder is not connected or the SPI is not working. + if (intitem->multiturncounter == 0xFFFF && intitem->position == 0x7FFFF && intitem->status_bits == 0x03 && intitem->crc == 0xFF) + { + // TODO: check if it can be manage it, or remove everything berfore the return because these diagnostic is not currently used. + diagn->type = hal_spiencoder_diagnostic_type_aksim2_not_connected; + diagn->info.value = 0; + return hal_res_NOK_generic; + } + *pos = intitem->position; } else if (intitem->config.type == hal_spiencoder_typeAMO)