eLua reference manual - MBED pio module

Overview

This module provide a function for accessing pin configuration features on the LPC17xx family of CPUs, and provides provides a pin mapping which corresponds to the pins and LEDs on the MBED platform. The pin configuration function allows the user to reconfigure pin function (as decribed in section 8.5 of the lpc17xx user manual, configure the pin as an open drain, and configure the pin as pullup, pulldown or tristate. Note that this module is a supplement of the platform independent pio module, not a replacement. Use this module only for setting up the MBED PIO pins, and the pio module for all the other PIO related operations. Below is a subset of available pin functions:

  • PWM
    MBED Pin ID Function
    LED1 1 FUNCTION_2
    LED2 2 FUNCTION_2
    LED3 3 FUNCTION_2
    LED4 4 FUNCTION_2
    p21 6 FUNCTION_1
    p22 5 FUNCTION_1
    p23 4 FUNCTION_1
    p24 3 FUNCTION_1
    p25 2 FUNCTION_1
    p26 1 FUNCTION_1
  • UART
    MBED Pin ID Function
    p13 1 (TX) FUNCTION_1
    p14 1 (RX) FUNCTION_1
    p28 2 (TX) FUNCTION_1
    p27 2 (RX) FUNCTION_1

In addition, this module provides pin mapping as found on the mbed board so that mbed.pio.p5 through mbed.pio.p30 map onto the mbed pins as described in the mbed handbook. LED pins are also usable, for example LED1 would correspond to mbed.pio.LED1.

Functions

mbed.pio.configpin( pin, function, mode, resistor)

Configure the pin.

Arguments:

  • pin - the pin, as encoded in the pio or mbed.pio module.
  • function - alternate pin function, Must be either mbed.pio.FUNCTION_0 (default), mbed.pio.FUNCTION_1, mbed.pio.FUNCTION_2, or mbed.pio.FUNCTION_3
  • mode - open drain mode, can be either mbed.pio.MODE_DEFAULT (no open drain) or mbed.pio.MODE_OD (open drain).
  • resistor - alternate pin function. Must be either mbed.pio.RES_PULLUP (default), mbed.pio.RES_TRISTATE, mbed.pio.RES_PULLDOWN.

Returns: nothing.