![]()
This module provides support for pin control of the µCore I/O ports. Most functions take a parameter which identify the pin or pins to effect. To make life easier, port.h includes pre-defined pin masks as follows:
#define PIN0 0x01
#define PIN1 0x02
#define PIN2 0x04
#define PIN3 0x08
#define PIN4 0x10
#define PIN5 0x20
#define PIN6 0x40
#define PIN7 0x80
#define PIN_ALL 0xff
Note that pin masks may be combined using the bitwise OR operator (|).
Make the specified pins outputs and drive them high (+5V).
port1_high(PIN3); // drives uCore pin P13 high port8_high(PIN0|PIN7); // drives uCore pins P80 and P87 high. |
Make the specified pins outputs and drive them low (0V).
port1_low(PIN3); // drives the uCore pin P13 low |
Allow the specified pins to electrically float. The pin can then be pulled up or down by an external resistor. This can be useful in certain kinds of interfacing. For example if implementing I2C in software, pins should be driven low using portn_low, but allowed to float high under the influence of a pull up resistor using portn_float.
Note that portb is an input only port which also acts as ADC inputs.
Make the specified pins inputs and test their current status. The function first places the specified pins in input mode (allowing them to electrically float) then returns the status of the specified pins. The function returns 0 if all the pins specified by the mask are being pulled low, else it returns non zero. Note that the status applies only to those pins specified in the mask, other input pins on the port are not tested.
if(port1_in(PIN0|PIN1)==0) // if both pin P10 & P11 are low
led_off(); // turn the LED off
else
led_on(); // else turn it on
|
Turn on or off the µCore on board status LED.
Home | Products | Technical Info | How to Order | Contact Us | Links