FlashCC26X4_ns.h
Go to the documentation of this file.
1 /*
2  * Copyright (c) 2021 Texas Instruments Incorporated - https://www.ti.com
3  * All rights reserved.
4  *
5  * Redistribution and use in source and binary forms, with or without
6  * modification, are permitted provided that the following conditions
7  * are met:
8  *
9  * * Redistributions of source code must retain the above copyright
10  * notice, this list of conditions and the following disclaimer.
11  *
12  * * Redistributions in binary form must reproduce the above copyright
13  * notice, this list of conditions and the following disclaimer in the
14  * documentation and/or other materials provided with the distribution.
15  *
16  * * Neither the name of Texas Instruments Incorporated nor the names of
17  * its contributors may be used to endorse or promote products derived
18  * from this software without specific prior written permission.
19  *
20  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
21  * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
22  * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
23  * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
24  * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
25  * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
26  * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
27  * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
28  * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
29  * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
30  * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
31  */
32 /*!*****************************************************************************
33  * @file FlashCC26X4_ns.h
34  * @brief Non-Secure Flash Client Interface for CC26X4 devices.
35  *
36  * The defined APIs are identical to the function calls in flash.c. This client
37  * interface allows the access to the Secure Flash Service.
38  *
39  * # Initialization #
40  * Users will need to call FlashOpen() once prior to any other function calls.
41  * FlashOpen() will only need to be called again if FlashClose() is called.
42  *
43  * # Error Codes #
44  * Typically the Flash Driver (flash.c) returns either a FAPI_STATUS code
45  * or a valid value greater than the FAPI_STATUS code range. FAPI_STATUS codes
46  * are positive and are defined below in FlashCC26X4_ns.h. The Non-Secure Flash
47  * Client Interface is responsible for interfacing with the Secure Partition
48  * Manager (SPM). Requests to the SPM may result in Platform Security
49  * Architecture (PSA) error codes. These error codes are referred to as
50  * PSA_ERROR codes. PSA_ERROR codes are negative values and are defined in
51  * "error.h". Due to the FAPI_STATUS and PSA_ERROR codes not overlapping,
52  * API's of the Non-Secure Flash Client Interface can dynamically return either
53  * value type. PSA_ERROR codes are considered higher priority and will take
54  * precedence. Therefore, if a PSA_ERROR occurs, a PSA_ERROR is returned.
55  * Otherwise, a valid Flash driver value will be returned. Each API will follow
56  * this guideline but please reference each API individually for specific
57  * return characteristics.
58  *
59  * # PSA_ERROR_PROGRAMMER_ERROR #
60  * A PSA_ERROR_PROGRAMMER_ERROR is a strict error code returned by the SPM.
61  * Once this error code is returned, the SPM will terminate the connection
62  * to the service. All subsequent requests to the service from the same client
63  * will not be processed and will continue to return a
64  * PSA_ERROR_PROGRAMMER_ERROR. The client must close the connection to the SPM
65  * and then re-establish the connection to continue. This can be accomplished
66  * in the Non-Secure Flash Client Interface by calling FlashClose() followed by
67  * FlashOpen(). In the Non-Secure Flash Client Interface,
68  * PSA_ERROR_PROGRAMMER_ERROR codes will primarily be returned due to requests
69  * trying to read from or write to secure memory regions. Please reference the
70  * PSA Firmware Framework specification for more details regarding the
71  * PSA_ERROR_PROGRAMMER_ERROR code.
72  *
73  * ============================================================================
74  */
75 
76 #ifndef ti_drivers_nvs_flash_FlashCC26X4_ns_H__
77 #define ti_drivers_nvs_flash_FlashCC26X4_ns_H__
78 
79 #include <stddef.h>
80 #include <stdint.h>
81 
82 #include <ti/devices/DeviceFamily.h>
83 #include DeviceFamily_constructPath(inc/hw_nvmnw.h)
84 #include DeviceFamily_constructPath(inc/hw_memmap.h)
85 #include DeviceFamily_constructPath(inc/hw_types.h)
86 #include DeviceFamily_constructPath(cmsis/core/cmsis_compiler.h)
87 
88 #ifdef __cplusplus
89 extern "C" {
90 #endif
91 
92 /* *************************************************************************** */
93 /* Values that can be returned from the API functions */
94 /* *************************************************************************** */
95 #define FAPI_STATUS_SUCCESS 0x00000000 // Function completed successfully
96 #define FAPI_STATUS_FSM_BUSY 0x00000001 // FSM is Busy
97 #define FAPI_STATUS_FSM_READY 0x00000002 // FSM is Ready
98 #define FAPI_STATUS_INCORRECT_DATABUFFER_LENGTH 0x00000003 // Incorrect parameter value
99 #define FAPI_STATUS_FSM_ERROR 0x00000004 // Operation failed
100 #define FAPI_STATUS_ADDRESS_ERROR 0x00000005 // Operation failed
101 #define FAPI_STATUS_ADDRESS_ALIGN_ERROR 0x00000006 // addr alignment error
102 #define FAPI_STATUS_BANK_NUM_ERROR 0x00000007 // bank number error
103 #define FAPI_STATUS_NOSUPPORT_ERROR 0x00000008 // Flash API is not supported
104 #define FAPI_STATUS_UNPROTECT_ERROR 0x00000009 // can't unprotect for saved setting
105 
115 int_fast16_t FlashOpen(void);
116 
124 void FlashClose(void);
125 
137 uint32_t FlashProtectionGet(uint32_t ui32SectorAddress);
138 
150 uint32_t FlashSectorErase(uint32_t ui32SectorAddress);
151 
165 uint32_t FlashProgram(uint8_t *pui8DataBuffer, uint32_t ui32Address, uint32_t ui32Count);
166 
180 uint32_t FlashProgram4X(uint8_t *pui8DataBuffer, uint32_t ui32Address, uint32_t ui32Count);
181 
192 uint32_t FlashSectorSizeGet(void);
193 
204 uint32_t FlashSizeGet(void);
205 
206 #ifdef __cplusplus
207 }
208 #endif
209 
210 #endif /* ti_drivers_nvs_flash_FlashCC26X4_ns_H__ */
uint32_t FlashProgram(uint8_t *pui8DataBuffer, uint32_t ui32Address, uint32_t ui32Count)
Call FlashProgram API using Secure Flash Service.
int_fast16_t FlashOpen(void)
Initialize a PSA connection to the Secure Flash Service.
void FlashClose(void)
End the PSA connection to the Secure Flash Service.
uint32_t FlashSizeGet(void)
Call FlashSizeGet API using Secure Flash Service.
uint32_t FlashProgram4X(uint8_t *pui8DataBuffer, uint32_t ui32Address, uint32_t ui32Count)
Call FlashProgram4X API using Secure Flash Service.
uint32_t FlashSectorSizeGet(void)
Call FlashSectorSizeGet API using Secure Flash Service.
uint32_t FlashSectorErase(uint32_t ui32SectorAddress)
Call FlashSectorErase API using Secure Flash Service.
uint32_t FlashProtectionGet(uint32_t ui32SectorAddress)
Call FlashProtectionGet API using Secure Flash Service.
© Copyright 1995-2022, Texas Instruments Incorporated. All rights reserved.
Trademarks | Privacy policy | Terms of use | Terms of sale