Fix formatting errors
This commit is contained in:
parent
876a801b2c
commit
3d2a5825d6
1 changed files with 146 additions and 161 deletions
|
@ -49,24 +49,21 @@ struct is31fl3743a_data {
|
|||
const struct device *gpio;
|
||||
};
|
||||
|
||||
static int is31fl3743a_reg_write(const struct device *dev, uint8_t addr, uint8_t value)
|
||||
{
|
||||
static int is31fl3743a_reg_write(const struct device *dev, uint8_t addr, uint8_t value) {
|
||||
const struct is31fl3743a_data *data = dev->data;
|
||||
const struct is31fl3743a_config *config = dev->config;
|
||||
|
||||
if (i2c_reg_write_byte(data->i2c, config->reg, addr, value)) {
|
||||
LOG_ERR("Failed writing value %x to register address %x on device %x.", value, addr, config->reg);
|
||||
LOG_ERR("Failed writing value %x to register address %x on device %x.", value, addr,
|
||||
config->reg);
|
||||
return -EIO;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int is31fl3743a_reg_burst_write(const struct device *dev,
|
||||
uint8_t start_addr,
|
||||
const uint8_t *buffer,
|
||||
size_t num_bytes)
|
||||
{
|
||||
static int is31fl3743a_reg_burst_write(const struct device *dev, uint8_t start_addr,
|
||||
const uint8_t *buffer, size_t num_bytes) {
|
||||
const struct is31fl3743a_data *data = dev->data;
|
||||
const struct is31fl3743a_config *config = dev->config;
|
||||
|
||||
|
@ -78,8 +75,7 @@ static int is31fl3743a_reg_burst_write(const struct device *dev,
|
|||
return 0;
|
||||
}
|
||||
|
||||
static int is31fl3743a_set_page(const struct device *dev, uint8_t page_addr)
|
||||
{
|
||||
static int is31fl3743a_set_page(const struct device *dev, uint8_t page_addr) {
|
||||
if (is31fl3743a_reg_write(dev, IS31FL3743A_PSWL, IS31FL3743A_PSWL_ENABLE)) {
|
||||
return -EIO;
|
||||
}
|
||||
|
@ -91,9 +87,7 @@ static int is31fl3743a_set_page(const struct device *dev, uint8_t page_addr)
|
|||
return 0;
|
||||
}
|
||||
|
||||
static inline bool num_pixels_ok(const struct is31fl3743a_config *config,
|
||||
size_t num_pixels)
|
||||
{
|
||||
static inline bool num_pixels_ok(const struct is31fl3743a_config *config, size_t num_pixels) {
|
||||
size_t num_bytes;
|
||||
|
||||
const bool overflow = size_mul_overflow(num_pixels, 3, &num_bytes);
|
||||
|
@ -105,10 +99,8 @@ static inline bool num_pixels_ok(const struct is31fl3743a_config *config,
|
|||
* Updates the RGB LED matrix using cs-order devicetree property
|
||||
* to assign correct R,G,B channels.
|
||||
*/
|
||||
static int is31fl3743a_strip_update_rgb(const struct device *dev,
|
||||
struct led_rgb *pixels,
|
||||
size_t num_pixels)
|
||||
{
|
||||
static int is31fl3743a_strip_update_rgb(const struct device *dev, struct led_rgb *pixels,
|
||||
size_t num_pixels) {
|
||||
const struct is31fl3743a_config *config = dev->config;
|
||||
|
||||
uint8_t *px_buffer = config->px_buffer;
|
||||
|
@ -143,10 +135,8 @@ static int is31fl3743a_strip_update_rgb(const struct device *dev,
|
|||
/**
|
||||
* Updates individual LED channels without an RGB interpretation.
|
||||
*/
|
||||
static int is31fl3743a_strip_update_channels(const struct device *dev,
|
||||
uint8_t *channels,
|
||||
size_t num_channels)
|
||||
{
|
||||
static int is31fl3743a_strip_update_channels(const struct device *dev, uint8_t *channels,
|
||||
size_t num_channels) {
|
||||
const struct is31fl3743a_config *config = dev->config;
|
||||
|
||||
if (config->px_buffer_size < num_channels) {
|
||||
|
@ -164,8 +154,7 @@ static int is31fl3743a_strip_update_channels(const struct device *dev,
|
|||
*
|
||||
* Function and scaling registers are then pre-configured based on devicetree settings.
|
||||
*/
|
||||
int static is31fl3743a_init(const struct device *dev)
|
||||
{
|
||||
int static is31fl3743a_init(const struct device *dev) {
|
||||
struct is31fl3743a_data *data = dev->data;
|
||||
const struct is31fl3743a_config *config = dev->config;
|
||||
|
||||
|
@ -197,7 +186,8 @@ int static is31fl3743a_init(const struct device *dev)
|
|||
}
|
||||
|
||||
is31fl3743a_reg_write(dev, 0x2f, 0xae); // Reset
|
||||
is31fl3743a_reg_write(dev, 0x00, (config->sws << 4) | (0x01 << 3) | 0x01 ); // SWS, H logic, Normal operation
|
||||
is31fl3743a_reg_write(
|
||||
dev, 0x00, (config->sws << 4) | (0x01 << 3) | 0x01); // SWS, H logic, Normal operation
|
||||
is31fl3743a_reg_write(dev, 0x01, config->gcc); // Set GCC
|
||||
is31fl3743a_reg_write(dev, 0x24, 0x08); // Thermal shutoff at 100*C, put into DT
|
||||
is31fl3743a_reg_write(dev, 0x25, (config->sync << 6)); // Set SYNC setting
|
||||
|
@ -210,7 +200,7 @@ int static is31fl3743a_init(const struct device *dev)
|
|||
uint8_t scaling_buffer[config->px_buffer_size];
|
||||
|
||||
for (size_t i = 0; i < config->px_buffer_size; ++i) {
|
||||
scaling_buffer[i] = 0xff;
|
||||
px_buffer[i] = 0xff;
|
||||
}
|
||||
|
||||
is31fl3743a_reg_burst_write(dev, 0x01, scaling_buffer, config->px_buffer_size);
|
||||
|
@ -224,7 +214,7 @@ static const struct led_strip_driver_api is31fl3743a_api = {
|
|||
};
|
||||
|
||||
#define IS31FL3743A_BUFFER_SIZE(idx) \
|
||||
IS31FL3743A_CS_PINS * (IS31FL3743A_SW_PINS - DT_INST_PROP(idx, sw_setting))
|
||||
IS31FL3743A_CS_PINS *(IS31FL3743A_SW_PINS - DT_INST_PROP(idx, sw_setting))
|
||||
|
||||
#define IS31FL3743A_GCC(idx) \
|
||||
(DT_INST_PROP(idx, riset) * DT_INST_PROP(idx, led_max_current) * 256 * 256) / (343 * 255)
|
||||
|
@ -252,13 +242,8 @@ static const struct led_strip_driver_api is31fl3743a_api = {
|
|||
.cs_map = is31fl3743a_##idx##_cs_map, \
|
||||
}; \
|
||||
\
|
||||
DEVICE_AND_API_INIT(is31fl3743a_##idx, \
|
||||
DT_INST_LABEL(idx), \
|
||||
&is31fl3743a_init, \
|
||||
&is31fl3743a_##idx##_data, \
|
||||
&is31fl3743a_##idx##_config, \
|
||||
POST_KERNEL, \
|
||||
CONFIG_LED_STRIP_INIT_PRIORITY, \
|
||||
&is31fl3743a_api); \
|
||||
DEVICE_AND_API_INIT(is31fl3743a_##idx, DT_INST_LABEL(idx), &is31fl3743a_init, \
|
||||
&is31fl3743a_##idx##_data, &is31fl3743a_##idx##_config, POST_KERNEL, \
|
||||
CONFIG_LED_STRIP_INIT_PRIORITY, &is31fl3743a_api);
|
||||
|
||||
DT_INST_FOREACH_STATUS_OKAY(IS31FL3743A_DEVICE);
|
||||
|
|
Loading…
Add table
Reference in a new issue