diff options
author | takeshi_hoshina <takeshi_hoshina@mail.toyota.co.jp> | 2020-10-27 11:16:21 +0900 |
---|---|---|
committer | takeshi_hoshina <takeshi_hoshina@mail.toyota.co.jp> | 2020-10-27 11:16:21 +0900 |
commit | 947c78887e791596d4a5ec2d1079f8b1a049628b (patch) | |
tree | 3981e88eb8764d7180722f8466f36b756dc005af /can_hal/src/inc | |
parent | 706ad73eb02caf8532deaf5d38995bd258725cb8 (diff) |
basesystem 0.1sandbox/ToshikazuOhiwa/basesystem
Diffstat (limited to 'can_hal/src/inc')
-rw-r--r-- | can_hal/src/inc/can_hal_core.h | 37 | ||||
-rw-r--r-- | can_hal/src/inc/can_hal_frameworkunifiedlog.h | 76 | ||||
-rw-r--r-- | can_hal/src/inc/can_hal_internal.h | 31 | ||||
-rw-r--r-- | can_hal/src/inc/can_hal_stm.h | 45 | ||||
-rw-r--r-- | can_hal/src/inc/can_mng_api.h | 120 |
5 files changed, 309 insertions, 0 deletions
diff --git a/can_hal/src/inc/can_hal_core.h b/can_hal/src/inc/can_hal_core.h new file mode 100644 index 00000000..57a9c9d8 --- /dev/null +++ b/can_hal/src/inc/can_hal_core.h @@ -0,0 +1,37 @@ +/* + * @copyright Copyright (c) 2020 TOYOTA MOTOR CORPORATION. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#ifndef _CAN_HAL_CORE_H_ +#define _CAN_HAL_CORE_H_ +#include <stdint.h> +#include "can_hal.h" +#ifdef __cplusplus +extern "C" { +#endif +CANHAL_RET_API CanOpenCore(CanHalType type); +CANHAL_RET_API CanCloseCore(CanHalType type); +EFrameworkunifiedStatus CanSendThreadStart(HANDLE h_app); +EFrameworkunifiedStatus CanSendThreadStop(HANDLE h_app); +void *CanRecvRun(void *arg); +void *CanHalPackMessage(HANDLE h_app, const void *msg, ssize_t msg_sz, + ssize_t *packed_sz); +void CanHalUnPackMessage(void *packed, HANDLE *h_app, void **msg, + ssize_t *msg_sz); +void CanHalDestroyPackedMessage(void *packed); +#ifdef __cplusplus +} +#endif +#endif diff --git a/can_hal/src/inc/can_hal_frameworkunifiedlog.h b/can_hal/src/inc/can_hal_frameworkunifiedlog.h new file mode 100644 index 00000000..f3a5f500 --- /dev/null +++ b/can_hal/src/inc/can_hal_frameworkunifiedlog.h @@ -0,0 +1,76 @@ +/* + * @copyright Copyright (c) 2018-2020 TOYOTA MOTOR CORPORATION. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#ifndef INC_CAN_HAL_FRAMEWORKUNIFIEDLOG_H_ +#define INC_CAN_HAL_FRAMEWORKUNIFIEDLOG_H_ + +#include <native_service/ns_logger_if.h> + +#define ZONE_INIT ZONEMASK(10) +#define ZONE_FUNC ZONEMASK(11) +#define ZONE_MEM ZONEMASK(12) +#define ZONE_13 ZONEMASK(13) +#define ZONE_14 ZONEMASK(14) +#define ZONE_15 ZONEMASK(15) +#define ZONE_16 ZONEMASK(16) +#define ZONE_17 ZONEMASK(17) +#define ZONE_18 ZONEMASK(18) +#define ZONE_19 ZONEMASK(19) +#define ZONE_20 ZONEMASK(20) +#define ZONE_21 ZONEMASK(21) +#define ZONE_22 ZONEMASK(22) +#define ZONE_23 ZONEMASK(23) +#define ZONE_24 ZONEMASK(24) +#define ZONE_25 ZONEMASK(25) +#define ZONE_26 ZONEMASK(26) +#define ZONE_27 ZONEMASK(27) +#define ZONE_28 ZONEMASK(28) +#define ZONE_INFO ZONEMASK(29) +#define ZONE_WARN ZONEMASK(30) +#define ZONE_ERR ZONEMASK(31) + +#define ZONE_TEXT_10 "Init" +#define ZONE_TEXT_11 "Function" +#define ZONE_TEXT_12 "Memory" +#define ZONE_TEXT_13 "" +#define ZONE_TEXT_14 "" +#define ZONE_TEXT_15 "" +#define ZONE_TEXT_16 "" +#define ZONE_TEXT_17 "" +#define ZONE_TEXT_18 "" +#define ZONE_TEXT_19 "" +#define ZONE_TEXT_20 "" +#define ZONE_TEXT_21 "" +#define ZONE_TEXT_22 "" +#define ZONE_TEXT_23 "" +#define ZONE_TEXT_24 "" +#define ZONE_TEXT_25 "" +#define ZONE_TEXT_26 "" +#define ZONE_TEXT_27 "" +#define ZONE_TEXT_28 "" +#define ZONE_TEXT_29 "Info" +#define ZONE_TEXT_30 "Warning" +#define ZONE_TEXT_31 "Error" + +#ifndef FRAMEWORKUNIFIEDLOGOPTIONS +#define FRAMEWORKUNIFIEDLOGOPTIONS (LSHAREDMEM) // LPRINT , LMSGQ, LSLOGGER +#endif + +#ifndef FRAMEWORKUNIFIEDLOGAPPZONES +#define FRAMEWORKUNIFIEDLOGAPPZONES ZONE_ERR, ZONE_WARN, ZONE_INFO +#endif + +#endif // INC_CAN_HAL_FRAMEWORKUNIFIEDLOG_H_ diff --git a/can_hal/src/inc/can_hal_internal.h b/can_hal/src/inc/can_hal_internal.h new file mode 100644 index 00000000..f42a73f7 --- /dev/null +++ b/can_hal/src/inc/can_hal_internal.h @@ -0,0 +1,31 @@ +/* + * @copyright Copyright (c) 2018-2020 TOYOTA MOTOR CORPORATION. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#ifndef INC_CAN_HAL_INTERNAL_H_ +#define INC_CAN_HAL_INTERNAL_H_ + +/** + * \~english Name of the CAN send thread + */ +#define CANHAL_CAN_SEND_THREAD "HalCANSend" + +enum CanHalInternalCmd { + INVALID_CMD = 0, + TX_INTERNAL, + TX_INTERNAL__CWORD118_ +}; + +#endif // INC_CAN_HAL_INTERNAL_H_ diff --git a/can_hal/src/inc/can_hal_stm.h b/can_hal/src/inc/can_hal_stm.h new file mode 100644 index 00000000..cd078140 --- /dev/null +++ b/can_hal/src/inc/can_hal_stm.h @@ -0,0 +1,45 @@ +/* + * @copyright Copyright (c) 2020 TOYOTA MOTOR CORPORATION. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#ifndef _CAN_HAL_STM_H_ +#define _CAN_HAL_STM_H_ +#include "can_hal.h" +#ifdef __cplusplus +extern "C" { +#endif +bool TypeIsValid(enum CanHalType type); +bool IsCanHalOpened(enum CanHalType type); +void SetCanHalStateOpen(enum CanHalType type); +void SetCanHalStateClose(enum CanHalType type); +bool IsDeviceEnabled(enum CanHalType type); +void SetDeviceStateEnable(enum CanHalType type); +void SetDeviceStateDisable(enum CanHalType type); +CANHAL_RET_API InvokeStateCallback(enum CanHalType type); +CANHAL_RET_API InvokeErrorCallback(HANDLE h_app, enum CanHalType type); +CANHAL_RET_API CanHalInternalSend(enum CanHalType type, + const void *msg, ssize_t sz); +CANHAL_RET_API CanHalInternalSend_CWORD118_(enum CanHalType type, + const void *msg, ssize_t sz); +CANHAL_RET_API CanHalSendStatus(enum CanHalType type, HANDLE h_app, + const void *msg, ssize_t sz); +CANHAL_RET_API CanHalReceiveNotify(enum CanHalType type, + const void *msg, ssize_t sz); +CANHAL_RET_API CanHalCreateInternalThread(HANDLE h_app, enum CanHalType type); +CANHAL_RET_API CanHalDestroyInternalThread(HANDLE h_app, enum CanHalType type); +#ifdef __cplusplus +} +#endif +#endif diff --git a/can_hal/src/inc/can_mng_api.h b/can_hal/src/inc/can_mng_api.h new file mode 100644 index 00000000..ef03750f --- /dev/null +++ b/can_hal/src/inc/can_mng_api.h @@ -0,0 +1,120 @@ +/* + * @copyright Copyright (c) 2020 TOYOTA MOTOR CORPORATION. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#ifndef __CAN_MNG_API_H__ +#define __CAN_MNG_API_H__ + +/** @includes + * + */ + +/** @define + * + */ +#ifndef UINT8 +#define UINT8 unsigned char +#endif +#ifndef UINT16 +#define UINT16 unsigned short +#endif +#ifndef INT32 +#define INT32 int +#endif +#ifndef UINT32 +#define UINT32 unsigned int +#endif + +/*------------------------------------------*/ +/* Log */ +/*------------------------------------------*/ +#if defined(CAN_MNG_API_FORCE_DEBUG) + #define CAN_MNG_API_LOGT(fmt,...) fprintf(stderr, "[T][CAN_API] %s(%s)(%d):" fmt "\n", __FILE__, __func__, __LINE__, ## __VA_ARGS__) + #define CAN_MNG_API_LOGD(fmt,...) fprintf(stderr, "[D][CAN_API] %s(%s)(%d):" fmt "\n", __FILE__, __func__, __LINE__, ## __VA_ARGS__) + #define CAN_MNG_API_LOGE(fmt,...) fprintf(stderr, "[E][CAN_API] %s(%s)(%d):" fmt "\n", __FILE__, __func__, __LINE__, ## __VA_ARGS__) +#else + #define CAN_MNG_API_LOGT(fmt,...) + #define CAN_MNG_API_LOGD(fmt,...) + #define CAN_MNG_API_LOGE(fmt,...) +#endif +/*------------------------------------------*/ +/* API return value */ +/*------------------------------------------*/ +#define CAN_CTL_RET_SUCCESS 0 /* Normal end */ +#define CAN_CTL_RET_ERR_PARAM -1 /* Parameter error */ +#define CAN_CTL_RET_ERR_NOSVC -2 /* Service not open error */ +#define CAN_CTL_RET_ERR_ERR -3 /* Other error */ + +/*------------------------------------------*/ +/* Received command information */ +/*------------------------------------------*/ +#define CAN_CTL_CMD_LEN_MAX 255 /* Maximum data length */ +#define CAN_DAT_LEN_MAX CAN_CTL_CMD_LEN_MAX /* Maximum data length */ +#define CAN_CTL_CMD_ID_HI_NUM 128 /* Number of higher CAN-ID(8bit) (00 to 7F) */ + +#define CAN_CTL_MAX_RCV_CAN_SIZE 23 + +/** @typedefs + * + */ +/* Object for CAN communication control API */ +typedef struct _CanCtlApiObj { + /* ID assigned to the command reception notification callback */ + INT32 call_id; +} CanCtlApiObj ; + +/* CAN command structure */ +typedef struct _CanCtlApiCmd { + UINT8 len; /* Data length */ + UINT8 data[CAN_DAT_LEN_MAX]; /* Data */ +} CanCtlApiCmd; + +/* Received ID MAP information */ +typedef struct _CanCtlRcvId { + UINT16 id[CAN_CTL_CMD_ID_HI_NUM]; /* CAN ID MAP(000~7FF) */ +} CanCtlRcvId; + + +/* CAN Frame structure */ +typedef union { + UINT8 Data[2]; +} CanId; + +#define LCN_SRV_MSB_FRAME_DAT_SIZE (8) /* MSB send/receive frame data size */ + +typedef struct _CanData { + CanId id; /* CAN Frame structure */ + UINT8 dlc; /* Valid bytes of DATA#1~#8. DLC is 1 to 8. */ + UINT8 Data[LCN_SRV_MSB_FRAME_DAT_SIZE]; /* Receive data */ + /* Data of DLC size is valid, otherwise set to 0 as invalid value. */ +} CanData; + +/** @forward declarations + * + */ +/* API prototype */ +#ifdef __cplusplus +extern "C" { +#endif +UINT32 CanCtlApiOpen(CanCtlApiObj* pClientObj); +UINT32 CanCtlApiClose(CanCtlApiObj* pClientObj); +UINT32 CanCtlApiSndCmd(CanCtlApiObj* pClientObj, CanCtlApiCmd* pSndCmd); +UINT32 CanCtlApiSetRcvId(CanCtlApiObj* pClientObj, CanCtlRcvId* pRcvId); +UINT32 CanCtlApiRcvCmd(CanCtlApiObj* pClientObj, CanCtlApiCmd* pRcvCmd); +UINT32 CanCtlApiRcvSpd(CanCtlApiObj* pClientObj, CanCtlApiCmd* pRcvCmd); +#ifdef __cplusplus +} +#endif +#endif /* __CAN_MNG_API_H__ */ |