Skip to content

Commit e989820

Browse files
actions-userozersa
authored andcommitted
Update Zephyr MSDK Hal based on MSDK PR: analogdevicesinc/msdk#1023
1 parent cf36b13 commit e989820

27 files changed

+568
-1037
lines changed

MAX/CMakeLists.txt

+1
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,7 @@ set(MSDK_PERIPH_INC_DIR ${MSDK_PERIPH_DIR}/Include/${TARGET_UC})
4040

4141
zephyr_include_directories(
4242
./Include
43+
${MSDK_LIBRARY_DIR}/CMSIS/Include
4344
${MSDK_CMSIS_DIR}/Include
4445
${MSDK_PERIPH_INC_DIR}
4546
)

MAX/Libraries/CMSIS/Device/Maxim/MAX32665/Include/max32665.h

+10-7
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,8 @@
2121
#ifndef LIBRARIES_CMSIS_DEVICE_MAXIM_MAX32665_INCLUDE_MAX32665_H_
2222
#define LIBRARIES_CMSIS_DEVICE_MAXIM_MAX32665_INCLUDE_MAX32665_H_
2323

24+
// clang-format off
25+
2426
#ifndef TARGET_NUM
2527
#define TARGET_NUM 32665
2628
#endif
@@ -178,15 +180,16 @@ typedef enum {
178180
/* ================================================================================ */
179181

180182
/* ---------------------- Configuration of the Cortex-M Processor and Core Peripherals ---------------------- */
181-
#define __CM4_REV 0x0100 /*!< Cortex-M4 Core Revision */
182-
#define __MPU_PRESENT 1 /*!< MPU present or not */
183-
#define __NVIC_PRIO_BITS 3 /*!< Number of Bits used for Priority Levels */
184-
#define __Vendor_SysTickConfig 0 /*!< Set to 1 if different SysTick Config is used */
185-
#define __FPU_PRESENT 1 /*!< FPU present or not */
183+
#define __CM4_REV 0x0100 /*!< Cortex-M4 Core Revision */
184+
#define __MPU_PRESENT 1 /*!< MPU present or not */
185+
#define __NVIC_PRIO_BITS 3 /*!< Number of Bits used for Priority Levels */
186+
#define __Vendor_SysTickConfig 0 /*!< Set to 1 if different SysTick Config is used */
187+
#define __FPU_PRESENT 1 /*!< FPU present or not */
186188

187-
#include <core_cm4.h> /*!< Cortex-M4 processor and core peripherals */
189+
#include <core_cm4.h> /*!< Cortex-M4 processor and core peripherals */
188190

189-
#include "system_max32665.h" /*!< System Header */
191+
#include "system_max32665.h" /*!< System Header */
192+
#include "system_core1_max32665.h" /*!< System Header for Core 1 */
190193

191194
/* ================================================================================ */
192195
/* ================== Device Specific Memory Section ================== */
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,59 @@
1+
/******************************************************************************
2+
*
3+
* Copyright (C) 2024 Analog Devices, Inc.
4+
*
5+
* Licensed under the Apache License, Version 2.0 (the "License");
6+
* you may not use this file except in compliance with the License.
7+
* You may obtain a copy of the License at
8+
*
9+
* http://www.apache.org/licenses/LICENSE-2.0
10+
*
11+
* Unless required by applicable law or agreed to in writing, software
12+
* distributed under the License is distributed on an "AS IS" BASIS,
13+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14+
* See the License for the specific language governing permissions and
15+
* limitations under the License.
16+
*
17+
******************************************************************************/
18+
19+
#ifndef LIBRARIES_CMSIS_DEVICE_MAXIM_MAX32665_INCLUDE_SYSTEM_CORE1_MAX32665_H_
20+
#define LIBRARIES_CMSIS_DEVICE_MAXIM_MAX32665_INCLUDE_SYSTEM_CORE1_MAX32665_H_
21+
22+
#ifdef __cplusplus
23+
extern "C" {
24+
#endif
25+
26+
#include <stdint.h>
27+
28+
/**
29+
* @brief Start Core 1 code.
30+
*/
31+
void Start_Core1(void);
32+
33+
/**
34+
* @brief Stops Core 1 by disabling CPU1 clock.
35+
*/
36+
void Stop_Core1(void);
37+
38+
/**
39+
* @brief Main function for Core 1 Code.
40+
* The user should override this function in their application code.
41+
*/
42+
int main_core1(void);
43+
44+
/**
45+
* @brief Equivalent to PreInit for Core 0,
46+
* Can be used for preliminary initialization.
47+
*/
48+
void PreInit_Core1(void);
49+
50+
/**
51+
* @brief Initialize the system for Core 1.
52+
*/
53+
void SystemInit_Core1(void);
54+
55+
#ifdef __cplusplus
56+
}
57+
#endif
58+
59+
#endif // LIBRARIES_CMSIS_DEVICE_MAXIM_MAX32665_INCLUDE_SYSTEM_CORE1_MAX32665_H_

MAX/Libraries/PeriphDrivers/Source/CORE1/system_core1.c renamed to MAX/Libraries/CMSIS/Device/Maxim/MAX32665/Source/system_core1_max32665.c

+32-30
Original file line numberDiff line numberDiff line change
@@ -18,64 +18,66 @@
1818
*
1919
******************************************************************************/
2020

21-
/**
22-
* @file core1startup.c
23-
* @brief Startup Code for MAX32665 Family CPU1
24-
* @details These functions are called at the startup of the second ARM core (CPU1/Core1)
25-
*/
2621
#include <string.h>
2722
#include <stdio.h>
2823
#include <stdlib.h>
29-
#include "max32665.h"
24+
#include "mxc_device.h"
3025
#include "mxc_sys.h"
3126
#include "gcr_regs.h"
32-
#include "icc_regs.h"
33-
#include "pwrseq_regs.h"
3427

35-
extern uint32_t __isr_vector_core1;
28+
extern void (*const __isr_vector_core1[])(void);
3629

37-
void Core1_Start(void)
30+
void Start_Core1(void)
3831
{
39-
MXC_GCR->gp0 = (uint32_t)(&__isr_vector_core1);
32+
// Save Core 1 vector table location in GCR.
33+
MXC_GCR->gp0 = (uint32_t)&__isr_vector_core1;
4034
MXC_GCR->perckcn1 &= ~MXC_F_GCR_PERCKCN1_CPU1D;
4135
}
4236

43-
void Core1_Stop(void)
37+
void Stop_Core1(void)
4438
{
4539
MXC_GCR->perckcn1 |= MXC_F_GCR_PERCKCN1_CPU1D;
4640
}
4741

48-
__weak int Core1_Main(void)
42+
/**
43+
* The user declares this in application code.
44+
*/
45+
__weak int main_core1(void)
4946
{
50-
// The user should declare this in application code, so we'll just spin
5147
while (1) {}
5248
}
49+
50+
/**
51+
* You may over-ride this function in your program by defining a custom
52+
* PreInit_Core1().
53+
*/
5354
__weak void PreInit_Core1(void)
5455
{
5556
return;
5657
}
5758

59+
/**
60+
* This function is called just before control is transferred to main()
61+
* on Core 1.
62+
*
63+
* You may over-ride this function in your program by defining a custom
64+
* SystemInit(), but care should be taken to reproduce the initialization
65+
* steps or a non-functional system may result.
66+
*/
5867
__weak void SystemInit_Core1(void)
5968
{
60-
/* Configure the interrupt controller to use the application vector table in
61-
* the application space */
69+
/**
70+
* Configure the interrupt controller to use the application vector
71+
* table in flash. Initially, VTOR points to the ROM's table.
72+
*/
6273
SCB->VTOR = (uint32_t)&__isr_vector_core1;
6374

64-
/* Enable FPU on Cortex-M4, which occupies coprocessor slots 10 & 11
65-
* Grant full access, per "Table B3-24 CPACR bit assignments".
66-
* DDI0403D "ARMv7-M Architecture Reference Manual" */
75+
/**
76+
* Enable FPU on Cortex-M4, which occupies coprocessor slots 10 & 11
77+
* Grant full access, per "Table B3-24 CPACR bit assignments".
78+
* DDI0403D "ARMv7-M Architecture Reference Manual"
79+
*/
6780
SCB->CPACR |= SCB_CPACR_CP10_Msk | SCB_CPACR_CP11_Msk;
6881
__DSB();
6982
__ISB();
70-
71-
// Enable ICache1 Clock
72-
MXC_GCR->perckcn1 &= ~(1 << 22);
73-
74-
// Invalidate cache and wait until ready
75-
MXC_ICC1->invalidate = 1;
76-
while (!(MXC_ICC1->cache_ctrl & MXC_F_ICC_CACHE_CTRL_RDY)) {}
77-
78-
// Enable Cache
79-
MXC_ICC1->cache_ctrl |= MXC_F_ICC_CACHE_CTRL_EN;
80-
while (!(MXC_ICC1->cache_ctrl & MXC_F_ICC_CACHE_CTRL_RDY)) {}
8183
}

MAX/Libraries/PeriphDrivers/Include/MAX32665/core1.h

+25-15
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,12 @@
2525
extern "C" {
2626
#endif
2727

28+
#include "mxc_device.h"
29+
30+
#warning "core1.h is deprecated (05-24-2024)."
31+
#warning "Use mxc_device.h instead, and set `ARM_DUALCORE=1` in project.mk"
32+
#warning "Core 1 Startup/System code is located at Libraries/CMSIS/Device/Maxim/MAX32665/"
33+
2834
/**
2935
* @file core1.h
3036
* @brief Startup Code for MAX32665 Family CPU1
@@ -35,32 +41,36 @@ extern "C" {
3541
* @brief Starts the code on core 1
3642
* Core1 code beings executing from Core1_Main()
3743
*/
38-
void Core1_Start(void);
44+
#if defined(__GNUC__)
45+
inline __attribute__((deprecated("Use Start_Core1(); instead."))) void Core1_Start(void)
46+
{
47+
Start_Core1();
48+
}
49+
#endif
3950

4051
/**
4152
* @brief Stops code executing in Core 1
4253
*/
43-
void Core1_Stop(void);
54+
#if defined(__GNUC__)
55+
inline __attribute__((deprecated("Use Stop_Core1(); instead."))) void Core1_Stop(void)
56+
{
57+
Stop_Core1();
58+
}
59+
#endif
4460

4561
/**
4662
* @brief Main function for Core 1 Code
4763
* The user should override this function
4864
* in their application code
4965
*/
50-
int Core1_Main(void);
51-
52-
/**
53-
* @brief Equivalent to PreInit for Core 0
54-
* Can be used for preliminary initialization
55-
*/
56-
void PreInit_Core1(void);
66+
#if defined(__GNUC__)
67+
inline __attribute__((deprecated(
68+
"Use `int main_core1(void)` instead - main_core1 is Core 1's entry point where code starts, not Core1_Main."))) int
69+
Core1_Main(void);
70+
#endif
5771

58-
/**
59-
* @brief Equivalent to PreInit for Core 1
60-
* Enables FPU, and ICache
61-
* Sets interrupt vector
62-
*/
63-
void SystemInit_Core1(void);
72+
// void PreInit_Core1(void) is now located in system_core_max32665.h
73+
// void SystemInit_Core1(void) is now located in system_core_max32665.h
6474

6575
#ifdef __cplusplus
6676
}

0 commit comments

Comments
 (0)