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.
Dependencies: MPU6050 mbed PID
Fork of BLE_MPU6050_test6_challenge_sb by
Revision 19:5f1e153ef63e, committed 2018-05-24
- Comitter:
- c201075
- Date:
- Thu May 24 04:20:45 2018 +0000
- Parent:
- 18:8bab3e5c4ea2
- Child:
- 20:b0e1fa37856d
- Commit message:
- Not use serial in interrupt handler!!
Changed in this revision
| main.cpp | Show annotated file Show diff for this revision Revisions of this file |
--- a/main.cpp Thu May 24 03:32:29 2018 +0000
+++ b/main.cpp Thu May 24 04:20:45 2018 +0000
@@ -30,6 +30,7 @@
uint8_t senPayload[10] = {0,};
uint8_t mpuPayload[12] = {0,};
+
//Characteristic Property Setting etc
GattCharacteristic cmdChar (cmd_uuid, cmdPayload, sizeof(cmdPayload), sizeof(cmdPayload), GattCharacteristic::BLE_GATT_CHAR_PROPERTIES_WRITE);
GattCharacteristic senChar (sen_uuid, senPayload, sizeof(senPayload), sizeof(senPayload), GattCharacteristic::BLE_GATT_CHAR_PROPERTIES_NOTIFY);
@@ -50,7 +51,8 @@
ble.startAdvertising();
wb.set_led2(0);
#ifdef DEBUG
- pc.printf("Disconnected\n\r");
+ //割り込みハンドラの中でシリアル通信しないこと。
+ //pc.printf("Disconnected\n\r");
#endif
}
//======================================================================
@@ -63,24 +65,25 @@
wb.control_enable(true);
wb.SetRPM(0,0);
#ifdef DEBUG
- pc.printf("Connected\n\r");
+ //割り込みハンドラの中でシリアル通信しないこと。
+ //pc.printf("Connected\n\r");
#endif
}
//======================================================================
//onDataWritten
//======================================================================
+
void onDataWritten(const GattCharacteristicWriteCBParams *params)
{
- float right_cmd;
- float left_cmd;
-
+ float right_cmd = 0;
+ float left_cmd = 0;
memcpy( &right_cmd, params->data , sizeof(right_cmd));
memcpy( &left_cmd, params->data + sizeof(right_cmd), sizeof(left_cmd));
-
- wb.SetRPM(left_cmd,right_cmd);
+ wb.SetRPM(right_cmd,left_cmd);
#ifdef DEBUG
- pc.printf("SetRPM %f,%f \n\r",left_cmd,right_cmd);
+ //割り込みハンドラの中でシリアル通信しないこと。
+ //printf("SetRPM:%f,%f",left_cmd,right_cmd)
#endif
}
/**************************************************************************/
