-
Notifications
You must be signed in to change notification settings - Fork 16
/
Copy pathflash.h
65 lines (52 loc) · 1.71 KB
/
flash.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
/*
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#ifndef FLASH_H_
#define FLASH_H_
#include "ring_buffer.h"
#include "hardware.h"
#define MICROCHIP_ID 0xBF
#define ADESTO_ID 0x1F
void SPI_Setup(void);
void getDevID();
/*
* eraseFlash()
* This will erase the entire flash
* memory. This must be called before writing
* to it to ensure it is in the erased state.
*/
void eraseFlash(void);
/*
* writeByteFlash(address, byte)
* This writes one byte to the address
* specified.
*/
void writeByteFlash (uint32_t, uint8_t);
/*
* writeFlash(address, data, length)
* This will write a block of data of size length
* to the flash starting at the address specified.
*
* The starting address MUST be an even number as
* writes are performed in pairs. If an odd number
* is given the actual start address will be the
* address one earlier.
*/
void writeFlash(uint32_t, uint8_t*, uint16_t);
/*
* readFlash(data, address, length)
* This reads the flash memory and stores the
* values into data. Data must be an array
* of size length or more.
*/
void readFlash(volatile uint8_t*, uint32_t, uint16_t);
#endif /* FLASH_H_ */