Summary: This article describes the simple and unique way of accessing hardware in the. Net Micro Framework. involves gpio,rs232 serial port and so on. A concise routine illustrates how to create an IO port and how to send the process of accepting data.
1.GPIO
Generally speaking, a MCU to communicate with the surrounding environment, the use of Gpio (General purpose Input/output) is undoubtedly the most common way. A gpio port that can be used for input or output after being initialized. A GPIO port can be described by two states-low (about 0 volts) and high (usually considered to be 3.3 volts of forward voltage).
In the. Net Micro Framework, the GPIO state is defined as a Boolean,false-> low, true-> high.
Tips here say Low (0 volts) and high (3.3 volts) are the voltages you actually add to the Gpio when you set the Gpio. And when considering the input of the general 1v below will be considered to be lower logic, 1.7~5.5 Volt is generally considered to be high logic. More than 5.5 of the voltage is not protected if the circuit is usually damaged your hardware.
1.1 Output
Under the Microsoft.SPOT.Hardware namespace, you can find the Outputport class, which inherits from the Microsoft.SPOT.Hardware.Port---a base class for describing Gpio.
Defining Outputport typically initializes a default value (True for high, false for low).
Outputport outputport = new Outputport (mypins.statusled, true);
/* The first parameter is enumerated type Microsoft.SPOT.Hardware.Cpu.Pin, but in order to make your code more flexible, it is highly recommended that you use your own encapsulated class to bind the Cpu's pin name and the GPIO port number. */
Then, Outputport's write and read methods can be used, the Write method controls the level state of the PIN, and the Read method returns the current state, which is the last set state.
The following example is used to let a custom pin's LEDs blink at a 1hz frequency (which is actually light and dark on each 0.5s).
Outputport outputport = new Outputport (mypins.statusled, true);
while (true)
{
thread.sleep;
Outputport.write (!outputport.read ()); Toggle Port
}