Pond Electronics - Home of the µFlash876 & µFlash876B embedded controllers, µStack & µConnect Bus.

The port module

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 (|).

portn_high

void port1_high(BYTE mask);
void port2_high(BYTE mask);
void port5_high(BYTE mask);
void port7_high(BYTE mask);
void port8_high(BYTE mask);

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.   

portn_low

void port1_low(BYTE mask);
void port2_low(BYTE mask);
void port5_low(BYTE mask);
void port7_low(BYTE mask);
void port8_low(BYTE mask);

Make the specified pins outputs and drive them low (0V).

port1_low(PIN3);    // drives the uCore pin P13 low   

portn_float

void port1_float(BYTE mask);
void port2_float(BYTE mask);
void port5_float(BYTE mask);
void port7_float(BYTE mask);
void port8_float(BYTE mask);

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.

portn_in

BYTE port1_in(BYTE mask);
BYTE port2_in(BYTE mask);
BYTE port5_in(BYTE mask);
BYTE port7_in(BYTE mask);
BYTE port8_in(BYTE mask);
BYTE portb_in(BYTE mask);

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

led_on and led_off

void led_on();
void led_off();

Turn on or off the µCore on board status LED.


Home | Products | Technical Info | How to Order | Contact Us | Links