diff --git a/main/DS4432U.c b/main/DS4432U.c index 23232f048..8432e57c1 100644 --- a/main/DS4432U.c +++ b/main/DS4432U.c @@ -3,13 +3,7 @@ #include "esp_log.h" #include "driver/i2c.h" -#define I2C_MASTER_SCL_IO 48 /*!< GPIO number used for I2C master clock */ -#define I2C_MASTER_SDA_IO 47 /*!< GPIO number used for I2C master data */ -#define I2C_MASTER_NUM 0 /*!< I2C master i2c port number, the number of i2c peripheral interfaces available will depend on the chip */ -#define I2C_MASTER_FREQ_HZ 400000 /*!< I2C master clock frequency */ -#define I2C_MASTER_TX_BUF_DISABLE 0 /*!< I2C master doesn't need buffer */ -#define I2C_MASTER_RX_BUF_DISABLE 0 /*!< I2C master doesn't need buffer */ -#define I2C_MASTER_TIMEOUT_MS 1000 +#include "DS4432U.h" // DS4432U+ -- Adjustable current DAC for use with the TPS40305 voltage regulator // address: 0x90 @@ -142,4 +136,4 @@ bool DS4432U_set_vcore(float core_voltage) DS4432U_set(reg_setting); /// eek! return true; -} \ No newline at end of file +} diff --git a/main/DS4432U.h b/main/DS4432U.h index 668ed3dda..4f682b451 100644 --- a/main/DS4432U.h +++ b/main/DS4432U.h @@ -3,10 +3,12 @@ #include "driver/i2c.h" +#include "i2c_params.h" + esp_err_t i2c_master_init(void); esp_err_t i2c_master_delete(void); void DS4432U_read(void); bool DS4432U_test(void); bool DS4432U_set_vcore(float); -#endif /* DS4432U_H_ */ \ No newline at end of file +#endif /* DS4432U_H_ */ diff --git a/main/EMC2101.c b/main/EMC2101.c index 3aabf99c7..620d0529f 100644 --- a/main/EMC2101.c +++ b/main/EMC2101.c @@ -4,15 +4,6 @@ #include "EMC2101.h" -#define I2C_MASTER_SCL_IO 48 /*!< GPIO number used for I2C master clock */ -#define I2C_MASTER_SDA_IO 47 /*!< GPIO number used for I2C master data */ -#define I2C_MASTER_NUM \ - 0 /*!< I2C master i2c port number, the number of i2c peripheral interfaces available will depend on the chip */ -#define I2C_MASTER_FREQ_HZ 400000 /*!< I2C master clock frequency */ -#define I2C_MASTER_TX_BUF_DISABLE 0 /*!< I2C master doesn't need buffer */ -#define I2C_MASTER_RX_BUF_DISABLE 0 /*!< I2C master doesn't need buffer */ -#define I2C_MASTER_TIMEOUT_MS 1000 - // static const char *TAG = "EMC2101.c"; /** diff --git a/main/EMC2101.h b/main/EMC2101.h index bc9623513..c15b855e1 100644 --- a/main/EMC2101.h +++ b/main/EMC2101.h @@ -1,6 +1,8 @@ #ifndef EMC2101_H_ #define EMC2101_H_ +#include "i2c_params.h" + #define EMC2101_I2CADDR_DEFAULT 0x4C ///< EMC2101 default i2c address #define EMC2101_CHIP_ID 0x16 ///< EMC2101 default device id from part id #define EMC2101_ALT_CHIP_ID 0x28 ///< EMC2101 alternate device id from part id @@ -87,4 +89,4 @@ uint16_t EMC2101_get_fan_speed(void); void EMC2101_init(bool); float EMC2101_get_external_temp(void); uint8_t EMC2101_get_internal_temp(void); -#endif /* EMC2101_H_ */ \ No newline at end of file +#endif /* EMC2101_H_ */ diff --git a/main/INA260.c b/main/INA260.c index 68d223268..22bd4ddfb 100644 --- a/main/INA260.c +++ b/main/INA260.c @@ -4,14 +4,6 @@ #include "INA260.h" -#define I2C_MASTER_SCL_IO 48 /*!< GPIO number used for I2C master clock */ -#define I2C_MASTER_SDA_IO 47 /*!< GPIO number used for I2C master data */ -#define I2C_MASTER_NUM 0 /*!< I2C master i2c port number, the number of i2c peripheral interfaces available will depend on the chip */ -#define I2C_MASTER_FREQ_HZ 400000 /*!< I2C master clock frequency */ -#define I2C_MASTER_TX_BUF_DISABLE 0 /*!< I2C master doesn't need buffer */ -#define I2C_MASTER_RX_BUF_DISABLE 0 /*!< I2C master doesn't need buffer */ -#define I2C_MASTER_TIMEOUT_MS 1000 - // static const char *TAG = "INA260.c"; /** @@ -67,4 +59,4 @@ float INA260_read_power(void) // ESP_LOGI(TAG, "Raw Power = %02X %02X", data[1], data[0]); return (data[1] | (data[0] << 8)) * 10; -} \ No newline at end of file +} diff --git a/main/INA260.h b/main/INA260.h index 574164d3c..45cba1d9e 100644 --- a/main/INA260.h +++ b/main/INA260.h @@ -1,6 +1,8 @@ #ifndef INA260_H_ #define INA260_H_ +#include "i2c_params.h" + #define INA260_I2CADDR_DEFAULT 0x40 ///< INA260 default i2c address #define INA260_REG_CONFIG 0x00 ///< Configuration register #define INA260_REG_CURRENT 0x01 ///< Current measurement register (signed) in mA @@ -107,4 +109,4 @@ float INA260_read_current(void); float INA260_read_voltage(void); float INA260_read_power(void); -#endif /* INA260_H_ */ \ No newline at end of file +#endif /* INA260_H_ */ diff --git a/main/i2c_params.h b/main/i2c_params.h new file mode 100644 index 000000000..3237213c7 --- /dev/null +++ b/main/i2c_params.h @@ -0,0 +1,12 @@ +#ifndef I2C_PARAMS_H_ +#define I2C_PARAMS_H_ + +#define I2C_MASTER_SCL_IO 48 /*!< GPIO number used for I2C master clock */ +#define I2C_MASTER_SDA_IO 47 /*!< GPIO number used for I2C master data */ +#define I2C_MASTER_NUM 0 /*!< I2C master i2c port number, the number of i2c peripheral interfaces available will depend on the chip */ +#define I2C_MASTER_FREQ_HZ 400000 /*!< I2C master clock frequency */ +#define I2C_MASTER_TX_BUF_DISABLE 0 /*!< I2C master doesn't need buffer */ +#define I2C_MASTER_RX_BUF_DISABLE 0 /*!< I2C master doesn't need buffer */ +#define I2C_MASTER_TIMEOUT_MS 1000 + +#endif /* I2C_PARAMS_H_ */