[16a384cf] | 1 | -- |
---|
| 2 | -- A test program that uses the TS1325 Button and LED packages. |
---|
| 3 | -- |
---|
| 4 | |
---|
| 5 | with Text_IO; |
---|
| 6 | |
---|
| 7 | with I386_Ports; |
---|
| 8 | use I386_Ports; |
---|
| 9 | |
---|
| 10 | with TS1325.LED; |
---|
| 11 | use TS1325.LED; |
---|
| 12 | |
---|
| 13 | with TS1325.Button; |
---|
| 14 | use TS1325.Button; |
---|
| 15 | |
---|
| 16 | with TS1325.Parallel; |
---|
| 17 | use TS1325.Parallel; |
---|
| 18 | |
---|
| 19 | procedure Ts1325_Test is |
---|
| 20 | |
---|
| 21 | Test_Parallel_Interval: Duration := 1.0; |
---|
| 22 | Read_Button_Interval: Duration := 1.0; |
---|
| 23 | Read_LED_Interval: Duration := 1.0; |
---|
| 24 | Set_LED_Interval: Duration := 0.2; |
---|
| 25 | |
---|
| 26 | task Test_Parallel is |
---|
| 27 | entry Start; |
---|
| 28 | end Test_Parallel; |
---|
| 29 | |
---|
| 30 | task body Test_Parallel is |
---|
| 31 | W_Data, R_Data: I386_Ports.Byte := 0; |
---|
| 32 | begin |
---|
| 33 | accept Start; |
---|
| 34 | |
---|
| 35 | loop |
---|
| 36 | W_Data := W_Data + 1; |
---|
| 37 | Write_Parallel_Port (W_Data); |
---|
| 38 | Read_Parallel_Port (R_Data); |
---|
| 39 | Text_IO.Put_Line ("Parallel Port Loopback: Data Write = " & |
---|
| 40 | I386_Ports.Byte'Image (W_Data) & |
---|
| 41 | ", Data Read = " & |
---|
| 42 | I386_Ports.Byte'Image (R_Data)); |
---|
| 43 | delay Test_Parallel_Interval; |
---|
| 44 | end loop; |
---|
| 45 | end Test_Parallel; |
---|
| 46 | |
---|
| 47 | task Read_Button is |
---|
| 48 | entry Start; |
---|
| 49 | end Read_Button; |
---|
| 50 | |
---|
| 51 | task body Read_Button is |
---|
| 52 | begin |
---|
| 53 | accept Start; |
---|
| 54 | |
---|
| 55 | loop |
---|
| 56 | if Is_Button_Pressed then |
---|
| 57 | Text_IO.Put_Line ("Button is pressed."); |
---|
| 58 | else |
---|
| 59 | Text_IO.Put_Line ("Button is not pressed."); |
---|
| 60 | end if; |
---|
| 61 | delay Read_Button_Interval; |
---|
| 62 | end loop; |
---|
| 63 | end Read_Button; |
---|
| 64 | |
---|
| 65 | task Read_Colour is |
---|
| 66 | entry Start; |
---|
| 67 | end Read_Colour; |
---|
| 68 | |
---|
| 69 | task body Read_Colour is |
---|
| 70 | begin |
---|
| 71 | accept Start; |
---|
| 72 | |
---|
| 73 | loop |
---|
| 74 | Text_IO.Put_Line ("Reading LED colour as " & |
---|
| 75 | LED_Colour'Image (LED_State.Get)); |
---|
| 76 | delay Read_LED_Interval; |
---|
| 77 | end loop; |
---|
| 78 | end Read_Colour; |
---|
| 79 | |
---|
| 80 | task Set_Colour is |
---|
| 81 | entry Start; |
---|
| 82 | end Set_Colour; |
---|
| 83 | |
---|
| 84 | task body Set_Colour is |
---|
| 85 | Colour: LED_Colour := Off; |
---|
| 86 | begin |
---|
| 87 | accept Start; |
---|
| 88 | |
---|
| 89 | loop |
---|
| 90 | LED_State.Set (Colour); |
---|
| 91 | |
---|
| 92 | if Colour = LED_Colour'Last then |
---|
| 93 | Colour := LED_Colour'First; |
---|
| 94 | else |
---|
| 95 | Colour := LED_Colour'Succ (Colour); |
---|
| 96 | end if; |
---|
| 97 | |
---|
| 98 | delay Set_LED_Interval; |
---|
| 99 | end loop; |
---|
| 100 | end Set_Colour; |
---|
| 101 | |
---|
| 102 | begin |
---|
| 103 | Text_IO.Put_Line ("TS-1325 Utilities Test"); |
---|
| 104 | Text_IO.Put_Line ("======================"); |
---|
| 105 | Text_IO.New_Line; |
---|
| 106 | Text_IO.Put_Line ("-=> Press the button to begin."); |
---|
| 107 | Text_IO.New_Line; |
---|
| 108 | |
---|
| 109 | Wait_For_Button_Press; |
---|
| 110 | |
---|
| 111 | Set_Colour.Start; |
---|
| 112 | Read_Colour.Start; |
---|
| 113 | Read_Button.Start; |
---|
| 114 | Test_Parallel.Start; |
---|
| 115 | end Ts1325_Test; |
---|