Skip to content

Commit

Permalink
Fix include files.
Browse files Browse the repository at this point in the history
  • Loading branch information
christoph2 committed Apr 30, 2022
1 parent c498209 commit 6d0fdc7
Show file tree
Hide file tree
Showing 10 changed files with 164 additions and 111 deletions.
14 changes: 7 additions & 7 deletions checker/splint/xcp_config.h
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,7 @@
#define XCP_ENABLE_UPLOAD XCP_ON
#define XCP_ENABLE_SHORT_UPLOAD XCP_ON
#define XCP_ENABLE_BUILD_CHECKSUM XCP_ON
#define XCP_ENABLE_TRANSPORT_LAYER_CMD \
#define XCP_ENABLE_TRANSPORT_LAYER_CMD \
XCP_OFF /* TODO: TL dependend include file! */
#define XCP_ENABLE_USER_CMD XCP_OFF

Expand Down Expand Up @@ -161,7 +161,7 @@
/*
** Transport-Layer specific Options (may not apply to every Transport).
*/
#if defined(KVASER_CAN)
#if defined(KVASER_CAN) || XCP_TRANSPORT_LAYER == XCP_ON_CAN
#define XCP_TRANSPORT_LAYER XCP_ON_CAN

#define XCP_ON_CAN_INBOUND_IDENTIFIER (0x102)
Expand All @@ -177,13 +177,13 @@
#else
#define XCP_TRANSPORT_LAYER XCP_ON_ETHERNET

#define XCP_MAX_CTO (64) // (16)
#define XCP_MAX_CTO (64) // (16)
#define XCP_MAX_DTO (64)

#define XCP_TRANSPORT_LAYER_LENGTH_SIZE (2)
#define XCP_TRANSPORT_LAYER_COUNTER_SIZE (2)
#define XCP_TRANSPORT_LAYER_CHECKSUM_SIZE (0)
#endif // KVASER_CAN
#endif // KVASER_CAN

/*
** Customization Options.
Expand Down Expand Up @@ -215,9 +215,9 @@
/*
** Application Settings.
*/
#define XCP_APP_TIMEBASE \
(10) /* Applications gets called every 'n' milliseconds, \
** 0 ==> free running. \
#define XCP_APP_TIMEBASE \
(10) /* Applications gets called every 'n' milliseconds, \
** 0 ==> free running. \
*/

