Author | Rob Jansen, Copyright © 2024..2024, all rights reserved. |
Adapted-by | |
Compiler | 2.5r8 |
Library functions for the MSP23008. The port and individual port bits are all accessed using pseudo variables. In this way accessing the pins is the same as accessing PIC IO pins. The provided pin functions are (x = 0..7): mcp23008_pinx_direction using value INPUT/OUTPUT mcp23008_pinx_polarty using value ENABLED/DISABLED mcp23008_pinx using value HIGH/LOW mcp23008_latchx using value HIGH/LOW mcp23008_pull_upx using value ENABLED/DISABLED Port pseudo variables, activating all pins at once: mcp23008_port_direction Bits 0 = output, 1 = input mcp23008_port_polarity Bits 0 = normal, 1 = inverted mcp23008_port Bits 0 = LOW, 1 = HIGH mcp23008_latch Bits 0 = LOW, 1 = HIGH mcp23008_pull_up Bits 0 = DISABLED, 1 = ENABLED All other functions are provided via procedures and functions as described in the Public API section.
Microchip MCP23008/MCP23008 8-bit I/O Expander with serial interface. Datasheet DS20001919F.
No dependency found
const byte _MCP23008_IOCON = 0x05
const byte _MCP23008_GPPU = 0x06
const byte _MCP23008_INTF = 0x07
const byte _MCP23008_DEFVAL = 0x03
const byte _MCP23008_IPOL = 0x01
const byte _MCP23008_GPIO = 0x09
const byte _MCP23008_INTCAP = 0x08
const byte _MCP23008_INTCON = 0x04
const byte _MCP23008_GPINTEN = 0x02
const byte _MCP23008_OLAT = 0x0A
const byte _MCP23008_IODIR = 0x00
mcp23008_pin4'put(bit in level)
mcp23008_latch6'put(bit in level)
mcp23008_port'put(byte in value)
mcp23008_pin4_direction'put(bit in direction)
mcp23008_pull_up4'put(bit in level)
mcp23008_pin7_direction'put(bit in direction)
mcp23008_pin7'put(bit in level)
mcp23008_pin3_direction'put(bit in direction)
mcp23008_latch3'put(bit in level)
mcp23008_pull_up1'put(bit in level)
mcp23008_latch5'put(bit in level)
mcp23008_slew_rate()
mcp23008_pin2'put(bit in level)
mcp23008_pull_up2'put(bit in level)
mcp23008_latch4'put(bit in level)
mcp23008_pin1_direction'put(bit in direction)
mcp23008_latch'put(byte in value)
mcp23008_pin6_direction'put(bit in direction)
mcp23008_latch7'put(bit in level)
mcp23008_pin5'put(bit in level)
mcp23008_pin7_polarity'put(bit in polarity)
mcp23008_pin5_polarity'put(bit in polarity)
mcp23008_pull_up7'put(bit in level)
mcp23008_pin0_direction'put(bit in direction)
mcp23008_pin2_direction'put(bit in direction)
mcp23008_pull_up5'put(bit in level)
mcp23008_disable_slew_rate()
mcp23008_pin0_polarity'put(bit in polarity)
mcp23008_pin5_direction'put(bit in direction)
mcp23008_pin3_polarity'put(bit in polarity)
mcp23008_pull_up6'put(bit in level)
mcp23008_pull_up0'put(bit in level)
mcp23008_set_interrupt_output_driving()
mcp23008_port_polarity'put(byte in polarity)
mcp23008_set_interrupt_output_open_drain()
mcp23008_port_direction'put(byte in direction)
mcp23008_pin0'put(bit in level)
mcp23008_latch0'put(bit in level)
mcp23008_pin6'put(bit in level)
mcp23008_latch2'put(bit in level)
mcp23008_pin1'put(bit in level)
mcp23008_set_interrupt_active_high()
mcp23008_set_interrupt_active_low()
mcp23008_pin3'put(bit in level)
mcp23008_pin1_polarity'put(bit in polarity)
mcp23008_set_interrupt_control(byte in value)
mcp23008_set_interrupt_on_change(byte in value)
mcp23008_latch1'put(bit in level)
mcp23008_pull_up3'put(bit in level)
mcp23008_pin4_polarity'put(bit in polarity)
mcp23008_set_interrupt_compare_value(byte in value)
mcp23008_pull_up'put(byte in value)
mcp23008_pin6_polarity'put(bit in polarity)
mcp23008_pin2_polarity'put(bit in polarity)
mcp23008_pin5_direction'get() return bit
mcp23008_pin7_polarity'get() return bit
mcp23008_pin2'get() return bit
mcp23008_pin6_direction'get() return bit
mcp23008_pin0_direction'get() return bit
mcp23008_latch1'get() return bit
mcp23008_pin2_polarity'get() return bit
mcp23008_pin6_polarity'get() return bit
mcp23008_port_direction'get() return byte
mcp23008_pin4_polarity'get() return bit
mcp23008_pull_up4'get() return bit
mcp23008_pin5_polarity'get() return bit
mcp23008_pull_up3'get() return bit
mcp23008_pin3_direction'get() return bit
mcp23008_pin5'get() return bit
mcp23008_pull_up2'get() return bit
mcp23008_pin7'get() return bit
mcp23008_latch4'get() return bit
mcp23008_pin1_polarity'get() return bit
mcp23008_latch6'get() return bit
mcp23008_pin3_polarity'get() return bit
mcp23008_pin6'get() return bit
mcp23008_get_interrupt_capture() return byte
mcp23008_latch3'get() return bit
mcp23008_pull_up7'get() return bit
mcp23008_pull_up6'get() return bit
mcp23008_pin3'get() return bit
mcp23008_pin0'get() return bit
mcp23008_pull_up5'get() return bit
mcp23008_pin1'get() return bit
mcp23008_port_polarity'get() return byte
mcp23008_pull_up0'get() return bit
mcp23008_pin1_direction'get() return bit
mcp23008_pin0_polarity'get() return bit
mcp23008_latch7'get() return bit
mcp23008_get_interrupt_flags() return byte
mcp23008_latch0'get() return bit
mcp23008_port'get() return byte
mcp23008_pin2_direction'get() return bit
mcp23008_pin7_direction'get() return bit
mcp23008_latch5'get() return bit
mcp23008_pull_up1'get() return bit
mcp23008_latch'get() return byte
mcp23008_pin4_direction'get() return bit
mcp23008_latch2'get() return bit
mcp23008_pin4'get() return bit
mcp23008_pull_up'get() return byte
const byte _MCP23008_IOCON = 0x05
No documentation found
const byte _MCP23008_GPPU = 0x06
No documentation found
const byte _MCP23008_INTF = 0x07
No documentation found
const byte _MCP23008_DEFVAL = 0x03
No documentation found
const byte _MCP23008_IPOL = 0x01
No documentation found
const byte _MCP23008_GPIO = 0x09
No documentation found
const byte _MCP23008_INTCAP = 0x08
Read only.
const byte _MCP23008_INTCON = 0x04
No documentation found
const byte _MCP23008_GPINTEN = 0x02
No documentation found
const byte _MCP23008_OLAT = 0x0A
No documentation found
const byte _MCP23008_IODIR = 0x00
Configuration and control registers of the MCP23008/MCP23008 (MCP23x08).
mcp23008_pin4'put(bit in level)
Pseudo variable to set the level of port pin 4. Level FALSE represents LOW, TRUE represents HIGH.
mcp23008_latch6'put(bit in level)
Pseudo variable to set the level of latch bit 6. Level FALSE represents LOW, TRUE represents HIGH.
mcp23008_port'put(byte in value)
Pseuse variable to set the port value. Value with bits set represents HIGH, bits cleared represents LOW.
mcp23008_pin4_direction'put(bit in direction)
Pseudo variable to set the pin direction of pin 4. Direction TRUE equals INPUT, direction FALSE equals OUTPUT.
mcp23008_pull_up4'put(bit in level)
Pseudo variable to set the resistor pull-up configuration of port pin 4. Level TRUE represents ENABLED, FALSE represents DISABLED.
mcp23008_pin7_direction'put(bit in direction)
Pseudo variable to set the pin direction of pin 7. Direction TRUE equals INPUT, direction FALSE equals OUTPUT.
mcp23008_pin7'put(bit in level)
Pseudo variable to set the level of port pin 7. Level FALSE represents LOW, TRUE represents HIGH.
mcp23008_pin3_direction'put(bit in direction)
Pseudo variable to set the pin direction of pin 3. Direction TRUE equals INPUT, direction FALSE equals OUTPUT.
mcp23008_latch3'put(bit in level)
Pseudo variable to set the level of latch bit 3. Level FALSE represents LOW, TRUE represents HIGH.
mcp23008_pull_up1'put(bit in level)
Pseudo variable to set the resistor pull-up configuration of port pin 1. Level TRUE represents ENABLED, FALSE represents DISABLED.
mcp23008_latch5'put(bit in level)
Pseudo variable to set the level of latch bit 5. Level FALSE represents LOW, TRUE represents HIGH.
mcp23008_slew_rate()
Enable slew rate for SDA output.
mcp23008_pin2'put(bit in level)
Pseudo variable to set the level of port pin 2. Level FALSE represents LOW, TRUE represents HIGH.
mcp23008_pull_up2'put(bit in level)
Pseudo variable to set the resistor pull-up configuration of port pin 2. Level TRUE represents ENABLED, FALSE represents DISABLED.
mcp23008_latch4'put(bit in level)
Pseudo variable to set the level of latch bit 4. Level FALSE represents LOW, TRUE represents HIGH.
mcp23008_pin1_direction'put(bit in direction)
Pseudo variable to set the pin direction of pin 1. Direction TRUE equals INPUT, direction FALSE equals OUTPUT.
mcp23008_latch'put(byte in value)
Pseudo variable to set the latch value. Value with bits set represents HIGH, bits cleared represents LOW.
mcp23008_pin6_direction'put(bit in direction)
Pseudo variable to set the pin direction of pin 6. Direction TRUE equals INPUT, direction FALSE equals OUTPUT.
mcp23008_latch7'put(bit in level)
Pseudo variable to set the level of latch bit 7. Level FALSE represents LOW, TRUE represents HIGH.
mcp23008_pin5'put(bit in level)
Pseudo variable to set the level of port pin 5. Level FALSE represents LOW, TRUE represents HIGH.
mcp23008_pin7_polarity'put(bit in polarity)
Pseudo variable to set the input polarity of pin 7. Polarity ENABLED (TRUE) is inverted, polarity DISABLED (FALSE) is normal.
mcp23008_pin5_polarity'put(bit in polarity)
Pseudo variable to set the input polarity of pin 5. Polarity ENABLED (TRUE) is inverted, polarity DISABLED (FALSE) is normal.
mcp23008_pull_up7'put(bit in level)
Pseudo variable to set the resistor pull-up configuration of port pin 7. Level TRUE represents ENABLED, FALSE represents DISABLED.
mcp23008_pin0_direction'put(bit in direction)
Pseudo variable to set the pin direction of pin 0. Direction TRUE equals INPUT, direction FALSE equals OUTPUT.
mcp23008_pin2_direction'put(bit in direction)
Pseudo variable to set the pin direction of pin 2. Direction TRUE equals INPUT, direction FALSE equals OUTPUT.
mcp23008_pull_up5'put(bit in level)
Pseudo variable to set the resistor pull-up configuration of port pin 5. Level TRUE represents ENABLED, FALSE represents DISABLED.
mcp23008_disable_slew_rate()
Disable lew rate for SDA output.
mcp23008_pin0_polarity'put(bit in polarity)
Pseudo variable to set the input polarity of pin 0. Polarity ENABLED (TRUE) is inverted, polarity DISABLED (FALSE) is normal.
mcp23008_pin5_direction'put(bit in direction)
Pseudo variable to set the pin direction of pin 5. Direction TRUE equals INPUT, direction FALSE equals OUTPUT.
mcp23008_pin3_polarity'put(bit in polarity)
Pseudo variable to set the input polarity of pin 3. Polarity ENABLED (TRUE) is inverted, polarity DISABLED (FALSE) is normal.
mcp23008_pull_up6'put(bit in level)
Pseudo variable to set the resistor pull-up configuration of port pin 6. Level TRUE represents ENABLED, FALSE represents DISABLED.
mcp23008_pull_up0'put(bit in level)
Pseudo variable to set the resistor pull-up configuration of port pin 0. Level TRUE represents ENABLED, FALSE represents DISABLED.
mcp23008_set_interrupt_output_driving()
Set the interrupt output to driving.
mcp23008_port_polarity'put(byte in polarity)
Pseudo variable to set the port input polarity. Polarity with bits set are inverted, bits cleared are normal.
mcp23008_set_interrupt_output_open_drain()
Set the interrupt output to open drain.
mcp23008_port_direction'put(byte in direction)
Pseudo variable to set the port direction. Direction with bits set are to INPUT, bits cleared are set to OUTPUT.
mcp23008_pin0'put(bit in level)
Pseudo variable to set the level of port pin 0. Level FALSE represents LOW, TRUE represents HIGH.
mcp23008_latch0'put(bit in level)
Pseudo variable to set the level of latch bit 0. Level FALSE represents LOW, TRUE represents HIGH.
mcp23008_pin6'put(bit in level)
Pseudo variable to set the level of port pin 6. Level FALSE represents LOW, TRUE represents HIGH.
mcp23008_latch2'put(bit in level)
Pseudo variable to set the level of latch bit 2. Level FALSE represents LOW, TRUE represents HIGH.
mcp23008_pin1'put(bit in level)
Pseudo variable to set the level of port pin 1. Level FALSE represents LOW, TRUE represents HIGH.
mcp23008_set_interrupt_active_high()
Set the interrupt polarity to active HIGH.
mcp23008_set_interrupt_active_low()
Set the interrupt polarity to active LOW.
mcp23008_pin3'put(bit in level)
Pseudo variable to set the level of port pin 3. Level FALSE represents LOW, TRUE represents HIGH.
mcp23008_pin1_polarity'put(bit in polarity)
Pseudo variable to set the input polarity of pin 1. Polarity ENABLED (TRUE) is inverted, polarity DISABLED (FALSE) is normal.
mcp23008_set_interrupt_control(byte in value)
Set the interrupt control value. See datasheet for details.
mcp23008_set_interrupt_on_change(byte in value)
Set interrupt on change register. Bit set is ENABLE, bit clear is DISABLE. See datasheet for details.
mcp23008_latch1'put(bit in level)
Pseudo variable to set the level of latch bit 1. Level FALSE represents LOW, TRUE represents HIGH.
mcp23008_pull_up3'put(bit in level)
Pseudo variable to set the resistor pull-up configuration of port pin 3. Level TRUE represents ENABLED, FALSE represents DISABLED.
mcp23008_pin4_polarity'put(bit in polarity)
Pseudo variable to set the input polarity of pin 4. Polarity ENABLED (TRUE) is inverted, polarity DISABLED (FALSE) is normal.
mcp23008_set_interrupt_compare_value(byte in value)
Set interrupt compare value. See datasheet for details.
mcp23008_pull_up'put(byte in value)
Pseudo variable to set the resistor pull-up configuration. Value with bits set represents ENABLED, bits cleared represents DISABLED.
mcp23008_pin6_polarity'put(bit in polarity)
Pseudo variable to set the input polarity of pin 6. Polarity ENABLED (TRUE) is inverted, polarity DISABLED (FALSE) is normal.
mcp23008_pin2_polarity'put(bit in polarity)
Pseudo variable to set the input polarity of pin 2. Polarity ENABLED (TRUE) is inverted, polarity DISABLED (FALSE) is normal.
_mcp23008_write_data(byte in register, byte in data)
Write a byte to the given register of the MCP23008 via the IIC interface.
mcp23008_pin5_direction'get() return bit
Pseudo variable to get the pin direction of pin 5. Return value TRUE equals INPUT, FALSE equals OUTPUT.
mcp23008_pin7_polarity'get() return bit
Pseudo variable to get the input polarity of pin 7. Return value TRUE represents inverted, polarity FALSE represents normal.
mcp23008_pin2'get() return bit
Pseudo variable to get the level of port pin 2. Return value TRUE represents level is HIGH, FALSE represents level is LOW.
mcp23008_pin6_direction'get() return bit
Pseudo variable to get the pin direction of pin 6. Return value TRUE equals INPUT, FALSE equals OUTPUT.
mcp23008_pin0_direction'get() return bit
Pseudo variable to get the pin direction of pin 0. Return value TRUE equals INPUT, FALSE equals OUTPUT.
mcp23008_latch1'get() return bit
Pseudo variable to get the level of latch bit 1. Return value TRUE represents level is HIGH, FALSE represents level is LOW.
mcp23008_pin2_polarity'get() return bit
Pseudo variable to get the input polarity of pin 2. Return value TRUE represents inverted, polarity FALSE represents normal.
mcp23008_pin6_polarity'get() return bit
Pseudo variable to get the input polarity of pin 6. Return value TRUE represents inverted, polarity FALSE represents normal.
mcp23008_port_direction'get() return byte
Pseudo variable to get the port direction. Return value with bits set are INPUT, bits cleared are OUTPUT.
mcp23008_pin4_polarity'get() return bit
Pseudo variable to get the input polarity of pin 4. Return value TRUE represents inverted, polarity FALSE represents normal.
mcp23008_pull_up4'get() return bit
Pseudo variable to get the resistor pull-up configuration of port pin 4. Return value TRUE represents ENABLED, FALSE represents DISABLED.
mcp23008_pin5_polarity'get() return bit
Pseudo variable to get the input polarity of pin 5. Return value TRUE represents inverted, polarity FALSE represents normal.
mcp23008_pull_up3'get() return bit
Pseudo variable to get the resistor pull-up configuration of port pin 3. Return value TRUE represents ENABLED, FALSE represents DISABLED.
mcp23008_pin3_direction'get() return bit
Pseudo variable to get the pin direction of pin 3. Return value TRUE equals INPUT, FALSE equals OUTPUT.
mcp23008_pin5'get() return bit
Pseudo variable to get the level of port pin 5. Return value TRUE represents level is HIGH, FALSE represents level is LOW.
mcp23008_pull_up2'get() return bit
Pseudo variable to get the resistor pull-up configuration of port pin 2. Return value TRUE represents ENABLED, FALSE represents DISABLED.
mcp23008_pin7'get() return bit
Pseudo variable to get the level of port pin 7. Return value TRUE represents level is HIGH, FALSE represents level is LOW.
mcp23008_latch4'get() return bit
Pseudo variable to get the level of latch bit 4. Return value TRUE represents level is HIGH, FALSE represents level is LOW.
mcp23008_pin1_polarity'get() return bit
Pseudo variable to get the input polarity of pin 1. Return value TRUE represents inverted, polarity FALSE represents normal.
mcp23008_latch6'get() return bit
Pseudo variable to get the level of latch bit 6. Return value TRUE represents level is HIGH, FALSE represents level is LOW.
mcp23008_pin3_polarity'get() return bit
Pseudo variable to get the input polarity of pin 3. Return value TRUE represents inverted, polarity FALSE represents normal.
mcp23008_pin6'get() return bit
Pseudo variable to get the level of port pin 6. Return value TRUE represents level is HIGH, FALSE represents level is LOW.
mcp23008_get_interrupt_capture() return byte
Return the interrupt capture status. See datasheet for details.
mcp23008_latch3'get() return bit
Pseudo variable to get the level of latch bit 3. Return value TRUE represents level is HIGH, FALSE represents level is LOW.
mcp23008_pull_up7'get() return bit
Pseudo variable to get the resistor pull-up configuration of port pin 7. Return value TRUE represents ENABLED, FALSE represents DISABLED.
mcp23008_pull_up6'get() return bit
Pseudo variable to get the resistor pull-up configuration of port pin 6. Return value TRUE represents ENABLED, FALSE represents DISABLED.
mcp23008_pin3'get() return bit
Pseudo variable to get the level of port pin 3. Return value TRUE represents level is HIGH, FALSE represents level is LOW.
mcp23008_pin0'get() return bit
Pseudo variable to get the level of port pin 0. Return value TRUE represents level is HIGH, FALSE represents level is LOW.
mcp23008_pull_up5'get() return bit
Pseudo variable to get the resistor pull-up configuration of port pin 5. Return value TRUE represents ENABLED, FALSE represents DISABLED.
mcp23008_pin1'get() return bit
Pseudo variable to get the level of port pin 1. Return value TRUE represents level is HIGH, FALSE represents level is LOW.
mcp23008_port_polarity'get() return byte
Pseudo variable to get the port polarity. Return value with bits set are inverted, bits cleared are normal.
mcp23008_pull_up0'get() return bit
Pseudo variable to get the resistor pull-up configuration of port pin 0. Return value TRUE represents ENABLED, FALSE represents DISABLED.
mcp23008_pin1_direction'get() return bit
Pseudo variable to get the pin direction of pin 1. Return value TRUE equals INPUT, FALSE equals OUTPUT.
mcp23008_pin0_polarity'get() return bit
Pseudo variable to get the input polarity of pin 0. Return value TRUE represents inverted, polarity FALSE represents normal.
mcp23008_latch7'get() return bit
Pseudo variable to get the level of latch bit 7. Return value TRUE represents level is HIGH, FALSE represents level is LOW.
mcp23008_get_interrupt_flags() return byte
Return the interrupt flags. See datasheet for details.
mcp23008_latch0'get() return bit
Pseudo variable to get the level of latch bit 0. Return value TRUE represents level is HIGH, FALSE represents level is LOW.
mcp23008_port'get() return byte
Pseudo variable to get the port value. Return value with bits set represents HIGH, bits cleared represents LOW.
mcp23008_pin2_direction'get() return bit
Pseudo variable to get the pin direction of pin 2. Return value TRUE equals INPUT, FALSE equals OUTPUT.
mcp23008_pin7_direction'get() return bit
Pseudo variable to get the pin direction of pin 7. Return value TRUE equals INPUT, FALSE equals OUTPUT.
mcp23008_latch5'get() return bit
Pseudo variable to get the level of latch bit 5. Return value TRUE represents level is HIGH, FALSE represents level is LOW.
mcp23008_pull_up1'get() return bit
Pseudo variable to get the resistor pull-up configuration of port pin 1. Return value TRUE represents ENABLED, FALSE represents DISABLED.
mcp23008_latch'get() return byte
Pseudo variable to get the latch value. Return value with bits set represents HIGH, bits cleared represents LOW.
mcp23008_pin4_direction'get() return bit
Pseudo variable to get the pin direction of pin 4. Return value TRUE equals INPUT, FALSE equals OUTPUT.
mcp23008_latch2'get() return bit
Pseudo variable to get the level of latch bit 2. Return value TRUE represents level is HIGH, FALSE represents level is LOW.
mcp23008_pin4'get() return bit
Pseudo variable to get the level of port pin 4. Return value TRUE represents level is HIGH, FALSE represents level is LOW.
mcp23008_pull_up'get() return byte
Pseudo variable to get the resistor pull-up configuration. Return value with bits set represents ENABLED, bits cleared represents DISABLED.
_mcp23008_read_data(byte in register) return byte
Read a byte from the given register of the MCP23008 via the IIC interface.
16f1825 | 16f1825_mcp23008.jal |