Page 394 - ARM Based Microcontroller Projects Using MBED
P. 394
380 15. Mbed RTOS PROJECTS
FIG. 15.13 Block diagram of the project.
FIG. 15.14 Circuit diagram of the project.
respectively. LockEntryBarrier output when set locks the entry barrier so that it does not open
and it is assigned to PC_2. The car park capacity is set to 100 cars. Inside the main program mes-
sage CLOSED is displayed since the car park is closed at the beginning of the program. Threads
CarParkandDisplayarestarted.Thesethreadswaitforeventflags1and2tobeset,respectively,
before they can continue. These flags are set when the StartButton is pressed (i.e., StartButton is
at logic LOW). Setting the flags starts the two threads. Thread Display displays the spaces avail-
able in the car park at screen coordinate (0, 9). Thread CarPark increases or decreases the space
count depending on whether the cars are entering or leaving the car park. When a car enters the
car park variable Spaces is decremented by one. Similarly, when a car leaves the car park var-
iableSpacesisincrementedbyone.Theprogrammakessurethatthespacecountisnotabovethe
car park capacity or below zero (this should never happen in practice).
Note that this project could have been implemented without using multitasking, but here
multitasking is used for demonstration purposes.