Cascoda SDK
Cascoda SDK for building software to run with CA-821x transceivers
cascoda_flash.h
Go to the documentation of this file.
1 /*
2  * Copyright (c) 2016, The OpenThread Authors.
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  * 1. Redistributions of source code must retain the above copyright
8  * notice, this list of conditions and the following disclaimer.
9  * 2. Redistributions in binary form must reproduce the above copyright
10  * notice, this list of conditions and the following disclaimer in the
11  * documentation and/or other materials provided with the distribution.
12  * 3. Neither the name of the copyright holder nor the
13  * names of its contributors may be used to endorse or promote products
14  * derived from this software without specific prior written permission.
15  *
16  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
17  * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
18  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
19  * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
20  * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
21  * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
22  * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
23  * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
24  * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
25  * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
26  * POSSIBILITY OF SUCH DAMAGE.
27  */
28 
35 #ifndef UTILS_FLASH_H
36 #define UTILS_FLASH_H
37 
38 #include <stdint.h>
39 #include "ca821x_api.h"
40 
41 #ifdef __cplusplus
42 extern "C" {
43 #endif
44 
47 {
48  uint32_t apromFlashBaseAddr;
49  uint32_t dataFlashBaseAddr;
51  uint16_t pageSize;
52  uint8_t numPages;
53 };
54 
65 ca_error utilsFlashInit(struct ca821x_dev *aInstance, const char *aApplicationName, uint32_t aNodeId);
66 
75 ca_error utilsFlashDeinit(struct ca821x_dev *aInstance);
76 
84 uint32_t utilsFlashGetSize(struct ca821x_dev *aInstance);
85 
101 ca_error utilsFlashErasePage(struct ca821x_dev *aInstance, uint32_t aAddress);
102 
114 ca_error utilsFlashStatusWait(struct ca821x_dev *aInstance, uint32_t aTimeout);
115 
132 uint32_t utilsFlashWrite(struct ca821x_dev *aInstance, uint32_t aAddress, const uint8_t *aData, uint32_t aSize);
133 
150 uint32_t utilsFlashRead(struct ca821x_dev *aInstance, uint32_t aAddress, uint8_t *aData, uint32_t aSize);
151 
158 uint32_t utilsFlashGetBaseAddress(struct ca821x_dev *aInstance);
159 
166 uint32_t utilsFlashGetUsedSize(struct ca821x_dev *aInstance);
167 
174 void utilsFlashSetBaseAddress(struct ca821x_dev *aInstance, uint32_t aAddress);
175 
182 void utilsFlashSetUsedSize(struct ca821x_dev *aInstance, uint32_t aSize);
183 
184 #ifdef __cplusplus
185 } // extern "C"
186 #endif
187 
188 #endif // UTILS_FLASH_H
The main ca821x-api include file.
ca_error utilsFlashStatusWait(struct ca821x_dev *aInstance, uint32_t aTimeout)
Check whether flash is ready or busy.
Definition: cascoda_flash.c:101
void utilsFlashSetUsedSize(struct ca821x_dev *aInstance, uint32_t aSize)
Internal function for setting the amount of flash used.
Definition: cascoda_flash.c:70
uint32_t utilsFlashGetUsedSize(struct ca821x_dev *aInstance)
Internal function for returning the amount of flash used.
Definition: cascoda_flash.c:58
uint32_t utilsFlashRead(struct ca821x_dev *aInstance, uint32_t aAddress, uint8_t *aData, uint32_t aSize)
Read flash.
Definition: cascoda_flash.c:144
uint32_t utilsFlashGetBaseAddress(struct ca821x_dev *aInstance)
Internal function for getting the base address.
Definition: cascoda_flash.c:52
ca_error utilsFlashInit(struct ca821x_dev *aInstance, const char *aApplicationName, uint32_t aNodeId)
Perform any initialization for flash driver.
Definition: cascoda_flash.c:76
uint32_t utilsFlashGetSize(struct ca821x_dev *aInstance)
Get the size of flash that can be read/write by the caller.
Definition: cascoda_flash.c:84
ca_error utilsFlashDeinit(struct ca821x_dev *aInstance)
Deinitialize the flash driver.
Definition: cascoda_bsp_dummy.c:431
void utilsFlashSetBaseAddress(struct ca821x_dev *aInstance, uint32_t aAddress)
Internal function for setting the base address.
Definition: cascoda_flash.c:64
ca_error utilsFlashErasePage(struct ca821x_dev *aInstance, uint32_t aAddress)
Erase one flash page that include the input address.
Definition: cascoda_flash.c:92
uint32_t utilsFlashWrite(struct ca821x_dev *aInstance, uint32_t aAddress, const uint8_t *aData, uint32_t aSize)
Write flash.
Definition: cascoda_flash.c:108
ca_error
Cascoda error type.
Definition: ca821x_error.h:51
CA-821x Device reference struct.
Definition: ca821x_api.h:123
Description of the internal flash.
Definition: cascoda_flash.h:47
uint8_t numPages
Number of flash pages that make up the user flash region.
Definition: cascoda_flash.h:52
uint32_t dataFlashBaseAddr
Base address of the dataflash.
Definition: cascoda_flash.h:49
uint16_t pageSize
Size of each flash page (in bytes)
Definition: cascoda_flash.h:51
uint32_t manufacturerDataFlashBaseAddr
Base address of flash page reserved for constant manufacturer data.
Definition: cascoda_flash.h:50
uint32_t apromFlashBaseAddr
Base address of the APROM flash.
Definition: cascoda_flash.h:48