diff options
Diffstat (limited to 'pico-watch.c')
-rw-r--r-- | pico-watch.c | 40 |
1 files changed, 40 insertions, 0 deletions
diff --git a/pico-watch.c b/pico-watch.c new file mode 100644 index 0000000..3d39b9b --- /dev/null +++ b/pico-watch.c @@ -0,0 +1,40 @@ +#include <stdio.h> +#include "pico/stdlib.h" +#include "hardware/i2c.h" +#include "hardware/timer.h" +#include "hardware/clocks.h" + +// I2C defines +// This example will use I2C0 on GPIO8 (SDA) and GPIO9 (SCL) running at 400KHz. +// Pins can be changed, see the GPIO function select table in the datasheet for information on GPIO assignments +#define I2C_PORT i2c0 +#define I2C_SDA 8 +#define I2C_SCL 9 + +int64_t alarm_callback(alarm_id_t id, void *user_data) { + // Put your timeout handler code in here + return 0; +} + + + +int main() +{ + stdio_init_all(); + + // I2C Initialisation. Using it at 400Khz. + i2c_init(I2C_PORT, 400*1000); + + gpio_set_function(I2C_SDA, GPIO_FUNC_I2C); + gpio_set_function(I2C_SCL, GPIO_FUNC_I2C); + gpio_pull_up(I2C_SDA); + gpio_pull_up(I2C_SCL); + + // Timer example code - This example fires off the callback after 2000ms + add_alarm_in_ms(2000, alarm_callback, NULL, false); + + + puts("Hello, world!"); + + return 0; +} |