LVTTL HW Trigger with control via virtual Serial over USB. Works well with NUCLEO boards.
Revision 0:46a9ecc2d2b8, committed 2016-01-22
- Comitter:
- Neolker
- Date:
- Fri Jan 22 10:33:36 2016 +0000
- Child:
- 1:26ff6101d6d5
- Commit message:
- final release
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 Fri Jan 22 10:33:36 2016 +0000
@@ -0,0 +1,50 @@
+/*
+* ---------------
+* TriggerNiNo 1.0
+* ---------------
+*
+* LVTTL HW Trigger with control via virtual Serial over USB.
+* Works well with NUCLEO-F031K6 and NUCLEO-F411RE.
+*
+* Copyright (C) <2015> Martin Wolker <neolker@gmail.com>
+*
+* TriggerNiNo is free software: you can redistribute it and/or modify
+* it under the terms of the GNU General Public License as published by
+* the Free Software Foundation, either version 3 of the License, or
+* (at your option) any later version.
+*
+* You should have received a copy of the GNU General Public License
+* If not, see <http://www.gnu.org/licenses/>.
+*/
+
+#include "mbed.h" //mbed official library.
+#define TRIGGER_PULSE_LENGTH_MS 500 //Length of the trigger pulse in ms.
+
+Serial pc(USBTX, USBRX); //Virtual Serial over USB with 9600 baud.
+DigitalOut trigger_output_positive(D2); //Declaration of positive trigger output.
+DigitalOut trigger_output_negative(D3); //Declaration of negative trigger output.
+DigitalOut trigger_indication(LED1); //Declaration of indication LED.
+
+void trigger(void)
+{
+ trigger_output_positive =! trigger_output_positive; //Change the state of the positive output.
+ trigger_output_negative =! trigger_output_negative; //Change the state of the negative output.
+ trigger_indication =! trigger_indication; //Change the state of the indication LED.
+}
+
+void interrupt(void)
+{
+ pc.getc(); //Get the character from the buffer and clear.
+ trigger(); //Trigger ON.
+ wait_ms(TRIGGER_PULSE_LENGTH_MS); //Waiting when the trigger pulse is ON.
+ trigger(); //Trigger OFF.
+}
+
+int main(void)
+{
+ pc.attach(&interrupt); //Call the interrupt, when any data are received from PC.
+ trigger_output_positive = 0; //Initial state of positive output in idle state.
+ trigger_output_negative = 1; //Initial state of negative output in idle state.
+ trigger_indication = 0; //Initial state of LED in idle state is OFF.
+ while(1) {} //Infinity loop.
+}
\ No newline at end of file
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/mbed.bld Fri Jan 22 10:33:36 2016 +0000 @@ -0,0 +1,1 @@ +http://mbed.org/users/mbed_official/code/mbed/builds/165afa46840b \ No newline at end of file
Martin Wolker