Maciej Zemlo
/
PRS_R1_AssTest
netemera prs
main.cpp@0:9dffac13db39, 2019-03-26 (annotated)
- Committer:
- yabool2001
- Date:
- Tue Mar 26 08:18:20 2019 +0000
- Revision:
- 0:9dffac13db39
- Child:
- 1:db05ea2d0fe7
PRS_R1_AssTest
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
yabool2001 | 0:9dffac13db39 | 1 | #include "mbed.h" |
yabool2001 | 0:9dffac13db39 | 2 | |
yabool2001 | 0:9dffac13db39 | 3 | Serial serial ( PA_9 , PA_3 ); |
yabool2001 | 0:9dffac13db39 | 4 | |
yabool2001 | 0:9dffac13db39 | 5 | DigitalOut led_blue ( PA_5 ); |
yabool2001 | 0:9dffac13db39 | 6 | DigitalOut led_red ( PA_8 ); |
yabool2001 | 0:9dffac13db39 | 7 | DigitalOut led_orange ( PA_10 ); |
yabool2001 | 0:9dffac13db39 | 8 | |
yabool2001 | 0:9dffac13db39 | 9 | InterruptIn int_pa_0 ( PA_0 ); |
yabool2001 | 0:9dffac13db39 | 10 | DigitalIn pulse ( PA_2 ); |
yabool2001 | 0:9dffac13db39 | 11 | DigitalIn pulse_safe ( PB_5 ); |
yabool2001 | 0:9dffac13db39 | 12 | DigitalIn flow_dir ( PB_9 ); |
yabool2001 | 0:9dffac13db39 | 13 | DigitalIn case_open ( PA_3 ); |
yabool2001 | 0:9dffac13db39 | 14 | |
yabool2001 | 0:9dffac13db39 | 15 | DigitalIn sw1 ( PB_2 ); |
yabool2001 | 0:9dffac13db39 | 16 | DigitalIn sw2 ( PB_6 ); |
yabool2001 | 0:9dffac13db39 | 17 | DigitalIn sw3 ( PB_7 ); |
yabool2001 | 0:9dffac13db39 | 18 | DigitalIn sel ( PA_3 ); |
yabool2001 | 0:9dffac13db39 | 19 | |
yabool2001 | 0:9dffac13db39 | 20 | |
yabool2001 | 0:9dffac13db39 | 21 | // Toggle LED |
yabool2001 | 0:9dffac13db39 | 22 | void toggle_led () |
yabool2001 | 0:9dffac13db39 | 23 | { |
yabool2001 | 0:9dffac13db39 | 24 | wait (0.1); //stan musi być utrzymany przez min. 0.1s |
yabool2001 | 0:9dffac13db39 | 25 | if ( pulse == 1 ) |
yabool2001 | 0:9dffac13db39 | 26 | led_blue = !led_blue; |
yabool2001 | 0:9dffac13db39 | 27 | if ( pulse_safe == 1 ) |
yabool2001 | 0:9dffac13db39 | 28 | led_red = !led_red; |
yabool2001 | 0:9dffac13db39 | 29 | if ( flow_dir == 1 ) |
yabool2001 | 0:9dffac13db39 | 30 | led_orange = !led_orange; |
yabool2001 | 0:9dffac13db39 | 31 | } |
yabool2001 | 0:9dffac13db39 | 32 | |
yabool2001 | 0:9dffac13db39 | 33 | int main() { |
yabool2001 | 0:9dffac13db39 | 34 | |
yabool2001 | 0:9dffac13db39 | 35 | led_blue = 1; |
yabool2001 | 0:9dffac13db39 | 36 | led_red = 1; |
yabool2001 | 0:9dffac13db39 | 37 | led_orange = 1; |
yabool2001 | 0:9dffac13db39 | 38 | |
yabool2001 | 0:9dffac13db39 | 39 | // Change LEDs blinking frequency when button is pressed |
yabool2001 | 0:9dffac13db39 | 40 | int_pa_0.fall( &toggle_led ); |
yabool2001 | 0:9dffac13db39 | 41 | |
yabool2001 | 0:9dffac13db39 | 42 | while ( 1 ) |
yabool2001 | 0:9dffac13db39 | 43 | { |
yabool2001 | 0:9dffac13db39 | 44 | wait ( 0.5 ); |
yabool2001 | 0:9dffac13db39 | 45 | serial.printf ( "DIP switch status:\n\r" ); |
yabool2001 | 0:9dffac13db39 | 46 | if ( sw1 ) |
yabool2001 | 0:9dffac13db39 | 47 | serial.printf ( "SW1 = 1\n\r" ); |
yabool2001 | 0:9dffac13db39 | 48 | else |
yabool2001 | 0:9dffac13db39 | 49 | serial.printf ( "SW1 = 0\n\r" ); |
yabool2001 | 0:9dffac13db39 | 50 | if ( sw2 ) |
yabool2001 | 0:9dffac13db39 | 51 | serial.printf ( "SW2 = 1\n\r" ); |
yabool2001 | 0:9dffac13db39 | 52 | else |
yabool2001 | 0:9dffac13db39 | 53 | serial.printf ( "SW2 = 0\n\r" ); |
yabool2001 | 0:9dffac13db39 | 54 | if ( sw3 ) |
yabool2001 | 0:9dffac13db39 | 55 | serial.printf ( "SW3 = 1\n\r" ); |
yabool2001 | 0:9dffac13db39 | 56 | else |
yabool2001 | 0:9dffac13db39 | 57 | serial.printf ( "SW3 = 0\n\r" ); |
yabool2001 | 0:9dffac13db39 | 58 | } |
yabool2001 | 0:9dffac13db39 | 59 | } |