PCA9533 linux driver

cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

PCA9533 linux driver

579 Views
lidiah
Contributor I

Hi.

i'm working with pca9533 i2c led dimmer. Looking at the linux driver drivers/leds/leds-pca9532.c, i have some doubts about the define of the control register:

/* m =  num_leds*/
#define PCA9532_REG_INPUT(i)	((i) >> 3)
#define PCA9532_REG_OFFSET(m)	((m) >> 4)
#define PCA9532_REG_PSC(m, i)	(PCA9532_REG_OFFSET(m) + 0x1 + (i) * 2)
#define PCA9532_REG_PWM(m, i)	(PCA9532_REG_OFFSET(m) + 0x2 + (i) * 2)
#define LED_REG(m, led)		(PCA9532_REG_OFFSET(m) + 0x5 + (led >> 2))
#define LED_NUM(led)		(led & 0x3)
#define LED_SHIFT(led)		(LED_NUM(led) * 2)
#define LED_MASK(led)		(0x3 << LED_SHIFT(led))

In particular, why is LED_REG defined with the shifts? Shouldn't it be just 0x5 as the datasheet says?

lidiah_0-1630486469514.pnglidiah_1-1630486521943.png

Thank you

0 Kudos
2 Replies

571 Views
TomasVaverka
NXP TechSupport
NXP TechSupport

Hi Lidia,

I am not familiar with this driver, but for the PCA9533 (4-bit I2C-bus LED dimmer), the address of the LS0 - LED selector register is indeed 0x05, so the second byte when writing to or reading from this register has to be 0x05.

Capture.JPG

Capture.JPG

 

Best regards,

Tomas

0 Kudos

567 Views
lidiah
Contributor I

Thank you,

that's why i was asking about the shifts #define LED_REG(m, led) (PCA9532_REG_OFFSET(m) + 0x5 + (led >> 2)).

maybe they have no effects on the writing/reading.

Lidia

0 Kudos