diff --git a/wiseconnect/components/device/silabs/si91x/mcu/core/common/src/rsi_debug.c b/wiseconnect/components/device/silabs/si91x/mcu/core/common/src/rsi_debug.c deleted file mode 100644 index d8f19ec72..000000000 --- a/wiseconnect/components/device/silabs/si91x/mcu/core/common/src/rsi_debug.c +++ /dev/null @@ -1,492 +0,0 @@ -/******************************************************************************* -* @file rsi_debug.c -* @brief -******************************************************************************* -* # License -* Copyright 2025 Silicon Laboratories Inc. www.silabs.com -******************************************************************************* -* -* SPDX-License-Identifier: Zlib -* -* The licensor of this software is Silicon Laboratories Inc. -* -* This software is provided 'as-is', without any express or implied -* warranty. In no event will the authors be held liable for any damages -* arising from the use of this software. -* -* Permission is granted to anyone to use this software for any purpose, -* including commercial applications, and to alter it and redistribute it -* freely, subject to the following restrictions: -* -* 1. The origin of this software must not be misrepresented; you must not -* claim that you wrote the original software. If you use this software -* in a product, an acknowledgment in the product documentation would be -* appreciated but is not required. -* 2. Altered source versions must be plainly marked as such, and must not be -* misrepresented as being the original software. -* 3. This notice may not be removed or altered from any source distribution. -* -******************************************************************************/ - -#include -#include "rsi_debug.h" -#include "USART.h" -#include "rsi_ccp_common.h" -#if defined(SL_COMPONENT_CATALOG_PRESENT) -#include "sl_component_catalog.h" -#endif /* SL_COMPONENT_CATALOG_PRESENT */ - -#ifdef SL_CATALOG_KERNEL_PRESENT -#include "cmsis_os2.h" -osMutexId_t si91x_prints_mutex = NULL; -#endif - -void ARM_UART_SignalEvent(uint32_t event); -extern void cache_uart_rx_data(const char character); - -#ifdef DEBUG_UART_UC -#define BOARD_BAUD_VALUE SL_DEBUG_BAUD_RATE //UART baud rate - -#if (SL_DEBUG_INSTANCE == SL_M4_USART0_INSTANCE) -#define M4_UART1_INSTANCE 1U //!Select m4 uart1 for prints. To overcome backward compatibility -extern ARM_DRIVER_USART Driver_USART0; -static ARM_DRIVER_USART *UARTdrv = &Driver_USART0; -#elif (SL_DEBUG_INSTANCE == SL_M4_UART1_INSTANCE) -#define M4_UART2_INSTANCE 1U //!Select m4 uart2 for prints. To overcome backward compatibility -extern ARM_DRIVER_USART Driver_UART1; -static ARM_DRIVER_USART *UARTdrv = &Driver_UART1; -#elif (SL_DEBUG_INSTANCE == SL_ULP_UART_INSTANCE) -#define ULP_UART_INSTANCE 1U //!Select ULP UART for prints. To overcome backward compatibility -extern ARM_DRIVER_USART Driver_ULP_UART; -static ARM_DRIVER_USART *UARTdrv = &Driver_ULP_UART; -#endif -#else -#define ULP_UART_INSTANCE 1U //!Select ULP UART for prints. To overcome backward compatibility -extern ARM_DRIVER_USART Driver_ULP_UART; -static ARM_DRIVER_USART *UARTdrv = &Driver_ULP_UART; -#define BOARD_BAUD_VALUE 115200 //UART baud rate -#endif - -ARM_USART_CAPABILITIES drv_ulp_capabilities; - -volatile uint32_t send_done = 0; -volatile uint32_t recv_done = 0; -#ifdef SLI_SI91X_MCU_INTR_BASED_RX_ON_UART // Add this macro to receive data in interrupt based -uint8_t rx_char; -#endif - -void ARM_UART_SignalEvent(uint32_t event) -{ - // Get the USART Event - event &= USART_EVENT_MASK; - switch (event) { - case ARM_USART_EVENT_SEND_COMPLETE: - send_done++; - break; - case ARM_USART_EVENT_RECEIVE_COMPLETE: -#ifdef SLI_SI91X_MCU_INTR_BASED_RX_ON_UART - UARTdrv->Receive((void *)&rx_char, 1); - cache_uart_rx_data(rx_char); -#endif - recv_done++; - break; - case ARM_USART_EVENT_TRANSFER_COMPLETE: - break; - case ARM_USART_EVENT_TX_COMPLETE: - break; - case ARM_USART_EVENT_TX_UNDERFLOW: - break; - case ARM_USART_EVENT_RX_OVERFLOW: - break; - case ARM_USART_EVENT_RX_TIMEOUT: - break; - case ARM_USART_EVENT_RX_BREAK: - break; - case ARM_USART_EVENT_RX_FRAMING_ERROR: - break; - case ARM_USART_EVENT_RX_PARITY_ERROR: - break; - case ARM_USART_EVENT_CTS: - break; - case ARM_USART_EVENT_DSR: - break; - case ARM_USART_EVENT_DCD: - break; - case ARM_USART_EVENT_RI: - break; - default: - // Handle unexpected events - break; - } -} - -/** - * @fn void Board_Debug_Init(void) - * @brief Initializes board UART for output, required for printf redirection. - * @return none - */ -void Board_Debug_Init(void) -{ - - UARTdrv->Uninitialize(); - - UARTdrv->Initialize(ARM_UART_SignalEvent); - - UARTdrv->PowerControl(ARM_POWER_FULL); - - /* Enable Receiver and Transmitter lines */ - UARTdrv->Control(ARM_USART_CONTROL_TX, 1); - - UARTdrv->Control(ARM_USART_CONTROL_RX, 1); - - UARTdrv->Control(ARM_USART_MODE_ASYNCHRONOUS | ARM_USART_DATA_BITS_8 | ARM_USART_PARITY_NONE | ARM_USART_STOP_BITS_1 - | ARM_USART_FLOW_CONTROL_NONE, - BOARD_BAUD_VALUE); - -#ifdef SL_CATALOG_KERNEL_PRESENT - if (si91x_prints_mutex == NULL) { - si91x_prints_mutex = osMutexNew(NULL); - } -#endif - -#ifdef SLI_SI91X_MCU_INTR_BASED_RX_ON_UART - UARTdrv->Receive((void *)&rx_char, 1); -#else -#if defined(M4_UART1_INSTANCE) && (M4_UART1_INSTANCE == 1) - NVIC_DisableIRQ(USART0_IRQn); -#endif - -#if defined(M4_UART2_INSTANCE) && (M4_UART2_INSTANCE == 1) - NVIC_DisableIRQ(UART1_IRQn); -#endif - -#if defined(ULP_UART_INSTANCE) && (ULP_UART_INSTANCE == 1) - NVIC_DisableIRQ(ULPSS_UART_IRQn); -#endif -#endif - - return; -} - -#if defined(__GNUC__) - -#if defined(__REDLIB_INTERFACE_VERSION__) && (__REDLIB_INTERFACE_VERSION__ >= 20000) -/* We are using new Redlib_v2 semihosting interface */ -#define WRITEFUNC __sys_write -#define READFUNC __sys_readc -#else -/* We are using original Redlib semihosting interface */ -#define WRITEFUNC __write -#define READFUNC __readc -#endif - -#if defined(DEBUG_ENABLE) -#if defined(DEBUG_SEMIHOSTING) -/* Do nothing, semihosting is enabled by default in LPCXpresso */ -#endif /* defined(DEBUG_SEMIHOSTING) */ -#endif /* defined(DEBUG_ENABLE) */ - -#if !defined(DEBUG_SEMIHOSTING) -int WRITEFUNC(int iFileHandle, const char *pcBuffer, int iLength); -int WRITEFUNC(int iFileHandle, const char *pcBuffer, int iLength) -{ - (void)iFileHandle; - (void)pcBuffer; // Explicitly mark pcBuffer as unused to avoid warnings - -#if defined(DEBUG_ENABLE) - for (int i = 0; i < iLength; i++) { - Board_UARTPutChar(pcBuffer[i]); - } -#endif - - return iLength; -} -#endif -/* Called by bottom level of scanf routine within RedLib C library to read - a character. With the default semihosting stub, this would read the character - from the debugger console window (which acts as stdin). But this version reads - the character from the LPC1768/RDB1768 UART. */ -int READFUNC(void); -int READFUNC(void) -{ -#if defined(DEBUG_ENABLE) - int c = Board_UARTGetChar(); - return c; - -#else - return -1; -#endif -} -#endif // defined( __GNUC__ ) - -#if defined(__CC_ARM) - -#include -#include - -#if defined(DEBUG_ENABLE) -#if defined(DEBUG_SEMIHOSTING) -#define ITM_Port8(n) (*((volatile unsigned char *)(0xE0000000 + 4 * n))) -#define ITM_Port16(n) (*((volatile unsigned short *)(0xE0000000 + 4 * n))) -#define ITM_Port32(n) (*((volatile unsigned long *)(0xE0000000 + 4 * n))) - -#define DEMCR (*((volatile unsigned long *)(0xE000EDFC))) -#define TRCENA 0x01000000 - -/* Write to SWO */ -void _ttywrch(int ch) -{ - if (DEMCR & TRCENA) { - while (ITM_Port32(0) == 0) { - } - ITM_Port8(0) = ch; - } -} - -#else -static void BoardOutChar(char ch) -{ -#ifndef SIM_9118 - Board_UARTPutChar(ch); -#else - *(volatile uint8_t *)0x800 = ch; -#endif -} -#endif /* defined(DEBUG_SEMIHOSTING) */ -#endif /* defined(DEBUG_ENABLE) */ - -#ifndef DEBUG_FILE_HANDLE -struct __FILE { - int handle; -}; - -FILE __stdout; -FILE __stdin; -FILE __stderr; -void *_sys_open(const char *name, int openmode) -{ - return NULL; -} - -int fputc(int c, FILE *f) -{ -#if defined(DEBUG_ENABLE) -#if defined(DEBUG_SEMIHOSTING) - _ttywrch(c); -#else - BoardOutChar((char)c); -#endif -#endif - return 0; -} - -int fgetc(FILE *f) -{ -#if defined(DEBUG_ENABLE) && !defined(DEBUG_SEMIHOSTING) - return Board_UARTGetChar(); -#else - return 0; -#endif -} -void _sys_exit(int return_code) -{ -label: - __WFI(); - goto label; /* endless loop */ -} - -int ferror(FILE *f) -{ - return EOF; -} -#endif - -#endif /* defined (__CC_ARM) */ - -/** @addtogroup SOC -* @{ -*/ -/** - * @fn void Board_UARTPutSTR(const uint8_t *ptr) - * @brief Prints a string to the UART. - * @param[in] ptr : Terminated string to output - * @return none - */ -void Board_UARTPutSTR(const uint8_t *ptr) -{ - for (int i = 0; ptr[i] != '\0'; i++) { - send_done = 0; - UARTdrv->Send(&ptr[i], 1); - while (send_done == 0) - ; - } - return; -} - -/** - * @fn uint8_t Board_UARTGetChar(void) - * @brief Get a single character from the UART, required for scanf input. - * @return EOF if not character was received, or character value - * - */ -uint8_t Board_UARTGetChar(void) -{ - uint8_t rev[1] = { 0 }; - recv_done = 0; - UARTdrv->Receive(&rev, 1); - while (recv_done == 0) { -#if defined(M4_UART1_INSTANCE) && (M4_UART1_INSTANCE == 1) - RSI_M4SSUsart0Handler(); -#endif -#if defined(M4_UART2_INSTANCE) && (M4_UART2_INSTANCE == 1) - RSI_M4SSUart1Handler(); -#endif -#if defined(ULP_UART_INSTANCE) && (ULP_UART_INSTANCE == 1) - RSI_ULPUartHandler(); -#endif - } - return rev[0]; -} - -/** - * @fn void Board_UARTPutChar(uint8_t ch) - * @brief Sends a single character on the UART, required for printf redirection. - * @param[in] ch : character to send - * @return none - */ -void Board_UARTPutChar(uint8_t ch) -{ - send_done = 0; - UARTdrv->Send(&ch, sizeof(ch)); - while (send_done == 0) { -#if defined(M4_UART1_INSTANCE) && (M4_UART1_INSTANCE == 1) - RSI_M4SSUsart0Handler(); -#endif -#if defined(M4_UART2_INSTANCE) && (M4_UART2_INSTANCE == 1) - RSI_M4SSUart1Handler(); -#endif -#if defined(ULP_UART_INSTANCE) && (ULP_UART_INSTANCE == 1) - RSI_ULPUartHandler(); -#endif - } - - return; -} -/** @} */ - -#ifdef SLI_SI91X_DBG_MIDDLEWARE_EN -int stdin_getchar(void) -{ - int32_t ch = -1; - - do { -#ifdef DEBUG_UART - ch = Board_UARTGetChar(); -#endif - } while (ch == -1); - return ch; -} -int stdout_putchar(int ch) -{ -#ifdef DEBUG_UART - Board_UARTPutChar((uint8_t)ch); -#endif - return ch; -} -int stderr_putchar(int ch) -{ -#ifdef DEBUG_UART - Board_UARTPutChar((uint8_t)ch); -#endif - return ch; -} - -#endif // SLI_SI91X_DBG_MIDDLEWARE_EN - -/* IAR support */ -#if defined(__ICCARM__) -/******************* - * - * Copyright 1998-2003 IAR Systems. All rights reserved. - * - * $Revision: 30870 $ - * - * This is a template implementation of the "__write" function used by - * the standard library. Replace it with a system-specific - * implementation. - * - * The "__write" function should output "size" number of bytes from - * "buffer" in some application-specific way. It should return the - * number of characters written, or _LLIO_ERROR on failure. - * - * If "buffer" is zero then __write should perform flushing of - * internal buffers, if any. In this case "handle" can be -1 to - * indicate that all handles should be flushed. - * - * The template implementation below assumes that the application - * provides the function "MyLowLevelPutchar". It should return the - * character written, or -1 on failure. - * - ********************/ - -#include - -#if defined(DEBUG_UART) && !defined(DEBUG_SEMIHOSTING) - -//_STD_BEGIN - -#pragma module_name = "?__write" - -/* - If the __write implementation uses internal buffering, uncomment - the following line to ensure that we are called with "buffer" as 0 - (i.e. flush) when the application terminates. */ -size_t __write(int handle, const unsigned char *buffer, size_t size) -{ -#if defined(DEBUG_UART) - size_t nChars = 0; - - if (buffer == 0) { - /* - This means that we should flush internal buffers. Since we - don't we just return. (Remember, "handle" == -1 means that all - handles should be flushed.) - */ - return 0; - } - - /* This template only writes to "standard out" and "standard err", - for all other file handles it returns failure. */ - if ((handle != _LLIO_STDOUT) && (handle != _LLIO_STDERR)) { - return _LLIO_ERROR; - } - - for (/* Empty */; size != 0; --size) { - Board_UARTPutChar(*buffer++); - ++nChars; - } - - return nChars; -#else - return size; -#endif /* defined(DEBUG_UART) */ -} - -//_STD_END -#endif - -#endif /* defined (__ICCARM__) */ - -/** - * @fn void dummy_printf(const char *fmt, ...) - * @brief It does nothing but used when DEBUG_UART is not defined, to avoid compilation errors. - * @param[in] fmt: format string - * @return none - */ -void dummy_printf(const char *fmt, ...) -{ - va_list args; - va_start(args, fmt); - // Do Nothing - va_end(args); -} diff --git a/wiseconnect/components/device/silabs/si91x/mcu/drivers/cmsis_driver/SAI.c b/wiseconnect/components/device/silabs/si91x/mcu/drivers/cmsis_driver/SAI.c deleted file mode 100644 index 225627fbd..000000000 --- a/wiseconnect/components/device/silabs/si91x/mcu/drivers/cmsis_driver/SAI.c +++ /dev/null @@ -1,664 +0,0 @@ -/* - * Copyright (c) 2013-2016 ARM Limited. All rights reserved. - * - * SPDX-License-Identifier: Apache-2.0 - * - * 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 - * - * 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. - */ -#include "rsi_ccp_user_config.h" - - -#include "SAI.h" -#include "clock_update.h" -#include "rsi_i2s.h" -#include "sl_si91x_i2s_config.h" - -#if defined(A11_ROM) -#include "rsi_rom_table_si91x.h" -#endif -extern RSI_UDMA_HANDLE_T udmaHandle0,udmaHandle1; //check -extern uint32_t dma_rom_buff0[30], dma_rom_buff1[30]; //we can keep wrapeers - -#define CONTROL_STRUCT0 (UDMA_NUMBER_OF_CHANNELS * 2) -#define CONTROL_STRUCT1 (ULP_UDMA_NUMBER_OF_CHANNELS * 2) -#define RESOLUTION_16_BIT 16 -#define I2S0_CHANNEL1_CHANNEL_OFFSET 2 - -#define I2S0_CLK_SRC ULP_I2S_PLL_CLK -#define I2S0_CLK_DIV_FACT 0 -#define I2S1_CLK_SRC ULP_I2S_REF_CLK -#define I2S1_CLK_DIV_FACT 0 - -/* IAR support */ -#if defined(__ICCARM__) -#pragma location = UDMA0_SRAM_BASE -extern RSI_UDMA_DESC_T UDMA0_Table[CONTROL_STRUCT0]; -#pragma location = UDMA1_SRAM_BASE -extern RSI_UDMA_DESC_T UDMA1_Table[CONTROL_STRUCT1]; -#endif - -/* DMA descriptors must be aligned to 16 bytes */ -#if defined(__CC_ARM) -extern RSI_UDMA_DESC_T UDMA0_Table[CONTROL_STRUCT0] ; -extern RSI_UDMA_DESC_T UDMA1_Table[CONTROL_STRUCT1] ; -#endif /* defined (__CC_ARM) */ - -#if defined( __GNUC__ ) -extern RSI_UDMA_DESC_T __attribute__ ((section(".udma_addr0"))) UDMA0_Table[CONTROL_STRUCT0]; -extern RSI_UDMA_DESC_T __attribute__ ((section(".udma_addr1"))) UDMA1_Table[CONTROL_STRUCT1]; -#endif /* defined (__GNUC__) */ - -extern UDMA_Channel_Info udma0_chnl_info[32] ; -extern UDMA_Channel_Info udma1_chnl_info[12] ; - -/* UDMA0 Resources */ -extern UDMA_RESOURCES UDMA0_Resources ; - -/* UDMA1 Resources */ -extern UDMA_RESOURCES UDMA1_Resources; - - -#if ((!defined(RTE_I2S0)) || (!defined(RTE_I2S1))) -#error "I2S missing in RTE_Device_917.h. Please update RTE_Device_917.h!" -#endif - -#if ((defined(RTE_Drivers_SAI0) && !RTE_I2S0) && (defined(RTE_Drivers_SAI1) && !RTE_I2S1)) -#error "I2S0/1 not configured in RTE_Device_917.h!" -#endif - -// Definitions - -// Frequency tolerance in percentage -#ifndef I2S_FREQ_TOLERANCE -#define I2S_FREQ_TOLERANCE (1.) -#endif - -#define D2F_DOMAIN (255UL) - -#if (RTE_I2S0) - -#if ((I2S0_TX_FIFO_LEVEL < 0U) || (I2S0_TX_FIFO_LEVEL > 7U)) -#error "Invalid FIFO Level value. FIFO Level can be 0 to 7" -#endif -#if ((I2S0_RX_FIFO_LEVEL < 0U) || (I2S0_RX_FIFO_LEVEL > 7U)) -#error "Invalid FIFO Level value. FIFO Level can be 0 to 7" -#endif -#endif - -#if (RTE_I2S1) - -#if ((I2S1_TX_FIFO_LEVEL < 0U) || (I2S1_TX_FIFO_LEVEL > 7U)) -#error "Invalid FIFO Level value. FIFO Level can be 0 to 7" -#endif -#if ((I2S1_RX_FIFO_LEVEL < 0U) || (I2S1_RX_FIFO_LEVEL > 7U)) -#error "Invalid FIFO Level value. FIFO Level can be 0 to 7" -#endif -#endif - - -#define ARM_SAI_DRV_VERSION ARM_DRIVER_VERSION_MAJOR_MINOR(1,5) // driver version -// Driver Version -static const ARM_DRIVER_VERSION DriverVersion = { - ARM_SAI_API_VERSION, - ARM_SAI_DRV_VERSION -}; - -// I2S0 -#if (RTE_I2S0) - -static I2S_INFO I2S0_Info = {0,{0},{0},{0}}; -static I2S_CLK I2S0_Clk = {I2S0_CLK_SRC, I2S0_CLK_DIV_FACT}; - -static I2S_PIN i2s0_sclk = {RTE_I2S0_SCLK_PORT,RTE_I2S0_SCLK_PIN,RTE_I2S0_SCLK_MUX,RTE_I2S0_SCLK_PAD}; -static I2S_PIN i2s0_wsclk = {RTE_I2S0_WSCLK_PORT,RTE_I2S0_WSCLK_PIN,RTE_I2S0_WSCLK_MUX,RTE_I2S0_WSCLK_PAD}; -static I2S_PIN i2s0_din0 = {RTE_I2S0_DIN0_PORT,RTE_I2S0_DIN0_PIN,RTE_I2S0_DIN0_MUX,RTE_I2S0_DIN0_PAD}; -static I2S_PIN i2s0_dout0 = {RTE_I2S0_DOUT0_PORT,RTE_I2S0_DOUT0_PIN,RTE_I2S0_DOUT0_MUX,RTE_I2S0_DOUT0_PAD}; -static I2S_PIN i2s0_din1 = {RTE_I2S0_DIN1_PORT,RTE_I2S0_DIN1_PIN,RTE_I2S0_DIN1_MUX,RTE_I2S0_DIN1_PAD}; -static I2S_PIN i2s0_dout1 = {RTE_I2S0_DOUT1_PORT,RTE_I2S0_DOUT1_PIN,RTE_I2S0_DOUT1_MUX,RTE_I2S0_DOUT1_PAD}; - - -#if (RTE_I2S0_CHNL_UDMA_TX_EN == 1U) - -void I2S0_UDMA_Tx_Event (uint32_t event, uint32_t dmaCh); - -static I2S_DMA I2S0_UDMA_TX_CHNL = { - { - UDMA_MODE_BASIC, - 0, - (RTE_I2S0_DMA_TX_LEN_PER_DES -1), - ARBSIZE_4, - 0x0, - 0x0, -#if (SL_I2S0_RESOLUTION <= RESOLUTION_16_BIT) - SRC_SIZE_16, - SRC_INC_16, - DST_SIZE_16, - DST_INC_NONE -#else - SRC_SIZE_32, - SRC_INC_32, - DST_SIZE_32, - DST_INC_NONE -#endif - }, -#if (SL_I2S0_CHANNEL == 0) - RTE_I2S0_CHNL_UDMA_TX_CH, -#else - (RTE_I2S0_CHNL_UDMA_TX_CH + I2S0_CHANNEL1_CHANNEL_OFFSET), -#endif - I2S0_UDMA_Tx_Event -}; -#endif - -#if (RTE_I2S0_CHNL_UDMA_RX_EN == 1U) - -void I2S0_UDMA_Rx_Event (uint32_t event, uint32_t dmaCh); -static I2S_DMA I2S0_UDMA_RX_CHNL = { - { - UDMA_MODE_BASIC, - 0, - (RTE_I2S0_DMA_RX_LEN_PER_DES -1), - ARBSIZE_4, - 0x0, - 0x0, -#if (SL_I2S0_RESOLUTION <= RESOLUTION_16_BIT) - SRC_SIZE_16, - SRC_INC_NONE, - DST_SIZE_16, - DST_INC_16 -#else - SRC_SIZE_32, - SRC_INC_NONE, - DST_SIZE_32, - DST_INC_32 -#endif - }, -#if (SL_I2S0_CHANNEL == 0) - RTE_I2S0_CHNL_UDMA_RX_CH, -#else - (RTE_I2S0_CHNL_UDMA_RX_CH + I2S0_CHANNEL1_CHANNEL_OFFSET), -#endif - I2S0_UDMA_Rx_Event -}; -#endif - - -static I2S_RESOURCES I2S0_Resources = { - { // Capabilities - 1, ///< supports asynchronous Transmit/Receive - 1, ///< supports synchronous Transmit/Receive - 0, ///< supports user defined Protocol - 1, ///< supports I2S Protocol - 0, ///< supports MSB/LSB justified Protocol - 1, ///< supports PCM short/long frame Protocol - 0, ///< supports AC'97 Protocol - 0, ///< supports Mono mode - 0, ///< supports Companding - 0, ///< supports MCLK (Master Clock) pin - 0, ///< supports Frame error event: \ref ARM_SAI_EVENT_FRAME_ERROR - }, - I2S0, - I2S0_IRQn, -#if (RTE_I2S0_CHNL_UDMA_TX_EN == 1U) - &I2S0_UDMA_TX_CHNL, -#else - NULL, -#endif -#if (RTE_I2S0_CHNL_UDMA_RX_EN == 1U) - &I2S0_UDMA_RX_CHNL, -#else - NULL, -#endif - I2S0_TX_FIFO_LEVEL, - I2S0_RX_FIFO_LEVEL, -#ifdef SL_I2S0_CHANNEL - SL_I2S0_CHANNEL, -#else - 0, -#endif - &I2S0_Info, - 0, - I2S_PROTOCOL, - &I2S0_Clk, - { - //pins - &i2s0_sclk, - &i2s0_wsclk, - &i2s0_din0, - &i2s0_dout0, - &i2s0_din1, - &i2s0_dout1, - }, - -}; -#endif - - -// I2S1 -#if (RTE_I2S1) -static I2S_INFO I2S1_Info = {0,{0},{0},{0}}; -static I2S_CLK I2S1_Clk = {I2S1_CLK_SRC, I2S1_CLK_DIV_FACT}; - -static I2S_PIN i2s1_sclk = {RTE_I2S1_SCLK_PORT,RTE_I2S1_SCLK_PIN,RTE_I2S1_SCLK_MUX,RTE_I2S1_SCLK_PAD}; -static I2S_PIN i2s1_wsclk = {RTE_I2S1_WSCLK_PORT,RTE_I2S1_WSCLK_PIN,RTE_I2S1_WSCLK_MUX,RTE_I2S1_WSCLK_PAD}; -static I2S_PIN i2s1_din0 = {RTE_I2S1_DIN0_PORT,RTE_I2S1_DIN0_PIN,RTE_I2S1_DIN0_MUX,RTE_I2S1_DIN0_PAD}; -static I2S_PIN i2s1_dout0 = {RTE_I2S1_DOUT0_PORT,RTE_I2S1_DOUT0_PIN,RTE_I2S1_DOUT0_MUX,RTE_I2S1_DOUT0_PAD}; - - -#if (RTE_I2S1_CHNL_UDMA_TX_EN == 1U) -void I2S1_UDMA_Tx_Event (uint32_t event, uint32_t dmaCh); -static I2S_DMA I2S1_UDMA_TX_CHNL = { - { - UDMA_MODE_BASIC, - 0, - RTE_I2S1_DMA_TX_LEN_PER_DES-1, - ARBSIZE_4, - 0x0, - 0x0, -#if (SL_ULP_I2S_RESOLUTION <= RESOLUTION_16_BIT) - SRC_SIZE_16, - SRC_INC_16, - DST_SIZE_16, - DST_INC_NONE -#else - SRC_SIZE_32, - SRC_INC_32, - DST_SIZE_32, - DST_INC_NONE -#endif - }, - RTE_I2S1_CHNL_UDMA_TX_CH, - I2S1_UDMA_Tx_Event -}; -#endif - -#if (RTE_I2S1_CHNL_UDMA_RX_EN == 1U) -void I2S1_UDMA_Rx_Event (uint32_t event, uint32_t dmaCh); -static I2S_DMA I2S1_UDMA_RX_CHNL = { - { - UDMA_MODE_BASIC, - 0, - RTE_I2S1_DMA_RX_LEN_PER_DES-1, - ARBSIZE_4, - 0x0, - 0x0, -#if (SL_ULP_I2S_RESOLUTION <= RESOLUTION_16_BIT) - SRC_SIZE_16, - SRC_INC_NONE, - DST_SIZE_16, - DST_INC_16 -#else - SRC_SIZE_32, - SRC_INC_NONE, - DST_SIZE_32, - DST_INC_32 -#endif - }, - RTE_I2S1_CHNL_UDMA_RX_CH, - I2S1_UDMA_Rx_Event -}; -#endif - -static I2S_RESOURCES I2S1_Resources = { - { // Capabilities - 1, ///< supports asynchronous Transmit/Receive - 1, ///< supports synchronous Transmit/Receive - 0, ///< supports user defined Protocol - 1, ///< supports I2S Protocol - 0, ///< supports MSB/LSB justified Protocol - 0, ///< supports PCM short/long frame Protocol - 0, ///< supports AC'97 Protocol - 0, ///< supports Mono mode - 0, ///< supports Companding - 0, ///< supports MCLK (Master Clock) pin - 0, ///< supports Frame error event: \ref ARM_SAI_EVENT_FRAME_ERROR - }, - I2S1, - I2S1_IRQn, -#if (RTE_I2S1_CHNL_UDMA_TX_EN == 1U) - &I2S1_UDMA_TX_CHNL, -#else - NULL, -#endif -#if (RTE_I2S1_CHNL_UDMA_RX_EN == 1U) - &I2S1_UDMA_RX_CHNL, -#else - NULL, -#endif - I2S1_TX_FIFO_LEVEL, - I2S1_RX_FIFO_LEVEL, - 0, - &I2S1_Info, - 0, - I2S_PROTOCOL, - &I2S1_Clk , - { - //pins - &i2s1_sclk, - &i2s1_wsclk, - &i2s1_din0, - &i2s1_dout0, - NULL, - NULL, - }, -}; -#endif - -// Extern Function - -/** - \fn ARM_DRIVER_VERSION I2Sx_GetVersion (void) - \brief Get driver version. - \return \ref ARM_DRIVER_VERSION */ -static ARM_DRIVER_VERSION I2Sx_GetVersion (void) -{ - return (DriverVersion); -} - -/** - \fn ARM_SAI_CAPABILITIES I2Sx_GetCapabilities (void) - \brief Get driver capabilities. - \param[in] i2s Pointer to I2S resources - \return \ref ARM_SAI_CAPABILITIES - */ -static ARM_SAI_CAPABILITIES I2S_GetCapabilities (I2S_RESOURCES *i2s) -{ - return (i2s->capabilities); -} - - -#if (RTE_I2S0) -// I2S0 Driver Wrapper functions -static ARM_SAI_CAPABILITIES I2S0_GetCapabilities (void) -{ - return I2S_GetCapabilities (&I2S0_Resources); -} - -static int32_t I2S0_Initialize (ARM_SAI_SignalEvent_t cb_event) -{ -#if defined(A11_ROM) - return ROMAPI_I2S_API->I2S_Initialize (cb_event, &I2S0_Resources,&UDMA0_Resources,UDMA0_Table,&udmaHandle0,dma_rom_buff0); -#else - return I2S_Initialize (cb_event, &I2S0_Resources,&UDMA0_Resources,UDMA0_Table,&udmaHandle0,dma_rom_buff0); -#endif -} - -static int32_t I2S0_Uninitialize (void) -{ -#if defined(A11_ROM) && defined(I2S_ROMDRIVER_PRESENT) - return ROMAPI_I2S_API->I2S_Uninitialize (&I2S0_Resources,&UDMA0_Resources); -#else - return I2S_Uninitialize (&I2S0_Resources,&UDMA0_Resources); -#endif -} - -static int32_t I2S0_PowerControl (ARM_POWER_STATE state) -{ -#if defined(A11_ROM) - return ROMAPI_I2S_API->I2S_PowerControl (state, &I2S0_Resources,&UDMA0_Resources,udmaHandle0); -#else - return I2S_PowerControl (state, &I2S0_Resources,&UDMA0_Resources,udmaHandle0); -#endif -} - -static int32_t I2S0_Send (const void *data, uint32_t num) -{ -#if defined(A11_ROM) && defined(I2S_ROMDRIVER_PRESENT) - return ROMAPI_I2S_API->I2S_Send (data, num, &I2S0_Resources,&UDMA0_Resources,udma0_chnl_info,udmaHandle0); -#else - return I2S_Send (data, num, &I2S0_Resources,&UDMA0_Resources,udma0_chnl_info,udmaHandle0); -#endif -} - -static int32_t I2S0_Receive (void *data, uint32_t num) -{ -#if defined(A11_ROM) && defined(I2S_ROMDRIVER_PRESENT) - return ROMAPI_I2S_API->I2S_Receive (data, num, &I2S0_Resources,&UDMA0_Resources,udma0_chnl_info,udmaHandle0); -#else - return I2S_Receive (data, num, &I2S0_Resources,&UDMA0_Resources,udma0_chnl_info,udmaHandle0); -#endif -} - -static uint32_t I2S0_GetTxCount (void) -{ -#if defined(A11_ROM) - return ROMAPI_I2S_API->I2S_GetTxCount (&I2S0_Resources); -#else - return I2S_GetTxCount (&I2S0_Resources); -#endif -} - -static uint32_t I2S0_GetRxCount (void) -{ -#if defined(A11_ROM) - return ROMAPI_I2S_API->I2S_GetRxCount (&I2S0_Resources); -#else - return I2S_GetRxCount (&I2S0_Resources); -#endif -} - -static int32_t I2S0_Control (uint32_t control, uint32_t arg1, uint32_t arg2) -{ -#if defined(A11_ROM) && defined(I2S_ROMDRIVER_PRESENT) - return ROMAPI_I2S_API->I2S_Control (control, arg1, arg2, &I2S0_Resources,&UDMA0_Resources,udmaHandle0); -#else - return I2S_Control (control, arg1, arg2, &I2S0_Resources,&UDMA0_Resources,udmaHandle0); -#endif -} - -static ARM_SAI_STATUS I2S0_GetStatus (void) -{ -#if defined(A11_ROM) - return ROMAPI_I2S_API->I2S_GetStatus (&I2S0_Resources); -#else - return I2S_GetStatus (&I2S0_Resources); -#endif -} - -void IRQ064_Handler (void) -{ -#if defined(A11_ROM) - ROMAPI_I2S_API-> I2S_IRQHandler (&I2S0_Resources); -#else - I2S_IRQHandler (&I2S0_Resources); -#endif -} - -#if (RTE_I2S0_CHNL_UDMA_TX_EN == 1) -void I2S0_UDMA_Tx_Event (uint32_t event, uint32_t dmaCh) -{ -#if defined(A11_ROM) - ROMAPI_I2S_API->I2S_UDMA_Tx_Event(event,dmaCh,&I2S0_Resources); -#else - I2S_UDMA_Tx_Event(event,(uint8_t)dmaCh,&I2S0_Resources); -#endif -} -#endif - -#if (RTE_I2S0_CHNL_UDMA_RX_EN == 1) -void I2S0_UDMA_Rx_Event (uint32_t event,uint32_t dmaCh) -{ -#if defined(A11_ROM) - ROMAPI_I2S_API->I2S_UDMA_Rx_Event (event,dmaCh, &I2S0_Resources); -#else - I2S_UDMA_Rx_Event (event,(uint8_t)dmaCh, &I2S0_Resources); -#endif -} -#endif - -// SAI0 Driver Control Block -ARM_DRIVER_SAI Driver_SAI0 = { - I2Sx_GetVersion, - I2S0_GetCapabilities, - I2S0_Initialize, - I2S0_Uninitialize, - I2S0_PowerControl, - I2S0_Send, - I2S0_Receive, - I2S0_GetTxCount, - I2S0_GetRxCount, - I2S0_Control, - I2S0_GetStatus -}; -#endif - -#if (RTE_I2S1) -// I2S1 Driver Wrapper functions -static ARM_SAI_CAPABILITIES I2S1_GetCapabilities (void) -{ - return I2S_GetCapabilities (&I2S1_Resources); -} - -static int32_t I2S1_Initialize (ARM_SAI_SignalEvent_t cb_event) -{ -#if defined(A11_ROM) && defined(I2S_ROMDRIVER_PRESENT) - return ROMAPI_I2S_API->I2S_Initialize (cb_event, &I2S1_Resources,&UDMA1_Resources,UDMA1_Table,&udmaHandle1,dma_rom_buff1); -#else - return I2S_Initialize (cb_event, &I2S1_Resources,&UDMA1_Resources,UDMA1_Table,&udmaHandle1,dma_rom_buff1); -#endif -} - -static int32_t I2S1_Uninitialize (void) -{ - RSI_PS_UlpssPeriPowerDown(ULPSS_PWRGATE_ULP_I2S); -#if defined(A11_ROM) && defined(I2S_ROMDRIVER_PRESENT) - return ROMAPI_I2S_API->I2S_Uninitialize (&I2S1_Resources,&UDMA1_Resources); -#else - return I2S_Uninitialize (&I2S1_Resources,&UDMA1_Resources); -#endif -} - -static int32_t I2S1_PowerControl (ARM_POWER_STATE state) -{ -#if defined(A11_ROM) - return ROMAPI_I2S_API->I2S_PowerControl (state, &I2S1_Resources,&UDMA1_Resources,udmaHandle1); -#else - return I2S_PowerControl (state, &I2S1_Resources,&UDMA1_Resources,udmaHandle1); -#endif -} - -static int32_t I2S1_Send (const void *data, uint32_t num) -{ -#if defined(A11_ROM) && defined(I2S_ROMDRIVER_PRESENT) - return ROMAPI_I2S_API->I2S_Send (data, num, &I2S1_Resources,&UDMA1_Resources,udma1_chnl_info,udmaHandle1); -#else - return I2S_Send (data, num, &I2S1_Resources,&UDMA1_Resources,udma1_chnl_info,udmaHandle1); -#endif -} - -static int32_t I2S1_Receive (void *data, uint32_t num) -{ -#if defined(A11_ROM) && defined(I2S_ROMDRIVER_PRESENT) - return ROMAPI_I2S_API->I2S_Receive (data, num, &I2S1_Resources,&UDMA1_Resources,udma1_chnl_info,udmaHandle1); -#else - return I2S_Receive (data, num, &I2S1_Resources,&UDMA1_Resources,udma1_chnl_info,udmaHandle1); -#endif -} - -static uint32_t I2S1_GetTxCount (void) -{ -#if defined(A11_ROM) - return ROMAPI_I2S_API->I2S_GetTxCount (&I2S1_Resources); -#else - return I2S_GetTxCount (&I2S1_Resources); -#endif -} - -static uint32_t I2S1_GetRxCount (void) -{ -#if defined(A11_ROM) - return ROMAPI_I2S_API->I2S_GetRxCount (&I2S1_Resources); -#else - return I2S_GetRxCount (&I2S1_Resources); -#endif -} - -static int32_t I2S1_Control (uint32_t control, uint32_t arg1, uint32_t arg2) -{ -#if defined(A11_ROM) && defined(I2S_ROMDRIVER_PRESENT) - return ROMAPI_I2S_API->I2S_Control (control, arg1, arg2, &I2S1_Resources,&UDMA1_Resources,udmaHandle1); -#else - return I2S_Control (control, arg1, arg2, &I2S1_Resources,&UDMA1_Resources,udmaHandle1); -#endif -} - -static ARM_SAI_STATUS I2S1_GetStatus (void) -{ -#if defined(A11_ROM) - return ROMAPI_I2S_API->I2S_GetStatus (&I2S1_Resources); -#else - return I2S_GetStatus (&I2S1_Resources); -#endif -} - -void I2S1_IRQHandler (void) -{ -#if defined(A11_ROM) - ROMAPI_I2S_API->I2S_IRQHandler (&I2S1_Resources); -#else - I2S_IRQHandler (&I2S1_Resources); -#endif -} - -#if (RTE_I2S1_CHNL_UDMA_TX_EN == 1) -void I2S1_UDMA_Tx_Event (uint32_t event,uint32_t dmaCh) -{ -#if defined(A11_ROM) - ROMAPI_I2S_API->I2S_UDMA_Tx_Event (event, dmaCh,&I2S1_Resources); -#else - I2S_UDMA_Tx_Event (event,(uint8_t)dmaCh,&I2S1_Resources); -#endif -} -#endif - -#if (RTE_I2S1_CHNL_UDMA_RX_EN == 1) -void I2S1_UDMA_Rx_Event (uint32_t event, uint32_t dmaCh) -{ -#if defined(A11_ROM) - ROMAPI_I2S_API->I2S_UDMA_Rx_Event (event, dmaCh, &I2S1_Resources); -#else - I2S_UDMA_Rx_Event (event,(uint8_t)dmaCh, &I2S1_Resources); -#endif -} -#endif - -uint8_t I2S_GetInitState(uint8_t i2s_instance) -{ - uint8_t status = 0; - - //Get the initialization status of I2S instance - if(i2s_instance == 0) { - status = (I2S0_Resources.flags && (0x01)); - } - if(i2s_instance == 1) { - status = (I2S1_Resources.flags && (0x01)); - } - - return status; -} -// SAI1 Driver Control Block -ARM_DRIVER_SAI Driver_SAI1 = { - I2Sx_GetVersion, - I2S1_GetCapabilities, - I2S1_Initialize, - I2S1_Uninitialize, - I2S1_PowerControl, - I2S1_Send, - I2S1_Receive, - I2S1_GetTxCount, - I2S1_GetRxCount, - I2S1_Control, - I2S1_GetStatus -}; -#endif - diff --git a/wiseconnect/components/device/silabs/si91x/mcu/drivers/cmsis_driver/UDMA.c b/wiseconnect/components/device/silabs/si91x/mcu/drivers/cmsis_driver/UDMA.c deleted file mode 100644 index 2be92c605..000000000 --- a/wiseconnect/components/device/silabs/si91x/mcu/drivers/cmsis_driver/UDMA.c +++ /dev/null @@ -1,277 +0,0 @@ -/******************************************************************************* -* @file UDMA.c -* @brief -******************************************************************************* -* # License -* Copyright 2025 Silicon Laboratories Inc. www.silabs.com -******************************************************************************* -* -* SPDX-License-Identifier: Zlib -* -* The licensor of this software is Silicon Laboratories Inc. -* -* This software is provided 'as-is', without any express or implied -* warranty. In no event will the authors be held liable for any damages -* arising from the use of this software. -* -* Permission is granted to anyone to use this software for any purpose, -* including commercial applications, and to alter it and redistribute it -* freely, subject to the following restrictions: -* -* 1. The origin of this software must not be misrepresented; you must not -* claim that you wrote the original software. If you use this software -* in a product, an acknowledgment in the product documentation would be -* appreciated but is not required. -* 2. Altered source versions must be plainly marked as such, and must not be -* misrepresented as being the original software. -* 3. This notice may not be removed or altered from any source distribution. -* -******************************************************************************/ - -#include "rsi_ccp_user_config.h" - -#include "UDMA.h" -#include "rsi_packing.h" - -#ifdef ADC_MULTICHANNEL_WITH_EXT_DMA -#include "rsi_adc.h" -extern adc_commn_config_t adc_commn_config; -#endif - -#ifdef DAC_FIFO_MODE_EN -#include "rsi_dac.h" -extern dac_config_t dac_callback_fun; -#endif - -#if defined(A11_ROM) -#include "rsi_rom_table_si91x.h" -#endif - -#include "rsi_udma_wrapper.h" - -//UDMA Defines//// -RSI_UDMA_HANDLE_T udmaHandle0; -RSI_UDMA_HANDLE_T udmaHandle1; -uint32_t dma_rom_buff0[30]; -uint32_t dma_rom_buff1[30]; - - -#if ((UDMA0_SRAM_BASE & (~0x3FF)) != UDMA0_SRAM_BASE) -#error "Invalid UDMA0 sram base address" -#endif - -#if ((UDMA1_SRAM_BASE & (~0x3FF)) != UDMA1_SRAM_BASE) -#error "Invalid UDMA1 sram base address" -#endif - -/* IAR support */ -#if defined(__ICCARM__) -#pragma location = UDMA0_SRAM_BASE -RSI_UDMA_DESC_T UDMA0_Table[CONTROL_STRUCT0]; -#pragma location = UDMA1_SRAM_BASE -RSI_UDMA_DESC_T UDMA1_Table[CONTROL_STRUCT1]; -#endif - -/* DMA descriptors must be aligned to 16 bytes */ -#if defined(__CC_ARM) -RSI_UDMA_DESC_T UDMA0_Table[CONTROL_STRUCT0] __attribute__ ((at(UDMA0_SRAM_BASE))); -RSI_UDMA_DESC_T UDMA1_Table[CONTROL_STRUCT1] __attribute__ ((at(UDMA1_SRAM_BASE))); -#endif /* defined (__CC_ARM) */ - -#if defined( __GNUC__ ) -RSI_UDMA_DESC_T UDMA0_Table[0]; -RSI_UDMA_DESC_T UDMA1_Table[0]; -#endif /* defined (__GNUC__) */ - -UDMA_Channel_Info udma0_chnl_info[32] = { 0U } ; -UDMA_Channel_Info udma1_chnl_info[12] = { 0U } ; - -#ifdef RTE_UDMA0 -/* I2C0 Resources */ -UDMA_RESOURCES UDMA0_Resources = { - UDMA0, - UDMA0_IRQn, - UDMA0_Table // SRAM base address -}; -#endif /* RTE_UDMA0 */ - -#ifdef RTE_UDMA1 - -/* I2C1 Resources */ -UDMA_RESOURCES UDMA1_Resources = { - UDMA1, - UDMA1_IRQn, - UDMA1_Table // SRAM base address -}; -#endif /* RTE_UDMA1 */ - -/*==============================================*/ -/** - * @fn void uDMAx_IRQHandler(UDMA_RESOURCES *udma, RSI_UDMA_DESC_T *UDMA_Table, UDMA_Channel_Info *chnl_info) - * @brief DMA interrupt handler - * @return none - */ -void uDMAx_IRQHandler(UDMA_RESOURCES *udma, RSI_UDMA_DESC_T *UDMA_Table, UDMA_Channel_Info *chnl_info) -{ - volatile uint32_t size = 0; - volatile uint32_t intr = 0; - volatile uint32_t src_inc = 0; - volatile uint32_t dst_inc = 0; - volatile uint32_t dma_len = 0; - - // error check, invalid instance - if ((udma->reg != UDMA0) && (udma->reg != UDMA1)) { - return; - } - - for (volatile uint32_t ch = 0; ch < UDMA_NUMBER_OF_CHANNELS; ch++) { - intr = udma->reg->UDMA_DONE_STATUS_REG; - if (intr & (1U << ch)) { - // Clear interrupt flag - udma->reg->UDMA_DONE_STATUS_REG = (1U << ch); - } else { - // DMA error interrupt - if (udma->reg->ERR_CLR & (1U << ch)) { - udma->reg->ERR_CLR_b.ERR_CLR = 0x1; - // Clear interrupt flag - udma->reg->UDMA_DONE_STATUS_REG = (1U << ch); - // Signal Event - if (chnl_info[ch].cb_event) { - chnl_info[ch].cb_event(UDMA_EVENT_ERROR, ch); - } - } - // continue check for subsequent channels - continue; - } - - // valid interrupt, check if data is waiting to transfer - if (chnl_info[ch].Cnt != chnl_info[ch].Size) { - // Data waiting to transfer - size = chnl_info[ch].Size - chnl_info[ch].Cnt; - if (size > 0) { - // Max DMA transfer size = 4k - if (size >= DESC_MAX_LEN) { - size = DESC_MAX_LEN; - } - dma_len = size - 1; - chnl_info[ch].Cnt += size; - } - // Source Address Increment - src_inc = UDMA_Table[ch].vsUDMAChaConfigData1.srcInc; - - if (src_inc != UDMA_SRC_INC_NONE) { - UDMA_Table[ch].pSrcEndAddr = (void *)((uint32_t)UDMA_Table[ch].pSrcEndAddr + (size << src_inc)); - } else { - UDMA_Table[ch].pSrcEndAddr = (void *)((uint32_t)UDMA_Table[ch].pSrcEndAddr); - } - - // Destination Address Increment - dst_inc = UDMA_Table[ch].vsUDMAChaConfigData1.dstInc; - - if (dst_inc != UDMA_DST_INC_NONE) { - UDMA_Table[ch].pDstEndAddr = (void *)((uint32_t)UDMA_Table[ch].pDstEndAddr + (size << dst_inc)); - } else { - UDMA_Table[ch].pDstEndAddr = (void *)((uint32_t)UDMA_Table[ch].pDstEndAddr); - } - - // Update other DMA parameters - UDMA_Table[ch].vsUDMAChaConfigData1.totalNumOfDMATrans = (unsigned int)(dma_len & 0x03FF); - UDMA_Table[ch].vsUDMAChaConfigData1.transferType = UDMA_MODE_BASIC; - - // Enable DMA Channel - udma->reg->CHNL_ENABLE_SET = (1U << ch); - } else { - // All Data has been transferred - // Signal Event - if (chnl_info[ch].cb_event) { - chnl_info[ch].cb_event(UDMA_EVENT_XFER_DONE, ch); - } - } - } - } - -void IRQ033_Handler(void) -{ - NVIC_DisableIRQ(UDMA0_IRQn); - #if defined(A11_ROM) && defined(UDMA_ROMDRIVER_PRESENT) - uint8_t channel; - uint32_t int_status; - uint8_t soft_trig_flag = 0; - int_status = UDMA0->UDMA_DONE_STATUS_REG; - //Identify the interrupt channel - for (channel = 0; channel < UDMA_NUMBER_OF_CHANNELS; channel++) { - if (int_status & (1U << channel)) { - break; - } - } - //Check if the transfer type is memory-memory - if ((UDMA0_Table[channel].vsUDMAChaConfigData1.srcInc != UDMA_SRC_INC_NONE) && - (UDMA0_Table[channel].vsUDMAChaConfigData1.dstInc != UDMA_DST_INC_NONE) && - (udma0_chnl_info[channel].Size != udma0_chnl_info[channel].Cnt)) { - soft_trig_flag = 1; - } - ROMAPI_UDMA_WRAPPER_API->uDMAx_IRQHandler (&UDMA0_Resources,UDMA0_Table,udma0_chnl_info); - if(soft_trig_flag) { - //Set the software trigger bit for starting next transfer - UDMA0->CHNL_SW_REQUEST |=(1U << channel); - } - #else - uDMAx_IRQHandler (&UDMA0_Resources,UDMA0_Table,udma0_chnl_info); - #endif - NVIC_EnableIRQ(UDMA0_IRQn); -} - -void IRQ010_Handler (void) -{ - NVIC_DisableIRQ(UDMA1_IRQn); -#if defined(DAC_FIFO_MODE_EN) || defined(ADC_MULTICHANNEL_WITH_EXT_DMA) - volatile uint32_t intr = 0; - intr = UDMA1_Resources.reg->UDMA_DONE_STATUS_REG; - - if((intr & BIT(DAC_UDMA_CHANNEL)) || (intr & BIT(ADC_UDMA_CHANNEL))) - { - if(intr & BIT(DAC_UDMA_CHANNEL)) - { -#ifdef DAC_FIFO_MODE_EN - RSI_UDMA_InterruptClear(udmaHandle1, DAC_UDMA_CHANNEL); - dac_callback_fun.callback_event(DAC_UDMA_PING_PONG_CONFIG); -#endif - } - else - { -#ifdef ADC_MULTICHANNEL_WITH_EXT_DMA - RSI_UDMA_InterruptClear(udmaHandle1, ADC_UDMA_CHANNEL); - adc_commn_config.call_back_event(ADC_CHNL0_INTR , EXTERNAL_DMA_RECONFIG); -#endif - } - NVIC_EnableIRQ(UDMA1_IRQn); - return; - } -#endif -#if defined(A11_ROM) && defined(UDMA_ROMDRIVER_PRESENT) - uint8_t channel; - uint32_t int_status; - uint8_t soft_trig_flag = 0; - int_status = UDMA1->UDMA_DONE_STATUS_REG; - //Identify the interrupt channel - for (channel = 0; channel < 12; channel++) { - if (int_status & (1U << channel)) { - break; - } - } - //Check if the transfer type is memory-memory - if ((UDMA1_Table[channel].vsUDMAChaConfigData1.srcInc != UDMA_SRC_INC_NONE) && - (UDMA1_Table[channel].vsUDMAChaConfigData1.dstInc != UDMA_DST_INC_NONE) && - (udma1_chnl_info[channel].Size != udma1_chnl_info[channel].Cnt)) { - soft_trig_flag = 1; - } - ROMAPI_UDMA_WRAPPER_API->uDMAx_IRQHandler (&UDMA1_Resources,UDMA1_Table,udma1_chnl_info); - if(soft_trig_flag) { - //Set the software trigger bit for starting next transfer - UDMA1->CHNL_SW_REQUEST |=(1U << channel); - } -#else - uDMAx_IRQHandler (&UDMA1_Resources,UDMA1_Table,udma1_chnl_info); -#endif - NVIC_EnableIRQ(UDMA1_IRQn); -} \ No newline at end of file diff --git a/wiseconnect/components/device/silabs/si91x/mcu/drivers/cmsis_driver/USART.c b/wiseconnect/components/device/silabs/si91x/mcu/drivers/cmsis_driver/USART.c deleted file mode 100644 index 95ef740ae..000000000 --- a/wiseconnect/components/device/silabs/si91x/mcu/drivers/cmsis_driver/USART.c +++ /dev/null @@ -1,1221 +0,0 @@ - /* -------------------------------------------------------------------------- - * Copyright (c) 2013-2016 ARM Limited. All rights reserved. - * - * SPDX-License-Identifier: Apache-2.0 - * - * 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. - * - * $Date: 25 Sep 2019 - * $Revision: V1.1 - * - * Driver: Driver_USART - * Configured: via RTE_Device_917.h configuration file - * Project: USART Driver for RS1xxxx - */ - -/* History: - * Version 1.0 - * Initial release - */ -#include "rsi_ccp_user_config.h" - -#include "UDMA.h" -#include "USART.h" -#include "clock_update.h" -#include "rsi_usart.h" -#if (SLI_SI91X_MCU_RS485_MODE== 1) -#include "sl_si91x_driver_gpio.h" -#ifdef UART1_RS485_MODE -#include "sl_si91x_uart1_rs485_common_config.h" -#endif -#ifdef UART0_RS485_MODE -#include "sl_si91x_uart0_rs485_common_config.h" -#endif -#endif -#ifdef USART_MODULE -#include "sl_si91x_usart_common_config.h" -#endif -#ifdef UART_MODULE -#include "sl_si91x_uart_common_config.h" -#endif -#ifdef ULP_UART_MODULE -#include "sl_si91x_ulp_uart_common_config.h" -#endif -#if defined(A11_ROM) -#include "rsi_rom_table_si91x.h" -#endif - -#define ARM_USART_DRV_VERSION ARM_DRIVER_VERSION_MAJOR_MINOR(2,10) /* driver version */ -extern RSI_UDMA_HANDLE_T udmaHandle0; -extern RSI_UDMA_HANDLE_T udmaHandle1; //check -extern uint32_t dma_rom_buff0[30]; -extern uint32_t dma_rom_buff1[30]; //we can keep wrapeers - -#define CONTROL_STRUCT0 (UDMA_NUMBER_OF_CHANNELS * 2) -#define CONTROL_STRUCT1 (ULP_UDMA_NUMBER_OF_CHANNELS * 2) - -/* IAR support */ -#if defined(__ICCARM__) -#pragma location = UDMA0_SRAM_BASE -extern RSI_UDMA_DESC_T UDMA0_Table[CONTROL_STRUCT0]; -#pragma location = UDMA1_SRAM_BASE -extern RSI_UDMA_DESC_T UDMA1_Table[CONTROL_STRUCT1]; -#endif - -/* DMA descriptors must be aligned to 16 bytes */ -#if defined(__CC_ARM) -extern RSI_UDMA_DESC_T UDMA0_Table[CONTROL_STRUCT0] ; -extern RSI_UDMA_DESC_T UDMA1_Table[CONTROL_STRUCT1] ; -#endif /* defined (__CC_ARM) */ - -#if defined( __GNUC__ ) -extern RSI_UDMA_DESC_T __attribute__ ((section(".udma_addr0"))) UDMA0_Table[CONTROL_STRUCT0]; -extern RSI_UDMA_DESC_T __attribute__ ((section(".udma_addr1"))) UDMA1_Table[CONTROL_STRUCT1]; -#endif /* defined (__GNUC__) */ - -extern UDMA_Channel_Info udma0_chnl_info[32] ; -extern UDMA_Channel_Info udma1_chnl_info[12] ; - -#if defined(SL_USART0_DMA_CONFIG_ENABLE) && (SL_USART0_DMA_CONFIG_ENABLE == 1) -#define RTE_USART0_CHNL_UDMA_TX_EN 1 -#define RTE_USART0_CHNL_UDMA_RX_EN 1 -#endif -#if defined(SL_UART1_DMA_CONFIG_ENABLE) && (SL_UART1_DMA_CONFIG_ENABLE == 1) -#define RTE_UART1_CHNL_UDMA_TX_EN 1 -#define RTE_UART1_CHNL_UDMA_RX_EN 1 -#endif -#if defined(SL_ULPUART_DMA_CONFIG_ENABLE) && (SL_ULPUART_DMA_CONFIG_ENABLE == 1) -#define RTE_ULPUART_CHNL_UDMA_TX_EN 1 -#define RTE_ULPUART_CHNL_UDMA_RX_EN 1 -#endif -/* UDMA0 Resources */ -extern UDMA_RESOURCES UDMA0_Resources ; - -/* UDMA1 Resources */ -extern UDMA_RESOURCES UDMA1_Resources; - -// Driver Version -static const ARM_DRIVER_VERSION UsartDriverVersion = -{ - ARM_USART_API_VERSION, - ARM_USART_DRV_VERSION -}; -// USART AND UART1 -#if (RTE_USART0) -#define USART0_IRQ_HANDLER IRQ038_Handler -static USART_INFO USART0_Info = {0}; - -/* USART PIN configuration structure*/ -static USART_PIN usart0_clock = { RTE_USART0_CLK_PORT ,RTE_USART0_CLK_PIN ,RTE_USART0_CLK_MUX ,RTE_USART0_CLK_PAD }; -static USART_PIN usart0_tx = { RTE_USART0_TX_PORT ,RTE_USART0_TX_PIN ,RTE_USART0_TX_MUX ,RTE_USART0_TX_PAD }; -static USART_PIN usart0_rx = { RTE_USART0_RX_PORT ,RTE_USART0_RX_PIN ,RTE_USART0_RX_MUX ,RTE_USART0_RX_PAD }; -static USART_PIN usart0_cts = { RTE_USART0_CTS_PORT ,RTE_USART0_CTS_PIN ,RTE_USART0_CTS_MUX ,RTE_USART0_CTS_PAD }; -static USART_PIN usart0_rts = { RTE_USART0_RTS_PORT ,RTE_USART0_RTS_PIN ,RTE_USART0_RTS_MUX ,RTE_USART0_RTS_PAD }; -static USART_PIN usart0_ir_tx = { RTE_USART0_IR_TX_PORT ,RTE_USART0_IR_TX_PIN ,RTE_USART0_IR_TX_MUX ,RTE_USART0_IR_TX_PAD }; -static USART_PIN usart0_ir_rx = { RTE_USART0_IR_RX_PORT ,RTE_USART0_IR_RX_PIN ,RTE_USART0_IR_RX_MUX ,RTE_USART0_IR_RX_PAD }; -#if defined(RTE_USART0_CHNL_UDMA_TX_EN) && (RTE_USART0_CHNL_UDMA_TX_EN == 1) -void USART0_UDMA_Tx_Event (uint32_t event ,uint32_t dmaCh); -static USART_DMA USART0_UDMA_TX_CHNL = { - { - UDMA_MODE_BASIC, - 0, - (RTE_USART0_DMA_TX_LEN_PER_DES-1), - ARBSIZE_1, - 0x0, - 0x0, - SRC_SIZE_8, - SRC_INC_8, - DST_SIZE_8, - DST_INC_NONE - }, - RTE_USART0_CHNL_UDMA_TX_CH, - USART0_UDMA_Tx_Event -}; -#endif -#if defined(RTE_USART0_CHNL_UDMA_RX_EN) && (RTE_USART0_CHNL_UDMA_RX_EN == 1) -void USART0_UDMA_Rx_Event (uint32_t event ,uint32_t dmaCh); -static USART_DMA USART0_UDMA_RX_CHNL = { - { - UDMA_MODE_BASIC, - 0, - (RTE_USART0_DMA_RX_LEN_PER_DES-1), - ARBSIZE_1, - 0x0, - 0x0, - SRC_SIZE_8, - SRC_INC_NONE, - DST_SIZE_8, - DST_INC_8 - }, - RTE_USART0_CHNL_UDMA_RX_CH, - USART0_UDMA_Rx_Event -}; -#endif -//Resources structure -static USART_RESOURCES USART0_Resources = { - - { // Capabilities - 1, // supports UART(Asynchronous) mode - 1, // supports Synchronous Master mode - 1, // supports Synchronous Slave mode - 1, // supports UART Single-wire mode - 1, // supports UART IrDA mode(SIR_MODE) - 0, // supports UART Smart Card mode - 0, // Smart Card Clock generator - 1, // RTS Flow Control available - 1, // CTS Flow Control available - 1, // Transmit completed event: \ref ARM_USART_EVENT_TX_COMPLETE - 1, // Signal receive character timeout event: \ref ARM_USART_EVENT_RX_TIMEOUT - 1, // RTS Line: 0=not available, 1=available. - 1, // CTS Line: 0=not available, 1=available. - 1, // DTR Line: 0=not available, 1=available. - 1, // DSR Line: 0=not available, 1=available. - 1, // DCD Line: 0=not available, 1=available. - 1, // RI Line: 0=not available, 1=available. - 1, // Signal CTS change event(optional) - 1, // Signal DSR change event(optional) - 1, // event_dcd(Signal DCD change event) - 1, // Signal RI change event - }, // Capabilities end -#if(RTE_USART_MODE) - USART0, // USART ADDRESS -#else - UART0, // UART ADDRESS -#endif - USART0_IRQn, // IRQn -#if defined(RTE_USART0_CHNL_UDMA_TX_EN) && (RTE_USART0_CHNL_UDMA_TX_EN == 1) - &USART0_UDMA_TX_CHNL, -#else - NULL, -#endif -#if defined(RTE_USART0_CHNL_UDMA_RX_EN) && (RTE_USART0_CHNL_UDMA_RX_EN == 1) - &USART0_UDMA_RX_CHNL, -#else - NULL, -#endif - &USART0_Info , - { - //pins - &usart0_clock, - &usart0_tx, - &usart0_rx, - &usart0_cts, - &usart0_rts, - &usart0_ir_tx, - &usart0_ir_rx , - }, - { //clocks - RTE_USART0_CLK_SRC, - ULP_UART_REF_CLK, - RTE_USART0_CLK_DIV_FACT, - RTE_USART0_FRAC_DIV_SEL , - } , //clocks end - { //sync mode - RTE_USART_MODE, - RTE_CONTINUOUS_CLOCK_MODE, - }, //sync mode end -}; - -#endif - -// UART1 -#if (RTE_UART1) -#define UART1_IRQ_HANDLER IRQ039_Handler -static USART_INFO UART1_Info = {0}; - -static USART_PIN uart1_tx = { RTE_UART1_TX_PORT ,RTE_UART1_TX_PIN ,RTE_UART1_TX_MUX ,RTE_UART1_TX_PAD }; -static USART_PIN uart1_rx = { RTE_UART1_RX_PORT ,RTE_UART1_RX_PIN ,RTE_UART1_RX_MUX ,RTE_UART1_RX_PAD }; -static USART_PIN uart1_cts = { RTE_UART1_CTS_PORT ,RTE_UART1_CTS_PIN ,RTE_UART1_CTS_MUX ,RTE_UART1_CTS_PAD }; -static USART_PIN uart1_rts = { RTE_UART1_RTS_PORT ,RTE_UART1_RTS_PIN ,RTE_UART1_RTS_MUX ,RTE_UART1_RTS_PAD }; -#if defined(RTE_UART1_CHNL_UDMA_TX_EN) && (RTE_UART1_CHNL_UDMA_TX_EN == 1) -void UART1_UDMA_Tx_Event (uint32_t event ,uint32_t dmaCh); - -static USART_DMA UART1_UDMA_TX_CHNL = { - { - UDMA_MODE_BASIC, - 0, - (RTE_UART1_DMA_TX_LEN_PER_DES-1), - ARBSIZE_1, - 0x0, - 0x0, - SRC_SIZE_8, - SRC_INC_8, - DST_SIZE_8, - DST_INC_NONE - }, - RTE_UART1_CHNL_UDMA_TX_CH, - UART1_UDMA_Tx_Event -}; -#endif -#if defined(RTE_UART1_CHNL_UDMA_RX_EN) && (RTE_UART1_CHNL_UDMA_RX_EN == 1) -void UART1_UDMA_Rx_Event (uint32_t event ,uint32_t dmaCh); -static USART_DMA UART1_UDMA_RX_CHNL = { - { - UDMA_MODE_BASIC, - 0, - (RTE_UART1_DMA_RX_LEN_PER_DES-1), - ARBSIZE_1, - 0x0, - 0x0, - SRC_SIZE_8, - SRC_INC_NONE, - DST_SIZE_8, - DST_INC_8 - }, - RTE_UART1_CHNL_UDMA_RX_CH, - UART1_UDMA_Rx_Event -}; -#endif - -//Resources structure -static USART_RESOURCES UART1_Resources = { - - { // Capabilities - 1, // supports UART(Asynchronous) mode - 0, // synchronous_master (not supported) - 0, // synchronous_slave (not supported) - 1, // supports UART Single-wire mode - 0, // IRDA(SIR_MODE) mode (not supported) - 0, // smart_card (not supported) - 0, // smart_card_clock (not supported) - 1, // CTS Flow Control available - 1, // RTS Flow Control available - 1, // Transmit completed event: \ref ARM_USART_EVENT_TX_COMPLETE - 1, // Signal receive character timeout event: \ref ARM_USART_EVENT_RX_TIMEOUT - 1, // RTS Line: 0=not available, 1=available. - 1, // CTS Line: 0=not available, 1=available. - 0, // DTR Line: 0=not available, 1=available. - 0, // DSR Line: 0=not available, 1=available. - 0, // DCD Line: 0=not available, 1=available. - 0, // RI Line: 0=not available, 1=available. - 0, // Signal CTS change event(optional) - 0, // Signal DSR change event(optional) - 0, // event_dcd(Signal DCD change event) - 0, // Signal RI change event - }, // Capabilities end - - UART1, // ADDRESS - UART1_IRQn, // IRQn -#if defined(RTE_UART1_CHNL_UDMA_TX_EN) && (RTE_UART1_CHNL_UDMA_TX_EN == 1) - &UART1_UDMA_TX_CHNL, -#else - NULL, -#endif -#if defined(RTE_UART1_CHNL_UDMA_RX_EN) && (RTE_UART1_CHNL_UDMA_RX_EN == 1) - &UART1_UDMA_RX_CHNL, -#else - NULL, -#endif - &UART1_Info, - { - NULL, - &uart1_tx, - &uart1_rx, - &uart1_cts, - &uart1_rts, - NULL, - NULL, - }, - - { //clocks - RTE_UART1_CLK_SRC, - ULP_UART_REF_CLK, - RTE_UART1_CLK_DIV_FACT, - RTE_UART1_FRAC_DIV_SEL , - } , - - { //sync mode - 0, - 0, - }, -}; - -#endif - -// ULPSS UART -#if (RTE_ULP_UART) -#define ULP_UART_IRQ_HANDLER IRQ012_Handler -static USART_INFO ULP_UART_Info = {0}; - -static USART_PIN ulp_uart_tx = { RTE_ULP_UART_TX_PORT ,RTE_ULP_UART_TX_PIN ,RTE_ULP_UART_TX_MUX ,RTE_ULP_UART_TX_PAD }; -static USART_PIN ulp_uart_rx = { RTE_ULP_UART_RX_PORT ,RTE_ULP_UART_RX_PIN ,RTE_ULP_UART_RX_MUX ,RTE_ULP_UART_RX_PAD }; -static USART_PIN ulp_uart_cts = { RTE_ULP_UART_CTS_PORT ,RTE_ULP_UART_CTS_PIN ,RTE_ULP_UART_CTS_MUX ,RTE_ULP_UART_CTS_PAD }; -static USART_PIN ulp_uart_rts = { RTE_ULP_UART_RTS_PORT ,RTE_ULP_UART_RTS_PIN ,RTE_ULP_UART_RTS_MUX ,RTE_ULP_UART_RTS_PAD }; - -#if defined(RTE_ULPUART_CHNL_UDMA_TX_EN) && (RTE_ULPUART_CHNL_UDMA_TX_EN == 1) -void ULPUART_UDMA_Tx_Event (uint32_t event ,uint32_t dmaCh); -static USART_DMA ULPUART_UDMA_TX_CHNL = { - { - UDMA_MODE_BASIC, - 0, - (RTE_ULP_UART_DMA_TX_LEN_PER_DES-1), - ARBSIZE_1, - 0x0, - 0x0, - SRC_SIZE_8, - SRC_INC_8, - DST_SIZE_8, - DST_INC_NONE - }, - RTE_ULPUART_CHNL_UDMA_TX_CH, - ULPUART_UDMA_Tx_Event -}; -#endif -#if defined(RTE_ULPUART_CHNL_UDMA_RX_EN) && (RTE_ULPUART_CHNL_UDMA_RX_EN == 1) -void ULPUART_UDMA_Rx_Event (uint32_t event ,uint32_t dmaCh); -static USART_DMA ULPUART_UDMA_RX_CHNL = { - { - UDMA_MODE_BASIC, - 0, - (RTE_ULP_UART_DMA_RX_LEN_PER_DES-1), - ARBSIZE_1, - 0x0, - 0x0, - SRC_SIZE_8, - SRC_INC_NONE, - DST_SIZE_8, - DST_INC_8 - }, - RTE_ULPUART_CHNL_UDMA_RX_CH, - ULPUART_UDMA_Rx_Event -}; -#endif - -// Resources structure -static USART_RESOURCES ULP_UART_Resources = { - - { // Capabilities - 1, // supports UART(Asynchronous) mode - 0, // synchronous_master (Not supported) - 0, // synchronous_slave (Not supported) - 1, // single_wire - 0, // IRDA (Not supported) - 0, // smart_card (Not supported) - 0, // smart_card_clock (Not supported) - #ifdef USART_ROMDRIVER_PRESENT - 0, // RTS Flow Control available - 0, // CTS Flow Control available - #else - 1, // RTS Flow Control available - 1, // CTS Flow Control available - #endif - 1, // Transmit completed event: \ref ARM_USART_EVENT_TX_COMPLETE - 1, // Signal receive character timeout event: \ref ARM_USART_EVENT_RX_TIMEOUT - #ifdef USART_ROMDRIVER_PRESENT - 0, // RTS Line: 0=not available, 1=available. - 0, // CTS Line: 0=not available, 1=available. - #else - 1, // RTS Line: 0=not available, 1=available. - 1, // CTS Line: 0=not available, 1=available. - #endif - 0, // DTR Line: 0=not available, 1=available. - 0, // DSR Line: 0=not available, 1=available. - 0, // DCD Line: 0=not available, 1=available. - 0, // RI Line: 0=not available, 1=available. - 0, // Signal CTS change event(optional) - 0, // Signal DSR change event(optional) - 0, // event_dcd(Signal DCD change event) - 0, // Signal RI change event - }, // Capabilities end - - ULP_UART, // ADDRESS - ULPSS_UART_IRQn, // IRQn -#if defined(RTE_ULPUART_CHNL_UDMA_TX_EN) && (RTE_ULPUART_CHNL_UDMA_TX_EN == 1) - &ULPUART_UDMA_TX_CHNL, -#else - NULL, -#endif -#if defined(RTE_ULPUART_CHNL_UDMA_RX_EN) && (RTE_ULPUART_CHNL_UDMA_RX_EN == 1) - &ULPUART_UDMA_RX_CHNL, -#else - NULL, -#endif - &ULP_UART_Info, - - { - NULL ,//pins - &ulp_uart_tx, - &ulp_uart_rx, - &ulp_uart_cts, - &ulp_uart_rts , - NULL, - NULL, - }, - { //clocks - USART_ULPREFCLK , - RTE_ULP_UART_CLK_SRC, - RTE_ULP_UART_CLK_DIV_FACT, - RTE_ULP_UART_FRAC_SEL , - } ,//clocks end - - { //sync mode - 0, - 0, - }, -}; - -#endif - -ARM_DRIVER_VERSION ARM_USARTx_GetVersion(void) -{ - return UsartDriverVersion; -} -/** - @fn ARM_USART_CAPABILITIES USART_GetCapabilities (const USART_RESOURCES *usart) - @brief Gets driver capabilities - @param[in] usart Pointer to USART resources - @return \ref ARM_USART_CAPABILITIES - */ -ARM_USART_CAPABILITIES USART_GetCapabilities (const USART_RESOURCES *usart) -{ - return usart->capabilities; -} -//USART0 -#if(RTE_USART0) -static ARM_USART_CAPABILITIES ARM_USART0_GetCapabilities (void) -{ - return USART_GetCapabilities (&USART0_Resources); -} -static int32_t ARM_USART0_Initialize (ARM_USART_SignalEvent_t cb_event) -{ -#if defined(A11_ROM) && defined(USART_ROMDRIVER_PRESENT) - return ROMAPI_USART_API->USART_Initialize (cb_event, &USART0_Resources,&UDMA0_Resources,UDMA0_Table,&udmaHandle0,dma_rom_buff0); -#else - return USART_Initialize (cb_event, &USART0_Resources,&UDMA0_Resources,UDMA0_Table,&udmaHandle0,dma_rom_buff0); -#endif -} - -static int32_t ARM_USART0_Uninitialize (void) -{ -#if defined(A11_ROM) && defined(USART_ROMDRIVER_PRESENT) - return ROMAPI_USART_API->USART_Uninitialize(&USART0_Resources,&UDMA0_Resources); -#else - return USART_Uninitialize(&USART0_Resources,&UDMA0_Resources); -#endif -} - -static int32_t ARM_USART0_PowerControl (ARM_POWER_STATE state) -{ -#if defined(A11_ROM) && defined(USART_ROMDRIVER_PRESENT) - return ROMAPI_USART_API->USART_PowerControl (state, &USART0_Resources,&UDMA0_Resources,udmaHandle0); -#else - return USART_PowerControl (state, &USART0_Resources,&UDMA0_Resources,udmaHandle0); -#endif -} - -static int32_t ARM_USART0_Send (const void *data, uint32_t num) -{ - if(num < RTE_USART0_DMA_TX_LEN_PER_DES) { - USART0_Resources.dma_tx->control.totalNumOfDMATrans=(unsigned int)((num-1) & 0x03FF); - } - else - { - USART0_Resources.dma_tx->control.totalNumOfDMATrans=RTE_USART0_DMA_TX_LEN_PER_DES-1; - } -#if defined(A11_ROM) && defined(USART_ROMDRIVER_PRESENT) - return ROMAPI_USART_API->USART_Send_Data (data, num, &USART0_Resources ,&UDMA0_Resources,udma0_chnl_info,udmaHandle0); -#else - return USART_Send_Data (data, num, &USART0_Resources ,&UDMA0_Resources,udma0_chnl_info,udmaHandle0); -#endif - -} -static int32_t ARM_USART0_Receive (const void *data, uint32_t num) -{ - if(num < RTE_USART0_DMA_RX_LEN_PER_DES) { - USART0_Resources.dma_rx->control.totalNumOfDMATrans=(unsigned int)((num-1) & 0x03FF); - } - else - { - USART0_Resources.dma_rx->control.totalNumOfDMATrans=RTE_USART0_DMA_RX_LEN_PER_DES-1; - } -#if defined(A11_ROM) && defined(USART_ROMDRIVER_PRESENT) - return ROMAPI_USART_API->USART_Receive_Data ( data, num,&USART0_Resources,&UDMA0_Resources,udma0_chnl_info,udmaHandle0); -#else - return USART_Receive_Data ( data, num,&USART0_Resources,&UDMA0_Resources,udma0_chnl_info,udmaHandle0); -#endif -} - -static int32_t ARM_USART0_Transfer (const void *data_out, const void *data_in, uint32_t num) -{ - if((num < RTE_USART0_DMA_TX_LEN_PER_DES) && (num < RTE_USART0_DMA_RX_LEN_PER_DES)) { - - USART0_Resources.dma_tx->control.totalNumOfDMATrans=(unsigned int)((num-1) & 0x03FF); - USART0_Resources.dma_rx->control.totalNumOfDMATrans=(unsigned int)((num-1) & 0x03FF); - } - else - { - USART0_Resources.dma_tx->control.totalNumOfDMATrans=RTE_USART0_DMA_TX_LEN_PER_DES-1; - USART0_Resources.dma_rx->control.totalNumOfDMATrans=RTE_USART0_DMA_RX_LEN_PER_DES-1; - } -#if defined(A11_ROM) && defined(USART_ROMDRIVER_PRESENT) - return ROMAPI_USART_API->USART_Transfer (data_out, data_in, num, &USART0_Resources,&UDMA0_Resources,udma0_chnl_info,udmaHandle0); -#else - return USART_Transfer (data_out, data_in, num, &USART0_Resources,&UDMA0_Resources,udma0_chnl_info,udmaHandle0); -#endif -} - -static uint32_t ARM_USART0_GetTxCount (void) -{ -#if defined(A11_ROM) && defined(USART_ROMDRIVER_PRESENT) - return ROMAPI_USART_API->USART_GetTxCount (&USART0_Resources); -#else - return USART_GetTxCount(&USART0_Resources); -#endif -} - -static uint32_t ARM_USART0_GetRxCount (void) -{ -#if defined(A11_ROM) && defined(USART_ROMDRIVER_PRESENT) - return ROMAPI_USART_API->USART_GetRxCount(&USART0_Resources); -#else - return USART_GetRxCount(&USART0_Resources); -#endif -} - -static int32_t ARM_USART0_Control (uint32_t control, uint32_t arg) -{ -#if RTE_USART_MODE - if(arg!=1) - arg= (arg >> 3); -#endif - uint32_t usart0_get_clock=0; - usart0_get_clock = RSI_CLK_GetBaseClock(M4_USART0); -#if defined(A11_ROM) && defined(USART_ROMDRIVER_PRESENT) - return ROMAPI_USART_API->USART_Control (control, arg, usart0_get_clock, &USART0_Resources,&UDMA0_Resources,udmaHandle0); -#else - return USART_Control (control, arg, usart0_get_clock, &USART0_Resources,&UDMA0_Resources,udmaHandle0); -#endif -} - -static ARM_USART_STATUS ARM_USART0_GetStatus (void) -{ -#if defined(A11_ROM) && defined(USART_ROMDRIVER_PRESENT) - return ROMAPI_USART_API->USART_GetStatus(&USART0_Resources); -#else - return USART_GetStatus(&USART0_Resources); -#endif -} - -static int32_t ARM_USART0_SetModemControl (ARM_USART_MODEM_CONTROL control) -{ -#if defined(A11_ROM) && defined(USART_ROMDRIVER_PRESENT) - return ROMAPI_USART_API->USART_SetModemControl (control, &USART0_Resources); -#else - return USART_SetModemControl(control, &USART0_Resources); -#endif -} - -static ARM_USART_MODEM_STATUS ARM_USART0_GetModemStatus (void) -{ -#if defined(A11_ROM) && defined(USART_ROMDRIVER_PRESENT) - return ROMAPI_USART_API->USART_GetModemStatus (&USART0_Resources); -#else - return USART_GetModemStatus(&USART0_Resources); -#endif -} - -void RSI_M4SSUsart0Handler(void) -{ -#if defined(A11_ROM) && defined(USART_ROMDRIVER_PRESENT) - ROMAPI_USART_API->UartIrqHandler(&USART0_Resources); -#else - UartIrqHandler(&USART0_Resources); -#endif -} -#if defined(RTE_USART0_CHNL_UDMA_TX_EN) && (RTE_USART0_CHNL_UDMA_TX_EN == 1) -void USART0_UDMA_Tx_Event (uint32_t event, uint32_t dmaCh) -{ -#if defined(A11_ROM) && defined(USART_ROMDRIVER_PRESENT) - ROMAPI_USART_API->USART_UDMA_Tx_Event (event,dmaCh, &USART0_Resources); -#else - USART_UDMA_Tx_Event (event,(uint8_t)dmaCh, &USART0_Resources); -#endif -} -#endif -#if defined(RTE_USART0_CHNL_UDMA_RX_EN) && (RTE_USART0_CHNL_UDMA_RX_EN == 1) -void USART0_UDMA_Rx_Event (uint32_t event,uint32_t dmaCh) -{ -#if defined(A11_ROM) && defined(USART_ROMDRIVER_PRESENT) - ROMAPI_USART_API->USART_UDMA_Rx_Event (event,dmaCh, &USART0_Resources); -#else - USART_UDMA_Rx_Event (event,(uint8_t)dmaCh, &USART0_Resources); -#endif -} -#endif - -// USART driver functions structure -ARM_DRIVER_USART Driver_USART0 = -{ - ARM_USARTx_GetVersion, - ARM_USART0_GetCapabilities, - ARM_USART0_Initialize, - ARM_USART0_Uninitialize, - ARM_USART0_PowerControl, - ARM_USART0_Send, - ARM_USART0_Receive, - ARM_USART0_Transfer, - ARM_USART0_GetTxCount, - ARM_USART0_GetRxCount, - ARM_USART0_Control, - ARM_USART0_GetStatus, - ARM_USART0_SetModemControl, - ARM_USART0_GetModemStatus -}; -// USART_IRQ_HANDLER -void USART0_IRQ_HANDLER (void) -{ -#if defined(A11_ROM) && defined(USART_ROMDRIVER_PRESENT) - ROMAPI_USART_API->UartIrqHandler(&USART0_Resources); -#else - UartIrqHandler(&USART0_Resources); -#endif -} - -#endif - -//UART1 -#if(RTE_UART1) - -static ARM_USART_CAPABILITIES ARM_UART1_GetCapabilities (void) -{ - return USART_GetCapabilities (&UART1_Resources); -} - -static int32_t ARM_UART1_Initialize (ARM_USART_SignalEvent_t cb_event) -{ -#if defined(A11_ROM) && defined(USART_ROMDRIVER_PRESENT) - return ROMAPI_USART_API->USART_Initialize (cb_event, &UART1_Resources,&UDMA0_Resources,UDMA0_Table,&udmaHandle0,dma_rom_buff0); -#else - return USART_Initialize (cb_event, &UART1_Resources,&UDMA0_Resources,UDMA0_Table,&udmaHandle0,dma_rom_buff0); -#endif -} - -static int32_t ARM_UART1_Uninitialize (void) -{ -#if defined(A11_ROM) && defined(USART_ROMDRIVER_PRESENT) - return ROMAPI_USART_API->USART_Uninitialize(&UART1_Resources,&UDMA0_Resources); -#else - return USART_Uninitialize(&UART1_Resources,&UDMA0_Resources); -#endif -} - -static int32_t ARM_UART1_PowerControl (ARM_POWER_STATE state) -{ -#if defined(A11_ROM) && defined(USART_ROMDRIVER_PRESENT) - return ROMAPI_USART_API->USART_PowerControl (state, &UART1_Resources,&UDMA0_Resources,udmaHandle0); -#else - return USART_PowerControl (state, &UART1_Resources,&UDMA0_Resources,udmaHandle0); -#endif -} - -static int32_t ARM_UART1_Send (const void *data, uint32_t num) -{ - if(num < RTE_UART1_DMA_TX_LEN_PER_DES) { - UART1_Resources.dma_tx->control.totalNumOfDMATrans = (unsigned int)((num-1) & 0x03FF); - } - else - { - UART1_Resources.dma_tx->control.totalNumOfDMATrans = RTE_UART1_DMA_TX_LEN_PER_DES-1; - } -#if defined(A11_ROM) && defined(USART_ROMDRIVER_PRESENT) - return ROMAPI_USART_API->USART_Send_Data (data, num, &UART1_Resources ,&UDMA0_Resources,udma0_chnl_info,udmaHandle0); -#else - return USART_Send_Data (data, num, &UART1_Resources ,&UDMA0_Resources,udma0_chnl_info,udmaHandle0); -#endif -} - -static int32_t ARM_UART1_Receive (const void *data, uint32_t num) -{ - if(num < RTE_UART1_DMA_RX_LEN_PER_DES) { - UART1_Resources.dma_rx->control.totalNumOfDMATrans = (unsigned int)((num-1) & 0x03FF); - } - else - { - UART1_Resources.dma_rx->control.totalNumOfDMATrans = RTE_UART1_DMA_RX_LEN_PER_DES-1; - } -#if defined(A11_ROM) && defined(USART_ROMDRIVER_PRESENT) - return ROMAPI_USART_API->USART_Receive_Data ( data, num,&UART1_Resources,&UDMA0_Resources,udma0_chnl_info,udmaHandle0); -#else - return USART_Receive_Data ( data, num,&UART1_Resources,&UDMA0_Resources,udma0_chnl_info,udmaHandle0); -#endif -} - -static int32_t ARM_UART1_Transfer (const void *data_out, const void *data_in, uint32_t num) -{ - if((num < RTE_UART1_DMA_TX_LEN_PER_DES) && (num < RTE_UART1_DMA_RX_LEN_PER_DES)) { - UART1_Resources.dma_tx->control.totalNumOfDMATrans = (unsigned int)((num-1) & 0x03FF); - UART1_Resources.dma_rx->control.totalNumOfDMATrans = (unsigned int)((num-1) & 0x03FF); - } - else - { - UART1_Resources.dma_tx->control.totalNumOfDMATrans = RTE_UART1_DMA_TX_LEN_PER_DES-1; - UART1_Resources.dma_rx->control.totalNumOfDMATrans = RTE_UART1_DMA_RX_LEN_PER_DES-1; - } -#if defined(A11_ROM) && defined(USART_ROMDRIVER_PRESENT) - return ROMAPI_USART_API->USART_Transfer (data_out, data_in, num, &UART1_Resources,&UDMA0_Resources,udma0_chnl_info,udmaHandle0); -#else - return USART_Transfer (data_out, data_in, num, &UART1_Resources,&UDMA0_Resources,udma0_chnl_info,udmaHandle0); -#endif -} - -static uint32_t ARM_UART1_GetTxCount (void) -{ -#if defined(A11_ROM) && defined(USART_ROMDRIVER_PRESENT) - return ROMAPI_USART_API->USART_GetTxCount (&UART1_Resources); -#else - return USART_GetTxCount(&UART1_Resources); -#endif -} - -static uint32_t ARM_UART1_GetRxCount (void) -{ -#if defined(A11_ROM) && defined(USART_ROMDRIVER_PRESENT) - return ROMAPI_USART_API->USART_GetRxCount(&UART1_Resources); -#else - return USART_GetRxCount(&UART1_Resources); -#endif -} - -static int32_t ARM_UART1_Control (uint32_t control, uint32_t arg) -{ - uint32_t uart1_get_clock; - uart1_get_clock = RSI_CLK_GetBaseClock(M4_UART1); -#if defined(A11_ROM) && defined(USART_ROMDRIVER_PRESENT) - return ROMAPI_USART_API->USART_Control (control, arg, uart1_get_clock, &UART1_Resources,&UDMA0_Resources,udmaHandle0); -#else - return USART_Control (control, arg, uart1_get_clock, &UART1_Resources,&UDMA0_Resources,udmaHandle0); -#endif -} - -static ARM_USART_STATUS ARM_UART1_GetStatus (void) -{ -#if defined(A11_ROM) && defined(USART_ROMDRIVER_PRESENT) - return ROMAPI_USART_API->USART_GetStatus(&UART1_Resources); -#else - return USART_GetStatus(&UART1_Resources); -#endif -} - -static int32_t ARM_UART1_SetModemControl (ARM_USART_MODEM_CONTROL control) -{ -#if defined(A11_ROM) && defined(USART_ROMDRIVER_PRESENT) - return ROMAPI_USART_API->USART_SetModemControl (control, &UART1_Resources); -#else - return USART_SetModemControl(control, &UART1_Resources); -#endif -} - -static ARM_USART_MODEM_STATUS ARM_UART1_GetModemStatus (void) -{ -#if defined(A11_ROM) && defined(USART_ROMDRIVER_PRESENT) - return ROMAPI_USART_API->USART_GetModemStatus (&UART1_Resources); -#else - return USART_GetModemStatus(&UART1_Resources); -#endif -} - -void RSI_M4SSUart1Handler(void) -{ -#if defined(A11_ROM) && defined(USART_ROMDRIVER_PRESENT) - ROMAPI_USART_API->UartIrqHandler(&UART1_Resources); -#else - UartIrqHandler(&UART1_Resources); -#endif -} - -#if defined(RTE_UART1_CHNL_UDMA_TX_EN) && (RTE_UART1_CHNL_UDMA_TX_EN == 1) -void UART1_UDMA_Tx_Event (uint32_t event,uint32_t dmaCh) -{ -#if defined(A11_ROM) && defined(USART_ROMDRIVER_PRESENT) - ROMAPI_USART_API->USART_UDMA_Tx_Event (event,dmaCh, &UART1_Resources); -#else - USART_UDMA_Tx_Event (event,(uint8_t)dmaCh, &UART1_Resources); -#endif -} -#endif - -#if defined(RTE_UART1_CHNL_UDMA_RX_EN) && (RTE_UART1_CHNL_UDMA_RX_EN == 1) -void UART1_UDMA_Rx_Event (uint32_t event,uint32_t dmaCh) -{ -#if defined(A11_ROM) && defined(USART_ROMDRIVER_PRESENT) - ROMAPI_USART_API->USART_UDMA_Rx_Event (event,dmaCh, &UART1_Resources); -#else - USART_UDMA_Rx_Event (event,(uint8_t)dmaCh, &UART1_Resources); -#endif -} -#endif -// USART driver functions structure -ARM_DRIVER_USART Driver_UART1 = { - ARM_USARTx_GetVersion, - ARM_UART1_GetCapabilities, - ARM_UART1_Initialize, - ARM_UART1_Uninitialize, - ARM_UART1_PowerControl, - ARM_UART1_Send, - ARM_UART1_Receive, - ARM_UART1_Transfer, - ARM_UART1_GetTxCount, - ARM_UART1_GetRxCount, - ARM_UART1_Control, - ARM_UART1_GetStatus, - ARM_UART1_SetModemControl, - ARM_UART1_GetModemStatus -}; - -// USART_IRQ_HANDLER -void UART1_IRQ_HANDLER (void) -{ -#if defined(A11_ROM) && defined(USART_ROMDRIVER_PRESENT) - ROMAPI_USART_API->UartIrqHandler(&UART1_Resources); -#else - UartIrqHandler(&UART1_Resources); -#endif -} -#endif - -//ULP_UART -#if(RTE_ULP_UART) -static ARM_USART_CAPABILITIES ARM_ULP_UART_GetCapabilities (void) -{ - return USART_GetCapabilities (&ULP_UART_Resources); -} -static int32_t ARM_ULP_UART_Initialize (ARM_USART_SignalEvent_t cb_event) -{ -#if defined(A11_ROM) && defined(USART_ROMDRIVER_PRESENT) - return ROMAPI_USART_API->USART_Initialize (cb_event, &ULP_UART_Resources,&UDMA1_Resources,UDMA1_Table,&udmaHandle1,dma_rom_buff1); -#else - return USART_Initialize (cb_event, &ULP_UART_Resources,&UDMA1_Resources,UDMA1_Table,&udmaHandle1,dma_rom_buff1); -#endif -} - -static int32_t ARM_ULP_UART_Uninitialize (void) -{ - RSI_PS_UlpssPeriPowerDown(ULPSS_PWRGATE_ULP_UART); -#if defined(A11_ROM) && defined(USART_ROMDRIVER_PRESENT) - return ROMAPI_USART_API->USART_Uninitialize(&ULP_UART_Resources ,&UDMA1_Resources); -#else - return USART_Uninitialize(&ULP_UART_Resources ,&UDMA1_Resources); -#endif -} - -static int32_t ARM_ULP_UART_PowerControl (ARM_POWER_STATE state) -{ -#if defined(A11_ROM) && defined(USART_ROMDRIVER_PRESENT) - return ROMAPI_USART_API->USART_PowerControl (state, &ULP_UART_Resources ,&UDMA1_Resources,udmaHandle1); -#else - return USART_PowerControl (state, &ULP_UART_Resources ,&UDMA1_Resources,udmaHandle1); -#endif -} - -static int32_t ARM_ULP_UART_Send (const void *data, uint32_t num) -{ - if(num < RTE_ULP_UART_DMA_TX_LEN_PER_DES) { - ULP_UART_Resources.dma_tx->control.totalNumOfDMATrans = (unsigned int)((num-1) & 0x03FF); - } - else - { - ULP_UART_Resources.dma_tx->control.totalNumOfDMATrans = RTE_ULP_UART_DMA_TX_LEN_PER_DES-1; - } -#if defined(A11_ROM) && defined(USART_ROMDRIVER_PRESENT) - return ROMAPI_USART_API->USART_Send_Data (data, num, &ULP_UART_Resources ,&UDMA1_Resources,udma1_chnl_info,udmaHandle1); -#else - return USART_Send_Data (data, num, &ULP_UART_Resources ,&UDMA1_Resources,udma1_chnl_info,udmaHandle1); -#endif -} - -static int32_t ARM_ULP_UART_Receive (const void *data, uint32_t num) -{ - if(num < RTE_ULP_UART_DMA_RX_LEN_PER_DES) { - ULP_UART_Resources.dma_rx->control.totalNumOfDMATrans = (unsigned int)((num-1) & 0x03FF); - } - else - { - ULP_UART_Resources.dma_rx->control.totalNumOfDMATrans = RTE_ULP_UART_DMA_RX_LEN_PER_DES-1; - } -#if defined(A11_ROM) && defined(USART_ROMDRIVER_PRESENT) - return ROMAPI_USART_API->USART_Receive_Data ( data, num,&ULP_UART_Resources,&UDMA1_Resources,udma1_chnl_info,udmaHandle1); -#else - return USART_Receive_Data ( data, num,&ULP_UART_Resources,&UDMA1_Resources,udma1_chnl_info,udmaHandle1); -#endif -} - -static int32_t ARM_ULP_UART_Transfer (const void *data_out, const void *data_in, uint32_t num) -{ - if((num < RTE_ULP_UART_DMA_TX_LEN_PER_DES) && (num < RTE_ULP_UART_DMA_RX_LEN_PER_DES)) { - ULP_UART_Resources.dma_tx->control.totalNumOfDMATrans = (unsigned int)((num-1) & 0x03FF); - ULP_UART_Resources.dma_rx->control.totalNumOfDMATrans = (unsigned int)((num-1) & 0x03FF); - } - else - { - ULP_UART_Resources.dma_tx->control.totalNumOfDMATrans = RTE_ULP_UART_DMA_TX_LEN_PER_DES-1; - ULP_UART_Resources.dma_rx->control.totalNumOfDMATrans = RTE_ULP_UART_DMA_RX_LEN_PER_DES-1; - } -#if defined(A11_ROM) && defined(USART_ROMDRIVER_PRESENT) - return ROMAPI_USART_API->USART_Transfer (data_out, data_in, num, &ULP_UART_Resources ,&UDMA1_Resources,udma1_chnl_info,udmaHandle1); -#else - return USART_Transfer (data_out, data_in, num, &ULP_UART_Resources ,&UDMA1_Resources,udma1_chnl_info,udmaHandle1); -#endif -} - -static uint32_t ARM_ULP_UART_GetTxCount (void) -{ -#if defined(A11_ROM) && defined(USART_ROMDRIVER_PRESENT) - return ROMAPI_USART_API->USART_GetTxCount (&ULP_UART_Resources); -#else - return USART_GetTxCount(&ULP_UART_Resources); -#endif -} - -static uint32_t ARM_ULP_UART_GetRxCount (void) -{ -#if defined(A11_ROM) && defined(USART_ROMDRIVER_PRESENT) - return ROMAPI_USART_API->USART_GetRxCount(&ULP_UART_Resources); -#else - return USART_GetRxCount(&ULP_UART_Resources); -#endif -} - -static int32_t ARM_ULP_UART_Control (uint32_t control, uint32_t arg) -{ - uint32_t ulp_uart_get_clock; - ulp_uart_get_clock = RSI_CLK_GetBaseClock(ULPSS_UART); -#if defined(A11_ROM) && defined(USART_ROMDRIVER_PRESENT) - return ROMAPI_USART_API->USART_Control (control, arg, ulp_uart_get_clock, &ULP_UART_Resources ,&UDMA1_Resources,udmaHandle1); -#else - return USART_Control (control, arg, ulp_uart_get_clock, &ULP_UART_Resources ,&UDMA1_Resources,udmaHandle1); -#endif -} - -static ARM_USART_STATUS ARM_ULP_UART_GetStatus (void) -{ -#if defined(A11_ROM) && defined(USART_ROMDRIVER_PRESENT) - return ROMAPI_USART_API->USART_GetStatus(&ULP_UART_Resources); -#else - return USART_GetStatus(&ULP_UART_Resources); -#endif -} - -static int32_t ARM_ULP_UART_SetModemControl (ARM_USART_MODEM_CONTROL control) -{ -#if defined(A11_ROM) && defined(USART_ROMDRIVER_PRESENT) - return ROMAPI_USART_API->USART_SetModemControl (control, &ULP_UART_Resources); -#else - return USART_SetModemControl(control, &ULP_UART_Resources); -#endif -} - -static ARM_USART_MODEM_STATUS ARM_ULP_UART_GetModemStatus (void) -{ -#if defined(A11_ROM) && defined(USART_ROMDRIVER_PRESENT) - return ROMAPI_USART_API->USART_GetModemStatus (&ULP_UART_Resources); -#else - return USART_GetModemStatus(&ULP_UART_Resources); -#endif -} - -void RSI_ULPUartHandler(void) -{ -#if defined(A11_ROM) && defined(USART_ROMDRIVER_PRESENT) - ROMAPI_USART_API->UartIrqHandler(&ULP_UART_Resources); -#else - UartIrqHandler(&ULP_UART_Resources); -#endif -} - -#if defined(RTE_ULPUART_CHNL_UDMA_TX_EN) && (RTE_ULPUART_CHNL_UDMA_TX_EN == 1) -void ULPUART_UDMA_Tx_Event (uint32_t event,uint32_t dmaCh) -{ -#if defined(A11_ROM) && defined(USART_ROMDRIVER_PRESENT) - ROMAPI_USART_API->USART_UDMA_Tx_Event (event,dmaCh, &ULP_UART_Resources); -#else - USART_UDMA_Tx_Event (event,(uint8_t)dmaCh, &ULP_UART_Resources); -#endif -} -#endif - -#if defined(RTE_ULPUART_CHNL_UDMA_RX_EN) && (RTE_ULPUART_CHNL_UDMA_RX_EN == 1) -void ULPUART_UDMA_Rx_Event (uint32_t event,uint32_t dmaCh) -{ -#if defined(A11_ROM) && defined(USART_ROMDRIVER_PRESENT) - ROMAPI_USART_API->USART_UDMA_Rx_Event (event,dmaCh, &ULP_UART_Resources); -#else - USART_UDMA_Rx_Event (event,(uint8_t)dmaCh, &ULP_UART_Resources); -#endif -} -#endif -// USART driver functions structure -ARM_DRIVER_USART Driver_ULP_UART = { - ARM_USARTx_GetVersion, - ARM_ULP_UART_GetCapabilities, - ARM_ULP_UART_Initialize, - ARM_ULP_UART_Uninitialize, - ARM_ULP_UART_PowerControl, - ARM_ULP_UART_Send, - ARM_ULP_UART_Receive, - ARM_ULP_UART_Transfer, - ARM_ULP_UART_GetTxCount, - ARM_ULP_UART_GetRxCount, - ARM_ULP_UART_Control, - ARM_ULP_UART_GetStatus, - ARM_ULP_UART_SetModemControl, - ARM_ULP_UART_GetModemStatus -}; - -// USART_IRQ_HANDLER -void ULP_UART_IRQ_HANDLER (void) -{ -#if defined(A11_ROM) && defined(USART_ROMDRIVER_PRESENT) - ROMAPI_USART_API->UartIrqHandler(&ULP_UART_Resources); -#else - UartIrqHandler(&ULP_UART_Resources); -#endif -} -uint32_t USART_GetParity_StopBit(uint8_t usart_peripheral) -{ - uint32_t reg_value = false; - - switch (usart_peripheral) { - case USART_0: - reg_value = USART0_Resources.pREGS->LCR; - break; - - case UART_1: - reg_value = UART1_Resources.pREGS->LCR; - break; - - case ULPUART: - reg_value = ULP_UART_Resources.pREGS->LCR; - break; - - default: - break; - } - return reg_value; -} -uint32_t USART_GetBaudrate(uint8_t usart_peripheral) -{ - uint32_t baud_rate = 0; - - switch (usart_peripheral) { - case USART_0: - baud_rate = USART0_Resources.info->baudrate; - break; - - case UART_1: - baud_rate = UART1_Resources.info->baudrate; - break; - - case ULPUART: - baud_rate = ULP_UART_Resources.info->baudrate; - break; - - default: - break; - } - return baud_rate; -} -uint8_t USART_GetInitState(uint8_t usart_peripheral) -{ - uint8_t init_state = false; - - switch (usart_peripheral) { - case USART_0: - init_state = (USART0_Resources.info->flags & USART_FLAG_INITIALIZED); - break; - - case UART_1: - init_state = (UART1_Resources.info->flags & USART_FLAG_INITIALIZED); - break; - - case ULPUART: - init_state = (ULP_UART_Resources.info->flags & USART_FLAG_INITIALIZED); - break; - - default: - break; - } - - return init_state; -} - -//Below set of functions are only used by SL_DMA added as part of Dx improvements -#ifdef SL_SI91X_USART_DMA -/******************************************************************************* - * Transfer complete callback function which is registered by SL_DMA driver - * for USART peripheral-memory and memory-peripheral transfers. This function calls - * USART Rx and Tx transfer complete event for respective channels. - * *****************************************************************************/ -void usart_transfer_complete_callback(uint32_t channel, void *data) { - (void)(&data); - (void)channel; -#if (SL_USART0_DMA_CONFIG_ENABLE == 1) - if(channel == RTE_USART0_CHNL_UDMA_TX_CH) { - USART_UDMA_Tx_Event(UDMA_EVENT_XFER_DONE, (uint8_t)channel, &USART0_Resources); - } - if(channel == RTE_USART0_CHNL_UDMA_RX_CH) { - USART_UDMA_Rx_Event(UDMA_EVENT_XFER_DONE, (uint8_t)channel, &USART0_Resources); - } -#endif -#if (SL_UART1_DMA_CONFIG_ENABLE == 1) - if(channel == RTE_UART1_CHNL_UDMA_TX_CH) { - USART_UDMA_Tx_Event(UDMA_EVENT_XFER_DONE, (uint8_t)channel, &UART1_Resources); - } - if(channel == RTE_UART1_CHNL_UDMA_RX_CH) { - USART_UDMA_Rx_Event(UDMA_EVENT_XFER_DONE, (uint8_t)channel, &UART1_Resources); - } -#endif -#if (SL_ULPUART_DMA_CONFIG_ENABLE == 1) - if(channel == RTE_ULPUART_CHNL_UDMA_TX_CH) { - USART_UDMA_Tx_Event(UDMA_EVENT_XFER_DONE, (uint8_t)channel, &ULP_UART_Resources); - } - if(channel == RTE_ULPUART_CHNL_UDMA_RX_CH) { - USART_UDMA_Rx_Event(UDMA_EVENT_XFER_DONE, (uint8_t)channel, &ULP_UART_Resources); - } -#endif -} - -/******************************************************************************* - * Error callback function which is registered by SL_DMA driver for USART - * peripheral-memory and memory-peripheral transfers. This function calls - * USART Rx and Tx error event for respective channels. - * *****************************************************************************/ -void usart_error_callback(uint32_t channel, void *data) { - (void)(&data); - (void)channel; -#if (SL_USART0_DMA_CONFIG_ENABLE == 1) - if(channel == RTE_USART0_CHNL_UDMA_TX_CH) { - USART_UDMA_Tx_Event(UDMA_EVENT_ERROR, (uint8_t)channel, &USART0_Resources); - } - if(channel == RTE_USART0_CHNL_UDMA_RX_CH) { - USART_UDMA_Rx_Event(UDMA_EVENT_ERROR, (uint8_t)channel, &USART0_Resources); - } -#endif -#if (SL_UART1_DMA_CONFIG_ENABLE == 1) - if(channel == RTE_UART1_CHNL_UDMA_TX_CH) { - USART_UDMA_Tx_Event(UDMA_EVENT_ERROR, (uint8_t)channel, &UART1_Resources); - } - if(channel == RTE_UART1_CHNL_UDMA_RX_CH) { - USART_UDMA_Rx_Event(UDMA_EVENT_ERROR, (uint8_t)channel, &UART1_Resources); - } -#endif -#if (SL_ULPUART_DMA_CONFIG_ENABLE == 1) - if(channel == RTE_ULPUART_CHNL_UDMA_TX_CH) { - USART_UDMA_Tx_Event(UDMA_EVENT_ERROR, (uint8_t)channel, &ULP_UART_Resources); - } - if(channel == RTE_ULPUART_CHNL_UDMA_RX_CH) { - USART_UDMA_Rx_Event(UDMA_EVENT_ERROR, (uint8_t)channel, &ULP_UART_Resources); - } -#endif -} -#endif -#endif diff --git a/wiseconnect/components/device/silabs/si91x/mcu/drivers/service/clock_manager/src/sli_si91x_clock_manager.c b/wiseconnect/components/device/silabs/si91x/mcu/drivers/service/clock_manager/src/sli_si91x_clock_manager.c index 6f128c655..5c7934082 100644 --- a/wiseconnect/components/device/silabs/si91x/mcu/drivers/service/clock_manager/src/sli_si91x_clock_manager.c +++ b/wiseconnect/components/device/silabs/si91x/mcu/drivers/service/clock_manager/src/sli_si91x_clock_manager.c @@ -235,8 +235,10 @@ sl_status_t sli_si91x_clock_manager_config_clks_on_ps_change(sl_power_state_t po break; } +#if defined(IOSTREAM_USART) || SL_SI91X_IOSTREAM_LOG_PRINTS_ENABLE || defined(DEBUG_UART) // Reinit debug uart after clock configuration DEBUGINIT(); +#endif return sli_status; }