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
				
			
		| 
						 | 
				
			
			@ -51,15 +51,15 @@ void aw9523b_init(uint8_t addr)
 | 
			
		|||
    i2c_init();
 | 
			
		||||
    // reset chip
 | 
			
		||||
    uint8_t data = 0;
 | 
			
		||||
    i2c_writeReg(addr, AW9523B_RESET, &data, 1, TIMEOUT);
 | 
			
		||||
    i2c_write_register(addr, AW9523B_RESET, &data, 1, TIMEOUT);
 | 
			
		||||
    wait_ms(1);
 | 
			
		||||
    // set max led current
 | 
			
		||||
    data = 0x03; // 37mA/4
 | 
			
		||||
    i2c_writeReg(addr, AW9523B_CTL, &data, 1, TIMEOUT);
 | 
			
		||||
    i2c_write_register(addr, AW9523B_CTL, &data, 1, TIMEOUT);
 | 
			
		||||
    // set port to led mode
 | 
			
		||||
    data = 0;
 | 
			
		||||
    i2c_writeReg(addr, AW9523B_P0_LED, &data, 1, TIMEOUT);
 | 
			
		||||
    i2c_writeReg(addr, AW9523B_P1_LED, &data, 1, TIMEOUT);
 | 
			
		||||
    i2c_write_register(addr, AW9523B_P0_LED, &data, 1, TIMEOUT);
 | 
			
		||||
    i2c_write_register(addr, AW9523B_P1_LED, &data, 1, TIMEOUT);
 | 
			
		||||
    // clear pwm buff
 | 
			
		||||
    for (uint8_t i = 0; i < 16; i++) {
 | 
			
		||||
        aw9523b_pwm_buf[i] = 0;
 | 
			
		||||
| 
						 | 
				
			
			@ -91,9 +91,9 @@ void aw9523b_update_pwm_buffers(uint8_t addr)
 | 
			
		|||
    if (aw9523b_pwm_dirty) {
 | 
			
		||||
        for (uint8_t i = 0; i < AW9523B_RGB_NUM; i++){
 | 
			
		||||
            aw9523b_led led = g_aw9523b_leds[i];
 | 
			
		||||
            i2c_writeReg(addr, led.r, &aw9523b_pwm_buf[PWM2BUF(led.r)], 1, TIMEOUT);
 | 
			
		||||
            i2c_writeReg(addr, led.g, &aw9523b_pwm_buf[PWM2BUF(led.g)], 1, TIMEOUT);
 | 
			
		||||
            i2c_writeReg(addr, led.b, &aw9523b_pwm_buf[PWM2BUF(led.b)], 1, TIMEOUT);
 | 
			
		||||
            i2c_write_register(addr, led.r, &aw9523b_pwm_buf[PWM2BUF(led.r)], 1, TIMEOUT);
 | 
			
		||||
            i2c_write_register(addr, led.g, &aw9523b_pwm_buf[PWM2BUF(led.g)], 1, TIMEOUT);
 | 
			
		||||
            i2c_write_register(addr, led.b, &aw9523b_pwm_buf[PWM2BUF(led.b)], 1, TIMEOUT);
 | 
			
		||||
        }
 | 
			
		||||
        aw9523b_pwm_dirty = false;
 | 
			
		||||
    }
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -47,13 +47,13 @@ void tca6424_init(void)
 | 
			
		|||
 | 
			
		||||
static void write_port(uint8_t p, uint8_t d)
 | 
			
		||||
{
 | 
			
		||||
    i2c_writeReg(TCA6424_ADDR, p, &d, 1, TIMEOUT);
 | 
			
		||||
    i2c_write_register(TCA6424_ADDR, p, &d, 1, TIMEOUT);
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
static uint8_t read_port(uint8_t port)
 | 
			
		||||
{
 | 
			
		||||
    uint8_t data = 0;
 | 
			
		||||
    i2c_readReg(TCA6424_ADDR, port, &data, 1, TIMEOUT);
 | 
			
		||||
    i2c_read_register(TCA6424_ADDR, port, &data, 1, TIMEOUT);
 | 
			
		||||
    return data;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -45,13 +45,13 @@ void tca6424_init(void)
 | 
			
		|||
 | 
			
		||||
static void write_port(uint8_t p, uint8_t d)
 | 
			
		||||
{
 | 
			
		||||
    i2c_writeReg(TCA6424_ADDR, p, &d, 1, TIMEOUT);
 | 
			
		||||
    i2c_write_register(TCA6424_ADDR, p, &d, 1, TIMEOUT);
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
static uint8_t read_port(uint8_t port)
 | 
			
		||||
{
 | 
			
		||||
    uint8_t data = 0;
 | 
			
		||||
    i2c_readReg(TCA6424_ADDR, port, &data, 1, TIMEOUT);
 | 
			
		||||
    i2c_read_register(TCA6424_ADDR, port, &data, 1, TIMEOUT);
 | 
			
		||||
    return data;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue