Pico_I2C_Tests/src/main_master.c

41 lines
891 B
C

#include <pico/stdlib.h>
#include <pico/cyw43_arch.h>
#include "Pico_I2C.h"
int main(void)
{
stdio_init_all();
if(cyw43_arch_init_with_country(CYW43_COUNTRY_FRANCE)) return PICO_ERROR_GENERIC;
cyw43_arch_gpio_put(CYW43_WL_GPIO_LED_PIN, true);
for(int i = 0; i < 3; i++)
{
cyw43_arch_gpio_put(CYW43_WL_GPIO_LED_PIN, false);
sleep_ms(100);
cyw43_arch_gpio_put(CYW43_WL_GPIO_LED_PIN, true);
sleep_ms(100);
}
while(true)
{
static uint64_t last_time = 0;
uint64_t time = time_us_64();
if(time - last_time > 1000 * 1000)
{
last_time = time;
static bool led_state = true;
led_state = !led_state;
cyw43_arch_gpio_put(CYW43_WL_GPIO_LED_PIN, led_state);
}
tight_loop_contents();
}
cyw43_arch_deinit();
return PICO_OK;
}