/**
* include file
*/
#include <stdio.h>
#include "pico/stdlib.h"
#include "hardware/i2c.h"
/*
#define I2C_PORT i2c0
#define I2C_ADDR 0x68
#define GYRO_CONFIG 0x1B
#define GYRO_XOUT_H 0x43
// ジャイロセンサーから傾きデータを取得する関数
int16_t read_word(uint8_t reg) {
// ジャイロセンサーにデータ要求を送信
uint8_t buf[2];
i2c_write_blocking(I2C_PORT, I2C_ADDR, ®, 1, true);
i2c_read_blocking(I2C_PORT, I2C_ADDR, buf, 2, false);
// 取得したデータをパース
return (buf[0] << 8) | buf[1];
}
int main() {
stdio_init_all();
i2c_init(I2C_PORT, 100000);
gpio_set_function(2, GPIO_FUNC_I2C);
gpio_set_function(3, GPIO_FUNC_I2C);
gpio_pull_up(2);
gpio_pull_up(3);
i2c_set_slave_mode(I2C_PORT, false, 0);
i2c_write_blocking(I2C_PORT, I2C_ADDR, &(uint8_t){GYRO_CONFIG}, 1, true);
i2c_write_blocking(I2C_PORT, I2C_ADDR, &(uint8_t){0x10}, 1, false);
while (true) {
// ジャイロセンサーから傾きデータを取得
int16_t x = read_word(GYRO_XOUT_H);
int16_t y = read_word(GYRO_XOUT_H + 2);
int16_t z = read_word(GYRO_XOUT_H + 4);
printf("X: %d, Y: %d, Z: %d\n", x, y, z);
printf("hello");
sleep_ms(100);
}
return 0;
}
*/
int main() {
while (true) {
printf("hello");
sleep_ms(100);
}
return 0;
}