Work with MPU6050

Dependencies:   MPU6050 BSP_DISCO_F746NG

Files at this revision

API Documentation at this revision

Comitter:
codebreaker7
Date:
Fri Nov 22 14:46:58 2019 +0000
Commit message:
Initial commit

Changed in this revision

.hgignore Show annotated file Show diff for this revision Revisions of this file
BSP_DISCO_F746NG.lib Show annotated file Show diff for this revision Revisions of this file
MPU6050.lib Show annotated file Show diff for this revision Revisions of this file
main.cpp Show annotated file Show diff for this revision Revisions of this file
mbed-os.lib Show annotated file Show diff for this revision Revisions of this file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/.hgignore	Fri Nov 22 14:46:58 2019 +0000
@@ -0,0 +1,2 @@
+BUILD
+mbed-os/
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/BSP_DISCO_F746NG.lib	Fri Nov 22 14:46:58 2019 +0000
@@ -0,0 +1,1 @@
+https://mbed.org/teams/ST/code/BSP_DISCO_F746NG/#1050c589b2ad
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/MPU6050.lib	Fri Nov 22 14:46:58 2019 +0000
@@ -0,0 +1,1 @@
+https://os.mbed.com/users/codebreaker7/code/MPU6050/#5e35d0f84d39
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/main.cpp	Fri Nov 22 14:46:58 2019 +0000
@@ -0,0 +1,62 @@
+#include "mbed.h"
+#include "stm32746g_discovery_lcd.h"
+#include "MPU6050.h"
+#define MBED_RAM_START 0x20000000
+
+Serial pc(USBTX,USBRX);    // default baud rate: 9600
+MPU6050 mpu6050;           // class: MPU6050, object: mpu6050 
+Ticker toggler1;
+Ticker filter;           
+
+void toggle_led1();
+void toggle_led2();
+void compFilter();
+
+float pitchAngle = 0;
+float rollAngle = 0;
+
+int main()
+{
+    BSP_LCD_Init();
+    BSP_LCD_LayerDefaultInit(LTDC_ACTIVE_LAYER, LCD_FB_START_ADDRESS);
+    BSP_LCD_SelectLayer(LTDC_ACTIVE_LAYER);
+    
+    mpu6050.whoAmI();                           // Communication test: WHO_AM_I register reading 
+    wait(1);
+    mpu6050.calibrate(accelBias,gyroBias);      // Calibrate MPU6050 and load biases into bias registers
+    pc.printf("Calibration is completed. \r\n");
+    wait(0.5);
+    mpu6050.init();                             // Initialize the sensor
+    wait(1);
+
+    while (1) {
+        BSP_LCD_Clear(LCD_COLOR_BLACK);
+        BSP_LCD_SetFont(&LCD_DEFAULT_FONT);
+        BSP_LCD_SetBackColor(LCD_COLOR_WHITE);
+        BSP_LCD_SetTextColor(LCD_COLOR_DARKBLUE);
+
+        BSP_LCD_DisplayStringAt(0, 1, (uint8_t *)"MBED EXAMPLE", CENTER_MODE);
+        HAL_Delay(2000);
+
+        BSP_LCD_SetBackColor(LCD_COLOR_BLACK);
+        BSP_LCD_SetTextColor(LCD_COLOR_ORANGE);
+        BSP_LCD_DisplayStringAt(0, 100, (uint8_t *)"DISCOVERY STM32F746NG", CENTER_MODE);
+        HAL_Delay(2000);
+
+        BSP_LCD_Clear(LCD_COLOR_GREEN);
+        BSP_LCD_SetTextColor(LCD_COLOR_BLUE);
+        BSP_LCD_DrawRect(10, 20, 50, 50);
+        BSP_LCD_SetTextColor(LCD_COLOR_BROWN);
+        BSP_LCD_DrawCircle(80, 80, 50);
+        BSP_LCD_SetTextColor(LCD_COLOR_YELLOW);
+        BSP_LCD_DrawEllipse(150, 150, 50, 100);
+        BSP_LCD_SetTextColor(LCD_COLOR_RED);
+        BSP_LCD_FillCircle(200, 200, 40);
+        HAL_Delay(2000);
+
+        BSP_LCD_SetBackColor(LCD_COLOR_GREEN);
+        BSP_LCD_SetTextColor(LCD_COLOR_CYAN);
+        BSP_LCD_DisplayStringAt(0, 6, (uint8_t *)"HAVE FUN !!!", RIGHT_MODE);
+        HAL_Delay(2000);
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/mbed-os.lib	Fri Nov 22 14:46:58 2019 +0000
@@ -0,0 +1,1 @@
+https://github.com/ARMmbed/mbed-os/#699372421a3b388fe568e9be85b1a985749a438f