diff --git a/ETH/Kconfig b/ETH/Kconfig index bf48dca9e2038cc1447c243fe51abb6952799970..d495b5d574d0b453455b40c7e7241e9276db9660 100644 --- a/ETH/Kconfig +++ b/ETH/Kconfig @@ -20,3 +20,9 @@ config MAC_E3XX default n ---help--- choose MAC_E3XX mac driver + +config MAC_RH850 + bool "RH850 MAC" + default n + ---help--- + choose MAC_RH850 mac driver diff --git a/ETH/MAC/rh850/CMakeLists.txt b/ETH/MAC/rh850/CMakeLists.txt new file mode 100644 index 0000000000000000000000000000000000000000..f0621b717851b696e099a59a061e8b49a3bf83b2 --- /dev/null +++ b/ETH/MAC/rh850/CMakeLists.txt @@ -0,0 +1,26 @@ +set(ETH_STACK_RH850_GETHMAC_DIR "${CMAKE_CURRENT_SOURCE_DIR}" CACHE PATH "Path from drivers/Eth_GethMac") + +set(ETHGETHMAC_RH850_INC) +set(ETHGETHMAC_RH850_SRCS) + +if(CONFIG_MAC_RH850) + nuttx_add_library(eth_gethmac STATIC) + list(APPEND ETHGETHMAC_RH850_INC + ${ETH_STACK_RH850_GETHMAC_DIR}/u2bx + ${NUTTX_DIR}/../../components/rt_framework/inc/ + ${NUTTX_DIR}/../../components/include/ + ${NUTTX_DIR}/../../components/include/autosar/ + ) + + file(GLOB_RECURSE ETHGETHMACSRCS + ${ETH_STACK_RH850_GETHMAC_DIR}/u2bx/*.c + ) + + list(APPEND ETHGETHMAC_RH850_SRCS + ${ETHGETHMACSRCS} + ) + + target_include_directories(eth_gethmac PRIVATE ${ETHGETHMAC_RH850_INC}) + target_sources(eth_gethmac PRIVATE ${ETHGETHMAC_RH850_SRCS}) + +endif() diff --git a/ETH/MAC/rh850/u2bx/EthTrcv_GeneralTypes.h b/ETH/MAC/rh850/u2bx/EthTrcv_GeneralTypes.h new file mode 100644 index 0000000000000000000000000000000000000000..e5d915a9abb2160c970af66121b46c021393d61c --- /dev/null +++ b/ETH/MAC/rh850/u2bx/EthTrcv_GeneralTypes.h @@ -0,0 +1,113 @@ +/* + * Copyright (c) 2025 Li Auto Inc. and its affiliates + * 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. + */ + +#include "Platform_Types.h" + +#if !defined(ETHTRCV_GENERAL_TYPES_H) +#define ETHTRCV_GENERAL_TYPES_H + +/********************************************************************************************************************** + * GLOBAL CONSTANT MACROS + *********************************************************************************************************************/ +/* ETHTRCV modes */ +#define ETHTRCV_MODE_DOWN (0x00U) +#define ETHTRCV_MODE_ACTIVE (0x01U) + +/* ETHTRCV link states */ +#define ETHTRCV_LINK_STATE_DOWN (0x00U) +#define ETHTRCV_LINK_STATE_ACTIVE (0x01U) + +/* ETHTRCV baud rates */ +#define ETHTRCV_BAUD_RATE_10MBIT (0x00U) +#define ETHTRCV_BAUD_RATE_100MBIT (0x01U) +#define ETHTRCV_BAUD_RATE_1000MBIT (0x02U) + +/* ETHTRCV duplex modes */ +#define ETHTRCV_DUPLEX_MODE_HALF (0x00U) +#define ETHTRCV_DUPLEX_MODE_FULL (0x01U) + +/* ETHTRCV state */ +#define ETHTRCV_STATE_UNINIT (0x00U) +#define ETHTRCV_STATE_INIT (0x01U) +#define ETHTRCV_STATE_ACTIVE (0x02U) +#define ETHTRCV_STATE_DOWN (0x03U) + +/* ETHTRCV wakeup types */ +#define ETHTRCV_WAKEUP_NOT_SUPPORTED (0x00U) +#define ETHTRCV_WAKEUP_BY_INTERRUPT (0x01U) +#define ETHTRCV_WAKEUP_BY_POLLING (0x02U) + +/* ETHTRCV wakeup modes */ +#define ETHTRCV_WUM_DISABLE (0x00U) +#define ETHTRCV_WUM_ENABLE (0x01U) +#define ETHTRCV_WUM_CLEAR (0x02U) + +/* ETHTRCV wakeup reasons */ +#define ETHTRCV_WUR_NONE (0x00U) +#define ETHTRCV_WUR_GENERAL (0x01U) +#define ETHTRCV_WUR_BUS (0x02U) +#define ETHTRCV_WUR_INTERNAL (0x03U) +#define ETHTRCV_WUR_RESET (0x04U) +#define ETHTRCV_WUR_POWER_ON (0x05U) +#define ETHTRCV_WUR_PIN (0x06U) +#define ETHTRCV_WUR_SYSERR (0x07U) +/* count of AUTOSAR wakeup reasons defined for the transceiver */ +#define ETHTRCV_WUR_NUM (0x07U) + +/* Masks defining the bitpositions of the AUTOSAR wakeup reasons for type EthTrcv_WakeupReasonFlagsType. */ +#define ETHTRCV_WUR_GENERAL_FLAGS_MASK (0x01U) +#define ETHTRCV_WUR_BUS_FLAGS_MASK (0x02U) +#define ETHTRCV_WUR_INTERNAL_FLAGS_MASK (0x04U) +#define ETHTRCV_WUR_RESET_FLAGS_MASK (0x08U) +#define ETHTRCV_WUR_POWER_ON_FLAGS_MASK (0x10U) +#define ETHTRCV_WUR_PIN_FLAGS_MASK (0x20U) +#define ETHTRCV_WUR_SYSERR_FLAGS_MASK (0x40U) +#define ETHTRCV_WUR_CLEAR_MASK (0x00U) + +/* EthTrcv wakeup inspection types */ +#define ETHTRCV_ICU_CHANNEL (0x01U) +#define ETHTRCV_TRCV_REGISTERS (0x02U) +#define ETHTRCV_USER_CODE (0x03U) + +/* ETHTRCV MII modes */ +#define ETHTRCV_MII_MODE (0x00U) +#define ETHTRCV_LIGHT_MII_MODE (0x01U) +#define ETHTRCV_RMII_MODE (0x02U) +#define ETHTRCV_RMII_XTAL_MODE (0x03U) +#define ETHTRCV_GMII_MODE (0x04U) +#define ETHTRCV_RGMII_MODE (0x05U) +#define ETHTRCV_RGMII_XTAL_MODE (0x06U) +#define ETHTRCV_STRAPPING_CONFIG_ONLY (0x07U) +#define ETHTRCV_DONT_CARE (0xFFU) + +/* ETHTRCV CONN NEG modes*/ +#define ETHTRCV_CONN_NEG_AUTO (0x00U) +#define ETHTRCV_CONN_NEG_MASTER (0x01U) +#define ETHTRCV_CONN_NEG_SLAVE (0x02U) +#define ETHTRCV_CONN_NEG_MANUAL (0x03U) + +#define ETHTRCV_PHYS_ADDR_LEN_BYTE (0x06U) + +typedef uint8 eth_trcv_linkstate_type; +typedef uint8 EthTrcv_WakeupReasonFlagsType; +typedef uint8 EthTrcv_WakeupInspectionType; +typedef uint8 EthTrcv_PhysAddrType[ETHTRCV_PHYS_ADDR_LEN_BYTE]; +typedef uint16 eth_frame_type; + +typedef uint16 eth_frame_type; +typedef uint8 eth_data_type; +typedef uint32 eth_buf_idx_type; + +#endif /* ETHTRCV_GENERAL_TYPES_H */ diff --git a/ETH/MAC/rh850/u2bx/Eth_GEthMac.c b/ETH/MAC/rh850/u2bx/Eth_GEthMac.c new file mode 100644 index 0000000000000000000000000000000000000000..791f3184499558c1bb1a0941bbbe37824021eb6f --- /dev/null +++ b/ETH/MAC/rh850/u2bx/Eth_GEthMac.c @@ -0,0 +1,17 @@ +/* + * Copyright (c) 2025 Li Auto Inc. and its affiliates + * 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. + */ + +#include "Eth_GEthMac.h" +#include "Eth_GEthMac_Cfg.h" diff --git a/ETH/MAC/rh850/u2bx/Eth_GEthMac.h b/ETH/MAC/rh850/u2bx/Eth_GEthMac.h new file mode 100644 index 0000000000000000000000000000000000000000..d59734aaf325291ade907fab5a4db012bc4b2d4e --- /dev/null +++ b/ETH/MAC/rh850/u2bx/Eth_GEthMac.h @@ -0,0 +1,62 @@ +/* + * Copyright (c) 2025 Li Auto Inc. and its affiliates + * 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 ETH_GETHMAC_H +#define ETH_GETHMAC_H +#include "Platform_Types.h" +#include "Eth_GeneralTypes.h" +#include "comstack_types.h" +#define ETHMCAL_AUTOSAR_VERSION_440 +typedef uint32 Eth_BufIdxType; +typedef uint16 Eth_FrameType; +typedef eth_timestamp_qual_type Eth_TimeStampQualType; +typedef uint8 Std_ReturnType; +// typedef enum { +// BUFREQ_OK, +// BUFREQ_E_NOT_OK, +// BUFREQ_E_BUSY, +// BUFREQ_E_OVFL +// } BufReq_ReturnType; +typedef eth_timestamp_type Eth_TimeStampType; +void Eth_GetPhysAddr +( + uint8 CtrlIdx, + uint8 *AddrPtr +); +BufReq_ReturnType Eth_ProvideTxBuffer +( + uint8 CtrlIdx, + uint8 Priority, + Eth_BufIdxType *BufIdxPtr, + uint8 **BufPtr, + uint16 *LenBytePtr +); + +Std_ReturnType Eth_Transmit( + uint8 CtrlIdx, + Eth_BufIdxType BufIdx, + Eth_FrameType FrameType, + boolean TxConfirmation, + uint16 LenByte, + const uint8 *PhysAddrPtr +); +#endif +Std_ReturnType Eth_GetCurrentTime( + uint8 CtrlIdx, + Eth_TimeStampQualType *TimeQualPtr, + Eth_TimeStampType *TimeStampPtr +); + + diff --git a/ETH/MAC/rh850/u2bx/Eth_GEthMac_Cfg.h b/ETH/MAC/rh850/u2bx/Eth_GEthMac_Cfg.h new file mode 100644 index 0000000000000000000000000000000000000000..3fda163e0cc6dfd2c656dd815130812568cae339 --- /dev/null +++ b/ETH/MAC/rh850/u2bx/Eth_GEthMac_Cfg.h @@ -0,0 +1,25 @@ +/* + * Copyright (c) 2025 Li Auto Inc. and its affiliates + * 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. + */ +/** + * Eth Driver Configuration File + */ +#ifndef ETH_GETHMAC_CFG_H +#define ETH_GETHMAC_CFG_H + + + + + +#endif diff --git a/ETH/MAC/rh850/u2bx/Eth_GeneralTypes.h b/ETH/MAC/rh850/u2bx/Eth_GeneralTypes.h new file mode 100644 index 0000000000000000000000000000000000000000..30ecb31cee9302b0574b833d96d007a70ce850cc --- /dev/null +++ b/ETH/MAC/rh850/u2bx/Eth_GeneralTypes.h @@ -0,0 +1,74 @@ +/* + * Copyright (c) 2025 Li Auto Inc. and its affiliates + * 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 ETH_GENERALTYPES_H +#define ETH_GENERALTYPES_H + +#include "Platform_Types.h" +typedef uint16 eth_frame_type; +typedef uint8 eth_data_type; + +typedef enum { + ETH_MODE_DOWN = 0x0U, + ETH_MODE_ACTIVE = 0x1U +} eth_mode_type; + +typedef enum { + ETH_STATE_UNINIT = 0x0U, + ETH_STATE_INIT = 0x1U +} eth_state_type; + +typedef enum { + ETH_RECEIVED = 0x0U, + ETH_NOT_RECEIVED, + ETH_RECEIVED_MORE_DATA_AVAILABLE +} eth_rx_status_type; + +typedef enum { + ETH_ADD_TO_FILTER = 0x0U, + ETH_REMOVE_FROM_FILTER +} eth_filter_action_type; + +typedef enum { + ETH_OK = 0x0U, + ETH_E_NOT_OK, + ETH_E_NO_ACCESS +} eth_return_type; + +typedef enum { + ETH_VALID = 0x0U, + ETH_INVALID, + ETH_UNCERTAIN +} eth_timestamp_qual_type; + +typedef struct { + uint32 nanoseconds; + uint32 seconds; + uint16 secondsHi; +} eth_timestamp_type; + +typedef struct { + eth_timestamp_type diff; + boolean sign; +} eth_time_int_diff_type; + +typedef struct { + eth_time_int_diff_type IngressTimeStampDelta; + eth_time_int_diff_type OriginTimeStampDelta; +} eth_rateratio_type; + +typedef uint32 eth_buf_idx_type; + +#endif /* ETH_GENERALTYPES_H */ diff --git a/ETH/MAC/rh850/u2bx/Platform_Types.h b/ETH/MAC/rh850/u2bx/Platform_Types.h new file mode 100644 index 0000000000000000000000000000000000000000..3b50abbd89b99ef6ffdc9ab908d2b9f32ad04ac5 --- /dev/null +++ b/ETH/MAC/rh850/u2bx/Platform_Types.h @@ -0,0 +1,117 @@ +/* + * Copyright (c) 2025 Li Auto Inc. and its affiliates + * 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 PLATFORM_TYPES_H +#define PLATFORM_TYPES_H +#if !defined(ASSEMBLY) +#ifdef __cplusplus +extern "C" { +#endif + +#define PLATFORM_TYPES_H_VENDOR_ID 0x8C +#define PLATFORM_TYPES_H_AR_RELEASE_MAJOR_VERSION 4 +#define PLATFORM_TYPES_H_AR_RELEASE_MINOR_VERSION 3 +#define PLATFORM_TYPES_H_AR_RELEASE_REVISION_VERSION 1 +#define PLATFORM_TYPES_H_SW_MAJOR_VERSION 1 +#define PLATFORM_TYPES_H_SW_MINOR_VERSION 0 +#define PLATFORM_TYPES_H_SW_PATCH_VERSION 0 +#if defined(__ghs__) +#include +#endif + +#define CPU_TYPE_8 8u +#define CPU_TYPE_16 16u +#define CPU_TYPE_32 32u +#define CPU_TYPE_64 64u + +#define MSB_FIRST (0u) /* Big Endian bit ordering */ +#define LSB_FIRST (1u) /* Little Endian bit ordering */ +#define CPU_BIT_ORDER (LSB_FIRST) + +#define HIGH_BYTE_FIRST (0u) /* Big Endian byte ordering */ +#define LOW_BYTE_FIRST (1u) /* Little Endian byte ordering */ +#define CPU_BYTE_ORDER LOW_BYTE_FIRST /* Little Endian */ + +/** + * @brief Processor type + */ +#define CPU_TYPE (CPU_TYPE_32) /* 32 bit */ + +#ifndef TRUE +#define TRUE (1u) +#endif +#ifndef FALSE +#define FALSE (0u) +#endif + +#if (CPU_TYPE == CPU_TYPE_64) +typedef unsigned char boolean; +typedef unsigned char uint8; +typedef unsigned short uint16; +typedef unsigned int uint32; +typedef unsigned long long uint64; +typedef signed char sint8; +typedef signed short sint16; +typedef signed int sint32; +typedef signed long long sint64; + +/* Unsigned integer at least 8 bit long. Range of at least 0 ..+255 (0x00..0xFF) - 8 bit */ +typedef unsigned int uint8_least; +typedef unsigned int uint16_least; +typedef unsigned int uint32_least; + +/** + * Signed integer at least 8 bit long. Range - at least -128 ..+127. + * At least 7 bit + 1 bit sign + */ +typedef signed int sint8_least; +typedef signed int sint16_least; +typedef signed int sint32_least; + +typedef float float32; +typedef double float64; + +#elif (CPU_TYPE == CPU_TYPE_32) +typedef unsigned char boolean; +typedef unsigned char uint8; +typedef unsigned short uint16; +typedef unsigned long uint32; +typedef unsigned long long uint64; +typedef signed char sint8; +typedef signed short sint16; +typedef signed long sint32; +typedef signed long long sint64; +typedef unsigned long uint8_least; +typedef unsigned long uint16_least; +typedef unsigned long uint32_least; +typedef signed long sint8_least; +typedef signed long sint16_least; +typedef signed long sint32_least; +typedef float float32; +typedef double float64; + +#elif (CPU_TYPE == CPU_TYPE_16) +#error "This MCAL release has no CPU_TYPE_16 support." +#endif + +typedef volatile uint32 addr_t; +typedef volatile uint32 vaddr_t; +typedef volatile uint32 paddr_t; + +#ifdef __cplusplus +} +#endif +#endif +#endif /* #ifndef PLATFORM_TYPES_H */