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 dac_controller2 by
Revision 2:c0287d9c2226, committed 2014-04-11
- Comitter:
- erichill44
- Date:
- Fri Apr 11 19:53:01 2014 +0000
- Parent:
- 1:4bd950ab8756
- Child:
- 3:29aa7212dda4
- Commit message:
- implemented CAN
Changed in this revision
| main.cpp | Show annotated file Show diff for this revision Revisions of this file |
--- a/main.cpp Fri Apr 04 18:48:23 2014 +0000
+++ b/main.cpp Fri Apr 11 19:53:01 2014 +0000
@@ -5,10 +5,40 @@
Timer programTimer;
//Timer DACC_timer;
//DigitalOut testLed(LED1);
+Ticker read;
+CAN can2(p30,p29);
+
+void canread() {
+ CANMessage msg;
+ if(can2.read(msg)) {
+ char command = msg.data[0];
+ switch (command) {
+ case 1:
+ DAC_set(3.0, FREQ_1HZ, FORM_SQUARE);
+ break;
+ case 2:
+ DAC_set(3.0, FREQ_1HZ, FORM_SIN);
+ break;
+ case 3:
+ DAC_set(3.0, FREQ_10HZ, FORM_SQUARE);
+ break;
+ case 4:
+ DAC_set(3.0, FREQ_10HZ, FORM_SIN);
+ break;
+ case 5:
+ DAC_start();
+ break;
+ case 6:
+ DAC_stop();
+ break;
+ default: break;
+ }
+ }
+ }
int main()
{
-
+ read.attach(&canread,1);
DAC_set(3.0, FREQ_1HZ, FORM_SQUARE);
DAC_start();
while(1) {
