

You can get fancy with threads, mainly by changing their stack size and priority. If you don’t provide one, the default causes the processor to sleep. Call rtos_attach_idle_hook to set that function. You can also create a function that does return and have it execute if there is idle time where no threads are ready to execute. There is also a yield call if you simply want to give up the time slice without sleeping for a specific amount of time. As I mentioned in the last post, you can sleep with the ThisThread::sleep_for call. Of course, the function shouldn’t return unless you want the thread to end. For many cases, you just define a void function that takes no arguments and use it with a Thread object: readknobThread.start(vol_thread) Any computer that understands media keys on a keyboard should work with the device. That thread will communicate with the PC as a USB keyboard. One will read the pot and send a message over to the other thread. Just for practice, we’ll create two threads of execution. We’ve seen the serial port, but you can also look like a mass storage device or a mouse, for example. In fact, the Mbed OS has drivers for all kinds of USB devices. The Black Pill is a good choice for this application since it has analog inputs and can act as a USB keyboard. However, this time, we’ll make a practical toy that lets you adjust your PC’s volume level with a pot. The example program, admittedly, didn’t use many of the features of the OS, unless you count what the USB serial port driver uses behind the scenes.
#Usb mass storage device driver vista 32 bit how to#
Last time, I told you how to get started with the “Black Pill” STM32F411 board using the Mbed OS.
