Library for MAX7300 GPIO Expander
Diff: max7300.h
- Revision:
- 1:e1ee2549a047
- Parent:
- 0:350a850a7191
- Child:
- 2:fd2de5d21702
--- a/max7300.h Wed Jul 15 15:10:04 2015 +0000
+++ b/max7300.h Thu Jul 16 21:27:05 2015 +0000
@@ -10,7 +10,6 @@
* Updated:
*
* @brief Header file for Max7300 class
-*
***********************************************************************
* Copyright (C) 2015 Maxim Integrated Products, Inc., All Rights Reserved.
*
@@ -116,53 +115,6 @@
}max7300_port_number_t;
- typedef enum
- {
- MAX7300_NO_OP = 0,
- MAX7300_CONFIGURATION = 4,
- MAX7300_MASK = 6,
- MAX7300_PORT_CONFIG_P07_P04 = 9,
- MAX7300_PORT_CONFIG_P11_P8,
- MAX7300_PORT_CONFIG_P15_P12,
- MAX7300_PORT_CONFIG_P19_P16,
- MAX7300_PORT_CONFIG_P23_P20,
- MAX7300_PORT_CONFIG_P27_P24,
- MAX7300_PORT_CONFIG_P31_P28,
- MAX7300_PORT_04_DATA = 0x24,
- MAX7300_PORT_05_DATA,
- MAX7300_PORT_06_DATA,
- MAX7300_PORT_07_DATA,
- MAX7300_PORT_08_DATA,
- MAX7300_PORT_09_DATA,
- MAX7300_PORT_10_DATA,
- MAX7300_PORT_11_DATA,
- MAX7300_PORT_12_DATA,
- MAX7300_PORT_13_DATA,
- MAX7300_PORT_14_DATA,
- MAX7300_PORT_15_DATA,
- MAX7300_PORT_16_DATA,
- MAX7300_PORT_17_DATA,
- MAX7300_PORT_18_DATA,
- MAX7300_PORT_19_DATA,
- MAX7300_PORT_20_DATA,
- MAX7300_PORT_21_DATA,
- MAX7300_PORT_22_DATA,
- MAX7300_PORT_23_DATA,
- MAX7300_PORT_24_DATA,
- MAX7300_PORT_25_DATA,
- MAX7300_PORT_26_DATA,
- MAX7300_PORT_27_DATA,
- MAX7300_PORT_28_DATA,
- MAX7300_PORT_29_DATA,
- MAX7300_PORT_30_DATA,
- MAX7300_PORT_31_DATA,
- MAX7300_8_PORTS_P04_P11_DATA = 0x44,
- MAX7300_8_PORTS_P12_P19_DATA = 0x4C,
- MAX7300_8_PORTS_P20_P27_DATA = 0x54,
- MAX7300_8_PORTS_P24_P31_DATA = 0x58
- }max7300_registers_t;
-
-
/**********************************************************//**
* @brief Constructor for Max7300 Class.
*
@@ -235,6 +187,32 @@
/**********************************************************//**
+ * @brief Enables Transition Detection
+ *
+ * @details Sets 'M' bit of configuration register
+ *
+ * On Entry:
+ *
+ * On Exit:
+ * @return 0 on success, non-0 on failure
+ **************************************************************/
+ int16_t enable_transition_detection(void);
+
+
+ /**********************************************************//**
+ * @brief Disables Transition Detection
+ *
+ * @details Clears 'M' bit of configuration register
+ *
+ * On Entry:
+ *
+ * On Exit:
+ * @return 0 on success, non-0 on failure
+ **************************************************************/
+ int16_t disable_transition_detection(void);
+
+
+ /**********************************************************//**
* @brief Configures a single MAX7300 GPIO port
*
* @details Configures MAX7300 GPIO port as either an output,
@@ -259,14 +237,8 @@
* @details Allows user to configure 4 ports at a time
*
* On Entry:
- * @param[in] reg - One of the following 7 registers
- * MAX7300_PORT_CONFIG_P7_P4,
- * MAX7300_PORT_CONFIG_P11_P8,
- * MAX7300_PORT_CONFIG_P15_P12,
- * MAX7300_PORT_CONFIG_P19_P16,
- * MAX7300_PORT_CONFIG_P23_P20,
- * MAX7300_PORT_CONFIG_P27_P24,
- * MAX7300_PORT_CONFIG_P31_P28
+ * @param[in] low_port - lowest of 4 ports to configure,
+ * on 4 port boundaries as in datasheet
*
* @param[in] data - Byte with each ports desired type with
* the following format - xx|xx|xx|xx
@@ -274,7 +246,24 @@
* On Exit:
* @return 0 on success, non-0 on failure
**************************************************************/
- int16_t config_ports(max7300_registers_t reg, uint8_t data);
+ int16_t config_4_ports(max7300_port_number_t low_port, uint8_t data);
+
+
+ /**********************************************************//**
+ * @brief Configures all MAX7300 GPIO ports
+ *
+ * @details Allows user to configure all ports to a single type
+ *
+ * On Entry:
+ * @param[in] port_type - One of the following port types
+ * MAX7300_PORT_OUTPUT
+ * MAX7300_PORT_INPUT
+ * MAX7300_PORT_INPUT_PULLUP
+ *
+ * On Exit:
+ * @return 0 on success, non-0 on failure
+ **************************************************************/
+ int16_t config_all_ports(max7300_port_type_t port_type);
/**********************************************************//**
@@ -283,9 +272,10 @@
* @details
*
* On Entry:
+ * @param[in] port_num - MAX7300 port number to read
*
* On Exit:
- * @return state of port, or
+ * @return state of port, or -1 on failure
**************************************************************/
int16_t read_port(max7300_port_number_t port_num);
@@ -296,9 +286,11 @@
* @details
*
* On Entry:
+ * @param[in] port_num - MAX7300 port to write
+ * @param[in] data - lsb of byte is written to port
*
* On Exit:
- * @return none
+ * @return 0 on success, non-0 on failure
**************************************************************/
int16_t write_port(max7300_port_number_t port_num, uint8_t data);
@@ -309,11 +301,14 @@
* @details
*
* On Entry:
+ * @param[in] low_port - lowest port of 8 ports to read,
+ * on 8 port boundaries as in datasheet.
+ * Max is port 24
*
* On Exit:
- * @return none
+ * @return state of ports, or -1 on failure
**************************************************************/
- int16_t read_eight_ports(max7300_registers_t reg);
+ int16_t read_8_ports(max7300_port_number_t low_port);
/**********************************************************//**
@@ -322,23 +317,48 @@
* @details
*
* On Entry:
+ * @param[in] low_port - lowest port of 8 ports to write,
+ * on 8 port boundaries as in datasheet.
+ * Max is port 24
+ *
+ * @param[in] data - Data is written to ports
*
* On Exit:
- * @return none
+ * @return 0 on success, non-0 on failure
**************************************************************/
- int16_t write_eight_ports(max7300_registers_t reg, uint8_t data);
+ int16_t write_8_ports(max7300_port_number_t low_port, uint8_t data);
+
+
+ /**********************************************************//**
+ * @brief Read transition detection mask register
+ *
+ * @details See page 11 of DS, right hand side column, paragraph 2
+ * for details on one-shot event.
+ *
+ * On Entry:
+ * @param[in] enable_snapshot - true to re-enable transition
+ * detection
+ *
+ * On Exit:
+ * @return contents of mask register, or -1 on failure
+ **************************************************************/
+ int16_t read_mask_register(bool enable_snapshot);
/**********************************************************//**
- * @brief
+ * @brief Write transition detection mask register
*
- * @details
+ * @details Enables transition detection on Ports 30-24
+ *
*
* On Entry:
+ * @param[in] data - Bits to set
*
* On Exit:
- * @return none
+ * @return 0 on success, non-0 on failure
**************************************************************/
+ int16_t write_mask_register(uint8_t data);
+
private:
@@ -346,5 +366,21 @@
bool _i2c_owner;
uint8_t _w_adrs;
uint8_t _r_adrs;
+
+
+ /**********************************************************//**
+ * @brief Write MAX7300 configuration register
+ *
+ * @details
+ *
+ * On Entry:
+ * @param[in] set_clear - If true set bit defined by data
+ *
+ * @param[in] data - 'S' or 'M' bit of configuration register
+ *
+ * On Exit:
+ * @return 0 on success, non-0 on failure
+ **************************************************************/
+ int16_t write_config_register(bool set_clear, uint8_t data);
};
#endif /* MAX7300_H*/
\ No newline at end of file