Skip to content

Commit

Permalink
eth boards: added support for enabling / disabling of mc serviced at …
Browse files Browse the repository at this point in the history
…compile time (to save RAM)
  • Loading branch information
marcoaccame committed Nov 19, 2020
1 parent 473a399 commit b6c0a71
Show file tree
Hide file tree
Showing 4 changed files with 215 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
// - external dependencies
// --------------------------------------------------------------------------------------------------------------------

#include "EOtheServices_hid.h"
#include "EoMotionControl.h"
#include "EOtheEntities.h"
#include "EOtheMemoryPool.h"
Expand All @@ -43,6 +44,30 @@

#include "EOCurrentsWatchdog_hid.h"

#if defined(EOTHESERVICES_disable_CurrentsWatchdog)


extern EOCurrentsWatchdog* eo_currents_watchdog_Initialise(void)
{
return NULL;
}

extern EOCurrentsWatchdog* eo_currents_watchdog_GetHandle(void)
{
return NULL;
}

extern void eo_currents_watchdog_Tick(EOCurrentsWatchdog* p, int16_t voltage, int16_t *currents)
{
}


extern eOresult_t eo_currents_watchdog_UpdateCurrentLimits(EOCurrentsWatchdog* p, uint8_t motor)
{
return eores_NOK_generic;
}

#elif !defined(EOTHESERVICES_disable_CurrentsWatchdog)

// --------------------------------------------------------------------------------------------------------------------
// - #define with internal scope
Expand Down Expand Up @@ -481,6 +506,7 @@ EO_static_inline eObool_t s_eo_currents_watchdog_averageCalc_collectDataIsComple

#endif //REMOVE_TO_AVOID_COMPILATION_WARNING

#endif // #elif !defined(EOTHESERVICES_disable_CurrentsWatchdog)

// --------------------------------------------------------------------------------------------------------------------
// - end-of-file (leave a blank line after)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,87 @@

#include "EOtheEncoderReader_hid.h"

#if defined(EOTHESERVICES_disable_theEncoderReader)

// provide empty implementation, so that we dont need to change the caller of the API

extern EOtheEncoderReader* eo_encoderreader_Initialise(void)
{
return NULL;
}

extern EOtheEncoderReader* eo_encoderreader_GetHandle(void)
{
return NULL;
}

// in some cases, we need to alert the pc104 that the board does not support this service
extern eOresult_t eo_encoderreader_SendReport(EOtheEncoderReader *p)
{
static const char s_eobj_ownname[] = "EOtheEncoderReader";
eOerrmanDescriptor_t errdes = {};
errdes.code = eoerror_code_get(eoerror_category_Config, eoerror_value_CFG_encoders_failed_notsupported);
errdes.sourcedevice = eo_errman_sourcedevice_localboard;
errdes.sourceaddress = 0;
errdes.par16 = errdes.par64 = 0;
eo_errman_Error(eo_errman_GetHandle(), eo_errortype_error, NULL, s_eobj_ownname, &errdes);
return eores_OK;
}


extern eOresult_t eo_encoderreader_Verify(EOtheEncoderReader *p, const eOmc_arrayof_4jomodescriptors_t * jomodes, eOservice_onendofoperation_fun_t onverify, eObool_t activateafterverify)
{
// we alert the host that the verification of the service has failed
eo_service_hid_SynchServiceState(eo_services_GetHandle(), eomn_serv_category_mc, eomn_serv_state_failureofverify);
if(NULL != onverify)
{
onverify(p, eobool_false);
}

// we tell that the reason is that this service is not supported
eo_encoderreader_SendReport(NULL);

return eores_NOK_generic;
}

extern eOresult_t eo_encoderreader_Activate(EOtheEncoderReader *p, const eOmc_arrayof_4jomodescriptors_t * jomodes)
{
eo_encoderreader_SendReport(NULL);
return eores_NOK_generic;
}

extern eOresult_t eo_encoderreader_Deactivate(EOtheEncoderReader *p)
{
return eores_NOK_generic;
}

extern eOresult_t eo_encoderreader_StartReading(EOtheEncoderReader *p)
{
return eores_NOK_generic;
}

extern eObool_t eo_encoderreader_IsReadingAvailable(EOtheEncoderReader *p)
{
return eobool_false;
}

extern eOresult_t eo_encoderreader_Read(EOtheEncoderReader *p, uint8_t position, eOencoderreader_valueInfo_t *primary, eOencoderreader_valueInfo_t *secondary)
{
return eores_NOK_generic;
}

extern eOresult_t eo_encoderreader_Diagnostics_Tick(EOtheEncoderReader* p)
{
return eores_NOK_generic;
}

extern eOresult_t eo_encoderreader_GetPrimaryEncoder(EOtheEncoderReader *p, uint8_t position, eOmc_encoder_descriptor_t *encoder)
{
return eores_NOK_generic;
}


#elif !defined(EOTHESERVICES_disable_theEncoderReader)

// --------------------------------------------------------------------------------------------------------------------
// - #define with internal scope
Expand Down Expand Up @@ -588,6 +669,8 @@ static void s_eo_encoderreader_read_encoders(void* p)
// return((eo_appEncReader_stream_number_t)pp);
//}

