Cascoda SDK
Cascoda SDK for building software to run with CA-821x transceivers
cascoda_external_flash.h
Go to the documentation of this file.
1 /*
2  * Copyright (c) 2021, Cascoda
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 are met:
7  *
8  * 1. Redistributions of source code must retain the above copyright notice,
9  * this list of conditions and the following disclaimer.
10  *
11  * 2. Redistributions in binary form must reproduce the above copyright notice,
12  * this list of conditions and the following disclaimer in the documentation
13  * and/or other materials provided with the distribution.
14  *
15  * 3. Neither the name of the copyright holder nor the names of its contributors
16  * may be used to endorse or promote products derived from this software without
17  * specific prior written permission.
18  *
19  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
20  * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
21  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
22  * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS OR CONTRIBUTORS BE
23  * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
24  * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
25  * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
26  * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
27  * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
28  * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
29  * POSSIBILITY OF SUCH DAMAGE.
30  */
36 #ifndef CASCODA_EXTERNAL_FLASH_H
37 #define CASCODA_EXTERNAL_FLASH_H
38 
41 #include "ca821x_api.h"
42 
43 #ifdef __cplusplus
44 extern "C" {
45 #endif
46 
47 #if CASCODA_EXTERNAL_FLASHCHIP_PRESENT
48 /****** External Erase Type ******/
49 typedef enum
50 {
51  ERASE_CHIP = 0,
52  ERASE_64KB,
53  ERASE_32KB,
54  ERASE_4KB,
55 } ExternalEraseType;
56 
57 /****** Information used for erase procedure ******/
58 typedef struct
59 {
60  u32_t startAddress;
61  u32_t eraseLength;
62  u32_t endAddress;
63  ExtFlashAPICallback otaCallback;
64  ExtFlashAPICallback upstreamCallback;
65 } ExtFlashEraseInfo;
66 
67 /****** Information used for writing procedure ******/
68 typedef struct
69 {
70  u32_t startAddress;
71  u32_t writeLength;
72  u32_t writeLimit;
73  u16_t pageSize;
74  ExtFlashAPICallback otaCallback;
75  ExtFlashAPICallback upstreamCallback;
76  u8_t *data;
77 } ExtFlashWriteInfo;
78 
79 /****** Information used for reading and checking procedures ******/
80 typedef struct
81 {
82  u32_t startAddress;
83  u32_t checklen;
84  u32_t checksum;
85  u32_t readLimit;
86  ExtFlashAPICallback upstreamCallback;
87 } ExtFlashCheckInfo;
88 
89 /****** Union of all external flash info structs ******/
90 union ExtFlashInfoStructs
91 {
92  ExtFlashEraseInfo eraseInfo;
93  ExtFlashWriteInfo writeInfo;
94  ExtFlashCheckInfo checkInfo;
95 };
96 
104 
116 ca_error external_flash_erase_helper(void *aContext);
117 
129 ca_error external_flash_write_helper(void *aContext);
130 
143 ca_error external_flash_check_helper(void *aContext);
144 #endif
145 
146 #ifdef __cplusplus
147 }
148 #endif
149 
150 #endif /* CASCODA_EXTERNAL_FLASH_H */
The main ca821x-api include file.
ca_error external_flash_check_helper(void *aContext)
Definition: cascoda_external_flash.c:364
ca_error external_flash_write_helper(void *aContext)
Definition: cascoda_external_flash.c:326
ca_error external_flash_erase_helper(void *aContext)
Definition: cascoda_external_flash.c:295
ca_error external_flash_evbme_send_upstream(void *aContext)
Definition: cascoda_external_flash.c:283
Stubs for OTA Upgrade procedure.
Type definitions used by Cascoda baremetal drivers.
unsigned long u32_t
Definition: cascoda_types.h:50
unsigned char u8_t
Definition: cascoda_types.h:46
unsigned short u16_t
Definition: cascoda_types.h:48
ca_error
Cascoda error type.
Definition: ca821x_error.h:51