staticint st1202_pwm_pattern_write(struct st1202_chip *chip, int led_num, int pattern, unsignedint value)
{
u8 value_l, value_h; int ret;
value_l = (u8)value;
value_h = (u8)(value >> 8);
/* * Datasheet: Register address low = 1Eh + 2*(xh) + 18h*(yh), * where x is the channel number (led number) in hexadecimal (x = 00h .. 0Bh) * and y is the pattern number in hexadecimal (y = 00h .. 07h)
*/
ret = st1202_write_reg(chip, (ST1202_PATTERN_PWM + (led_num * 2) + 0x18 * pattern),
value_l); if (ret != 0) return ret;
/* * Datasheet: Register address high = 1Eh + 01h + 2(xh) +18h*(yh), * where x is the channel number in hexadecimal (x = 00h .. 0Bh) * and y is the pattern number in hexadecimal (y = 00h .. 07h)
*/
ret = st1202_write_reg(chip, (ST1202_PATTERN_PWM + 0x1 + (led_num * 2) + 0x18 * pattern),
value_h); if (ret != 0) return ret;
staticint st1202_setup(struct st1202_chip *chip)
{ int ret;
guard(mutex)(&chip->lock);
/* * Once the supply voltage is applied, the LED1202 executes some internal checks. * Afterwards, it stops the oscillator and puts the internal LDO in quiescent mode. * To start the device, EN bit must be set inside the “Device Enable” register at * address 01h. As soon as EN is set, the LED1202 loads the adjustment parameters * from the internal non-volatile memory and performs an auto-calibration procedure * in order to increase the output current precision. * Such initialization lasts about 6.5 ms.
*/
/* Reset the chip during setup */
ret = st1202_write_reg(chip, ST1202_DEV_ENABLE, ST1202_DEV_ENABLE_RESET); if (ret < 0) return ret;
/* Enable phase-shift delay feature */
ret = st1202_write_reg(chip, ST1202_CONFIG_REG, ST1202_CONFIG_REG_SHFT); if (ret < 0) return ret;
/* Enable the device */
ret = st1202_write_reg(chip, ST1202_DEV_ENABLE, ST1202_DEV_ENABLE_ON); if (ret < 0) return ret;
/* Duration of initialization */
usleep_range(6500, 10000);
/* Deactivate all LEDS (channels) and activate only the ones found in Device Tree */
ret = st1202_write_reg(chip, ST1202_CHAN_ENABLE_LOW, ST1202_CHAN_DISABLE_ALL); if (ret < 0) return ret;
ret = st1202_write_reg(chip, ST1202_CHAN_ENABLE_HIGH, ST1202_CHAN_DISABLE_ALL); if (ret < 0) return ret;
ret = st1202_write_reg(chip, ST1202_CONFIG_REG,
ST1202_CONFIG_REG_PATS | ST1202_CONFIG_REG_PATSR); if (ret < 0) return ret;
ret = devm_led_classdev_register_ext(&client->dev, &led->led_cdev, &init_data); if (ret < 0) return dev_err_probe(&client->dev, ret, "Failed to register LED class device\n");
}
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.