Knud Dalgaard / 310-TMC3-TestHW

Dependencies:   mbed

Embed: (wiki syntax)

« Back to documentation index

MCP23017 Class Reference

MCP23017 Class Reference

MCP23017 class. More...

#include <MCP23017.h>

Public Member Functions

 MCP23017 (PinName sda, PinName scl, int i2cAddress)
 Constructor for the MCP23017 connected to specified I2C pins at a specific address.
void reset (void)
 Reset MCP23017 device to its power-on state.
void write_bit (int value, int bit_number)
 Write a 0/1 value to an output bit.
void write_mask (unsigned short data, unsigned short mask)
 Write a masked 16-bit value to the device.
int read_bit (int bit_number)
 Read a 0/1 value from an input bit.
int read_mask (unsigned short mask)
 Read a 16-bit value from the device and apply mask.
void config (unsigned short dir_config, unsigned short pullup_config, unsigned short polarity_config)
 Configure an MCP23017 device.

Detailed Description

MCP23017 class.

Allow access to an I2C connected MCP23017 16-bit I/O extender chip Example:

      MCP23017     *par_port; 

Definition at line 54 of file MCP23017.h.


Constructor & Destructor Documentation

MCP23017 ( PinName  sda,
PinName  scl,
int  i2cAddress 
)

Constructor for the MCP23017 connected to specified I2C pins at a specific address.

16-bit I/O expander with I2C interface

Parameters:
sdaI2C data pin
sclI2C clock pin
i2cAddressI2C address

Definition at line 30 of file MCP23017.cpp.


Member Function Documentation

void config ( unsigned short  dir_config,
unsigned short  pullup_config,
unsigned short  polarity_config 
)

Configure an MCP23017 device.

Parameters:
dir_configdata direction value (1 = input, 0 = output)
pullup_config100k pullup value (1 = enabled, 0 = disabled)
polarity_configpolarity value (1 = flip, 0 = normal)

Definition at line 105 of file MCP23017.cpp.

int read_bit ( int  bit_number )

Read a 0/1 value from an input bit.

Parameters:
bit_numberbit number range 0 --> 15
Returns:
0/1 value read

Definition at line 88 of file MCP23017.cpp.

int read_mask ( unsigned short  mask )

Read a 16-bit value from the device and apply mask.

Parameters:
mask16-bit mask value
Returns:
16-bit data with mask applied

Definition at line 96 of file MCP23017.cpp.

void reset ( void   )

Reset MCP23017 device to its power-on state.

Definition at line 39 of file MCP23017.cpp.

void write_bit ( int  value,
int  bit_number 
)

Write a 0/1 value to an output bit.

Parameters:
value0 or 1
bit_numberbit number range 0 --> 15

Definition at line 67 of file MCP23017.cpp.

void write_mask ( unsigned short  data,
unsigned short  mask 
)

Write a masked 16-bit value to the device.

Parameters:
data16-bit data value
mask16-bit mask value

Definition at line 79 of file MCP23017.cpp.