1 /**************************************************************************/
2 /* */
3 /* Copyright (c) Microsoft Corporation. All rights reserved. */
4 /* */
5 /* This software is licensed under the Microsoft Software License */
6 /* Terms for Microsoft Azure RTOS. Full text of the license can be */
7 /* found in the LICENSE file at https://aka.ms/AzureRTOS_EULA */
8 /* and in the root directory of this software. */
9 /* */
10 /**************************************************************************/
11
12
13 /**************************************************************************/
14 /**************************************************************************/
15 /** */
16 /** LevelX Component */
17 /** */
18 /** NAND Flash */
19 /** */
20 /**************************************************************************/
21 /**************************************************************************/
22
23 #define LX_SOURCE_CODE
24
25
26 /* Disable ThreadX error checking. */
27
28 #ifndef LX_DISABLE_ERROR_CHECKING
29 #define LX_DISABLE_ERROR_CHECKING
30 #endif
31
32
33 /* Include necessary system files. */
34
35 #include "lx_api.h"
36
37
38 /**************************************************************************/
39 /* */
40 /* FUNCTION RELEASE */
41 /* */
42 /* _lx_nand_flash_sectors_release PORTABLE C */
43 /* 6.2.1 */
44 /* AUTHOR */
45 /* */
46 /* Xiuwen Cai, Microsoft Corporation */
47 /* */
48 /* DESCRIPTION */
49 /* */
50 /* This function releases multiple logical sectors from being managed */
51 /* in the NAND flash. */
52 /* */
53 /* INPUT */
54 /* */
55 /* nand_flash NAND flash instance */
56 /* logical_sector Logical sector number */
57 /* sector_count Number of sector to release */
58 /* */
59 /* OUTPUT */
60 /* */
61 /* return status */
62 /* */
63 /* CALLS */
64 /* */
65 /* _lx_nand_flash_sector_release Release one sector */
66 /* */
67 /* CALLED BY */
68 /* */
69 /* Application Code */
70 /* */
71 /* RELEASE HISTORY */
72 /* */
73 /* DATE NAME DESCRIPTION */
74 /* */
75 /* 03-08-2023 Xiuwen Cai Initial Version 6.2.1 */
76 /* */
77 /**************************************************************************/
_lx_nand_flash_sectors_release(LX_NAND_FLASH * nand_flash,ULONG logical_sector,ULONG sector_count)78 UINT _lx_nand_flash_sectors_release(LX_NAND_FLASH *nand_flash, ULONG logical_sector, ULONG sector_count)
79 {
80
81 UINT status = LX_SUCCESS;
82 UINT i;
83
84
85 /* Loop to release all the sectors. */
86 for (i = 0; i < sector_count; i++)
87 {
88
89 /* Release one sector. */
90 status = _lx_nand_flash_sector_release(nand_flash, logical_sector + i);
91
92 /* Check return status. */
93 if (status)
94 {
95
96 /* Error, break the loop. */
97 break;
98 }
99 }
100
101 /* Return status. */
102 return(status);
103 }
104
105