Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Get updates for HWINFO, USB AND MAX32650 #15

Merged
merged 4 commits into from
Feb 10, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 18 additions & 0 deletions MAX/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,24 @@ zephyr_include_directories(
${MSDK_PERIPH_INC_DIR}
)

if (CONFIG_UDC_MAX32)
zephyr_compile_definitions(
-DUSE_ZEPHYR_USB_STACK=1
)

set(MSDK_MAXUSB_DIR ${MSDK_LIBRARY_DIR}/MAXUSB)

zephyr_include_directories(
${MSDK_MAXUSB_DIR}/include/core
${MSDK_MAXUSB_DIR}/include/core/musbhsfc
)

zephyr_library_sources(
${MSDK_MAXUSB_DIR}/src/core/usb_event.c
${MSDK_MAXUSB_DIR}/src/core/musbhsfc/usb.c
)
endif()

add_subdirectory_ifdef(CONFIG_SOC_MAX32520 Source/MAX32520)
add_subdirectory_ifdef(CONFIG_SOC_MAX32570 Source/MAX32570)
add_subdirectory_ifdef(CONFIG_SOC_MAX32572 Source/MAX32572)
Expand Down
11 changes: 9 additions & 2 deletions MAX/Include/wrap_max32_sys.h
Original file line number Diff line number Diff line change
Expand Up @@ -34,14 +34,21 @@ void max32xx_system_init(void);
/*
* MAX32665, MAX32666 related mapping
*/
#if defined(CONFIG_SOC_MAX32665) || (CONFIG_SOC_MAX32666)
#if defined(CONFIG_SOC_MAX32665) || defined(CONFIG_SOC_MAX32666) || \
defined(CONFIG_SOC_MAX32650)

#define ADI_MAX32_CLK_IPO MXC_SYS_CLOCK_HIRC96
#define ADI_MAX32_CLK_ERFO MXC_SYS_CLOCK_XTAL32M
#define ADI_MAX32_CLK_IBRO MXC_SYS_CLOCK_HIRC8
#if !defined(CONFIG_SOC_MAX32650)
#define ADI_MAX32_CLK_ERFO MXC_SYS_CLOCK_XTAL32M
#define ADI_MAX32_CLK_ISO MXC_SYS_CLOCK_HIRC
#define ADI_MAX32_CLK_INRO MXC_SYS_CLOCK_LIRC8K
#define ADI_MAX32_CLK_ERTCO MXC_SYS_CLOCK_XTAL32K
#else
#define ADI_MAX32_CLK_ISO MXC_SYS_CLOCK_HFXIN
#define ADI_MAX32_CLK_INRO MXC_SYS_CLOCK_NANORING
#define ADI_MAX32_CLK_ERTCO MXC_SYS_CLOCK_X32K
#endif

