Skip to content

Commit

Permalink
add #define to disable hb consumer
Browse files Browse the repository at this point in the history
  • Loading branch information
ryanpdx committed Nov 26, 2023
1 parent ba3b5f4 commit d6d72af
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 0 deletions.
12 changes: 12 additions & 0 deletions common/CO_threads.c
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,14 @@

static thread_t *nmt_tp;
static thread_t *sdo_srv_tp[OD_CNT_SDO_SRV];
#if OD_CNT_SDO_CLI > 0
static thread_t *sdo_cli_tp[OD_CNT_SDO_CLI];
#endif
static thread_t *em_tp;
static thread_t *pdo_sync_tp;
#if OD_CNT_HB_CONS == 1
static thread_t *hbcons_tp;
#endif

static CO_NMT_internalState_t NMTstate;

Expand Down Expand Up @@ -218,6 +222,7 @@ THD_FUNCTION(pdo_sync, arg)
chThdExit(MSG_OK);
}

#if OD_CNT_HB_CONS == 1
/* CANopen Heartbeat Consumer thread */
THD_FUNCTION(hb_cons, arg)
{
Expand All @@ -239,6 +244,7 @@ THD_FUNCTION(hb_cons, arg)
CO_HBconsumer_initCallbackPre(HBcons, NULL, NULL);
chThdExit(MSG_OK);
}
#endif

/* CANopen NMT and Heartbeat thread */
THD_FUNCTION(nmt, arg)
Expand Down Expand Up @@ -266,7 +272,9 @@ THD_FUNCTION(nmt, arg)
#endif
em_tp = chThdCreateFromHeap(NULL, THD_WORKING_AREA_SIZE(0x200), "Emergency", HIGHPRIO-2, em, co->em);
pdo_sync_tp = chThdCreateFromHeap(NULL, THD_WORKING_AREA_SIZE(0x200), "PDO SYNC", HIGHPRIO-2, pdo_sync, co);
#if OD_CNT_HB_CONS == 1
hbcons_tp = chThdCreateFromHeap(NULL, THD_WORKING_AREA_SIZE(0x200), "HB Consumer", HIGHPRIO-3, hb_cons, co->HBcons);
#endif

/* Enter normal operating mode */
CO_CANsetNormalMode(co->CANmodule);
Expand Down Expand Up @@ -308,8 +316,10 @@ THD_FUNCTION(nmt, arg)
chEvtSignal(em_tp, CO_EVT_TERMINATE);
chThdTerminate(pdo_sync_tp);
chEvtSignal(pdo_sync_tp, CO_EVT_TERMINATE);
#if OD_CNT_HB_CONS == 1
chThdTerminate(hbcons_tp);
chEvtSignal(hbcons_tp, CO_EVT_TERMINATE);
#endif

/* Wait for CANopen threads to end */
#if OD_CNT_SDO_CLI > 0
Expand All @@ -322,7 +332,9 @@ THD_FUNCTION(nmt, arg)
}
chThdWait(em_tp);
chThdWait(pdo_sync_tp);
#if OD_CNT_HB_CONS == 1
chThdWait(hbcons_tp);
#endif

/* Terminate and return reset value */
chThdExit(reset);
Expand Down
2 changes: 2 additions & 0 deletions common/include/CO_driver_target.h
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,8 @@ extern "C" {
#endif

#ifndef CO_CONFIG_HB_CONS
#define CO_CONFIG_HB_CONS 0
#else
#define CO_CONFIG_HB_CONS (CO_CONFIG_HB_CONS_ENABLE | \
CO_CONFIG_HB_CONS_CALLBACK_MULTI | \
CO_CONFIG_HB_CONS_QUERY_FUNCT | \
Expand Down

0 comments on commit d6d72af

Please sign in to comment.