Contiki 3.x
ext-flash.h
Go to the documentation of this file.
1 /*
2  * Copyright (c) 2014, Texas Instruments Incorporated - http://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  * 1. Redistributions of source code must retain the above copyright
9  * notice, this list of conditions and the following disclaimer.
10  * 2. Redistributions in binary form must reproduce the above copyright
11  * notice, this list of conditions and the following disclaimer in the
12  * documentation and/or other materials provided with the distribution.
13  * 3. Neither the name of the copyright holder nor the names of its
14  * contributors may be used to endorse or promote products derived
15  * from this software without specific prior written permission.
16  *
17  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
18  * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
19  * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
20  * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
21  * COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
22  * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
23  * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
24  * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
25  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
26  * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
27  * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
28  * OF THE POSSIBILITY OF SUCH DAMAGE.
29  */
30 /*---------------------------------------------------------------------------*/
31 /**
32  * \addtogroup common-cc26xx-peripherals
33  * @{
34  *
35  * \defgroup sensortag-cc26xx-ext-flash SensorTag/LaunchPad External Flash
36  * @{
37  *
38  * \file
39  * Header file for the Sensortag/LaunchPad External Flash Driver
40  */
41 /*---------------------------------------------------------------------------*/
42 #ifndef EXT_FLASH_H_
43 #define EXT_FLASH_H_
44 /*---------------------------------------------------------------------------*/
45 #include <stdint.h>
46 #include <stdlib.h>
47 #include <stdbool.h>
48 /*---------------------------------------------------------------------------*/
49 /**
50  * \brief Initialize storage driver.
51  * \return True when successful.
52  */
53 bool ext_flash_open(void);
54 
55 /**
56  * \brief Close the storage driver
57  *
58  * This call will put the device in its lower power mode (power down).
59  */
60 void ext_flash_close(void);
61 
62 /**
63  * \brief Read storage content
64  * \param offset Address to read from
65  * \param length Number of bytes to read
66  * \param buf Buffer where to store the read bytes
67  * \return True when successful.
68  *
69  * buf must be allocated by the caller
70  */
71 bool ext_flash_read(size_t offset, size_t length, uint8_t *buf);
72 
73 /**
74  * \brief Erase storage sectors corresponding to the range.
75  * \param offset Address to start erasing
76  * \param length Number of bytes to erase
77  * \return True when successful.
78  *
79  * The erase operation will be sector-wise, therefore a call to this function
80  * will generally start the erase procedure at an address lower than offset
81  */
82 bool ext_flash_erase(size_t offset, size_t length);
83 
84 /**
85  * \brief Write to storage sectors.
86  * \param offset Address to write to
87  * \param length Number of bytes to write
88  * \param buf Buffer holding the bytes to be written
89  *
90  * \return True when successful.
91  */
92 bool ext_flash_write(size_t offset, size_t length, const uint8_t *buf);
93 
94 /**
95  * \brief Test the flash (power on self-test)
96  * \return True when successful.
97  */
98 bool ext_flash_test(void);
99 
100 /**
101  * \brief Initialise the external flash
102  *
103  * This function will explicitly put the part in its lowest power mode
104  * (power-down).
105  *
106  * In order to perform any operation, the caller must first wake the device
107  * up by calling ext_flash_open()
108  */
109 void ext_flash_init(void);
110 /*---------------------------------------------------------------------------*/
111 #endif /* EXT_FLASH_H_ */
112 /*---------------------------------------------------------------------------*/
113 /**
114  * @}
115  * @}
116  */
bool ext_flash_test(void)
Test the flash (power on self-test)
Definition: ext-flash.c:438
bool ext_flash_read(size_t offset, size_t length, uint8_t *buf)
Read storage content.
Definition: ext-flash.c:297
bool ext_flash_open()
Initialize storage driver.
Definition: ext-flash.c:271
void ext_flash_init()
Initialise the external flash.
Definition: ext-flash.c:449
bool ext_flash_erase(size_t offset, size_t length)
Erase storage sectors corresponding to the range.
Definition: ext-flash.c:389
bool ext_flash_write(size_t offset, size_t length, const uint8_t *buf)
Write to storage sectors.
Definition: ext-flash.c:332
void ext_flash_close()
Close the storage driver.
Definition: ext-flash.c:288