Read delay calibration: return error codes
[gram.git] / libgram / README.md
1 # libgram, the C companion for gram
2
3 libgram is the C library for gram core initialization and calibration.
4
5 ## HowTo
6
7 Build libgram with make. In your firmware:
8
9 ```C
10 #include <gram.h>
11
12 int main(void) {
13 struct gramCtx ctx;
14 struct gramProfile profile {
15 .mode_registers = {
16 0x320, 0x6, 0x200, 0
17 },
18 .rdly_p0 = 0,
19 .rdly_p1 = 0
20 };
21 int err = gram_init(&ctx, &profile, 0x10000000, 0x00006000, 0x00005000);
22
23 return 0;
24 }
25 ```
26
27 Link it to this library and you should be good to go!
28
29 ## Error handling
30
31 ```
32 GRAM_ERR_NONE: No error happened (hardcoded to zero)
33 GRAM_ERR_UNDOCUMENTED: Undocumented error, shame on us lazy coders (take a look at the code)
34 GRAM_ERR_RDLY_MAX: Read delay calibration unsuccessful because its value exceeds DQSBUFM's max
35 ```
36
37 ## Using libgram outside the SoC
38
39 Compile libgram with `CFLAGS="-DGRAM_RW_FUNC"` (run `make clean` beforehand) and define the following bus access functions:
40
41 ```c
42 uint32_t gram_read(struct gramCtx *ctx, void *addr);
43 int gram_write(struct gramCtx *ctx, void *addr, uint32_t value);
44 ```
45
46 If you want to use the default compiler on your computer, use `CFLAGS="-DGRAM_RW_FUNC" make TRIPLE=""`.