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: mbed
Revision 0:cf3829614495, committed 2016-05-11
- Comitter:
- SES01
- Date:
- Wed May 11 07:31:23 2016 +0000
- Child:
- 1:e45830806a1c
- Commit message:
- test
Changed in this revision
| main.cpp | Show annotated file Show diff for this revision Revisions of this file |
| mbed.bld | Show annotated file Show diff for this revision Revisions of this file |
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/main.cpp Wed May 11 07:31:23 2016 +0000
@@ -0,0 +1,65 @@
+#include "mbed.h"
+
+#define F_MD 18000 //PWMキャリア周波数設定
+
+/*
+ * High_A High_B
+ * ┃ ┃
+ * ┃ ┃
+ * ┣━━━┫
+ * ┃ ┃
+ * ┃ ┃
+ * Low_A Low_B
+ */
+
+//Serial pc(USBTX, USBRX);
+Serial comPort(dp16, dp15);
+//DigitalOut myled1(LED1); //汎用IOで使用するためLED1は使用できない
+DigitalOut myled(dp24);
+DigitalOut driverEnable(dp28);
+//dp1 = ローサイドPWM1, dp2 = ローサイドPWM2
+//dp5 = ハイサイドPWM1, dp27 = ハイサイドPWM2 (オープンドレイン)
+PwmOut Low_A(dp1);
+PwmOut Low_B(dp2);
+DigitalOut High_A(dp5);
+DigitalOut High_B(dp27);
+
+AnalogIn ain(dp4);
+BusInOut led7(dp6, dp9, dp10, dp11, dp13, dp14, dp17, dp18);
+
+void com_rx() {
+ /*switch (comPort.getc()) {
+ case 255
+
+ }*/
+}
+
+int main() {
+ //comPort.baud(9600);
+ //comPort.format(8, Serial::None, 1);
+ comPort.attach(&com_rx, Serial::RxIrq);
+
+ int FP_MD = 1000000 / F_MD; //PWM一周期の周期(マイクロ秒)
+
+ led7.output();
+
+ High_A = 0;
+ High_B = 1;
+
+ Low_A.period_us(FP_MD);
+ Low_A.write(0);
+ Low_B.period_us(FP_MD);
+ Low_B.write(0);
+ //初期設定完了
+
+ //flipper.attach(&flip, 2.0);
+ //flipper.attach(&flip, 2.0);
+ //myled1 = 1;
+ led7 = 0b11011010;
+ driverEnable = 1;
+ while (1) {
+ Low_A.write((ain.read() - 0.2) * 1.25 < 0 ? 0 : (ain.read() - 0.2) * 1.25);
+ //pc.printf("%f\n", (ain.read() - 0.2) * 1.25 < 0 ? 0 : (ain.read() - 0.2) * 1.25);
+ comPort.printf("%d", 0b01010101);
+ }
+}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/mbed.bld Wed May 11 07:31:23 2016 +0000 @@ -0,0 +1,1 @@ +http://mbed.org/users/mbed_official/code/mbed/builds/082adc85693f \ No newline at end of file