#endif // #elif !defined(EOTHESERVICES_disable_theEncoderReader)

// --------------------------------------------------------------------------------------------------------------------
// - end-of-file (leave a blank line after)
// --------------------------------------------------------------------------------------------------------------------
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,6 @@

#include "EOMtheEMSappl.h"

//#include "EOmcController.h"
#include "Controller.h"

#include "hal_sys.h"
Expand Down Expand Up @@ -69,6 +68,105 @@
#include "EOtheMotionController_hid.h"


#if defined(EOTHESERVICES_disable_theMotionController)

// provide empty implementation, so that we dont need to change the caller of the API

extern EOtheMotionController* eo_motioncontrol_Initialise(void)
{
return NULL;
}

extern EOtheMotionController* eo_motioncontrol_GetHandle(void)
{
return NULL;
}

extern eOmn_serv_state_t eo_motioncontrol_GetServiceState(EOtheMotionController *p)
{
return eomn_serv_state_notsupported;
}

// in some cases, we need to alert the pc104 that the board does not support this service
extern eOresult_t eo_motioncontrol_SendReport(EOtheMotionController *p)
{
static const char s_eobj_ownname[] = "EOtheMotionController";
eOerrmanDescriptor_t errdes = {};
errdes.code = eoerror_code_get(eoerror_category_Config, eoerror_value_CFG_mc_failed_notsupported);
errdes.sourcedevice = eo_errman_sourcedevice_localboard;
errdes.sourceaddress = 0;
errdes.par16 = errdes.par64 = 0;
eo_errman_Error(eo_errman_GetHandle(), eo_errortype_error, NULL, s_eobj_ownname, &errdes);
return eores_OK;
}


extern eOresult_t eo_motioncontrol_Verify(EOtheMotionController *p, const eOmn_serv_configuration_t * servcfg, eOservice_onendofoperation_fun_t onverify, eObool_t activateafterverify)
{
// we alert the host that the verification of the service has failed
eo_service_hid_SynchServiceState(eo_services_GetHandle(), eomn_serv_category_mc, eomn_serv_state_failureofverify);
if(NULL != onverify)
{
onverify(p, eobool_false);
}

// we tell that the reason is that this service is not supported
eo_motioncontrol_SendReport(NULL);

return eores_NOK_generic;
}

extern eOresult_t eo_motioncontrol_Activate(EOtheMotionController *p, const eOmn_serv_configuration_t * servcfg)
{
eo_motioncontrol_SendReport(NULL);
return eores_NOK_generic;
}

extern eOresult_t eo_motioncontrol_Deactivate(EOtheMotionController *p)
{
return eores_NOK_generic;
}

extern eOresult_t eo_motioncontrol_Start(EOtheMotionController *p)
{
eo_motioncontrol_SendReport(NULL);
return eores_NOK_generic;
}

extern eOresult_t eo_motioncontrol_SetRegulars(EOtheMotionController *p, eOmn_serv_arrayof_id32_t* arrayofid32, uint8_t* numberofthem)
{
eo_motioncontrol_SendReport(NULL);
return eores_NOK_generic;
}

extern eOresult_t eo_motioncontrol_Tick(EOtheMotionController *p)
{
return eores_NOK_generic;
}

extern eOresult_t eo_motioncontrol_Stop(EOtheMotionController *p)
{
return eores_NOK_generic;
}

extern eOresult_t eo_motioncontrol_Transmission(EOtheMotionController *p, eObool_t on)
{
return eores_NOK_generic;
}

extern eOresult_t eo_motioncontrol_AddRegulars(EOtheMotionController *p, eOmn_serv_arrayof_id32_t* arrayofid32, uint8_t* numberofthem)
{
return eores_NOK_generic;
}

extern eOmotioncontroller_mode_t eo_motioncontrol_GetMode(EOtheMotionController *p)
{
return eo_motcon_mode_NONE;
}


#elif !defined(EOTHESERVICES_disable_theMotionController)

// --------------------------------------------------------------------------------------------------------------------
// - #define with internal scope
// --------------------------------------------------------------------------------------------------------------------
Expand Down Expand Up @@ -2004,6 +2102,8 @@ static eOresult_t s_eo_motioncontrol_updatePositionFromEncoder(uint8_t index, eO
return res;
}

#endif // #elif !defined(EOTHESERVICES_disable_theMotionController)

// --------------------------------------------------------------------------------------------------------------------
// - end-of-file (leave a blank line after)
// --------------------------------------------------------------------------------------------------------------------
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,11 @@ extern "C" {
//#define EOTHESERVICES_disable_theSKIN
//#define EOTHESERVICES_disable_thePSC
//#define EOTHESERVICES_disable_theMC4boards
#define EOTHESERVICES_disable_theMotionController
#define EOTHESERVICES_disable_theEncoderReader
#define EOTHESERVICES_disable_CurrentsWatchdog
#define EOTHESERVICES_disable_theMAIS
#define EOTHESERVICES_disable_thePSC

#if defined(EOTHESERVICES_disable_theInertials2) && defined(EOTHESERVICES_disable_theInertials3)
#define EOTHESERVICES_disable_theMEMs
Expand Down

0 comments on commit b6c0a71

Please sign in to comment.