# libgram, the C companion for gram
-libgram is the C library for gram core initialization and memory testing.
+libgram is the C library for gram core initialization and calibration.
## HowTo
```
GRAM_ERR_NONE: No error happened (hardcoded to zero)
GRAM_ERR_UNDOCUMENTED: Undocumented error, shame on us lazy coders (take a look at the code)
+GRAM_ERR_RDLY_MAX: Read delay calibration unsuccessful because its value exceeds DQSBUFM's max
```
## Using libgram outside the SoC
if (gram_read_burstdet(&ctx, 0)) {
min_rdly_p0 = rdly;
break;
+ } else if (rdly == 7) {
+ return GRAM_ERR_RDLY_MAX;
}
}
if (gram_read_burstdet(&ctx, 1)) {
min_rdly_p1 = rdly;
break;
+ } else if (rdly == 7) {
+ return GRAM_ERR_RDLY_MAX;
}
}
if (!gram_read_burstdet(&ctx, 0)) {
max_rdly_p0 = rdly - 1;
break;
+ } else if (rdly == 7) {
+ return GRAM_ERR_RDLY_MAX;
}
}
if (!gram_read_burstdet(&ctx, 1)) {
max_rdly_p1 = rdly - 1;
break;
+ } else if (rdly == 7) {
+ return GRAM_ERR_RDLY_MAX;
}
}
profile->rdly_p0 = (min_rdly_p0+max_rdly_p0)/2;
profile->rdly_p1 = (min_rdly_p1+max_rdly_p1)/2;
- return 0;
+ return GRAM_ERR_NONE;
}
void gram_load_calibration(const struct gramCtx *ctx, const struct gramProfile *profile) {