From c343ed972e0b86d615c5d0f1260c9d6a589f7fa0 Mon Sep 17 00:00:00 2001 From: GitHub Actions Date: Thu, 19 Dec 2024 20:31:55 +0000 Subject: [PATCH] Update Zephyr MSDK Hal based on MSDK PR: https://github.com/analogdevicesinc/msdk/pull/1305 --- MAX/Include/wrap_max32_can.h | 56 ++++++++++++++++++++++++++++++++++ MAX/Include/wrap_max32_dma.h | 10 ++++++ MAX/Include/wrap_max32_usb.h | 59 ++++++++++++++++++++++++++++++++++++ MAX/msdk_sha | 2 +- 4 files changed, 126 insertions(+), 1 deletion(-) create mode 100644 MAX/Include/wrap_max32_can.h create mode 100644 MAX/Include/wrap_max32_usb.h diff --git a/MAX/Include/wrap_max32_can.h b/MAX/Include/wrap_max32_can.h new file mode 100644 index 0000000..9f8d992 --- /dev/null +++ b/MAX/Include/wrap_max32_can.h @@ -0,0 +1,56 @@ +/****************************************************************************** + * + * Copyright (C) 2024 Analog Devices, Inc. + * + * 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 LIBRARIES_ZEPHYR_MAX_INCLUDE_WRAP_MAX32_CAN_H_ +#define LIBRARIES_ZEPHYR_MAX_INCLUDE_WRAP_MAX32_CAN_H_ + +/***** Includes *****/ +#include + +#ifdef __cplusplus +extern "C" { +#endif + +static inline void Wrap_MXC_CAN_Init(uint32_t can_idx, mxc_can_obj_cfg_t cfg, + mxc_can_unit_event_cb_t unit_cb, + mxc_can_object_event_cb_t obj_cb) +{ + /* The only API difference between the MAX32662 and MAX32690 relevant to + * implementing the max32 CAN driver in Zephyr is that the former requires a + * GPIO mapping parameter, which is not used anyway (MSDK_NO_GPIO_CLK_INIT). + */ + + /* MAX32662 related mapping */ +#if defined(CONFIG_SOC_MAX32662) + /* A value of -1 is invalid, will configure no GPIOs, but still pass through + * to MXC_CAN_RevA_Init, even in case MSDK_NO_GPIO_CLK_INIT wasn't set. + */ + MXC_CAN_Init(can_idx, cfg, unit_cb, obj_cb, -1); + + /* MAX32690 related mapping */ +#elif defined(CONFIG_SOC_MAX32690) + MXC_CAN_Init(can_idx, cfg, unit_cb, obj_cb); + +#endif // part number +} + +#ifdef __cplusplus +} +#endif + +#endif // LIBRARIES_ZEPHYR_MAX_INCLUDE_WRAP_MAX32_CAN_H_ diff --git a/MAX/Include/wrap_max32_dma.h b/MAX/Include/wrap_max32_dma.h index 5690ced..1cd0377 100644 --- a/MAX/Include/wrap_max32_dma.h +++ b/MAX/Include/wrap_max32_dma.h @@ -87,6 +87,16 @@ static inline int Wrap_MXC_DMA_AcquireChannel(mxc_dma_regs_t *dma) #endif } +static inline int Wrap_MXC_DMA_GetChannelIndex(mxc_dma_regs_t *dma, uint8_t ch) +{ +#if defined(CONFIG_SOC_MAX32657) + (void)dma; + return ch; +#else + return (ch + MXC_DMA_GET_IDX(dma) * (MXC_DMA_CHANNELS / MXC_DMA_INSTANCES)); +#endif +} + static inline void Wrap_MXC_DMA_Handler(mxc_dma_regs_t *dma) { #if defined(CONFIG_SOC_MAX32657) || defined(CONFIG_SOC_MAX32665) || defined(CONFIG_SOC_MAX32666) diff --git a/MAX/Include/wrap_max32_usb.h b/MAX/Include/wrap_max32_usb.h new file mode 100644 index 0000000..961e6c9 --- /dev/null +++ b/MAX/Include/wrap_max32_usb.h @@ -0,0 +1,59 @@ +/****************************************************************************** + * + * Copyright (C) 2024 Analog Devices, Inc. + * + * 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 LIBRARIES_ZEPHYR_MAX_INCLUDE_WRAP_MAX32_USB_H_ +#define LIBRARIES_ZEPHYR_MAX_INCLUDE_WRAP_MAX32_USB_H_ + +/***** Includes *****/ +#include +#include +#include + +#ifdef __cplusplus +extern "C" { +#endif + +/* + * MAX32665, MAX32666 related mapping + */ +#if defined(CONFIG_SOC_MAX32665) || (CONFIG_SOC_MAX32666) + +static inline int Wrap_MXC_USB_Init(maxusb_cfg_options_t *options) +{ + return MXC_USB_Init(options); +} + +/* + * MAX32690 related mapping + */ +#elif defined(CONFIG_SOC_MAX32690) + +static inline int Wrap_MXC_USB_Init(maxusb_cfg_options_t *options) +{ + MXC_MCR->ldoctrl |= MXC_F_MCR_LDOCTRL_0P9EN; + + return MXC_USB_Init(options); +} + +#endif // part number + +#ifdef __cplusplus +} +#endif + +#endif // LIBRARIES_ZEPHYR_MAX_INCLUDE_WRAP_MAX32_USB_H_ diff --git a/MAX/msdk_sha b/MAX/msdk_sha index d88cfda..4ed7401 100644 --- a/MAX/msdk_sha +++ b/MAX/msdk_sha @@ -1 +1 @@ -b1e26c4a3111763c9663691ed7455739665da5e3 +506501c5caba0fd4d331c65449545fb5e17de089