#define z_sysclk_prescaler(v) MXC_SYS_SYSTEM_DIV_##v
#define sysclk_prescaler(v) z_sysclk_prescaler(v)
Expand Down
28 changes: 27 additions & 1 deletion MAX/Include/wrap_max32_uart.h
Original file line number Diff line number Diff line change
Expand Up @@ -26,26 +26,47 @@
extern "C" {
#endif

#if defined(CONFIG_SOC_MAX32665) || (CONFIG_SOC_MAX32666)
#if defined(CONFIG_SOC_MAX32665) || defined(CONFIG_SOC_MAX32666) || \
defined(CONFIG_SOC_MAX32650)
#if !defined(CONFIG_SOC_MAX32650)
// status flags
#define ADI_MAX32_UART_RX_EMPTY MXC_F_UART_STATUS_RX_EMPTY
#define ADI_MAX32_UART_TX_EMPTY MXC_F_UART_STATUS_TX_EMPTY
#define ADI_MAX32_UART_STATUS_TX_FULL MXC_F_UART_STATUS_TX_FULL
// error flags
#define ADI_MAX32_UART_ERROR_OVERRUN MXC_F_UART_INT_FL_RX_OVERRUN
#define ADI_MAX32_UART_ERROR_PARITY MXC_F_UART_INT_FL_RX_PARITY_ERROR
#define ADI_MAX32_UART_ERROR_FRAMING MXC_F_UART_INT_FL_RX_FRAME_ERROR
#else
// status flags
#define ADI_MAX32_UART_RX_EMPTY MXC_F_UART_STAT_RX_EMPTY
#define ADI_MAX32_UART_TX_EMPTY MXC_F_UART_STAT_TX_EMPTY
#define ADI_MAX32_UART_STATUS_TX_FULL MXC_F_UART_STAT_TX_FULL
// error flags
#define ADI_MAX32_UART_ERROR_OVERRUN MXC_F_UART_INT_FL_RX_OVR
#define ADI_MAX32_UART_ERROR_PARITY MXC_F_UART_INT_FL_PARITY
#define ADI_MAX32_UART_ERROR_FRAMING MXC_F_UART_INT_FL_FRAME
#endif
// interrupt flag
#define ADI_MAX32_UART_INT_EOT MXC_F_UART_INT_EN_LAST_BREAK // End Of Transmission Interrupt
#define ADI_MAX32_UART_INT_OE MXC_F_UART_INT_EN_RX_OVERRUN // Overrun Error Interrupt
#define ADI_MAX32_UART_INT_BE MXC_F_UART_INT_EN_BREAK // Break Error Interrupt
#define ADI_MAX32_UART_INT_PE MXC_F_UART_INT_EN_RX_PARITY_ERROR // Parity Error Interrupt
#define ADI_MAX32_UART_INT_FE MXC_F_UART_INT_EN_RX_FRAME_ERROR // Framing Error Interrupt
#if !defined(CONFIG_SOC_MAX32650)
#define ADI_MAX32_UART_INT_RT MXC_F_UART_INT_EN_RX_TIMEOUT // Receive Timeout Interrupt
#define ADI_MAX32_UART_INT_TX MXC_F_UART_INT_EN_TX_FIFO_THRESH // Transmit Interrupt
#define ADI_MAX32_UART_INT_RX MXC_F_UART_INT_EN_RX_FIFO_THRESH // Receive Interrupt
#define ADI_MAX32_UART_INT_CTS MXC_F_UART_INT_EN_CTS_CHANGE // CTS Modem Interrupt
#define ADI_MAX32_UART_INT_TX_OEM \
MXC_F_UART_INT_EN_TX_FIFO_ALMOST_EMPTY // TX FIFO Almost Empty Interrupt
#else
#define ADI_MAX32_UART_INT_RT MXC_F_UART_INT_EN_RX_TO // Receive Timeout Interrupt
#define ADI_MAX32_UART_INT_TX MXC_F_UART_INT_EN_TX_FIFO_LVL // Transmit Interrupt
#define ADI_MAX32_UART_INT_RX MXC_F_UART_INT_EN_RX_FIFO_LVL // Receive Interrupt
#define ADI_MAX32_UART_INT_CTS MXC_F_UART_INT_EN_CTS // CTS Modem Interrupt
#define ADI_MAX32_UART_INT_TX_OEM MXC_F_UART_INT_EN_TX_FIFO_AE // TX FIFO Almost Empty Interrupt
#endif
// parity
#define ADI_MAX32_UART_CFG_PARITY_NONE MXC_UART_PARITY_DISABLE
#define ADI_MAX32_UART_CFG_PARITY_ODD MXC_UART_PARITY_ODD
Expand All @@ -72,7 +93,11 @@ static inline int Wrap_MXC_UART_Init(mxc_uart_regs_t *uart)
return ret;
}

#if defined(CONFIG_SOC_MAX32650)
uart->ctrl0 |= MXC_F_UART_CTRL0_ENABLE;
#else
uart->ctrl |= MXC_F_UART_CTRL_ENABLE;
#endif

return ret;
}
Expand Down Expand Up @@ -126,6 +151,7 @@ static inline void Wrap_MXC_UART_DisableRxDMA(mxc_uart_regs_t *uart)
// status flags
#define ADI_MAX32_UART_RX_EMPTY MXC_F_UART_STATUS_RX_EM
#define ADI_MAX32_UART_TX_EMPTY MXC_F_UART_STATUS_TX_EM
#define ADI_MAX32_UART_STATUS_TX_FULL MXC_F_UART_STATUS_TX_FULL

#if defined(CONFIG_SOC_MAX32662)
// error flags
Expand Down
59 changes: 59 additions & 0 deletions MAX/Include/wrap_max32_usb.h
Original file line number Diff line number Diff line change
@@ -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 <usb.h>
#include <usb_event.h>
#include <mcr_regs.h>

