- C 86.8%
- Python 8.4%
- CMake 4.8%
| Filename | Latest commit message | Latest commit date |
|---|---|---|
| include | ||
| src | ||
| CMakeLists.txt | ||
| conanfile.py | ||
| README.md | ||
lf-at24c32
Reusable AT24C32 EEPROM driver library for the Raspberry Pi Pico C SDK, packaged as a Conan package. This is designed for the AT24C32 EEPROM found on DS3231 + AT24C32 breakout boards.
This is part of the Lost + Found suite of projects.
🛠️ Usage with CMake
Copy the driver directory into your project as a subdirectory:
add_subdirectory(lib/lf-at24c32)
target_link_libraries(your_project PRIVATE
lf-at24c32
)
And in your C/C++ code:
#include "lf_at24c32.h"
🔌 Hardware Setup
Connect the DS3231/AT24C32 breakout I2C pins to your Raspberry Pi Pico:
- Pico GP4 (SDA) <-> Breakout SDA
- Pico GP5 (SCL) <-> Breakout SCL
- Pico GND <-> Breakout GND
- Pico 3V3 OUT <-> Breakout VCC
(Note: Pins can be configured on any available Pico I2C bus and GPIOs).
💡 Example
#include <stdio.h>
#include "pico/stdlib.h"
#include "hardware/i2c.h"
#include "lf_at24c32.h"
#define I2C_PORT i2c0
#define PIN_SDA 4
#define PIN_SCL 5
int main() {
stdio_init_all();
sleep_ms(2000);
// Initialize I2C
i2c_init(I2C_PORT, 100 * 1000);
gpio_set_function(PIN_SDA, GPIO_FUNC_I2C);
gpio_set_function(PIN_SCL, GPIO_FUNC_I2C);
gpio_pull_up(PIN_SDA);
gpio_pull_up(PIN_SCL);
// Create and initialize device context
lf_at24c32_t eeprom;
if (!lf_at24c32_init(&eeprom, I2C_PORT, LF_AT24C32_DEFAULT_I2C_ADDR)) {
printf("Failed to initialize driver context!\n");
return -1;
}
// Ping device to verify it's connected
if (!lf_at24c32_ping(&eeprom)) {
printf("EEPROM not responding at address 0x%02X!\n", eeprom.i2c_addr);
return -1;
}
printf("EEPROM detected successfully.\n");
// Write a test string (crosses page boundaries automatically!)
const char *msg = "This is a long test message to demonstrate multi-page writing capabilities of the new lf-at24c32 driver library.";
uint16_t msg_len = strlen(msg) + 1;
printf("Writing test message...\n");
if (lf_at24c32_write_bytes(&eeprom, 0x0000, (const uint8_t *)msg, msg_len)) {
printf("Write successful.\n");
} else {
printf("Write failed!\n");
}
// Read it back
char read_buf[128] = {0};
printf("Reading test message back...\n");
if (lf_at24c32_read_bytes(&eeprom, 0x0000, (uint8_t *)read_buf, msg_len)) {
printf("Read message: \"%s\"\n", read_buf);
} else {
printf("Read failed!\n");
}
return 0;
}
⚙️ Prerequisites: Setting up Conan with uv
To install the Conan CLI package manager securely and in an isolated environment on your system, it is recommended to use uv:
# Install Conan globally as an isolated tool
uv tool install conan
This makes the conan executable available on your PATH immediately and keeps your system's Python packages clean.
📦 Consumption via Forgejo Conan Registry
The package is hosted and distributed through the Forgejo Conan Package Registry at git.clowderlabs.com.
1. Add the Remote Registry
Add the remote repository to your local Conan configuration:
conan remote add clowder https://git.clowderlabs.com/api/packages/blong/conan
2. Authenticate
Log in using your personal access token:
conan remote login -p <your_token> clowder <username>
3. Add to your Project
Add the dependency to your conanfile.txt (or conanfile.py):
[requires]
lf-at24c32/0.0.1
Then install the dependencies:
conan install . --output-folder=build --build=missing
Expected Output of conan install
When running conan install, Conan downloads the source package from your remote Forgejo registry, unpacks it locally, and generates the necessary target files for CMake:
======== Computing dependency graph ========
lf-at24c32/0.0.1: Not found in local cache, looking in remotes...
lf-at24c32/0.0.1: Checking remote: clowder
Connecting to remote 'clowder' with user 'blong'
lf-at24c32/0.0.1: Downloaded recipe revision 8809dc809c8e0261b8f0ab07c5e434dd
======== Computing necessary packages ========
Requirements
lf-at24c32/0.0.1#8809dc809c8e0261b8f0ab07c5e434dd:da39a3ee5e6b4b0d3255bfef95601890afd80709 - Build
======== Installing packages ========
lf-at24c32/0.0.1: Sources downloaded from 'clowder'
-------- Installing package lf-at24c32/0.0.1 (1 of 1) --------
lf-at24c32/0.0.1: Building from source
lf-at24c32/0.0.1: Package lf-at24c32/0.0.1:da39a3ee5e6b4b0d3255bfef95601890afd80709
>>> Source step
lf-at24c32/0.0.1: Copying sources to build folder
>>> Package step
Calling package()
package(): Packaged 1 '.c' file: lf_at24c32.c
package(): Packaged 1 '.txt' file: CMakeLists.txt
package(): Packaged 1 '.h' file: lf_at24c32.h
Package 'da39a3ee5e6b4b0d3255bfef95601890afd80709' created
======== Finalizing install (deploy, generators) ========
Generator 'CMakeDeps' calling 'generate()'
CMakeDeps necessary find_package() and targets for your CMakeLists.txt
find_package(lf-at24c32)
target_link_libraries(... lf-at24c32::lf-at24c32)
Install finished successfully
🛠️ Local Testing
To test building and exporting this Conan package locally without uploading, run:
conan export .
This will register lf-at24c32/0.0.1 in your local Conan cache for offline testing.