Lines Matching +full:data +full:- +full:bits

4  * SPDX-License-Identifier: Apache-2.0
13 #include <zephyr/dt-bindings/led/led.h>
48 /** Length in bytes of data packet per TLC5791 device */
51 /** write command for writing control data and GS data to internal registers */
54 /** GS reference clock select bit in FC data (0 = internal oscillator clock, 1 = SCKI clock). */
57 /** GS reference clock edge select bit for OUTXn on-off timing control in FC data */
60 /** Constant-current output enable bit in FC data (0 = output control enabled, 1 = blank). */
63 /** Auto display repeat mode enable bit in FC data (0 = disabled, 1 = enabled). */
66 /** Display timing reset mode enable bit in FC data (0 = disabled, 1 = enabled). */
69 /** Bit mask for write cmd in data byte 27 */
72 /** Bit mask for control bits in data byte 27 */
75 /** Bit mask for control bits in data byte 26 */
78 /** Bit mask for global brightness control for color 1 in data byte 26, upper 5 bits of GBC */
81 /** Bit mask for global brightness control for color 1 in data byte 25, lower 2 bits of GBC */
84 /** Bit mask for global brightness control for color 2 in data byte 25, upper 6 bits of GBC */
87 /** Bit mask for global brightness control for color 2 in data byte 24, lower 1 bits of GBC */
90 /** Bit mask for global brightness control for color 3 in data byte 24, all 7 bits of GBC */
94 * @brief create data byte 27 from control data
96 * @param control_data control bits
97 * @return uint8_t the serialized data byte 27
106 * @brief create data byte 26 from control data and color 1 GBC
108 * @param control_data control bits
110 * @return uint8_t the serialized data byte 26
119 * @brief create data byte 25 from color 1 and 2 GBC
123 * @return uint8_t the serialized data byte 25
132 * @brief create data byte 24 from color 2 and 3 GBC
136 * @return uint8_t the serialized data byte 24
148 * @param pixel_data rgb data to be mapped
157 temp = pixel_data->r; in tlc5971_map_color()
160 temp = pixel_data->g; in tlc5971_map_color()
163 temp = pixel_data->b; in tlc5971_map_color()
174 * @brief serialize control data and pixel data for device daisy chain
180 * @param pixels pixel RGB data for daisy chain
186 const struct tlc5971_config *cfg = dev->config; in tlc5971_fill_data_buffer()
187 struct tlc5971_data *data = dev->data; in tlc5971_fill_data_buffer() local
188 uint8_t *data_buffer = data->data_buffer; in tlc5971_fill_data_buffer()
192 * tlc5971 device order is reversed as the rgb data for the last device in the daisy chain in tlc5971_fill_data_buffer()
195 for (int device = (num_pixels / TLC5971_PIXELS_PER_DEVICE) - 1; device >= 0; device--) { in tlc5971_fill_data_buffer()
201 data_buffer[count++] = tlc5971_data_byte27(data->control_data); in tlc5971_fill_data_buffer()
202 data_buffer[count++] = tlc5971_data_byte26(data->control_data, data->gbc_color_1); in tlc5971_fill_data_buffer()
203 data_buffer[count++] = tlc5971_data_byte25(data->gbc_color_1, data->gbc_color_2); in tlc5971_fill_data_buffer()
204 data_buffer[count++] = tlc5971_data_byte24(data->gbc_color_2, data->gbc_color_3); in tlc5971_fill_data_buffer()
206 for (int pixel = (TLC5971_PIXELS_PER_DEVICE - 1); pixel >= 0; pixel--) { in tlc5971_fill_data_buffer()
207 /* data is "reversed" so RGB0 comes last, i.e at byte 0 */ in tlc5971_fill_data_buffer()
212 * Convert pixel data into SPI frames, mapping user colors to tlc5971 in tlc5971_fill_data_buffer()
213 * data frame color order (BGR). in tlc5971_fill_data_buffer()
215 for (int color = 0; color < cfg->num_colors; color++) { in tlc5971_fill_data_buffer()
217 tlc5971_map_color(cfg->color_mapping[color], pixel_data); in tlc5971_fill_data_buffer()
233 const struct tlc5971_config *cfg = dev->config; in tlc5971_transmit_data()
234 struct tlc5971_data *data = dev->data; in tlc5971_transmit_data() local
237 .buf = data->data_buffer, in tlc5971_transmit_data()
246 return spi_write_dt(&cfg->bus, &tx); in tlc5971_transmit_data()
258 const struct tlc5971_config *cfg = dev->config; in tlc5971_length()
260 return (size_t)cfg->num_pixels; in tlc5971_length()
265 const struct tlc5971_config *cfg = dev->config; in tlc5971_set_global_brightness()
266 struct tlc5971_data *data = dev->data; in tlc5971_set_global_brightness() local
267 int res = -EINVAL; in tlc5971_set_global_brightness()
272 data->gbc_color_1 = tlc5971_map_color(cfg->color_mapping[0], &pixel); in tlc5971_set_global_brightness()
273 data->gbc_color_2 = tlc5971_map_color(cfg->color_mapping[1], &pixel); in tlc5971_set_global_brightness()
274 data->gbc_color_3 = tlc5971_map_color(cfg->color_mapping[2], &pixel); in tlc5971_set_global_brightness()
283 const struct tlc5971_config *cfg = dev->config; in tlc5971_init()
284 struct tlc5971_data *data = dev->data; in tlc5971_init() local
286 if (!spi_is_ready_dt(&cfg->bus)) { in tlc5971_init()
287 LOG_ERR("%s: SPI device %s not ready", dev->name, cfg->bus.bus->name); in tlc5971_init()
288 return -ENODEV; in tlc5971_init()
291 if ((cfg->num_pixels % TLC5971_PIXELS_PER_DEVICE) != 0) { in tlc5971_init()
292 LOG_ERR("%s: chain length must be multiple of 4", dev->name); in tlc5971_init()
293 return -EINVAL; in tlc5971_init()
296 if (cfg->num_colors != TLC5971_NUMBER_OF_COLORS) { in tlc5971_init()
297 LOG_ERR("%s: the tlc5971 only supports %i colors", dev->name, in tlc5971_init()
299 return -EINVAL; in tlc5971_init()
302 for (int i = 0; i < cfg->num_colors; i++) { in tlc5971_init()
303 switch (cfg->color_mapping[i]) { in tlc5971_init()
309 LOG_ERR("%s: invalid color mapping", dev->name); in tlc5971_init()
310 return -EINVAL; in tlc5971_init()
315 * set up sane defaults for control data. in tlc5971_init()
319 data->control_data = TLC5971_BYTE27_CTRL_BIT_OUTTMG | TLC5971_BYTE26_CTRL_BIT_DSPRPT | in tlc5971_init()