Skip to content

Commit 388391e

Browse files
authored
Merge pull request #104 from oresat/configs-changes
Some RPDO and SYNC #define fixes
2 parents 178ab4d + 9fc93e6 commit 388391e

File tree

2 files changed

+11
-8
lines changed

2 files changed

+11
-8
lines changed

common/CO_threads.c

+10-4
Original file line numberDiff line numberDiff line change
@@ -192,7 +192,7 @@ THD_FUNCTION(pdo_sync, arg)
192192

193193
/* Register the callback function to wake up thread when message received */
194194
CO_SYNC_initCallbackPre(co->SYNC, chThdGetSelfX(), process_cb);
195-
#ifdef OD_CNT_RPDO
195+
#if OD_CNT_RPDO > 0
196196
for (int i = 0; i < OD_CNT_RPDO; i++) {
197197
CO_RPDO_initCallbackPre(&co->RPDO[i], chThdGetSelfX(), process_cb);
198198
}
@@ -203,18 +203,24 @@ THD_FUNCTION(pdo_sync, arg)
203203
uint32_t timeout = ((typeof(timeout))-1);
204204
bool_t syncWas;
205205

206+
#if (CO_CONFIG_SYNC) & CO_CONFIG_SYNC_ENABLE
206207
/* Process SYNC */
207208
syncWas = CO_process_SYNC(co, TIME_I2US(chVTTimeElapsedSinceX(prev_time)), &timeout);
209+
#endif
210+
#if (CO_CONFIG_PDO) & CO_CONFIG_RPDO_ENABLE
208211
/* Read inputs */
209212
CO_process_RPDO(co, syncWas, TIME_I2US(chVTTimeElapsedSinceX(prev_time)), &timeout);
213+
#endif
214+
#if (CO_CONFIG_PDO) & CO_CONFIG_TPDO_ENABLE
210215
/* Write outputs */
211216
CO_process_TPDO(co, syncWas, TIME_I2US(chVTTimeElapsedSinceX(prev_time)), &timeout);
217+
#endif
212218

213219
prev_time = chVTGetSystemTime();
214220
chEvtWaitAnyTimeout(CO_EVT_WAKEUP | CO_EVT_TERMINATE, TIME_US2I(timeout));
215221
}
216222
CO_SYNC_initCallbackPre(co->SYNC, NULL, NULL);
217-
#ifdef OD_CNT_RPDO
223+
#if OD_CNT_RPDO > 0
218224
for (int i = 0; i < OD_CNT_RPDO; i++) {
219225
CO_RPDO_initCallbackPre(&co->RPDO[i], NULL, NULL);
220226
}
@@ -345,7 +351,7 @@ void CO_init(CO_t **pCO, CANDriver *CANptr, uint8_t node_id, uint16_t bitrate, c
345351
CO_t *CO = NULL;
346352
CO_ReturnError_t err;
347353
/* TODO: Use proper OD interface */
348-
#ifdef OD_CNT_RPDO
354+
#if OD_CNT_RPDO > 0
349355
struct {
350356
uint8_t highestSub_indexSupported;
351357
uint32_t COB_IDUsedByRPDO;
@@ -359,7 +365,7 @@ void CO_init(CO_t **pCO, CANDriver *CANptr, uint8_t node_id, uint16_t bitrate, c
359365
RPDOCommParam[i].COB_IDUsedByRPDO += node_id + i / 4;
360366
}
361367
#endif
362-
#ifdef OD_CNT_TPDO
368+
#if OD_CNT_TPDO > 0
363369
struct {
364370
uint8_t highestSub_indexSupported;
365371
uint32_t COB_IDUsedByTPDO;

common/include/CO_driver_target.h

+1-4
Original file line numberDiff line numberDiff line change
@@ -102,11 +102,8 @@ extern "C" {
102102
#endif
103103

104104
#ifndef CO_CONFIG_PDO
105-
#define CO_CONFIG_PDO (CO_CONFIG_RPDO_ENABLE | \
106-
CO_CONFIG_TPDO_ENABLE | \
107-
CO_CONFIG_RPDO_TIMERS_ENABLE | \
105+
#define CO_CONFIG_PDO (CO_CONFIG_TPDO_ENABLE | \
108106
CO_CONFIG_TPDO_TIMERS_ENABLE | \
109-
CO_CONFIG_PDO_SYNC_ENABLE | \
110107
CO_CONFIG_PDO_OD_IO_ACCESS | \
111108
CO_CONFIG_GLOBAL_FLAG_CALLBACK_PRE | \
112109
CO_CONFIG_GLOBAL_FLAG_TIMERNEXT | \

0 commit comments

Comments
 (0)