#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_
10 changes: 5 additions & 5 deletions MAX/Libraries/CMSIS/Device/Maxim/MAX32650/Include/uart_regs.h
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
*
* Copyright (C) 2022-2023 Maxim Integrated Products, Inc. (now owned by
* Analog Devices, Inc.),
* Copyright (C) 2023-2024 Analog Devices, Inc.
* Copyright (C) 2023-2025 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.
Expand Down Expand Up @@ -506,11 +506,11 @@ typedef struct {
#define MXC_V_UART_DMA_RXDMA_EN_EN ((uint32_t)0x1UL) /**< DMA_RXDMA_EN_EN Value */
#define MXC_S_UART_DMA_RXDMA_EN_EN (MXC_V_UART_DMA_RXDMA_EN_EN << MXC_F_UART_DMA_RXDMA_EN_POS) /**< DMA_RXDMA_EN_EN Setting */

#define MXC_F_UART_DMA_TXDMA_LVL_POS 8 /**< DMA_TXDMA_LVL Position */
#define MXC_F_UART_DMA_TXDMA_LVL ((uint32_t)(0x3FUL << MXC_F_UART_DMA_TXDMA_LVL_POS)) /**< DMA_TXDMA_LVL Mask */
#define MXC_F_UART_DMA_TXDMA_LEVEL_POS 8 /**< DMA_TXDMA_LVL Position */
#define MXC_F_UART_DMA_TXDMA_LEVEL ((uint32_t)(0x3FUL << MXC_F_UART_DMA_TXDMA_LEVEL_POS)) /**< DMA_TXDMA_LVL Mask */

#define MXC_F_UART_DMA_RXDMA_LVL_POS 16 /**< DMA_RXDMA_LVL Position */
#define MXC_F_UART_DMA_RXDMA_LVL ((uint32_t)(0x3FUL << MXC_F_UART_DMA_RXDMA_LVL_POS)) /**< DMA_RXDMA_LVL Mask */
#define MXC_F_UART_DMA_RXDMA_LEVEL_POS 16 /**< DMA_RXDMA_LVL Position */
#define MXC_F_UART_DMA_RXDMA_LEVEL ((uint32_t)(0x3FUL << MXC_F_UART_DMA_RXDMA_LEVEL_POS)) /**< DMA_RXDMA_LVL Mask */

/**@} end of group UART_DMA_Register */

Expand Down
63 changes: 63 additions & 0 deletions MAX/Libraries/MAXUSB/include/core/musbhsfc/usb_hwopt.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
/******************************************************************************
*
* Copyright (C) 2022-2023 Maxim Integrated Products, Inc. (now owned by
* Analog Devices, Inc.),
* Copyright (C) 2023-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_MAXUSB_INCLUDE_CORE_MUSBHSFC_USB_HWOPT_H_
#define LIBRARIES_MAXUSB_INCLUDE_CORE_MUSBHSFC_USB_HWOPT_H_

#include "mxc_device.h"
#include "usbhs_regs.h"

#ifdef __cplusplus
extern "C" {
#endif

/* Configuration options for MUSBHSFC */
typedef struct {
unsigned int enable_hs; /* 0 = full-speed only, otherwise high-speed if negotiated */
void (*delay_us)(unsigned int usec); /* User-supplied function to delay usec micro-seconds */
int (*init_callback)(void); /* User-supplied function for initializing the USB block */
int (*shutdown_callback)(void); /* User-supplied function for shutting down the USB block */
} maxusb_cfg_options_t;

/**
* @brief Put the transceiver into a low power state.
*/
void MXC_USB_Sleep(void);

/**
* @brief Power up the USB transceiver, must be called once the device wakes from sleep.
*/
void MXC_USB_Wakeup(void);

/**
* @brief Send a remote wakeup signal to the host.
*/
void MXC_USB_RemoteWakeup(void);

/*
* @brief USB internal DMA engine interrupt handler
*/
void MXC_USB_DmaIsr(void);

#ifdef __cplusplus
}
#endif

#endif //LIBRARIES_MAXUSB_INCLUDE_CORE_MUSBHSFC_USB_HWOPT_H_
Loading