MCPcopy Create free account
hub / github.com/CANopenNode/CANopenNode / CO_CANmodule_init

Function CO_CANmodule_init

example/CO_driver_blank.c:37–90  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

35}
36
37CO_ReturnError_t
38CO_CANmodule_init(CO_CANmodule_t* CANmodule, void* CANptr, CO_CANrx_t rxArray[], uint16_t rxSize, CO_CANtx_t txArray[],
39 uint16_t txSize, uint16_t CANbitRate) {
40 uint16_t i;
41
42 /* verify arguments */
43 if (CANmodule == NULL || rxArray == NULL || txArray == NULL) {
44 return CO_ERROR_ILLEGAL_ARGUMENT;
45 }
46
47 /* Configure object variables */
48 CANmodule->CANptr = CANptr;
49 CANmodule->rxArray = rxArray;
50 CANmodule->rxSize = rxSize;
51 CANmodule->txArray = txArray;
52 CANmodule->txSize = txSize;
53 CANmodule->CANerrorStatus = 0;
54 CANmodule->CANnormal = false;
55 CANmodule->useCANrxFilters = (rxSize <= 32U) ? true : false; /* microcontroller dependent */
56 CANmodule->bufferInhibitFlag = false;
57 CANmodule->firstCANtxMessage = true;
58 CANmodule->CANtxCount = 0U;
59 CANmodule->errOld = 0U;
60
61 for (i = 0U; i < rxSize; i++) {
62 rxArray[i].ident = 0U;
63 rxArray[i].mask = 0xFFFFU;
64 rxArray[i].object = NULL;
65 rxArray[i].CANrx_callback = NULL;
66 }
67 for (i = 0U; i < txSize; i++) {
68 txArray[i].bufferFull = false;
69 }
70
71 /* Configure CAN module registers */
72
73 /* Configure CAN timing */
74
75 /* Configure CAN module hardware filters */
76 if (CANmodule->useCANrxFilters) {
77 /* CAN module filters are used, they will be configured with */
78 /* CO_CANrxBufferInit() functions, called by separate CANopen */
79 /* init functions. */
80 /* Configure all masks so, that received message must match filter */
81 } else {
82 /* CAN module filters are not used, all messages with standard 11-bit */
83 /* identifier will be received */
84 /* Configure mask 0 so, that all messages with standard identifier are accepted */
85 }
86
87 /* configure CAN interrupt registers */
88
89 return CO_ERROR_NO;
90}
91
92void
93CO_CANmodule_disable(CO_CANmodule_t* CANmodule) {

Callers 1

CO_CANinitFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected