1 /***************************************************************************/ /**
2  * @file  rsi_hal_mcu_m4_ram.c
3  *******************************************************************************
4  * # License
5  * <b>Copyright 2024 Silicon Laboratories Inc. www.silabs.com</b>
6  *******************************************************************************
7  *
8  * SPDX-License-Identifier: Zlib
9  *
10  * The licensor of this software is Silicon Laboratories Inc.
11  *
12  * This software is provided 'as-is', without any express or implied
13  * warranty. In no event will the authors be held liable for any damages
14  * arising from the use of this software.
15  *
16  * Permission is granted to anyone to use this software for any purpose,
17  * including commercial applications, and to alter it and redistribute it
18  * freely, subject to the following restrictions:
19  *
20  * 1. The origin of this software must not be misrepresented; you must not
21  *    claim that you wrote the original software. If you use this software
22  *    in a product, an acknowledgment in the product documentation would be
23  *    appreciated but is not required.
24  * 2. Altered source versions must be plainly marked as such, and must not be
25  *    misrepresented as being the original software.
26  * 3. This notice may not be removed or altered from any source distribution.
27  *
28  ******************************************************************************/
29 
30 #if defined(SLI_SI917) || defined(SLI_SI915)
31 //! This file should be in RAM
32 #include "sl_device.h"
33 
34 /*==================================================*/
35 /**
36  * @fn          void sl_mv_m4_app_from_flash_to_ram(int option)
37  * @brief       Raise interrupt to NWP and poll for task done
38  * @param[in]   option
39  * @param[out]  none
40  */
41 
sl_mv_m4_app_from_flash_to_ram(int option)42 void sl_mv_m4_app_from_flash_to_ram(int option)
43 {
44 
45   //! Disable all interrupts
46   __disable_irq();
47 
48   if (option == UPGRADE_M4_IMAGE_OTA) {
49     //! Raise interrupt to NWP
50     raise_m4_to_ta_interrupt(UPGRADE_M4_IMAGE);
51 
52     //! Poll for bit to clear
53     while (M4SS_P2P_INTR_CLR_REG & UPGRADE_M4_IMAGE)
54       ;
55   } else if (option == TA_WRITES_ON_COMM_FLASH) {
56     //! Raise interrupt to NWP
57     raise_m4_to_ta_interrupt(M4_WAITING_FOR_TA_TO_WR_ON_FLASH);
58 
59     //! Poll for bit to clear
60     while (M4SS_P2P_INTR_CLR_REG & M4_WAITING_FOR_TA_TO_WR_ON_FLASH)
61       ;
62   } else if (option == M4_WAIT_FOR_NWP_DEINIT) {
63     //! Raise interrupt to NWP
64     raise_m4_to_ta_interrupt(M4_WAITING_FOR_TA_DEINIT);
65 
66     //! Poll for bit to clear
67     while (M4SS_P2P_INTR_CLR_REG & M4_WAITING_FOR_TA_DEINIT)
68       ;
69   }
70 
71   //! Enable all interrupts
72   __enable_irq();
73 }
74 
75 #endif
76