M
I figured it out myself:
#include <FreeRTOS.h>
#include <devices.h>
#include <fpioa.h>
#include <pin_cfg.h>
#include <stdio.h>
#include <task.h>
#define SDA (31)
#define SCL (30)
#define DEVICE_ADDRESS 0x68
void vI2cTaskCore1(void *arg) {
const TickType_t xFrequency = 1000;
TickType_t xLastWakeTime;
/* Initialise the xLastWakeTime variable with the current time. */
xLastWakeTime = xTaskGetTickCount();
handle_t i2c0 = io_open("/dev/i2c0");
uint8_t sda = SDA;
uint8_t scl = SCL;
fpioa_set_function(sda, FUNC_I2C0_SDA);
fpioa_set_function(scl, FUNC_I2C0_SCLK);
uint8_t writeBuffer[2];
uint8_t readBuffer[2];
handle_t device= i2c_get_device(i2c0, DEVICE_ADDRESS, 7);
while (1) {
writeBuffer[0] = 0x01; /* Register */
io_write(device, writeBuffer, 1);
io_read(device, readBuffer, 2);
printf("Values %d, %d\r\n", readBuffer[0], readBuffer[1]);
/* Wait for the next cycle. */
vTaskDelayUntil(&xLastWakeTime, pdMS_TO_TICKS(xFrequency));
}
}
int main() {
BaseType_t xReturn;
xReturn = xTaskCreateAtProcessor(CORE_1, &vI2cTaskCore1, "vI2cTaskCore1", 512, NULL, 2, NULL);
if (xReturn != pdPASS) {
printf("Task %s run problem\r\n", "vI2cTaskCore1");
}
for (;;) {
}
}