From c78f66e75925d387542174bda67dd446e3b80765 Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Tue, 2 Jul 2024 00:06:49 +0000 Subject: [PATCH] [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci --- checker/cl-tidy/xcp.c | 2 +- flsemu/common.c | 229 +++++++++++++------------- inc/xcp.h | 17 +- src/tl/can/arduino_can.cpp | 2 +- src/xcp_daq.c | 25 ++- tools/arduino/hello_xcp/hello_xcp.ino | 6 +- tools/arduino/hello_xcp/xcp.h | 83 ++++------ 7 files changed, 176 insertions(+), 188 deletions(-) diff --git a/checker/cl-tidy/xcp.c b/checker/cl-tidy/xcp.c index 544b997..202d885 100644 --- a/checker/cl-tidy/xcp.c +++ b/checker/cl-tidy/xcp.c @@ -667,7 +667,7 @@ void Xcp_SendPdu(void) { Xcp_PduOut.data[XCP_TRANSPORT_LAYER_LENGTH_SIZE] = XCP_LOBYTE(Xcp_State.counter); Xcp_State.counter++; #elif XCP_TRANSPORT_LAYER_COUNTER_SIZE == 2 - Xcp_PduOut.data[XCP_TRANSPORT_LAYER_LENGTH_SIZE] = XCP_LOBYTE(Xcp_State.counter); + Xcp_PduOut.data[XCP_TRANSPORT_LAYER_LENGTH_SIZE] = XCP_LOBYTE(Xcp_State.counter); Xcp_PduOut.data[XCP_TRANSPORT_LAYER_LENGTH_SIZE + 1] = XCP_HIBYTE(Xcp_State.counter); Xcp_State.counter++; #endif /* XCP_TRANSPORT_LAYER_COUNTER_SIZE */ diff --git a/flsemu/common.c b/flsemu/common.c index 064c5c7..50e20e7 100644 --- a/flsemu/common.c +++ b/flsemu/common.c @@ -120,12 +120,12 @@ void FlsEmu_OpenCreate(uint8_t segmentIdx) { length = strlen(segment->name); #if defined(_MSC_VER) strncpy_s((char *)rom, 1024, (char *)segment->name, length); - rom[length] = '\x00'; - strcat_s((char *)rom, 1024, ".rom"); + rom[length] = '\x00'; + strcat_s((char *)rom, 1024, ".rom"); #else strncpy((char *)rom, (char *)segment->name, length); - rom[length] = '\x00'; - strcat((char *)rom, ".rom"); + rom[length] = '\x00'; + strcat((char *)rom, ".rom"); #endif /* _MSC_VER */ numPages = FlsEmu_NumPages(segmentIdx); result = FlsEmu_OpenCreatePersitentArray(rom, pageSize * numPages, segment->persistentArray); @@ -139,148 +139,147 @@ void FlsEmu_OpenCreate(uint8_t segmentIdx) { for (pageIdx = 0U; pageIdx < numPages; ++pageIdx) { // FIXME!!! offset = ((Xcp_PointerSizeType)segment->persistentArray->mappingAddress) + (pageIdx * pageSize); - XcpUtl_MemSet((void*)offset, FLSEMU_ERASED_VALUE, segment->pageSize); + XcpUtl_MemSet((void *)offset, FLSEMU_ERASED_VALUE, segment->pageSize); if (fillerSize > 0) { - XcpUtl_MemSet((void*)(offset + segment->pageSize), FLSEMU_FILLER_VALUE, fillerSize); + XcpUtl_MemSet((void *)(offset + segment->pageSize), FLSEMU_FILLER_VALUE, fillerSize); } } } } } - void *FlsEmu_BasePointer(uint8_t segmentIdx) { - /// TODO: getSegment() - FlsEmu_SegmentType const *segment = XCP_NULL; - FLSEMU_ASSERT_INITIALIZED(); +void *FlsEmu_BasePointer(uint8_t segmentIdx) { + /// TODO: getSegment() + FlsEmu_SegmentType const *segment = XCP_NULL; + FLSEMU_ASSERT_INITIALIZED(); - if (!FLSEMU_VALIDATE_SEGMENT_IDX(segmentIdx)) { - return XCP_NULL; - } - segment = FlsEmu_GetConfig()->segments[segmentIdx]; - return segment->persistentArray->mappingAddress; + if (!FLSEMU_VALIDATE_SEGMENT_IDX(segmentIdx)) { + return XCP_NULL; } + segment = FlsEmu_GetConfig()->segments[segmentIdx]; + return segment->persistentArray->mappingAddress; +} - uint32_t FlsEmu_NumPages(uint8_t segmentIdx) { - FlsEmu_SegmentType const *segment = XCP_NULL; - FLSEMU_ASSERT_INITIALIZED(); +uint32_t FlsEmu_NumPages(uint8_t segmentIdx) { + FlsEmu_SegmentType const *segment = XCP_NULL; + FLSEMU_ASSERT_INITIALIZED(); - if (!FLSEMU_VALIDATE_SEGMENT_IDX(segmentIdx)) { - return UINT32(0); - } - segment = FlsEmu_GetConfig()->segments[segmentIdx]; + if (!FLSEMU_VALIDATE_SEGMENT_IDX(segmentIdx)) { + return UINT32(0); + } + segment = FlsEmu_GetConfig()->segments[segmentIdx]; + + return segment->memSize / segment->pageSize; +} + +void FlsEmu_EraseSector(uint8_t segmentIdx, uint32_t address) { + uint32_t mask = 0UL; + uint16_t *ptr = XCP_NULL; + FlsEmu_SegmentType const *segment = XCP_NULL; - return segment->memSize / segment->pageSize; + FLSEMU_ASSERT_INITIALIZED(); + if (!FLSEMU_VALIDATE_SEGMENT_IDX(segmentIdx)) { + return; + } + segment = FlsEmu_GetConfig()->segments[segmentIdx]; + mask = (uint32_t)segment->sectorSize - 1UL; + ptr = (uint16_t *)segment->persistentArray->mappingAddress; + if ((address & mask) != 0UL) { + // TODO: warn misalignment. + // ("address (%#X) should be aligned to %u-byte sector boundary.", address, + // segment->sectorSize) } + XcpUtl_MemSet(ptr + (address & ~mask), FLSEMU_ERASED_VALUE, segment->sectorSize); +} - void FlsEmu_EraseSector(uint8_t segmentIdx, uint32_t address) { - uint32_t mask = 0UL; - uint16_t *ptr = XCP_NULL; - FlsEmu_SegmentType const *segment = XCP_NULL; +void FlsEmu_ErasePage(uint8_t segmentIdx, uint8_t page) { + uint8_t *ptr = (uint8_t *)FlsEmu_BasePointer(segmentIdx); + FlsEmu_SegmentType *segment = XCP_NULL; - FLSEMU_ASSERT_INITIALIZED(); - if (!FLSEMU_VALIDATE_SEGMENT_IDX(segmentIdx)) { - return; - } - segment = FlsEmu_GetConfig()->segments[segmentIdx]; - mask = (uint32_t)segment->sectorSize - 1UL; - ptr = (uint16_t *)segment->persistentArray->mappingAddress; - if ((address & mask) != 0UL) { - // TODO: warn misalignment. - // ("address (%#X) should be aligned to %u-byte sector boundary.", address, - // segment->sectorSize) - } - XcpUtl_MemSet(ptr + (address & ~mask), FLSEMU_ERASED_VALUE, segment->sectorSize); + FLSEMU_ASSERT_INITIALIZED(); + if (!FLSEMU_VALIDATE_SEGMENT_IDX(segmentIdx)) { + return; } + segment = FlsEmu_GetConfig()->segments[segmentIdx]; + XcpUtl_MemSet(ptr + (segment->pageSize * page), FLSEMU_ERASED_VALUE, segment->pageSize); + segment->currentPage = page; +} - void FlsEmu_ErasePage(uint8_t segmentIdx, uint8_t page) { - uint8_t *ptr = (uint8_t *)FlsEmu_BasePointer(segmentIdx); - FlsEmu_SegmentType *segment = XCP_NULL; +void FlsEmu_EraseBlock(uint8_t segmentIdx, uint16_t block) { + /* TODO: Nur den entsprechenden Block mappen!!! */ + uint8_t *ptr = XCP_NULL; + uint32_t offset = 0UL; + uint32_t blockSize = 0UL; + FlsEmu_SegmentType const *segment = XCP_NULL; - FLSEMU_ASSERT_INITIALIZED(); - if (!FLSEMU_VALIDATE_SEGMENT_IDX(segmentIdx)) { - return; - } - segment = FlsEmu_GetConfig()->segments[segmentIdx]; - XcpUtl_MemSet(ptr + (segment->pageSize * page), FLSEMU_ERASED_VALUE, segment->pageSize); - segment->currentPage = page; + FLSEMU_ASSERT_INITIALIZED(); + if (!FLSEMU_VALIDATE_SEGMENT_IDX(segmentIdx)) { + return; } + segment = FlsEmu_GetConfig()->segments[segmentIdx]; + assert(block < (segment->blockCount)); - void FlsEmu_EraseBlock(uint8_t segmentIdx, uint16_t block) { - /* TODO: Nur den entsprechenden Block mappen!!! */ - uint8_t *ptr = XCP_NULL; - uint32_t offset = 0UL; - uint32_t blockSize = 0UL; - FlsEmu_SegmentType const *segment = XCP_NULL; + blockSize = (segment->memSize / segment->blockCount); + offset = (blockSize * block); - FLSEMU_ASSERT_INITIALIZED(); - if (!FLSEMU_VALIDATE_SEGMENT_IDX(segmentIdx)) { - return; - } - segment = FlsEmu_GetConfig()->segments[segmentIdx]; - assert(block < (segment->blockCount)); + ptr = (uint8_t *)FlsEmu_BasePointer(segmentIdx) + offset; + XcpUtl_MemSet(ptr, FLSEMU_ERASED_VALUE, blockSize); +} - blockSize = (segment->memSize / segment->blockCount); - offset = (blockSize * block); +Xcp_MemoryMappingResultType FlsEmu_MemoryMapper(Xcp_MtaType *dst, Xcp_MtaType const *src) { + uint8_t idx = 0; + uint8_t *ptr = XCP_NULL; + FlsEmu_SegmentType const *segment = XCP_NULL; - ptr = (uint8_t *)FlsEmu_BasePointer(segmentIdx) + offset; - XcpUtl_MemSet(ptr, FLSEMU_ERASED_VALUE, blockSize); - } + /* printf("addr: %x ext: %d\n", src->address, src->ext); */ - Xcp_MemoryMappingResultType FlsEmu_MemoryMapper(Xcp_MtaType * dst, Xcp_MtaType const *src) { - uint8_t idx = 0; - uint8_t *ptr = XCP_NULL; - FlsEmu_SegmentType const *segment = XCP_NULL; - - /* printf("addr: %x ext: %d\n", src->address, src->ext); */ - - for (idx = 0; idx < FlsEmu_GetConfig()->numSegments; ++idx) { - ptr = FlsEmu_BasePointer(idx); - segment = FlsEmu_GetConfig()->segments[idx]; - if ((src->address >= segment->baseAddress) && (src->address < (segment->baseAddress + segment->pageSize))) { - if (src->ext >= FlsEmu_NumPages(idx)) { - return XCP_MEMORY_ADDRESS_INVALID; - } else { - FlsEmu_SelectPage(idx, src->ext); - } - dst->address = ((Xcp_PointerSizeType)ptr - segment->baseAddress) + src->address; - dst->ext = src->ext; - /* printf("MAPPED: addr: %x ext: %d TO: %x:%d\n", src->address, src->ext, - * dst->address, dst->ext); */ - return XCP_MEMORY_MAPPED; + for (idx = 0; idx < FlsEmu_GetConfig()->numSegments; ++idx) { + ptr = FlsEmu_BasePointer(idx); + segment = FlsEmu_GetConfig()->segments[idx]; + if ((src->address >= segment->baseAddress) && (src->address < (segment->baseAddress + segment->pageSize))) { + if (src->ext >= FlsEmu_NumPages(idx)) { + return XCP_MEMORY_ADDRESS_INVALID; + } else { + FlsEmu_SelectPage(idx, src->ext); } + dst->address = ((Xcp_PointerSizeType)ptr - segment->baseAddress) + src->address; + dst->ext = src->ext; + /* printf("MAPPED: addr: %x ext: %d TO: %x:%d\n", src->address, src->ext, + * dst->address, dst->ext); */ + return XCP_MEMORY_MAPPED; } - return XCP_MEMORY_NOT_MAPPED; } + return XCP_MEMORY_NOT_MAPPED; +} - /*! - * Align emulated page-size to OS allocation granularity. - */ - uint32_t FlsEmu_AllocatedSize(uint8_t segmentIdx) { - FlsEmu_SegmentType const *segment = XCP_NULL; - FLSEMU_ASSERT_INITIALIZED(); - - if (!FLSEMU_VALIDATE_SEGMENT_IDX(segmentIdx)) { - return (uint32_t)0; - } - segment = FlsEmu_GetConfig()->segments[segmentIdx]; +/*! + * Align emulated page-size to OS allocation granularity. + */ +uint32_t FlsEmu_AllocatedSize(uint8_t segmentIdx) { + FlsEmu_SegmentType const *segment = XCP_NULL; + FLSEMU_ASSERT_INITIALIZED(); - return FlsEmu_SystemMemory.AllocationGranularity * - (((segment->pageSize / FlsEmu_SystemMemory.AllocationGranularity) + - ((segment->pageSize % FlsEmu_SystemMemory.AllocationGranularity) != 0)) ? - 1 : - 0); + if (!FLSEMU_VALIDATE_SEGMENT_IDX(segmentIdx)) { + return (uint32_t)0; } + segment = FlsEmu_GetConfig()->segments[segmentIdx]; - FlsEmu_ConfigType const *FlsEmu_GetConfig(void) { - return FlsEmu_Config; - } + return FlsEmu_SystemMemory.AllocationGranularity * (((segment->pageSize / FlsEmu_SystemMemory.AllocationGranularity) + + ((segment->pageSize % FlsEmu_SystemMemory.AllocationGranularity) != 0)) ? + 1 : + 0); +} - FlsEmu_ModuleStateType *FlsEmu_GetModuleState(void) { - return &FlsEmu_ModuleState; - } +FlsEmu_ConfigType const *FlsEmu_GetConfig(void) { + return FlsEmu_Config; +} - bool FlsEmu_Initialized(void) { - FlsEmu_ModuleStateType const *state = FlsEmu_GetModuleState(); +FlsEmu_ModuleStateType *FlsEmu_GetModuleState(void) { + return &FlsEmu_ModuleState; +} - return *state == FLSEMU_INIT; - } +bool FlsEmu_Initialized(void) { + FlsEmu_ModuleStateType const *state = FlsEmu_GetModuleState(); + + return *state == FLSEMU_INIT; +} diff --git a/inc/xcp.h b/inc/xcp.h index 7820d52..bc5cee8 100644 --- a/inc/xcp.h +++ b/inc/xcp.h @@ -106,7 +106,8 @@ extern "C" { #if XCP_TRANSPORT_LAYER == XCP_ON_CAN - #if ((XCP_ENABLE_CAN_GET_SLAVE_ID == XCP_ON) || (XCP_ENABLE_CAN_GET_DAQ_ID == XCP_ON) || (XCP_ENABLE_CAN_SET_DAQ_ID == XCP_ON)) + #if ((XCP_ENABLE_CAN_GET_SLAVE_ID == XCP_ON) || (XCP_ENABLE_CAN_GET_DAQ_ID == XCP_ON) || \ + (XCP_ENABLE_CAN_SET_DAQ_ID == XCP_ON)) #define XCP_ENABLE_TRANSPORT_LAYER_CMD (XCP_ON) #endif @@ -250,8 +251,7 @@ extern "C" { #define XCP_DAQ_ENTITY_TYPE uint32_t #endif - #define XCP_SET_ID(name) \ - { UINT16(sizeof((name)) - UINT16(1)), (uint8_t const *)(name) } + #define XCP_SET_ID(name) { UINT16(sizeof((name)) - UINT16(1)), (uint8_t const *)(name) } #if !defined(XCP_MAX_BS) #define XCP_MAX_BS (0) @@ -269,7 +269,7 @@ extern "C" { #define XCP_MIN_ST_PGM (0) #endif /* XCP_MIN_ST_PGM */ - #define XCP_DOWNLOAD_PAYLOAD_LENGTH ((XCP_MAX_CTO)-2) + #define XCP_DOWNLOAD_PAYLOAD_LENGTH ((XCP_MAX_CTO) - 2) /* * Packet Identifiers. @@ -449,8 +449,7 @@ extern "C" { #define XCP_DAQ_PREDEFINDED_LIST_COUNT (sizeof(XcpDaq_PredefinedLists) / sizeof(XcpDaq_PredefinedLists[0])) /* DAQ Implementation Macros */ - #define XCP_DAQ_DEFINE_ODT_ENTRY(meas) \ - { { /*(uint32_t)*/ &(meas) }, sizeof((meas)) } + #define XCP_DAQ_DEFINE_ODT_ENTRY(meas) { { /*(uint32_t)*/ &(meas) }, sizeof((meas)) } /* DAQ Event Implementation Macros */ #define XCP_DAQ_BEGIN_EVENTS const XcpDaq_EventType XcpDaq_Events[XCP_DAQ_MAX_EVENT_CHANNEL] = { @@ -458,7 +457,9 @@ extern "C" { } \ ; #define XCP_DAQ_DEFINE_EVENT(name, props, timebase, cycle) \ - { (uint8_t const * const)(name), sizeof((name)) - 1, (props), (timebase), (cycle), } + { \ + (uint8_t const * const)(name), sizeof((name)) - 1, (props), (timebase), (cycle), \ + } #define XCP_DAQ_BEGIN_ID_LIST const uint32_t Xcp_DaqIDs[] = { #define XCP_DAQ_END_ID_LIST \ @@ -496,7 +497,7 @@ extern "C" { /* ** XCPonCAN specific function-like macros. */ - #define XCP_ON_CAN_IS_EXTENDED_IDENTIFIER(i) (((i)&XCP_ON_CAN_EXT_IDENTIFIER) == XCP_ON_CAN_EXT_IDENTIFIER) + #define XCP_ON_CAN_IS_EXTENDED_IDENTIFIER(i) (((i) & XCP_ON_CAN_EXT_IDENTIFIER) == XCP_ON_CAN_EXT_IDENTIFIER) #define XCP_ON_CAN_STRIP_IDENTIFIER(i) ((i) & (~XCP_ON_CAN_EXT_IDENTIFIER)) /* diff --git a/src/tl/can/arduino_can.cpp b/src/tl/can/arduino_can.cpp index 8ea28a3..ea73347 100644 --- a/src/tl/can/arduino_can.cpp +++ b/src/tl/can/arduino_can.cpp @@ -135,7 +135,7 @@ static void on_receive() { #else static void on_receive(int packetSize) { uint_least8_t idx = 0; - XcpTl_Dlc = packetSize; + XcpTl_Dlc = packetSize; #endif #if (XCP_CAN_INTERFACE == XCP_CAN_IF_SEED_STUDIO_CAN_SHIELD) || (XCP_CAN_INTERFACE == XCP_CAN_IF_SEED_STUDIO_CAN_FD_SHIELD) diff --git a/src/xcp_daq.c b/src/xcp_daq.c index d01f769..094a7e7 100644 --- a/src/xcp_daq.c +++ b/src/xcp_daq.c @@ -109,16 +109,16 @@ bool XcpDaq_QueueEnqueue(uint16_t len, uint8_t const *data); */ #if XCP_DAQ_ENABLE_DYNAMIC_LISTS == XCP_ON XCP_STATIC const uint8_t XcpDaq_AllocTransitionTable[5][4] = { - /* FREE_DAQ ALLOC_DAQ ALLOC_ODT ALLOC_ODT_ENTRY */ - /* ALLOC_IDLE*/ {UINT8(DAQ_ALLOC_OK), UINT8(DAQ_ALLOC_ERR), UINT8(DAQ_ALLOC_ERR), UINT8(DAQ_ALLOC_ERR)}, - /* AFTER_FREE_DAQ */ - { UINT8(DAQ_ALLOC_OK), UINT8(DAQ_ALLOC_OK), UINT8(DAQ_ALLOC_ERR), UINT8(DAQ_ALLOC_ERR)}, - /* AFTER_ALLOC_DAQ */ - { UINT8(DAQ_ALLOC_OK), UINT8(DAQ_ALLOC_OK), UINT8(DAQ_ALLOC_OK), UINT8(DAQ_ALLOC_ERR)}, - /* AFTER_ALLOC_ODT */ - { UINT8(DAQ_ALLOC_OK), UINT8(DAQ_ALLOC_ERR), UINT8(DAQ_ALLOC_OK), UINT8(DAQ_ALLOC_OK) }, - /* AFTER_ALLOC_ODT_ENTRY */ - { UINT8(DAQ_ALLOC_OK), UINT8(DAQ_ALLOC_ERR), UINT8(DAQ_ALLOC_ERR), UINT8(DAQ_ALLOC_OK) }, + /* FREE_DAQ ALLOC_DAQ ALLOC_ODT ALLOC_ODT_ENTRY */ + /* ALLOC_IDLE*/ { UINT8(DAQ_ALLOC_OK), UINT8(DAQ_ALLOC_ERR), UINT8(DAQ_ALLOC_ERR), UINT8(DAQ_ALLOC_ERR) }, + /* AFTER_FREE_DAQ */ + { UINT8(DAQ_ALLOC_OK), UINT8(DAQ_ALLOC_OK), UINT8(DAQ_ALLOC_ERR), UINT8(DAQ_ALLOC_ERR) }, + /* AFTER_ALLOC_DAQ */ + { UINT8(DAQ_ALLOC_OK), UINT8(DAQ_ALLOC_OK), UINT8(DAQ_ALLOC_OK), UINT8(DAQ_ALLOC_ERR) }, + /* AFTER_ALLOC_ODT */ + { UINT8(DAQ_ALLOC_OK), UINT8(DAQ_ALLOC_ERR), UINT8(DAQ_ALLOC_OK), UINT8(DAQ_ALLOC_OK) }, + /* AFTER_ALLOC_ODT_ENTRY */ + { UINT8(DAQ_ALLOC_OK), UINT8(DAQ_ALLOC_ERR), UINT8(DAQ_ALLOC_ERR), UINT8(DAQ_ALLOC_OK) }, }; #endif /* XCP_DAQ_ENABLE_DYNAMIC_LISTS */ @@ -390,9 +390,8 @@ void XcpDaq_SetPointer( bool XcpDaq_ValidateConfiguration(void) { #if (XCP_DAQ_ENABLE_DYNAMIC_LISTS == XCP_ON) && (XCP_DAQ_ENABLE_PREDEFINED_LISTS == XCP_OFF) /* Dynamic DAQs only */ - return (bool - )((XcpDaq_EntityCount > (XCP_DAQ_ENTITY_TYPE)0) && (XcpDaq_ListCount > (XCP_DAQ_ENTITY_TYPE)0) && - (XcpDaq_OdtCount > (XCP_DAQ_ENTITY_TYPE)0)); + return (bool)((XcpDaq_EntityCount > (XCP_DAQ_ENTITY_TYPE)0) && (XcpDaq_ListCount > (XCP_DAQ_ENTITY_TYPE)0) && + (XcpDaq_OdtCount > (XCP_DAQ_ENTITY_TYPE)0)); #elif (XCP_DAQ_ENABLE_DYNAMIC_LISTS == XCP_OFF) && (XCP_DAQ_ENABLE_PREDEFINED_LISTS == XCP_ON) /* Predefined DAQs only */ return (bool)XCP_TRUE; diff --git a/tools/arduino/hello_xcp/hello_xcp.ino b/tools/arduino/hello_xcp/hello_xcp.ino index 06e857c..f4f8bac 100644 --- a/tools/arduino/hello_xcp/hello_xcp.ino +++ b/tools/arduino/hello_xcp/hello_xcp.ino @@ -1,7 +1,7 @@ #include -//#include +// #include #include "xcp.h" @@ -185,7 +185,7 @@ auto sin0 = SineWave(&triangle, 0xff, 100.0, true); void loop() { XcpTl_MainFunction(); Xcp_MainFunction(); -//#if 0 + // #if 0 if ((millis() - startTime) >= 10) { startTime = millis(); triangle.step(); @@ -195,5 +195,5 @@ void loop() { sine_wave = sin0.get_float_value(); XcpDaq_TriggerEvent(0); } -//#endif + // #endif } diff --git a/tools/arduino/hello_xcp/xcp.h b/tools/arduino/hello_xcp/xcp.h index 135bd2b..23102e6 100644 --- a/tools/arduino/hello_xcp/xcp.h +++ b/tools/arduino/hello_xcp/xcp.h @@ -413,14 +413,13 @@ typedef struct tagXcpTl_ConnectionType { */ #ifndef __XCP_TL_TIMEOUT_H -#define __XCP_TL_TIMEOUT_H + #define __XCP_TL_TIMEOUT_H -#if XCP_ENABLE_EXTERN_C_GUARDS == XCP_ON - #if defined(__cplusplus) + #if XCP_ENABLE_EXTERN_C_GUARDS == XCP_ON + #if defined(__cplusplus) extern "C" { - #endif /* __cplusplus */ -#endif /* XCP_EXTERN_C_GUARDS */ - + #endif /* __cplusplus */ + #endif /* XCP_EXTERN_C_GUARDS */ void XcpTl_TimeoutInit(uint16_t timeout_value, void (*timeout_function)(void)); @@ -432,11 +431,11 @@ extern "C" { void XcpTl_TimeoutReset(void); -#if XCP_ENABLE_EXTERN_C_GUARDS == XCP_ON - #if defined(__cplusplus) + #if XCP_ENABLE_EXTERN_C_GUARDS == XCP_ON + #if defined(__cplusplus) } - #endif /* __cplusplus */ -#endif /* XCP_EXTERN_C_GUARDS */ + #endif /* __cplusplus */ + #endif /* XCP_EXTERN_C_GUARDS */ #endif // __XCP_TL_TIMEOUT_H @@ -478,12 +477,11 @@ extern "C" { #endif /* __cplusplus */ #endif /* XCP_EXTERN_C_GUARDS */ - - void XcpUtl_MemCopy(void* dst, void const * src, uint32_t len); - void XcpUtl_MemSet(void* dest, uint8_t fill_char, uint32_t len); - bool XcpUtl_MemCmp(void const * dst, void const * src, uint32_t len); - void XcpUtl_Hexdump(uint8_t const * buf, uint16_t sz); - void XcpUtl_Itoa(uint32_t value, uint8_t base, uint8_t* buf); + void XcpUtl_MemCopy(void *dst, void const *src, uint32_t len); + void XcpUtl_MemSet(void *dest, uint8_t fill_char, uint32_t len); + bool XcpUtl_MemCmp(void const *dst, void const *src, uint32_t len); + void XcpUtl_Hexdump(uint8_t const *buf, uint16_t sz); + void XcpUtl_Itoa(uint32_t value, uint8_t base, uint8_t *buf); #define XcpUtl_ZeroMem(dest, len) XcpUtl_MemSet((dest), '\0', (len)) @@ -529,7 +527,6 @@ extern "C" { #include - #define XCP_PROTOCOL_VERSION_MAJOR (1) #define XCP_PROTOCOL_VERSION_RELEASE (0) @@ -602,7 +599,8 @@ extern "C" { #if XCP_TRANSPORT_LAYER == XCP_ON_CAN - #if ((XCP_ENABLE_CAN_GET_SLAVE_ID == XCP_ON) || (XCP_ENABLE_CAN_GET_DAQ_ID == XCP_ON) || (XCP_ENABLE_CAN_SET_DAQ_ID == XCP_ON)) + #if ((XCP_ENABLE_CAN_GET_SLAVE_ID == XCP_ON) || (XCP_ENABLE_CAN_GET_DAQ_ID == XCP_ON) || \ + (XCP_ENABLE_CAN_SET_DAQ_ID == XCP_ON)) #define XCP_ENABLE_TRANSPORT_LAYER_CMD (XCP_ON) #endif @@ -746,8 +744,7 @@ extern "C" { #define XCP_DAQ_ENTITY_TYPE uint32_t #endif - #define XCP_SET_ID(name) \ - { UINT16(sizeof((name)) - UINT16(1)), (uint8_t const *)(name) } + #define XCP_SET_ID(name) { UINT16(sizeof((name)) - UINT16(1)), (uint8_t const *)(name) } #if !defined(XCP_MAX_BS) #define XCP_MAX_BS (0) @@ -765,7 +762,7 @@ extern "C" { #define XCP_MIN_ST_PGM (0) #endif /* XCP_MIN_ST_PGM */ - #define XCP_DOWNLOAD_PAYLOAD_LENGTH ((XCP_MAX_CTO)-2) + #define XCP_DOWNLOAD_PAYLOAD_LENGTH ((XCP_MAX_CTO) - 2) /* * Packet Identifiers. @@ -945,8 +942,7 @@ extern "C" { #define XCP_DAQ_PREDEFINDED_LIST_COUNT (sizeof(XcpDaq_PredefinedLists) / sizeof(XcpDaq_PredefinedLists[0])) /* DAQ Implementation Macros */ - #define XCP_DAQ_DEFINE_ODT_ENTRY(meas) \ - { { /*(uint32_t)*/ &(meas) }, sizeof((meas)) } + #define XCP_DAQ_DEFINE_ODT_ENTRY(meas) { { /*(uint32_t)*/ &(meas) }, sizeof((meas)) } /* DAQ Event Implementation Macros */ #define XCP_DAQ_BEGIN_EVENTS const XcpDaq_EventType XcpDaq_Events[XCP_DAQ_MAX_EVENT_CHANNEL] = { @@ -954,7 +950,9 @@ extern "C" { } \ ; #define XCP_DAQ_DEFINE_EVENT(name, props, timebase, cycle) \ - { (uint8_t const * const)(name), sizeof((name)) - 1, (props), (timebase), (cycle), } + { \ + (uint8_t const * const)(name), sizeof((name)) - 1, (props), (timebase), (cycle), \ + } #define XCP_DAQ_BEGIN_ID_LIST const uint32_t Xcp_DaqIDs[] = { #define XCP_DAQ_END_ID_LIST \ @@ -992,7 +990,7 @@ extern "C" { /* ** XCPonCAN specific function-like macros. */ - #define XCP_ON_CAN_IS_EXTENDED_IDENTIFIER(i) (((i)&XCP_ON_CAN_EXT_IDENTIFIER) == XCP_ON_CAN_EXT_IDENTIFIER) + #define XCP_ON_CAN_IS_EXTENDED_IDENTIFIER(i) (((i) & XCP_ON_CAN_EXT_IDENTIFIER) == XCP_ON_CAN_EXT_IDENTIFIER) #define XCP_ON_CAN_STRIP_IDENTIFIER(i) ((i) & (~XCP_ON_CAN_EXT_IDENTIFIER)) /* @@ -1793,7 +1791,6 @@ extern "C" { #endif /* __cplusplus */ #endif /* XCP_EXTERN_C_GUARDS */ - /* ** Global Functions. */ @@ -1838,7 +1835,6 @@ extern "C" { * s. FLOSS-EXCEPTION.txt */ - /* ** Private Options. */ @@ -4211,7 +4207,6 @@ XCP_STATIC void Xcp_WriteDaqEntry(uint8_t bitOffset, uint8_t elemSize, uint8_t a * expressed or implied by its publication or distribution. **********************************************************************/ - /* ** Local Types */ @@ -4603,7 +4598,6 @@ void Xcp_ChecksumMainFunction(void) { #include #endif /* _WIN32 */ - /* ** Private Parameters for now. */ @@ -4675,16 +4669,16 @@ bool XcpDaq_QueueEnqueue(uint16_t len, uint8_t const *data); */ #if XCP_DAQ_ENABLE_DYNAMIC_LISTS == XCP_ON XCP_STATIC const uint8_t XcpDaq_AllocTransitionTable[5][4] = { - /* FREE_DAQ ALLOC_DAQ ALLOC_ODT ALLOC_ODT_ENTRY */ - /* ALLOC_IDLE*/ {UINT8(DAQ_ALLOC_OK), UINT8(DAQ_ALLOC_ERR), UINT8(DAQ_ALLOC_ERR), UINT8(DAQ_ALLOC_ERR)}, - /* AFTER_FREE_DAQ */ - { UINT8(DAQ_ALLOC_OK), UINT8(DAQ_ALLOC_OK), UINT8(DAQ_ALLOC_ERR), UINT8(DAQ_ALLOC_ERR)}, - /* AFTER_ALLOC_DAQ */ - { UINT8(DAQ_ALLOC_OK), UINT8(DAQ_ALLOC_OK), UINT8(DAQ_ALLOC_OK), UINT8(DAQ_ALLOC_ERR)}, - /* AFTER_ALLOC_ODT */ - { UINT8(DAQ_ALLOC_OK), UINT8(DAQ_ALLOC_ERR), UINT8(DAQ_ALLOC_OK), UINT8(DAQ_ALLOC_OK) }, - /* AFTER_ALLOC_ODT_ENTRY */ - { UINT8(DAQ_ALLOC_OK), UINT8(DAQ_ALLOC_ERR), UINT8(DAQ_ALLOC_ERR), UINT8(DAQ_ALLOC_OK) }, + /* FREE_DAQ ALLOC_DAQ ALLOC_ODT ALLOC_ODT_ENTRY */ + /* ALLOC_IDLE*/ { UINT8(DAQ_ALLOC_OK), UINT8(DAQ_ALLOC_ERR), UINT8(DAQ_ALLOC_ERR), UINT8(DAQ_ALLOC_ERR) }, + /* AFTER_FREE_DAQ */ + { UINT8(DAQ_ALLOC_OK), UINT8(DAQ_ALLOC_OK), UINT8(DAQ_ALLOC_ERR), UINT8(DAQ_ALLOC_ERR) }, + /* AFTER_ALLOC_DAQ */ + { UINT8(DAQ_ALLOC_OK), UINT8(DAQ_ALLOC_OK), UINT8(DAQ_ALLOC_OK), UINT8(DAQ_ALLOC_ERR) }, + /* AFTER_ALLOC_ODT */ + { UINT8(DAQ_ALLOC_OK), UINT8(DAQ_ALLOC_ERR), UINT8(DAQ_ALLOC_OK), UINT8(DAQ_ALLOC_OK) }, + /* AFTER_ALLOC_ODT_ENTRY */ + { UINT8(DAQ_ALLOC_OK), UINT8(DAQ_ALLOC_ERR), UINT8(DAQ_ALLOC_ERR), UINT8(DAQ_ALLOC_OK) }, }; #endif /* XCP_DAQ_ENABLE_DYNAMIC_LISTS */ @@ -4956,9 +4950,8 @@ void XcpDaq_SetPointer( bool XcpDaq_ValidateConfiguration(void) { #if (XCP_DAQ_ENABLE_DYNAMIC_LISTS == XCP_ON) && (XCP_DAQ_ENABLE_PREDEFINED_LISTS == XCP_OFF) /* Dynamic DAQs only */ - return (bool - )((XcpDaq_EntityCount > (XCP_DAQ_ENTITY_TYPE)0) && (XcpDaq_ListCount > (XCP_DAQ_ENTITY_TYPE)0) && - (XcpDaq_OdtCount > (XCP_DAQ_ENTITY_TYPE)0)); + return (bool)((XcpDaq_EntityCount > (XCP_DAQ_ENTITY_TYPE)0) && (XcpDaq_ListCount > (XCP_DAQ_ENTITY_TYPE)0) && + (XcpDaq_OdtCount > (XCP_DAQ_ENTITY_TYPE)0)); #elif (XCP_DAQ_ENABLE_DYNAMIC_LISTS == XCP_OFF) && (XCP_DAQ_ENABLE_PREDEFINED_LISTS == XCP_ON) /* Predefined DAQs only */ return (bool)XCP_TRUE; @@ -5349,7 +5342,6 @@ bool XcpDaq_QueueDequeue(uint16_t *len, uint8_t *data) { * s. FLOSS-EXCEPTION.txt */ - void XcpUtl_MemCopy(/*@out@*/ void *dst, /*@in@*/ void const *src, uint32_t len) { uint8_t *pd = (uint8_t *)dst; uint8_t const *ps = (uint8_t const *)src; @@ -5465,7 +5457,6 @@ void XcpUtl_Itoa(uint32_t value, uint8_t base, uint8_t *buf) { * s. FLOSS-EXCEPTION.txt */ - /* * * Time-out handling functions for Transport-Layer. @@ -5545,7 +5536,6 @@ void XcpTl_TimeoutReset(void) { #include "Arduino.h" #endif - #define XCP_SXI_MAKEWORD(buf, offs) ((*((buf) + (offs))) | ((*((buf) + (offs) + 1) << 8))) #define TIMEOUT_VALUE (100) @@ -5725,7 +5715,6 @@ void serialEvent() #include #include - typedef struct tagHwStateType { uint32_t StartingTime; } HwStateType; @@ -5919,7 +5908,7 @@ static void on_receive() { #else static void on_receive(int packetSize) { uint_least8_t idx = 0; - XcpTl_Dlc = packetSize; + XcpTl_Dlc = packetSize; #endif #if (XCP_CAN_INTERFACE == XCP_CAN_IF_SEED_STUDIO_CAN_SHIELD) || (XCP_CAN_INTERFACE == XCP_CAN_IF_SEED_STUDIO_CAN_FD_SHIELD)