From 934fb9a0f6e759326179278a6c438f8d8afed6f3 Mon Sep 17 00:00:00 2001 From: GitHub Actions Date: Tue, 17 Dec 2024 19:14:34 +0000 Subject: [PATCH] Update Zephyr MSDK Hal based on MSDK PR: https://github.com/analogdevicesinc/msdk/pull/1285 --- .../CMSIS/Device/Maxim/MAX32657/Source/heap.c | 77 +++++++++++++++++++ .../Maxim/MAX32657/Source/system_max32657.c | 10 ++- .../PeriphDrivers/Source/UART/uart_me30.c | 16 +++- .../PeriphDrivers/Source/UART/uart_revb.c | 14 ++-- MAX/msdk_sha | 2 +- 5 files changed, 110 insertions(+), 9 deletions(-) diff --git a/MAX/Libraries/CMSIS/Device/Maxim/MAX32657/Source/heap.c b/MAX/Libraries/CMSIS/Device/Maxim/MAX32657/Source/heap.c index 80559e95..4409f35a 100644 --- a/MAX/Libraries/CMSIS/Device/Maxim/MAX32657/Source/heap.c +++ b/MAX/Libraries/CMSIS/Device/Maxim/MAX32657/Source/heap.c @@ -21,6 +21,7 @@ #include #include #include +#include /* sbrk @@ -48,3 +49,79 @@ caddr_t _sbrk(int incr) return (caddr_t)prev_heap_end; } + +// struct mallinfo { +// size_t arena; /* total space allocated from system */ +// size_t ordblks; /* number of non-inuse chunks */ +// size_t smblks; /* unused -- always zero */ +// size_t hblks; /* number of mmapped regions */ +// size_t hblkhd; /* total space in mmapped regions */ +// size_t usmblks; /* unused -- always zero */ +// size_t fsmblks; /* unused -- always zero */ +// size_t uordblks; /* total allocated space */ +// size_t fordblks; /* total non-inuse space */ +// size_t keepcost; /* top-most, releasable (via malloc_trim) space */ +// }; + +/* +The structure fields contain the following information: + + arena The total amount of memory allocated by means other than + mmap(2) (i.e., memory allocated on the heap). This figure + includes both in-use blocks and blocks on the free list. + + ordblks + The number of ordinary (i.e., non-fastbin) free blocks. + + smblks The number of fastbin free blocks (see mallopt(3)). + + hblks The number of blocks currently allocated using mmap(2). + (See the discussion of M_MMAP_THRESHOLD in mallopt(3).) + + hblkhd The number of bytes in blocks currently allocated using + mmap(2). + + usmblks + This field is unused, and is always 0. Historically, it + was the "highwater mark" for allocated space—that is, the + maximum amount of space that was ever allocated (in + bytes); this field was maintained only in nonthreading + environments. + + fsmblks + The total number of bytes in fastbin free blocks. + + uordblks + The total number of bytes used by in-use allocations. + + fordblks + The total number of bytes in free blocks. + + keepcost + The total amount of releasable free space at the top of + the heap. This is the maximum number of bytes that could + ideally (i.e., ignoring page alignment restrictions, and + so on) be released by malloc_trim(3). +*/ + +struct mallinfo mallinfo(void) +{ + struct mallinfo temp_mallinfo; + + if (heap_end == 0) { + heap_end = (caddr_t)&__HeapBase; + } + + temp_mallinfo.arena = ((size_t)&__HeapLimit - (size_t)&__HeapBase); + temp_mallinfo.ordblks = 0; /* Unused */ + temp_mallinfo.smblks = 0; /* Unused */ + temp_mallinfo.hblks = 0; /* Unused */ + temp_mallinfo.hblkhd = 0; /* Unused */ + temp_mallinfo.usmblks = 0; /* Unused */ + temp_mallinfo.fsmblks = 0; /* Unused */ + temp_mallinfo.uordblks = (size_t)heap_end - (size_t)&__HeapBase; + temp_mallinfo.fordblks = (size_t)&__HeapLimit - (size_t)heap_end; + temp_mallinfo.keepcost = 0 /* Unused */; + + return temp_mallinfo; +} diff --git a/MAX/Libraries/CMSIS/Device/Maxim/MAX32657/Source/system_max32657.c b/MAX/Libraries/CMSIS/Device/Maxim/MAX32657/Source/system_max32657.c index 2c15ccba..48e262b7 100644 --- a/MAX/Libraries/CMSIS/Device/Maxim/MAX32657/Source/system_max32657.c +++ b/MAX/Libraries/CMSIS/Device/Maxim/MAX32657/Source/system_max32657.c @@ -26,6 +26,7 @@ #include "system_max32657.h" #include "gcr_regs.h" #include "mpc.h" +#include "icc.h" #if defined(__ARM_FEATURE_CMSE) && (__ARM_FEATURE_CMSE == 3U) #include "partition_max32657.h" @@ -130,6 +131,9 @@ __weak int Board_Init(void) return 0; } +/* This function is used for the Bluetooth stack initialization */ +__weak void PalSysInit(void) {} + /** * This function is called just before control is transferred to main(). * @@ -171,8 +175,8 @@ __weak void SystemInit(void) /* Enable interrupts */ __enable_irq(); - // TODO(ICC): Enable the internal cache controller after testing. - // MXC_ICC_Enable(); + // Enable the internal cache controller. + MXC_ICC_Enable(); /* Change system clock source to the main high-speed clock */ MXC_SYS_Clock_Select(MXC_SYS_CLOCK_IPO); @@ -181,6 +185,8 @@ __weak void SystemInit(void) PinInit(); Board_Init(); + + PalSysInit(); } #if defined(__ARM_FEATURE_CMSE) && (__ARM_FEATURE_CMSE == 3U) diff --git a/MAX/Libraries/PeriphDrivers/Source/UART/uart_me30.c b/MAX/Libraries/PeriphDrivers/Source/UART/uart_me30.c index 9963fa84..29e80435 100644 --- a/MAX/Libraries/PeriphDrivers/Source/UART/uart_me30.c +++ b/MAX/Libraries/PeriphDrivers/Source/UART/uart_me30.c @@ -77,6 +77,11 @@ int MXC_UART_Init(mxc_uart_regs_t *uart, unsigned int baud, mxc_uart_clock_t clo } #endif // MSDK_NO_GPIO_CLK_INIT + retval = MXC_UART_SetClockSource(uart, clock); + if (retval != E_NO_ERROR) { + return retval; + } + return MXC_UART_RevB_Init((mxc_uart_revb_regs_t *)uart, baud, clock); } @@ -173,7 +178,16 @@ int MXC_UART_SetFlowCtrl(mxc_uart_regs_t *uart, mxc_uart_flow_t flowCtrl, int rt int MXC_UART_SetClockSource(mxc_uart_regs_t *uart, mxc_uart_clock_t clock) { - return MXC_UART_RevB_SetClockSource((mxc_uart_revb_regs_t *)uart, clock); + switch (clock) { + case MXC_UART_APB_CLK: + return MXC_UART_RevB_SetClockSource((mxc_uart_revb_regs_t *)uart, 0); + + case MXC_UART_IBRO_CLK: + return MXC_UART_RevB_SetClockSource((mxc_uart_revb_regs_t *)uart, 1); + + default: + return E_BAD_PARAM; + } } int MXC_UART_GetActive(mxc_uart_regs_t *uart) diff --git a/MAX/Libraries/PeriphDrivers/Source/UART/uart_revb.c b/MAX/Libraries/PeriphDrivers/Source/UART/uart_revb.c index 83e99ad0..49522049 100644 --- a/MAX/Libraries/PeriphDrivers/Source/UART/uart_revb.c +++ b/MAX/Libraries/PeriphDrivers/Source/UART/uart_revb.c @@ -636,7 +636,7 @@ int MXC_UART_RevB_Transaction(mxc_uart_revb_req_t *req) while (req->txCnt < req->txLen) { while (!(MXC_UART_GetFlags((mxc_uart_regs_t *)(req->uart)) & - MXC_F_UART_REVB_INT_FL_TX_HE) && + (MXC_F_UART_REVB_INT_FL_TX_HE | MXC_F_UART_REVB_INT_FL_TX_OB)) && !(req->uart->status & MXC_F_UART_REVB_STATUS_TX_EM)) {} numToWrite = MXC_UART_GetTXFIFOAvailable((mxc_uart_regs_t *)(req->uart)); @@ -644,7 +644,8 @@ int MXC_UART_RevB_Transaction(mxc_uart_revb_req_t *req) numToWrite; req->txCnt += MXC_UART_WriteTXFIFO((mxc_uart_regs_t *)(req->uart), &req->txData[req->txCnt], numToWrite); - MXC_UART_ClearFlags((mxc_uart_regs_t *)(req->uart), MXC_F_UART_REVB_INT_FL_TX_HE); + MXC_UART_ClearFlags((mxc_uart_regs_t *)(req->uart), + (MXC_F_UART_REVB_INT_FL_TX_HE | MXC_F_UART_REVB_INT_FL_TX_OB)); } } @@ -709,7 +710,8 @@ int MXC_UART_RevB_TransactionAsync(mxc_uart_revb_req_t *req) NVIC_SetPendingIRQ(MXC_UART_GET_IRQ(uart_num)); } else { /* Else enable the half empty interrupt */ - MXC_UART_EnableInt((mxc_uart_regs_t *)(req->uart), MXC_F_UART_REVB_INT_EN_TX_HE); + MXC_UART_EnableInt((mxc_uart_regs_t *)(req->uart), + (MXC_F_UART_REVB_INT_EN_TX_HE | MXC_F_UART_REVB_INT_EN_TX_OB)); } } @@ -783,7 +785,8 @@ int MXC_UART_RevB_AsyncCallback(mxc_uart_revb_regs_t *uart, int retVal) int MXC_UART_RevB_AsyncStopTx(mxc_uart_revb_regs_t *uart) { - MXC_UART_DisableInt((mxc_uart_regs_t *)uart, MXC_F_UART_REVB_INT_EN_TX_HE); + MXC_UART_DisableInt((mxc_uart_regs_t *)uart, + (MXC_F_UART_REVB_INT_EN_TX_HE | MXC_F_UART_REVB_INT_EN_TX_OB)); return E_NO_ERROR; } @@ -838,7 +841,8 @@ int MXC_UART_RevB_AsyncHandler(mxc_uart_revb_regs_t *uart) numToWrite = MXC_UART_WriteTXFIFO((mxc_uart_regs_t *)(req->uart), &req->txData[req->txCnt], numToWrite); req->txCnt += numToWrite; - MXC_UART_ClearFlags(req->uart, MXC_F_UART_REVB_INT_FL_TX_HE); + MXC_UART_ClearFlags(req->uart, + (MXC_F_UART_REVB_INT_FL_TX_HE | MXC_F_UART_REVB_INT_FL_TX_OB)); } req = (mxc_uart_req_t *)AsyncRxRequests[uart_num]; diff --git a/MAX/msdk_sha b/MAX/msdk_sha index f1914810..e3028e60 100644 --- a/MAX/msdk_sha +++ b/MAX/msdk_sha @@ -1 +1 @@ -1b95c3c0d3cedfa086518f2c628723007cac838d +6e61aa32b0dc0b7ef6e8476c039e2aacb792fc1c