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
Revision 0:0ea84b3cf851, committed 2018-04-30
- Comitter:
- mr_wang
- Date:
- Mon Apr 30 09:43:36 2018 +0000
- Commit message:
- NYP_humanoid
Changed in this revision
diff -r 000000000000 -r 0ea84b3cf851 LSM6DSL.lib --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/LSM6DSL.lib Mon Apr 30 09:43:36 2018 +0000 @@ -0,0 +1,1 @@ +https://developer.mbed.org/teams/ST/code/LSM6DSL/#20ccff7dd652
diff -r 000000000000 -r 0ea84b3cf851 accgyro.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/accgyro.cpp Mon Apr 30 09:43:36 2018 +0000 @@ -0,0 +1,45 @@ +#include "LSM6DSLSensor.h" +#include "accgyro.h" +#include "mbed.h" +#include "rtos.h" + +//Serial pc(USBTX, USBRX); +DigitalOut led1(LED1); +int32_t ACCGYRO_gyro_axes[3]; +int32_t ACCGYRO_acc_axes[3]; +static DevI2C devI2c(PB_11,PB_10); +static LSM6DSLSensor acc_gyro(&devI2c,LSM6DSL_ACC_GYRO_I2C_ADDRESS_LOW,PD_11); +EventQueue ACCGYRO_queue; +Mutex ACCGYRO_mutex; + +int32_t ACCGYRO_get_gyro_x() +{ + int32_t temp; + //ACCGYRO_mutex.lock(); + temp = ACCGYRO_gyro_axes[0]; + //ACCGYRO_mutex.unlock(); + return temp; +} + +void ACCGYRO_task() +{ + led1 = !led1; + //ACCGYRO_mutex.lock(); + acc_gyro.get_x_axes(ACCGYRO_gyro_axes); + acc_gyro.get_g_axes(ACCGYRO_acc_axes); + //ACCGYRO_mutex.unlock(); + //pc.printf("LSM6DSL [acc/mg]: %6ld\r\n", ACCGYRO_gyro_axes[0]); +}; + +void ACCGYRO_init() +{ + //pc.printf("Initing LSM6DSL\r\n", ACCGYRO_gyro_axes[0]); + acc_gyro.init(NULL); + acc_gyro.enable_x(); + acc_gyro.enable_g(); + //RtosTimer ACCGYRO_Timer(&ACCGYRO_task,osTimerPeriodic); + //ACCGYRO_Timer.start(100); + //pc.printf("Init done\r\n"); + //ACCGYRO_queue.call_every(1000, ACCGYRO_task); + //ACCGYRO_queue.dispatch(); +};
diff -r 000000000000 -r 0ea84b3cf851 accgyro.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/accgyro.h Mon Apr 30 09:43:36 2018 +0000 @@ -0,0 +1,9 @@ +#ifndef __ACCGYRO_H__ +#define __ACCGYRO_H__ + +int32_t ACCGYRO_get_gyro_x(); + +void ACCGYRO_init(); +void ACCGYRO_task(); + +#endif \ No newline at end of file
diff -r 000000000000 -r 0ea84b3cf851 main.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/main.cpp Mon Apr 30 09:43:36 2018 +0000 @@ -0,0 +1,34 @@ +#include "mbed.h" +#include "rtos.h" + +#include "accgyro.h" +//Serial pc(USBTX, USBRX); +DigitalOut led2(LED2); +Thread eventthread; +EventQueue eventqueue; + +int main() +{ + ACCGYRO_init(); + eventthread.start(callback(&eventqueue, &EventQueue::dispatch_forever)); + //ACCGYRO_thread.start(ACCGYRO_init); + //Thread::wait(osWaitForever); + eventqueue.call_every(1000, ACCGYRO_task); + //q.dispatch(); + //eventqueue.call_every(1000,printf,"LSM6DSL [acc/mg]: %6ld\r\n", ACCGYRO_get_gyro_x()); + //q.dispatch(); + + + while(1) + { + eventqueue.call(printf,"LSM6DSL [acc/mg]: %6ld\r\n", ACCGYRO_get_gyro_x()); + led2 = !led2; + wait(1); + //q.dispatch(); + //q.call(printf, "*\n"); + //printf("*"); + //Thread::wait(1000); + //printf("LSM6DSL [acc/mg]: %6ld\r\n", ACCGYRO_get_gyro_x()); + //printf("LSM6DSL [gyro/mdps]: %6ld, %6ld, %6ld\r\n", axes[0], axes[1], axes[2]); + } +} \ No newline at end of file
diff -r 000000000000 -r 0ea84b3cf851 mbed-os.lib --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/mbed-os.lib Mon Apr 30 09:43:36 2018 +0000 @@ -0,0 +1,1 @@ +https://github.com/ARMmbed/mbed-os/#569159b784f70feaa32ce226aaca896fb83452f7