#endif /* __XCP_CONFIG_H */
2 changes: 1 addition & 1 deletion examples/xcpsim/app_config.c
Original file line number Diff line number Diff line change
Expand Up @@ -154,7 +154,7 @@ bool Xcp_HookFunction_GetId(uint8_t id_type, uint8_t **result,

if (id_type == 0x80) { /* First user-defined identification type. */
#if defined(_WIN32)
fp = _popen("cmd /c ver", "r");
fp = _popen("cmd /c ver", "rt");
#else
fp = popen("uname -a ", "r");
#endif
Expand Down
8 changes: 6 additions & 2 deletions examples/xcpsim/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,8 @@
* s. FLOSS-EXCEPTION.txt
*/

#include <assert.h>

#include "app_config.h"
#include "xcp.h"
#include "xcp_terminal.h"
Expand All @@ -34,12 +36,14 @@ void parse_options(int argc, char **argv, Xcp_OptionsType *options);
void AppTask(void);

int main(int argc, char **argv) {
assert(sizeof(void *) == 4);

parse_options(argc, argv, &Xcp_Options);
// FlsEmu_Init(&FlsEmu_Config);
FlsEmu_Init(&FlsEmu_Config);
Xcp_Init();
Xcp_DisplayInfo();
XcpThrd_RunThreads();
// FlsEmu_DeInit();
FlsEmu_DeInit();
XcpHw_Deinit();
XcpTl_DeInit();
return 0;
Expand Down
28 changes: 22 additions & 6 deletions examples/xcpsim/xcp_config.h
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,10 @@
//#define XCP_BUILD_TYPE XCP_RELEASE_BUILD
#define XCP_BUILD_TYPE XCP_DEBUG_BUILD

#define XCP_TRANSPORT_LAYER \
XCP_ON_SXI // Alternatively one could use [TP_CAN | TP_ETHER | TP_SXI] on the
// command line, e.g. -DTP_ETHER

#define XCP_ENABLE_EXTERN_C_GUARDS XCP_OFF

#define XCP_ENABLE_SLAVE_BLOCKMODE XCP_ON
Expand Down Expand Up @@ -162,7 +166,7 @@
/*
** Transport-Layer specific Options (may not apply to every Transport).
*/
#if defined(TP_CAN)
#if defined(TP_CAN) || (XCP_TRANSPORT_LAYER == XCP_ON_CAN)
#define XCP_TRANSPORT_LAYER XCP_ON_CAN

#define XCP_ON_CAN_INBOUND_IDENTIFIER (0x102)
Expand All @@ -175,7 +179,7 @@
#define XCP_ON_CAN_TSEG2 (2)
#define XCP_ON_CAN_SJW (2)
#define XCP_ON_CAN_NOSAMP (1)
#elif defined(TP_BLUETOOTH)
#elif defined(TP_BLUETOOTH) || (XCP_TRANSPORT_LAYER == XCP_ON_BTH)
#define XCP_TRANSPORT_LAYER XCP_ON_BTH

#define XCP_MAX_CTO (64) // (16)
Expand All @@ -184,7 +188,7 @@
#define XCP_TRANSPORT_LAYER_LENGTH_SIZE (2)
#define XCP_TRANSPORT_LAYER_COUNTER_SIZE (2)
#define XCP_TRANSPORT_LAYER_CHECKSUM_SIZE (0)
#elif defined(TP_ETHER)
#elif defined(TP_ETHER) || (XCP_TRANSPORT_LAYER == XCP_ON_ETHERNET)
#define XCP_TRANSPORT_LAYER XCP_ON_ETHERNET

#define XCP_MAX_CTO (64) // (16)
Expand All @@ -193,9 +197,16 @@
#define XCP_TRANSPORT_LAYER_LENGTH_SIZE (2)
#define XCP_TRANSPORT_LAYER_COUNTER_SIZE (2)
#define XCP_TRANSPORT_LAYER_CHECKSUM_SIZE (0)
#elif defined(TP_SXI) || (XCP_TRANSPORT_LAYER == XCP_ON_SXI)

#define XCP_MAX_CTO (64)
#define XCP_MAX_DTO (64)
#define XCP_TRANSPORT_LAYER_LENGTH_SIZE (2)
#define XCP_TRANSPORT_LAYER_COUNTER_SIZE (2)
#define XCP_TRANSPORT_LAYER_CHECKSUM_SIZE (2)
#else
#error \
"No transport-layer. please define either TP_ETHER, TP_CAN, or TP_BLUETOOTH."
"No transport-layer specified. Please define either TP_ETHER, TP_CAN, or TP_BLUETOOTH."
#endif // KVASER_CAN

/*
Expand All @@ -204,11 +215,16 @@
#define XCP_ENABLE_ADDRESS_MAPPER XCP_ON
#define XCP_ENABLE_CHECK_MEMORY_ACCESS XCP_ON
#define XCP_REPLACE_STD_COPY_MEMORY XCP_OFF
#define XCP_ENABLE_GET_ID_HOOK XCP_ON

#define XCP_ENABLE_GET_ID_HOOK XCP_OFF
/*
**
** Arduino Specific Options.
**
*/

/*
** Platform Specific Options.
** Platform Specific Function-like Macros.
*/
#define XCP_ENTER_CRITICAL() XcpHw_AcquireLock(XCP_HW_LOCK_XCP)
#define XCP_LEAVE_CRITICAL() XcpHw_ReleaseLock(XCP_HW_LOCK_XCP)
Expand Down
20 changes: 11 additions & 9 deletions inc/xcp.h
Original file line number Diff line number Diff line change
Expand Up @@ -43,12 +43,12 @@
#define XCP_ON (1)
#define XCP_OFF (0)

#define XCP_ON_CAN (0)
#define XCP_ON_CANFD (1)
#define XCP_ON_FLEXRAY (2)
#define XCP_ON_USB (3)
#define XCP_ON_ETHERNET (4)
#define XCP_ON_SXI (5)
#define XCP_ON_CAN (1)
#define XCP_ON_CANFD (2)
#define XCP_ON_FLEXRAY (3)
#define XCP_ON_USB (4)
#define XCP_ON_ETHERNET (5)
#define XCP_ON_SXI (6)
#define XCP_ON_BTH (128) /* XCP on Bluetooth -- non-standard. */

#define XCP_DAQ_CONFIG_TYPE_STATIC (0)
Expand Down Expand Up @@ -926,15 +926,17 @@ typedef struct tagXcp_1DArrayType {
} Xcp_1DArrayType;

typedef struct tagXcp_OptionsType {
#if defined(TP_ETHER)
#if XCP_TRANSPORT_LAYER == XCP_ON_ETHERNET
bool ipv6;
bool tcp;
uint16_t port;
#elif defined(TP_BLUETOOTH)
#elif XCP_TRANSPORT_LAYER == XCP_ON_BTH
char interface2[6];
#elif defined(TP_CAN)
#elif XCP_TRANSPORT_LAYER == XCP_ON_CAN
bool fd;
char interface[64];
#elif XCP_TRANSPORT_LAYER == XCP_ON_SXI
bool dummy;
#endif
} Xcp_OptionsType;

Expand Down
7 changes: 6 additions & 1 deletion inc/xcp_hw.h
Original file line number Diff line number Diff line change
Expand Up @@ -32,10 +32,15 @@ extern "C" {
#endif /* __cplusplus */
#endif /* XCP_EXTERN_C_GUARDS */

/*!!! START-INCLUDE-SECTION !!!*/
#include "xcp.h"
/*!!! END-INCLUDE-SECTION !!!*/

/*
** Global Functions.
*/
void XcpHw_ParseCommandLineOptions(int argc, char **argv, Xcp_OptionsType *options);
void XcpHw_ParseCommandLineOptions(int argc, char **argv,
Xcp_OptionsType *options);
void XcpHw_ErrorMsg(char *const function, int errorCode);
void XcpHw_Sleep(uint64_t usec);

Expand Down
48 changes: 30 additions & 18 deletions inc/xcp_macros.h
Original file line number Diff line number Diff line change
Expand Up @@ -44,46 +44,55 @@ extern "C" {
#define XCP_DEBUG_BUILD (1)
#define XCP_RELEASE_BUILD (2)

#include "xcp_config.h"

#if defined(_WIN32) || (XCP_BUILD_TYPE == XCP_DEBUG_BUILD)
#include <stdio.h>
#endif /* defined(_WIN32) */

#if !defined(XCP_LOBYTE)
#define XCP_LOBYTE(w) ((uint8_t)((w) & (uint8_t)0xff)) /**< Get the low-byte from a word. */
#define XCP_LOBYTE(w) \
((uint8_t)((w) & (uint8_t)0xff)) /**< Get the low-byte from a word. */
#endif

#if !defined(XCP_HIBYTE)
#define XCP_HIBYTE(w) ((uint8_t)(((w) & (uint16_t)0xff00U) >> 8U)) /**< Get the high-byte from a word. */
#define XCP_HIBYTE(w) \
((uint8_t)(((w) & (uint16_t)0xff00U) >> \
8U)) /**< Get the high-byte from a word. */
#endif

#if !defined(XCP_LOWORD)
#define XCP_LOWORD(w) ((uint16_t)((w) & (uint16_t)0xffff)) /**< Get the low-word from a double-word. */
#define XCP_LOWORD(w) \
((uint16_t)((w) & \
(uint16_t)0xffff)) /**< Get the low-word from a double-word. */
#endif

#if !defined(XCP_HIWORD)
#define XCP_HIWORD(w) ((uint16_t)(((w) & (uint32_t)0xffff0000) >> 16U)) /**< Get the high-word from a doubleword. */
#define XCP_HIWORD(w) \
((uint16_t)(((w) & (uint32_t)0xffff0000) >> \
16U)) /**< Get the high-word from a doubleword. */
#endif

#if !defined(XCP_MAKEWORD)
#define XCP_MAKEWORD(h, l) \
((((uint16_t)((h) & ((uint8_t)0xff))) << (uint16_t)8) | \
((uint16_t)((l) & ((uint8_t)0xff)))) /**< Make word from high and low bytes. */
#define XCP_MAKEWORD(h, l) \
((((uint16_t)((h) & ((uint8_t)0xff))) << (uint16_t)8) | \
((uint16_t)((l) & \
((uint8_t)0xff)))) /**< Make word from high and low bytes. */
#endif

#if !defined(XCP_MAKEDWORD)
#define XCP_MAKEDWORD(h, l) \
((((uint32_t)((h) & ((uint16_t)0xffffu))) << (uint32_t)16) | \
((uint32_t)((l) & ((uint16_t)0xffffu)))) /**< Make double-word from high and low words. */
#define XCP_MAKEDWORD(h, l) \
((((uint32_t)((h) & ((uint16_t)0xffffu))) << (uint32_t)16) | \
((uint32_t)((l) & ((uint16_t)0xffffu)))) /**< Make double-word from high \
and low words. */
#endif

#if !defined(XCP_MAX)
#define XCP_MAX(l, r) (((l) > (r)) ? (l) : (r)) /**< Computes the maximum of \a l and \a r. */
#define XCP_MAX(l, r) \
(((l) > (r)) ? (l) : (r)) /**< Computes the maximum of \a l and \a r. */
#endif

#if !defined(XCP_MIN)
#define XCP_MIN(l, r) (((l) < (r)) ? (l) : (r)) /**< Computes the minimum of \a l and \a r. */
#define XCP_MIN(l, r) \
(((l) < (r)) ? (l) : (r)) /**< Computes the minimum of \a l and \a r. */
#endif

#if !defined(XCP_TRUE)
Expand All @@ -98,12 +107,13 @@ extern "C" {
#if defined(__cplusplus)
#define XCP_NULL (0)
#else
#define XCP_NULL ((void*)0)
#define XCP_NULL ((void *)0)
#endif
#endif

#if XCP_BUILD_TYPE == XCP_DEBUG_BUILD
#define XCP_STATIC /**< Static only on DEBUG builds. Rationale: (unit-) testing. */
#define XCP_STATIC /**< Static only on DEBUG builds. Rationale: (unit-) \
testing. */
#else
#define XCP_STATIC static
#endif /* XCP_BUILD_TYPE */
Expand Down Expand Up @@ -147,7 +157,7 @@ extern "C" {
#define DBG_TRACE4(A, B, C, D) DBG_PRINT4(A, B, C, D)
#define DBG_TRACE5(A, B, C, D, E) DBG_PRINT5(A, B, C, D, E)
#define DBG_TRACE6(A, B, C, D, E, F) DBG_PRINT6(A, B, C, D, E, F)
#endif // defined(_WIN32)
#endif // defined(_WIN32)
#else
#define INLINE
#define DBG_PRINT1(a)
Expand All @@ -165,7 +175,9 @@ extern "C" {
#define DBG_TRACE6(a, b, c, d, e, f)
#endif /* XCP_BUILD_TYPE == XCP_DEBUG_BUILD */

#define XCP_ARRAY_SIZE(arr) (sizeof((arr)) / sizeof((arr)[0])) /**< Calculates the number of elements of \a arr */
#define XCP_ARRAY_SIZE(arr) \
(sizeof((arr)) / \
sizeof((arr)[0])) /**< Calculates the number of elements of \a arr */

#if XCP_ENABLE_EXTERN_C_GUARDS == XCP_ON
#if defined(__cplusplus)
Expand Down
3 changes: 3 additions & 0 deletions inc/xcp_types.h
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,10 @@ extern "C" {
#endif

#if defined(__CSMC__) || !defined(C99_COMPILER) || !defined(C11_COMPILER)

#if !defined(__cplusplus)
typedef unsigned char bool;
#endif

typedef signed char int8_t;
typedef unsigned char uint8_t;
Expand Down

0 comments on commit 6d0fdc7

Please sign in to comment.