GCC Code Coverage Report
Directory: ./ Exec Total Coverage
File: lx_nand_flash_sectors_write.c Lines: 0 7 0.0 %
Date: 2024-03-11 05:20:25 Branches: 0 4 0.0 %

Line Branch Exec Source
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_write                        PORTABLE C      */
42
/*                                                           6.2.1       */
43
/*  AUTHOR                                                                */
44
/*                                                                        */
45
/*    Xiuwen Cai, Microsoft Corporation                                   */
46
/*                                                                        */
47
/*  DESCRIPTION                                                           */
48
/*                                                                        */
49
/*    This function writes multiple logical sectors to the NAND flash.    */
50
/*                                                                        */
51
/*  INPUT                                                                 */
52
/*                                                                        */
53
/*    nand_flash                            NAND flash instance           */
54
/*    logical_sector                        Logical sector number         */
55
/*    buffer                                Pointer to buffer to write    */
56
/*                                            (the size is number of      */
57
/*                                             bytes in a page)           */
58
/*    sector_count                          Number of sector to write     */
59
/*                                                                        */
60
/*  OUTPUT                                                                */
61
/*                                                                        */
62
/*    return status                                                       */
63
/*                                                                        */
64
/*  CALLS                                                                 */
65
/*                                                                        */
66
/*    _lx_nand_flash_sector_write           Write one sector              */
67
/*                                                                        */
68
/*  CALLED BY                                                             */
69
/*                                                                        */
70
/*    Application Code                                                    */
71
/*                                                                        */
72
/*  RELEASE HISTORY                                                       */
73
/*                                                                        */
74
/*    DATE              NAME                      DESCRIPTION             */
75
/*                                                                        */
76
/*  03-08-2023     Xiuwen Cai               Initial Version 6.2.1        */
77
/*                                                                        */
78
/**************************************************************************/
79
UINT  _lx_nand_flash_sectors_write(LX_NAND_FLASH *nand_flash, ULONG logical_sector, VOID *buffer, ULONG sector_count)
80
{
81
82
UINT status = LX_SUCCESS;
83
UINT i;
84
85
86
    /* Loop to write all the sectors.  */
87
    for (i = 0; i < sector_count; i++)
88
    {
89
90
        /* Write one sector.  */
91
        status = _lx_nand_flash_sector_write(nand_flash, logical_sector + i, ((UCHAR*)buffer) + i * nand_flash -> lx_nand_flash_bytes_per_page);
92
93
        /* Check return status.  */
94
        if (status)
95
        {
96
97
            /* Error, break the loop.  */
98
            break;
99
        }
100
    }
101
102
    /* Return status.  */
103
    return(status);
104
}
105
106