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

chore(Other): Add zephyr related wrapper and system file in MSDK #990

Merged
merged 3 commits into from
Apr 16, 2024
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
31 changes: 17 additions & 14 deletions .github/workflows/scripts/zephyr-hal.sh
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,6 @@ else
hal_adi="./hal_adi"
fi

src="${msdk}/Libraries"
dst="${hal_adi}/MAX/Libraries"

root_dir=$(pwd)

# Get SHA
Expand All @@ -24,29 +21,35 @@ cd ${root_dir}


# Cleanup hal_adi
rm -rf ${dst}/CMSIS/*
rm -rf ${dst}/PeriphDrivers/*
rm -rf ${hal_adi}/MAX/

# Create parent folder
mkdir -p ${hal_adi}/MAX/Libraries/CMSIS
mkdir -p ${hal_adi}/MAX/Libraries/PeriphDrivers

# Copy zephyr wrappers, system files and cmakefiles
cp -rf ${msdk}/Libraries/zephyr/MAX/* ${hal_adi}/MAX/

# Copy CMSIS folder
cp -rf ${src}/CMSIS/Device ${dst}/CMSIS/
cp -rf ${src}/CMSIS/Include ${dst}/CMSIS/
cp -rf ${msdk}/Libraries/CMSIS/Device ${hal_adi}/MAX/Libraries/CMSIS/
cp -rf ${msdk}/Libraries/CMSIS/Include ${hal_adi}/MAX/Libraries/CMSIS/

# Copy PeriphDrivers folder
cp -rf ${src}/PeriphDrivers/Include ${dst}/PeriphDrivers/
cp -rf ${src}/PeriphDrivers/Source ${dst}/PeriphDrivers/
cp -rf ${msdk}/Libraries/PeriphDrivers/Include ${hal_adi}/MAX/Libraries/PeriphDrivers/
cp -rf ${msdk}/Libraries/PeriphDrivers/Source ${hal_adi}/MAX/Libraries/PeriphDrivers/

# Remove unneeded files
rm -rf ${dst}/CMSIS/Device/Maxim/GCC
rm -rf ${dst}/CMSIS/Device/Maxim/MAX*/Source/IAR
rm -rf ${dst}/CMSIS/Device/Maxim/MAX*/Source/GCC
rm -rf ${dst}/CMSIS/Device/Maxim/MAX*/Source/ARM
rm -rf ${hal_adi}/MAX/Libraries/CMSIS/Device/Maxim/GCC
rm -rf ${hal_adi}/MAX/Libraries/CMSIS/Device/Maxim/MAX*/Source/IAR
rm -rf ${hal_adi}/MAX/Libraries/CMSIS/Device/Maxim/MAX*/Source/GCC
rm -rf ${hal_adi}/MAX/Libraries/CMSIS/Device/Maxim/MAX*/Source/ARM

# Check either dirty or clean
cd ${hal_adi}
if [[ -n $(git status -s) ]]; then
echo "New change exist need to be pushed"
# Set new SHA
echo "${msdk_head}" > MAX/Libraries/msdk_sha
echo "${msdk_head}" > MAX/msdk_sha
else
# No need to push to hal_adi
echo "No any change in hal_adi"
Expand Down
62 changes: 62 additions & 0 deletions Libraries/zephyr/MAX/CMakeLists.txt
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@ozersa does this add the source files to the top-level build? Since Zephyr uses CMake it would also be nice to start setting things up more modularly for each library to support find_package

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks noted.

Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
##############################################################################
#
# 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.
#
##############################################################################


if (${CONFIG_SOC} MATCHES "max32666")
set(TARGET_LC "max32665")
elseif (${CONFIG_SOC} MATCHES "max326651")
set(TARGET_LC "max32650")
else ()
set(TARGET_LC ${CONFIG_SOC})
endif()
string(TOUPPER ${TARGET_LC} TARGET_UC)

zephyr_compile_definitions(
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@ozersa also suggest adding -D${TARGET_UC}

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks, will consider on next update.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@Jake-Carter I took a look it now, to apply it on #996
But a little confused.
Do you propose replacing
-DTARGET=${TARGET_UC} with -DTARGET=-D${TARGET_UC} ?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@ozersa just to have both TARGET and the actual value of TARGET_UC defined.

zephyr_compile_definitions(
    -D${TARGET_UC}
    -DTARGET=${TARGET_UC}
    ...
)

Some places in the drivers need to check the target value. Since the pre-processor can't do string comparisons sometimes TARGET_UC itself is checked.

#ifdef MAX78000
// ...
#endif

-DTARGET=${TARGET_UC}
-DMSDK_NO_GPIO_CLK_INIT=1
-DMSDK_NO_LOCKING=1
)

get_filename_component(MSDK_LIBRARY_DIR "./Libraries" ABSOLUTE)
set(MSDK_CMSIS_DIR ${MSDK_LIBRARY_DIR}/CMSIS/Device/Maxim/${TARGET_UC})
set(MSDK_PERIPH_DIR ${MSDK_LIBRARY_DIR}/PeriphDrivers)
set(MSDK_PERIPH_SRC_DIR ${MSDK_PERIPH_DIR}/Source)
set(MSDK_PERIPH_INC_DIR ${MSDK_PERIPH_DIR}/Include/${TARGET_UC})

zephyr_include_directories(
./Include
${MSDK_CMSIS_DIR}/Include
${MSDK_PERIPH_INC_DIR}
)

add_subdirectory_ifdef(CONFIG_SOC_MAX32520 Source/MAX32520)
add_subdirectory_ifdef(CONFIG_SOC_MAX32570 Source/MAX32570)
add_subdirectory_ifdef(CONFIG_SOC_MAX32572 Source/MAX32572)
add_subdirectory_ifdef(CONFIG_SOC_MAX32650 Source/MAX32650)
add_subdirectory_ifdef(CONFIG_SOC_MAX32655 Source/MAX32655)
add_subdirectory_ifdef(CONFIG_SOC_MAX32660 Source/MAX32660)
add_subdirectory_ifdef(CONFIG_SOC_MAX32662 Source/MAX32662)
add_subdirectory_ifdef(CONFIG_SOC_MAX32665 Source/MAX32665)
add_subdirectory_ifdef(CONFIG_SOC_MAX32666 Source/MAX32665)
add_subdirectory_ifdef(CONFIG_SOC_MAX32670 Source/MAX32670)
add_subdirectory_ifdef(CONFIG_SOC_MAX32672 Source/MAX32672)
add_subdirectory_ifdef(CONFIG_SOC_MAX32675 Source/MAX32675)
add_subdirectory_ifdef(CONFIG_SOC_MAX32680 Source/MAX32680)
add_subdirectory_ifdef(CONFIG_SOC_MAX32690 Source/MAX32690)
add_subdirectory_ifdef(CONFIG_SOC_MAX78000 Source/MAX78000)
add_subdirectory_ifdef(CONFIG_SOC_MAX78002 Source/MAX78002)
Loading
Loading