Merge pull request #1 from gotocoffee1/add-lss
Some changes for older compilers and big endian machines
This commit is contained in:
commit
32035de7b1
2 changed files with 20 additions and 18 deletions
|
|
@ -189,7 +189,7 @@ typedef union {
|
||||||
uint32_t productCode;
|
uint32_t productCode;
|
||||||
uint32_t revisionNumber;
|
uint32_t revisionNumber;
|
||||||
uint32_t serialNumber;
|
uint32_t serialNumber;
|
||||||
};
|
} identity;
|
||||||
} CO_LSS_address_t;
|
} CO_LSS_address_t;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
@ -258,10 +258,10 @@ static const uint16_t CO_LSS_bitTimingTableLookup[] = {
|
||||||
* Macro to check if two LSS addresses are equal
|
* Macro to check if two LSS addresses are equal
|
||||||
*/
|
*/
|
||||||
#define CO_LSS_ADDRESS_EQUAL(/*CO_LSS_address_t*/ a1, /*CO_LSS_address_t*/ a2) \
|
#define CO_LSS_ADDRESS_EQUAL(/*CO_LSS_address_t*/ a1, /*CO_LSS_address_t*/ a2) \
|
||||||
(a1.productCode == a2.productCode && \
|
(a1.identity.productCode == a2.identity.productCode && \
|
||||||
a1.revisionNumber == a2.revisionNumber && \
|
a1.identity.revisionNumber == a2.identity.revisionNumber && \
|
||||||
a1.serialNumber == a2.serialNumber && \
|
a1.identity.serialNumber == a2.identity.serialNumber && \
|
||||||
a1.vendorID == a2.vendorID)
|
a1.identity.vendorID == a2.identity.vendorID)
|
||||||
|
|
||||||
#endif /* CO_NO_LSS_CLIENT == 1 || CO_NO_LSS_SERVER == 1 */
|
#endif /* CO_NO_LSS_CLIENT == 1 || CO_NO_LSS_SERVER == 1 */
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -79,7 +79,8 @@ static void CO_LSSslave_serviceSwitchStateSelective(
|
||||||
CO_LSS_cs_t service,
|
CO_LSS_cs_t service,
|
||||||
const CO_CANrxMsg_t *msg)
|
const CO_CANrxMsg_t *msg)
|
||||||
{
|
{
|
||||||
uint32_t value = CO_getUint32(&msg->data[1]);
|
uint32_t value;
|
||||||
|
CO_memcpySwap4(&value, &msg->data[1]);
|
||||||
|
|
||||||
if(LSSslave->lssState != CO_LSS_STATE_WAITING) {
|
if(LSSslave->lssState != CO_LSS_STATE_WAITING) {
|
||||||
return;
|
return;
|
||||||
|
|
@ -87,16 +88,16 @@ static void CO_LSSslave_serviceSwitchStateSelective(
|
||||||
|
|
||||||
switch (service) {
|
switch (service) {
|
||||||
case CO_LSS_SWITCH_STATE_SEL_VENDOR:
|
case CO_LSS_SWITCH_STATE_SEL_VENDOR:
|
||||||
LSSslave->lssSelect.vendorID = value;
|
LSSslave->lssSelect.identity.vendorID = value;
|
||||||
break;
|
break;
|
||||||
case CO_LSS_SWITCH_STATE_SEL_PRODUCT:
|
case CO_LSS_SWITCH_STATE_SEL_PRODUCT:
|
||||||
LSSslave->lssSelect.productCode = value;
|
LSSslave->lssSelect.identity.productCode = value;
|
||||||
break;
|
break;
|
||||||
case CO_LSS_SWITCH_STATE_SEL_REV:
|
case CO_LSS_SWITCH_STATE_SEL_REV:
|
||||||
LSSslave->lssSelect.revisionNumber = value;
|
LSSslave->lssSelect.identity.revisionNumber = value;
|
||||||
break;
|
break;
|
||||||
case CO_LSS_SWITCH_STATE_SEL_SERIAL:
|
case CO_LSS_SWITCH_STATE_SEL_SERIAL:
|
||||||
LSSslave->lssSelect.serialNumber = value;
|
LSSslave->lssSelect.identity.serialNumber = value;
|
||||||
|
|
||||||
if (CO_LSS_ADDRESS_EQUAL(LSSslave->lssAddress, LSSslave->lssSelect)) {
|
if (CO_LSS_ADDRESS_EQUAL(LSSslave->lssAddress, LSSslave->lssSelect)) {
|
||||||
LSSslave->lssState = CO_LSS_STATE_CONFIGURATION;
|
LSSslave->lssState = CO_LSS_STATE_CONFIGURATION;
|
||||||
|
|
@ -193,7 +194,8 @@ static void CO_LSSslave_serviceConfig(
|
||||||
|
|
||||||
/* notify application */
|
/* notify application */
|
||||||
if (LSSslave->pFunctLSSactivateBitRate != NULL) {
|
if (LSSslave->pFunctLSSactivateBitRate != NULL) {
|
||||||
uint16_t delay = CO_getUint16(&msg->data[1]);
|
uint16_t delay;
|
||||||
|
CO_memcpySwap2(&delay, &msg->data[1]);
|
||||||
LSSslave->pFunctLSSactivateBitRate(
|
LSSslave->pFunctLSSactivateBitRate(
|
||||||
LSSslave->functLSSactivateBitRateObject, delay);
|
LSSslave->functLSSactivateBitRateObject, delay);
|
||||||
}
|
}
|
||||||
|
|
@ -243,16 +245,16 @@ static void CO_LSSslave_serviceInquire(
|
||||||
|
|
||||||
switch (service) {
|
switch (service) {
|
||||||
case CO_LSS_INQUIRE_VENDOR:
|
case CO_LSS_INQUIRE_VENDOR:
|
||||||
value = LSSslave->lssAddress.vendorID;
|
value = LSSslave->lssAddress.identity.vendorID;
|
||||||
break;
|
break;
|
||||||
case CO_LSS_INQUIRE_PRODUCT:
|
case CO_LSS_INQUIRE_PRODUCT:
|
||||||
value = LSSslave->lssAddress.productCode;
|
value = LSSslave->lssAddress.identity.productCode;
|
||||||
break;
|
break;
|
||||||
case CO_LSS_INQUIRE_REV:
|
case CO_LSS_INQUIRE_REV:
|
||||||
value = LSSslave->lssAddress.revisionNumber;
|
value = LSSslave->lssAddress.identity.revisionNumber;
|
||||||
break;
|
break;
|
||||||
case CO_LSS_INQUIRE_SERIAL:
|
case CO_LSS_INQUIRE_SERIAL:
|
||||||
value = LSSslave->lssAddress.serialNumber;
|
value = LSSslave->lssAddress.identity.serialNumber;
|
||||||
break;
|
break;
|
||||||
case CO_LSS_INQUIRE_NODE_ID:
|
case CO_LSS_INQUIRE_NODE_ID:
|
||||||
value = (uint32_t)LSSslave->activeNodeID;
|
value = (uint32_t)LSSslave->activeNodeID;
|
||||||
|
|
@ -262,7 +264,7 @@ static void CO_LSSslave_serviceInquire(
|
||||||
}
|
}
|
||||||
/* send response */
|
/* send response */
|
||||||
LSSslave->TXbuff->data[0] = service;
|
LSSslave->TXbuff->data[0] = service;
|
||||||
CO_setUint32(&LSSslave->TXbuff->data[1], value);
|
CO_memcpySwap4(&LSSslave->TXbuff->data[1], &value);
|
||||||
CO_memset(&LSSslave->TXbuff->data[5], 0, 4);
|
CO_memset(&LSSslave->TXbuff->data[5], 0, 4);
|
||||||
CO_CANsend(LSSslave->CANdevTx, LSSslave->TXbuff);
|
CO_CANsend(LSSslave->CANdevTx, LSSslave->TXbuff);
|
||||||
}
|
}
|
||||||
|
|
@ -295,7 +297,7 @@ static void CO_LSSslave_serviceIdent(
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
idNumber = CO_getUint32(&msg->data[1]);
|
CO_memcpySwap4(&idNumber, &msg->data[1]);
|
||||||
bitCheck = msg->data[5];
|
bitCheck = msg->data[5];
|
||||||
lssSub = msg->data[6];
|
lssSub = msg->data[6];
|
||||||
lssNext = msg->data[7];
|
lssNext = msg->data[7];
|
||||||
|
|
@ -396,7 +398,7 @@ CO_ReturnError_t CO_LSSslave_init(
|
||||||
|
|
||||||
/* check LSS address for plausibility. As a bare minimum, the vendor
|
/* check LSS address for plausibility. As a bare minimum, the vendor
|
||||||
* ID and serial number must be set */
|
* ID and serial number must be set */
|
||||||
if (lssAddress.vendorID==0 || lssAddress.serialNumber==0) {
|
if (lssAddress.identity.vendorID==0 || lssAddress.identity.serialNumber==0) {
|
||||||
return CO_ERROR_ILLEGAL_ARGUMENT;
|
return CO_ERROR_ILLEGAL_ARGUMENT;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue