Thread *gyroRun(SPIDriver *spip, tprio_t prio) { Thread *tp; init_l3g4200d(spip); tp = chThdCreateFromHeap(NULL, GYRO_WA_SIZE, prio, l3g4200d_update_thread, (void*)spip); extChannelEnable(&EXTD1, GYRO_INT2); l3g4200d_update(spip); return tp; }
void gyroscope_init(int spi_bus_num) { printf("Initializing gyroscope...\n"); lm3s69xx_gpio_set_pin(SSI_SS_PIN, true); lm3s69xx_gpio_digital_enable(SSI_SS_PIN, true); rtems_device_minor_number minor = RTEMS_LIBI2C_MAKE_MINOR(spi_bus_num, SSI_SS_PIN); check_whoami(minor); init_l3g4200d(minor); measure_offset(minor, &gyro_data.offset); printf("Gyroscope offset: %"PRId16", %"PRId16", %"PRId16"\n", gyro_data.offset.x, gyro_data.offset.y, gyro_data.offset.z); rtems_id task_id; rtems_task_create(rtems_build_name('G', 'Y', 'R', 'O'), 1, RTEMS_MINIMUM_STACK_SIZE, RTEMS_DEFAULT_MODES, RTEMS_DEFAULT_ATTRIBUTES, &task_id); rtems_task_start(task_id, gyroscope_task, 0); }