i2c: rename read/write register functions (#22905)
This commit is contained in:
		
							parent
							
								
									e1f59a6efc
								
							
						
					
					
						commit
						a522b1f156
					
				
					 44 changed files with 184 additions and 170 deletions
				
			
		| 
						 | 
				
			
			@ -33,13 +33,13 @@ bool mcp23018_set_config(uint8_t slave_addr, mcp23018_port_t port, uint8_t conf)
 | 
			
		|||
    uint8_t cmdDirection = port ? CMD_IODIRB : CMD_IODIRA;
 | 
			
		||||
    uint8_t cmdPullup    = port ? CMD_GPPUB : CMD_GPPUA;
 | 
			
		||||
 | 
			
		||||
    i2c_status_t ret = i2c_writeReg(addr, cmdDirection, &conf, sizeof(conf), TIMEOUT);
 | 
			
		||||
    i2c_status_t ret = i2c_write_register(addr, cmdDirection, &conf, sizeof(conf), TIMEOUT);
 | 
			
		||||
    if (ret != I2C_STATUS_SUCCESS) {
 | 
			
		||||
        dprintf("mcp23018_set_config::directionFAILED::%u\n", ret);
 | 
			
		||||
        return false;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    ret = i2c_writeReg(addr, cmdPullup, &conf, sizeof(conf), TIMEOUT);
 | 
			
		||||
    ret = i2c_write_register(addr, cmdPullup, &conf, sizeof(conf), TIMEOUT);
 | 
			
		||||
    if (ret != I2C_STATUS_SUCCESS) {
 | 
			
		||||
        dprintf("mcp23018_set_config::pullupFAILED::%u\n", ret);
 | 
			
		||||
        return false;
 | 
			
		||||
| 
						 | 
				
			
			@ -52,7 +52,7 @@ bool mcp23018_set_output(uint8_t slave_addr, mcp23018_port_t port, uint8_t conf)
 | 
			
		|||
    uint8_t addr = SLAVE_TO_ADDR(slave_addr);
 | 
			
		||||
    uint8_t cmd  = port ? CMD_GPIOB : CMD_GPIOA;
 | 
			
		||||
 | 
			
		||||
    i2c_status_t ret = i2c_writeReg(addr, cmd, &conf, sizeof(conf), TIMEOUT);
 | 
			
		||||
    i2c_status_t ret = i2c_write_register(addr, cmd, &conf, sizeof(conf), TIMEOUT);
 | 
			
		||||
    if (ret != I2C_STATUS_SUCCESS) {
 | 
			
		||||
        dprintf("mcp23018_set_output::FAILED::%u\n", ret);
 | 
			
		||||
        return false;
 | 
			
		||||
| 
						 | 
				
			
			@ -65,7 +65,7 @@ bool mcp23018_set_output_all(uint8_t slave_addr, uint8_t confA, uint8_t confB) {
 | 
			
		|||
    uint8_t addr    = SLAVE_TO_ADDR(slave_addr);
 | 
			
		||||
    uint8_t conf[2] = {confA, confB};
 | 
			
		||||
 | 
			
		||||
    i2c_status_t ret = i2c_writeReg(addr, CMD_GPIOA, &conf[0], sizeof(conf), TIMEOUT);
 | 
			
		||||
    i2c_status_t ret = i2c_write_register(addr, CMD_GPIOA, &conf[0], sizeof(conf), TIMEOUT);
 | 
			
		||||
    if (ret != I2C_STATUS_SUCCESS) {
 | 
			
		||||
        dprintf("mcp23018_set_output::FAILED::%u\n", ret);
 | 
			
		||||
        return false;
 | 
			
		||||
| 
						 | 
				
			
			@ -78,7 +78,7 @@ bool mcp23018_readPins(uint8_t slave_addr, mcp23018_port_t port, uint8_t* out) {
 | 
			
		|||
    uint8_t addr = SLAVE_TO_ADDR(slave_addr);
 | 
			
		||||
    uint8_t cmd  = port ? CMD_GPIOB : CMD_GPIOA;
 | 
			
		||||
 | 
			
		||||
    i2c_status_t ret = i2c_readReg(addr, cmd, out, sizeof(uint8_t), TIMEOUT);
 | 
			
		||||
    i2c_status_t ret = i2c_read_register(addr, cmd, out, sizeof(uint8_t), TIMEOUT);
 | 
			
		||||
    if (ret != I2C_STATUS_SUCCESS) {
 | 
			
		||||
        dprintf("mcp23018_readPins::FAILED::%u\n", ret);
 | 
			
		||||
        return false;
 | 
			
		||||
| 
						 | 
				
			
			@ -97,7 +97,7 @@ bool mcp23018_readPins_all(uint8_t slave_addr, uint16_t* out) {
 | 
			
		|||
 | 
			
		||||
    data16 data = {.u16 = 0};
 | 
			
		||||
 | 
			
		||||
    i2c_status_t ret = i2c_readReg(addr, CMD_GPIOA, &data.u8[0], sizeof(data), TIMEOUT);
 | 
			
		||||
    i2c_status_t ret = i2c_read_register(addr, CMD_GPIOA, &data.u8[0], sizeof(data), TIMEOUT);
 | 
			
		||||
    if (ret != I2C_STATUS_SUCCESS) {
 | 
			
		||||
        dprintf("mcp23018_readPins::FAILED::%u\n", ret);
 | 
			
		||||
        return false;
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -66,7 +66,7 @@ bool pca9505_set_config(uint8_t slave_addr, pca9505_port_t port, uint8_t conf) {
 | 
			
		|||
            break;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    i2c_status_t ret = i2c_writeReg(addr, cmd, &conf, sizeof(conf), TIMEOUT);
 | 
			
		||||
    i2c_status_t ret = i2c_write_register(addr, cmd, &conf, sizeof(conf), TIMEOUT);
 | 
			
		||||
    if (ret != I2C_STATUS_SUCCESS) {
 | 
			
		||||
        print("pca9505_set_config::FAILED\n");
 | 
			
		||||
        return false;
 | 
			
		||||
| 
						 | 
				
			
			@ -96,7 +96,7 @@ bool pca9505_set_polarity(uint8_t slave_addr, pca9505_port_t port, uint8_t conf)
 | 
			
		|||
            break;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    i2c_status_t ret = i2c_writeReg(addr, cmd, &conf, sizeof(conf), TIMEOUT);
 | 
			
		||||
    i2c_status_t ret = i2c_write_register(addr, cmd, &conf, sizeof(conf), TIMEOUT);
 | 
			
		||||
    if (ret != I2C_STATUS_SUCCESS) {
 | 
			
		||||
        print("pca9505_set_polarity::FAILED\n");
 | 
			
		||||
        return false;
 | 
			
		||||
| 
						 | 
				
			
			@ -126,7 +126,7 @@ bool pca9505_set_output(uint8_t slave_addr, pca9505_port_t port, uint8_t conf) {
 | 
			
		|||
            break;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    i2c_status_t ret = i2c_writeReg(addr, cmd, &conf, sizeof(conf), TIMEOUT);
 | 
			
		||||
    i2c_status_t ret = i2c_write_register(addr, cmd, &conf, sizeof(conf), TIMEOUT);
 | 
			
		||||
    if (ret != I2C_STATUS_SUCCESS) {
 | 
			
		||||
        print("pca9505_set_output::FAILED\n");
 | 
			
		||||
        return false;
 | 
			
		||||
| 
						 | 
				
			
			@ -156,7 +156,7 @@ bool pca9505_readPins(uint8_t slave_addr, pca9505_port_t port, uint8_t* out) {
 | 
			
		|||
            break;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    i2c_status_t ret = i2c_readReg(addr, cmd, out, sizeof(uint8_t), TIMEOUT);
 | 
			
		||||
    i2c_status_t ret = i2c_read_register(addr, cmd, out, sizeof(uint8_t), TIMEOUT);
 | 
			
		||||
    if (ret != I2C_STATUS_SUCCESS) {
 | 
			
		||||
        print("pca9505_readPins::FAILED\n");
 | 
			
		||||
        return false;
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -37,7 +37,7 @@ bool pca9555_set_config(uint8_t slave_addr, pca9555_port_t port, uint8_t conf) {
 | 
			
		|||
    uint8_t addr = SLAVE_TO_ADDR(slave_addr);
 | 
			
		||||
    uint8_t cmd  = port ? CMD_CONFIG_1 : CMD_CONFIG_0;
 | 
			
		||||
 | 
			
		||||
    i2c_status_t ret = i2c_writeReg(addr, cmd, &conf, sizeof(conf), TIMEOUT);
 | 
			
		||||
    i2c_status_t ret = i2c_write_register(addr, cmd, &conf, sizeof(conf), TIMEOUT);
 | 
			
		||||
    if (ret != I2C_STATUS_SUCCESS) {
 | 
			
		||||
        print("pca9555_set_config::FAILED\n");
 | 
			
		||||
        return false;
 | 
			
		||||
| 
						 | 
				
			
			@ -50,7 +50,7 @@ bool pca9555_set_output(uint8_t slave_addr, pca9555_port_t port, uint8_t conf) {
 | 
			
		|||
    uint8_t addr = SLAVE_TO_ADDR(slave_addr);
 | 
			
		||||
    uint8_t cmd  = port ? CMD_OUTPUT_1 : CMD_OUTPUT_0;
 | 
			
		||||
 | 
			
		||||
    i2c_status_t ret = i2c_writeReg(addr, cmd, &conf, sizeof(conf), TIMEOUT);
 | 
			
		||||
    i2c_status_t ret = i2c_write_register(addr, cmd, &conf, sizeof(conf), TIMEOUT);
 | 
			
		||||
    if (ret != I2C_STATUS_SUCCESS) {
 | 
			
		||||
        print("pca9555_set_output::FAILED\n");
 | 
			
		||||
        return false;
 | 
			
		||||
| 
						 | 
				
			
			@ -63,7 +63,7 @@ bool pca9555_set_output_all(uint8_t slave_addr, uint8_t confA, uint8_t confB) {
 | 
			
		|||
    uint8_t addr    = SLAVE_TO_ADDR(slave_addr);
 | 
			
		||||
    uint8_t conf[2] = {confA, confB};
 | 
			
		||||
 | 
			
		||||
    i2c_status_t ret = i2c_writeReg(addr, CMD_OUTPUT_0, &conf[0], sizeof(conf), TIMEOUT);
 | 
			
		||||
    i2c_status_t ret = i2c_write_register(addr, CMD_OUTPUT_0, &conf[0], sizeof(conf), TIMEOUT);
 | 
			
		||||
    if (ret != I2C_STATUS_SUCCESS) {
 | 
			
		||||
        dprintf("pca9555_set_output::FAILED::%u\n", ret);
 | 
			
		||||
        return false;
 | 
			
		||||
| 
						 | 
				
			
			@ -76,7 +76,7 @@ bool pca9555_readPins(uint8_t slave_addr, pca9555_port_t port, uint8_t* out) {
 | 
			
		|||
    uint8_t addr = SLAVE_TO_ADDR(slave_addr);
 | 
			
		||||
    uint8_t cmd  = port ? CMD_INPUT_1 : CMD_INPUT_0;
 | 
			
		||||
 | 
			
		||||
    i2c_status_t ret = i2c_readReg(addr, cmd, out, sizeof(uint8_t), TIMEOUT);
 | 
			
		||||
    i2c_status_t ret = i2c_read_register(addr, cmd, out, sizeof(uint8_t), TIMEOUT);
 | 
			
		||||
    if (ret != I2C_STATUS_SUCCESS) {
 | 
			
		||||
        print("pca9555_readPins::FAILED\n");
 | 
			
		||||
        return false;
 | 
			
		||||
| 
						 | 
				
			
			@ -95,7 +95,7 @@ bool pca9555_readPins_all(uint8_t slave_addr, uint16_t* out) {
 | 
			
		|||
 | 
			
		||||
    data16 data = {.u16 = 0};
 | 
			
		||||
 | 
			
		||||
    i2c_status_t ret = i2c_readReg(addr, CMD_INPUT_0, &data.u8[0], sizeof(data), TIMEOUT);
 | 
			
		||||
    i2c_status_t ret = i2c_read_register(addr, CMD_INPUT_0, &data.u8[0], sizeof(data), TIMEOUT);
 | 
			
		||||
    if (ret != I2C_STATUS_SUCCESS) {
 | 
			
		||||
        print("pca9555_readPins_all::FAILED\n");
 | 
			
		||||
        return false;
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue