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 USBSerial_HelloWorld by
Revision 11:79e90b5d04c9, committed 2018-10-24
- Comitter:
- malcolmlear
- Date:
- Wed Oct 24 11:05:33 2018 +0000
- Parent:
- 10:6924c58f3a91
- Commit message:
- Example
Changed in this revision
main.cpp | Show annotated file Show diff for this revision Revisions of this file |
--- a/main.cpp Wed Feb 22 14:53:00 2017 +0000 +++ b/main.cpp Wed Oct 24 11:05:33 2018 +0000 @@ -3,9 +3,11 @@ SPI spi(p5, p6, p7); // DAC mosi, miso, sclk DigitalOut cs(p8); // active low DAC enable -DigitalOut outen(p21); // active low pulse output enable -DigitalOut outxpol(p23); // pulse output x polarity -DigitalOut outypol(p22); // pulse output y polarity +DigitalOut outen(p21); // active high pulse output enable +DigitalOut outxpol1(p23); // pulse output x1 polarity +DigitalOut outxpol2(p22); // pulse output x2 polarity +DigitalOut outypol1(p25); // pulse output y1 polarity +DigitalOut outypol2(p24); // pulse output y2 polarity USBSerial serial; // USB serial communication int v = 0; // voltage 0 to 1023 = 0 to 102.3 V @@ -28,9 +30,11 @@ } int main() { - outen = 1; // output off - outxpol = 0; - outypol = 0; + outen = 0; // output off + outxpol1 = 0; + outxpol2 = 0; + outypol1 = 0; + outypol2 = 0; cs = 1; // spi not selected spi.format(16,2); spi.frequency(1000000); @@ -40,31 +44,39 @@ e = 1; // set error serial.scanf("%s", CmdIn); if (strcmp(CmdIn, CmdP0) == 0) { - outxpol = 1; - outypol = 1; + outxpol1 = 1; + outxpol2 = 0; + outypol1 = 1; + outypol2 = 0; e = 0; } if (strcmp(CmdIn, CmdP1) == 0) { - outxpol = 1; - outypol = 0; + outxpol1 = 1; + outxpol2 = 0; + outypol1 = 0; + outypol2 = 1; e = 0; } if (strcmp(CmdIn, CmdP2) == 0) { - outxpol = 0; - outypol = 0; + outxpol1 = 0; + outxpol2 = 1; + outypol1 = 0; + outypol2 = 1; e = 0; } if (strcmp(CmdIn, CmdP3) == 0) { - outxpol = 0; - outypol = 1; + outxpol1 = 0; + outxpol2 = 1; + outypol1 = 1; + outypol2 = 0; e = 0; } if (strcmp(CmdIn, CmdO0) == 0) { - outen = 1; + outen = 0; e = 0; } if (strcmp(CmdIn, CmdO1) == 0) { - outen = 0; + outen = 1; e = 0; } if (strncmp(CmdIn, CmdVn, 2) == 0) {