Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Fork of A_NYP_humanoid by
accgyro.cpp
00001 #include "LSM6DSLSensor.h" 00002 #include "accgyro.h" 00003 #include "mbed.h" 00004 #include "rtos.h" 00005 00006 //Serial pc(USBTX, USBRX); 00007 DigitalOut led1(LED1); 00008 int32_t ACCGYRO_gyro_axes[3]; 00009 int32_t ACCGYRO_acc_axes[3]; 00010 static DevI2C devI2c(PB_11,PB_10); 00011 static LSM6DSLSensor acc_gyro(&devI2c,LSM6DSL_ACC_GYRO_I2C_ADDRESS_LOW,PD_11); 00012 EventQueue ACCGYRO_queue; 00013 Mutex ACCGYRO_mutex; 00014 00015 int32_t ACCGYRO_get_gyro_x() 00016 { 00017 int32_t temp; 00018 //ACCGYRO_mutex.lock(); 00019 temp = ACCGYRO_gyro_axes[0]; 00020 //ACCGYRO_mutex.unlock(); 00021 return temp; 00022 } 00023 00024 void ACCGYRO_task() 00025 { 00026 led1 = !led1; 00027 //ACCGYRO_mutex.lock(); 00028 acc_gyro.get_x_axes(ACCGYRO_gyro_axes); 00029 acc_gyro.get_g_axes(ACCGYRO_acc_axes); 00030 //ACCGYRO_mutex.unlock(); 00031 //pc.printf("LSM6DSL [acc/mg]: %6ld\r\n", ACCGYRO_gyro_axes[0]); 00032 }; 00033 00034 void ACCGYRO_init() 00035 { 00036 //pc.printf("Initing LSM6DSL\r\n", ACCGYRO_gyro_axes[0]); 00037 acc_gyro.init(NULL); 00038 acc_gyro.enable_x(); 00039 acc_gyro.enable_g(); 00040 //RtosTimer ACCGYRO_Timer(&ACCGYRO_task,osTimerPeriodic); 00041 //ACCGYRO_Timer.start(100); 00042 //pc.printf("Init done\r\n"); 00043 //ACCGYRO_queue.call_every(1000, ACCGYRO_task); 00044 //ACCGYRO_queue.dispatch(); 00045 };
Generated on Sat Jul 23 2022 15:31:17 by
1.7.2
