Skip to content
Snippets Groups Projects
Commit bec4be9a authored by Benoit Rat's avatar Benoit Rat
Browse files

libswitchhw: update pca9554 i2c functions

parent 5c48e158
Branches
Tags
No related merge requests found
#include "libshw_i2c.h" #include "libshw_i2c.h"
int wrswhw_pca9554_configure(struct i2c_bus* bus, uint32_t address) int wrswhw_pca9554_configure(struct i2c_bus* bus, uint32_t address,uint8_t value)
{ {
//config initial port dir //config initial port dir
uint8_t config_outputs[2] = {PCA9554_CMD_DIR_REG, WRSWHW_OUTPUT_BITMAP}; uint8_t config_outputs[2] = {PCA9554_CMD_DIR_REG, value};
int result = i2c_transfer(bus, address, sizeof(config_outputs), 0, config_outputs); int result = i2c_transfer(bus, address, sizeof(config_outputs), 0, config_outputs);
if (result < 0) if (result < 0)
return result; return result;
return wrswhw_pca9554_set_output_reg(bus, address, WRSWHW_INITIAL_OUTPUT_STATE);
} }
......
...@@ -20,12 +20,14 @@ ...@@ -20,12 +20,14 @@
#define PCA9554_CMD_POLARITY_REG 2 #define PCA9554_CMD_POLARITY_REG 2
#define PCA9554_CMD_DIR_REG 3 #define PCA9554_CMD_DIR_REG 3
#define I2C_CHIP_PCA9554 1
//output bitmap for each expander (all out) //output bitmap for each expander (all out)
#define WRSWHW_OUTPUT_BITMAP 0 #define WRSWHW_OUTPUT_BITMAP 0
//initial state for outputs //initial state for outputs
#define WRSWHW_INITIAL_OUTPUT_STATE (LINK1_SFP_TX_DISABLE | LINK0_SFP_TX_DISABLE) #define WRSWHW_INITIAL_OUTPUT_STATE (LINK1_SFP_TX_DISABLE | LINK0_SFP_TX_DISABLE)
int wrswhw_pca9554_configure(struct i2c_bus* bus, uint32_t address); int wrswhw_pca9554_configure(struct i2c_bus* bus, uint32_t address,uint8_t value);
int wrswhw_pca9554_set_output_reg(struct i2c_bus* bus, uint32_t address, uint8_t value); int wrswhw_pca9554_set_output_reg(struct i2c_bus* bus, uint32_t address, uint8_t value);
int wrswhw_pca9554_get_input(struct i2c_bus* bus, uint32_t address); int wrswhw_pca9554_get_input(struct i2c_bus* bus, uint32_t address);
......
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment