Dirt-simple sample libraries for EECE 387. These libraries are intended to be minimalist samples-- they don't take advantage of more complex hardware features such as interrupt synchronization.
- A Two Wire Interface ("I2C") master library, which allows simple control of an I2C device using a bus-pirate-like syntax. See the documentation for
twi/master.h, or the samples below. - A uart-over-stdio library, which is conveneint for simple serial monitors. See The documentation for
uart/stdio.h, or the samples below.
A simple TWI interface using Bus Pirate-like syntax, and stdio over serial. (Compatible with Arduino boards!)
#include "uart/stdio.h"
#include "twi/master.h"
int main() {
uint8_t reading_low, reading_high;
//Set up an I2c communication at 100kHz.
set_up_twi_hardware(100000);
//And take repeated light sensor readings.
while(1) {
perform_bus_pirate_twi_command("[ 0x72 0xAC [ 0x73 r s ]", &reading_low, &reading_high);
printf("Sensor reading: %d\n", (reading_high << 8) | reading_low);
_delay_ms(100);
}
}For more detailed examples, see the top-level code files. Annotated source: