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