-
Notifications
You must be signed in to change notification settings - Fork 8
/
nand.h
executable file
·43 lines (27 loc) · 1.03 KB
/
nand.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
//(c) uARM project https://github.com/uARM-Palm/uARM [email protected]
#ifndef _NAND_H_
#define _NAND_H_
#include "mem.h"
#include "CPU.h"
#include <stdio.h>
#include "soc_GPIO.h"
struct NAND;
typedef void (*NandReadyCbk)(void *userData, bool ready);
//options
#define NAND_FLAG_SAMSUNG_ADDRESSED_VIA_AREAS 0x01 //use 0x01 and 0x50 commands to save one bit on byte addressing
#define NAND_HAS_SECOND_READ_CMD 0x02
struct NandSpecs {
uint32_t bytesPerPage;
uint32_t blocksPerDevice;
uint8_t pagesPerBlockLg2;
uint8_t flags;
uint8_t devIdLen;
uint8_t devId[];
};
struct NAND* nandInit(FILE *nandFile, const struct NandSpecs *specs, NandReadyCbk readyCbk, void *readyCbkData);
void nandSecondReadyCbkSet(struct NAND* nand, NandReadyCbk readyCbk, void *readyCbkData);
bool nandWrite(struct NAND* nand, bool cle, bool ale, uint8_t val);
bool nandRead(struct NAND* nand, bool cle, bool ale, uint8_t *valP);
bool nandIsReady(struct NAND *nand);
void nandPeriodic(struct NAND *nand);
#endif