Digital
This source code creates a array for controlling all digital pins at one place in form Pins array which would be used so that we get meaningful functions to work upon and also the implementation of rustduino library is easier for the user. For more details see section 16,17,25 and 26 of ATMEGA2560P datasheet.
#
StructureThis struct contain digital pin and its corresponding digital pin no.
DigitalPin
#
Implementations for toggle
#
impl Toggles the appropriate bit in PINxn register so that the mode of the pin is changed from high to low or vice versa.
#
Usagehigh
#
impl Set the pin to high output value.
#
Usagelow
#
impl Sets the pin to low output value.
#
Usagewrite
(used for Analog Write)#
impl We have to output or write a PWM wave to a digital pin, which can be 2 to 13 or 44 to 46 other pins will not work. Of these pins, 4 and 13 give output at 980 hertz while all pin except 4 and 13 are set to give output at 490 hertz.
The analog Write function takes in the value generated by mapping the 10 bit result from analog Read to a 8 bit number.