Library for MAX7300 GPIO Expander
Revision 7:e75913818f75, committed 2016-05-12
- Comitter:
- j3
- Date:
- Thu May 12 23:35:32 2016 +0000
- Parent:
- 6:3674af0a03cf
- Commit message:
- updated docs
Changed in this revision
max7300.cpp | Show annotated file Show diff for this revision Revisions of this file |
max7300.h | Show annotated file Show diff for this revision Revisions of this file |
diff -r 3674af0a03cf -r e75913818f75 max7300.cpp --- a/max7300.cpp Fri Oct 16 23:14:22 2015 +0000 +++ b/max7300.cpp Thu May 12 23:35:32 2016 +0000 @@ -1,16 +1,5 @@ /******************************************************************//** * @file max7300.cpp -* -* @author Justin Jordan -* -* @version 0.0 -* -* Started: 14JUL15 -* -* Updated: -* -* @brief Source file for Max7300 class -*********************************************************************** * Copyright (C) 2015 Maxim Integrated Products, Inc., All Rights Reserved. * * Permission is hereby granted, free of charge, to any person obtaining a
diff -r 3674af0a03cf -r e75913818f75 max7300.h --- a/max7300.h Fri Oct 16 23:14:22 2015 +0000 +++ b/max7300.h Thu May 12 23:35:32 2016 +0000 @@ -1,16 +1,5 @@ /******************************************************************//** * @file max7300.h -* -* @author Justin Jordan -* -* @version 0.0 -* -* Started: 14JUL15 -* -* Updated: -* -* @brief Header file for Max7300 class -*********************************************************************** * Copyright (C) 2015 Maxim Integrated Products, Inc., All Rights Reserved. * * Permission is hereby granted, free of charge, to any person obtaining a @@ -49,10 +38,48 @@ #include "mbed.h" +/** +* @brief 2-Wire-Interfaced, 2.5V to 5.5V, 20-Port or 28-Port I/O +* Expander +* +* @details The MAX7300 compact, serial-interfaced, I/O expansion +* peripheral provides microprocessors with up to 28 ports. Each port +* is individually user configurable to either a logic input or logic +* output. +* @code +* #include "mbed.h" +* #include "max7300.h" +* +* int main (void) +* { +* I2C i2c_bus(D14, D15); +* +* Max7300 io_expander(&i2c_bus, Max7300::MAX7300_I2C_ADRS0); +* +* for(uint8_t idx = 0; idx < 10; idx++) +* { +* //configure ports 12 - 21 as outputs +* io_expander.config_port((Max7300::max7300_port_number_t) (idx+12), Max7300::MAX7300_PORT_OUTPUT); +* +* //configure ports 22 - 31 as inputs +* io_expander.config_port((Max7300::max7300_port_number_t) (idx+22), Max7300::MAX7300_PORT_INPUT); +* } +* +* io_expander.enable_ports(); +* +* //rest of application... +* } +* @endcode +*/ class Max7300 { public: + /** + * @brief Valid 7-bit I2C addresses + * @details 16 valid I2C addresses are possible through the + * connection od AD0 and AD1 to Vcc, GND, SDA, or SCL. + */ typedef enum { MAX7300_I2C_ADRS0 = 0x40, @@ -74,6 +101,11 @@ }max7300_i2c_adrs_t; + /** + * @brief Valid port configurations + * @details Valid port configurations for the MAX7300 are; + * push-pull GPO, schmitt GPI, schmitt GPI with pull-up. + */ typedef enum { MAX7300_PORT_OUTPUT = 1, @@ -82,6 +114,10 @@ }max7300_port_type_t; + /** + * @brief Valid port numbers + * @details Simple enumeration of port numbers + */ typedef enum { MAX7300_PORT_04 = 4, @@ -125,7 +161,8 @@ * @param[in] i2c_adrs - 7-bit slave address of MAX7300 * * On Exit: - * @return none + * + * @return None **************************************************************/ Max7300(I2C *i2c_bus, max7300_i2c_adrs_t i2c_adrs); @@ -142,7 +179,8 @@ * @param[in] i2c_adrs - 7-bit slave address of MAX7300 * * On Exit: - * @return none + * + * @return None **************************************************************/ Max7300(PinName sda, PinName scl, max7300_i2c_adrs_t i2c_adrs); @@ -155,7 +193,8 @@ * On Entry: * * On Exit: - * @return none + * + * @return None **************************************************************/ ~Max7300(); @@ -168,7 +207,8 @@ * On Entry: * * On Exit: - * @return 0 on success, non-0 on failure + * + * @return 0 on success, non-0 on failure **************************************************************/ int16_t enable_ports(void); @@ -181,7 +221,8 @@ * On Entry: * * On Exit: - * @return 0 on success, non-0 on failure + * + * @return 0 on success, non-0 on failure **************************************************************/ int16_t disable_ports(void); @@ -194,7 +235,8 @@ * On Entry: * * On Exit: - * @return 0 on success, non-0 on failure + * + * @return 0 on success, non-0 on failure **************************************************************/ int16_t enable_transition_detection(void); @@ -207,7 +249,8 @@ * On Entry: * * On Exit: - * @return 0 on success, non-0 on failure + * + * @return 0 on success, non-0 on failure **************************************************************/ int16_t disable_transition_detection(void); @@ -226,7 +269,8 @@ * MAX7300_PORT_INPUT_PULLUP * * On Exit: - * @return 0 on success, non-0 on failure + * + * @return 0 on success, non-0 on failure **************************************************************/ int16_t config_port(max7300_port_number_t port_num, max7300_port_type_t port_type); @@ -244,7 +288,8 @@ * the following format - xx|xx|xx|xx * * On Exit: - * @return 0 on success, non-0 on failure + * + * @return 0 on success, non-0 on failure **************************************************************/ int16_t config_4_ports(max7300_port_number_t low_port, uint8_t data); @@ -261,7 +306,8 @@ * MAX7300_PORT_INPUT_PULLUP * * On Exit: - * @return 0 on success, non-0 on failure + * + * @return 0 on success, non-0 on failure **************************************************************/ int16_t config_all_ports(max7300_port_type_t port_type); @@ -275,7 +321,8 @@ * @param[in] port_num - MAX7300 port number to read * * On Exit: - * @return state of port, or -1 on failure + * + * @return State of port, or -1 on failure **************************************************************/ int16_t read_port(max7300_port_number_t port_num); @@ -290,7 +337,8 @@ * @param[in] data - lsb of byte is written to port * * On Exit: - * @return 0 on success, non-0 on failure + * + * @return 0 on success, non-0 on failure **************************************************************/ int16_t write_port(max7300_port_number_t port_num, uint8_t data); @@ -306,7 +354,8 @@ * Max is port 24 * * On Exit: - * @return state of ports, or -1 on failure + * + * @return State of ports, or -1 on failure **************************************************************/ int16_t read_8_ports(max7300_port_number_t low_port); @@ -324,7 +373,8 @@ * @param[in] data - Data is written to ports * * On Exit: - * @return 0 on success, non-0 on failure + * + * @return 0 on success, non-0 on failure **************************************************************/ int16_t write_8_ports(max7300_port_number_t low_port, uint8_t data); @@ -340,7 +390,8 @@ * detection * * On Exit: - * @return contents of mask register, or -1 on failure + * + * @return 0 on success, non-0 on failure **************************************************************/ int16_t read_mask_register(bool enable_snapshot); @@ -355,7 +406,8 @@ * @param[in] data - Bits to set * * On Exit: - * @return 0 on success, non-0 on failure + * + * @return 0 on success, non-0 on failure **************************************************************/ int16_t write_mask_register(uint8_t data);