LibDriver APA102C
Loading...
Searching...
No Matches
driver_apa102c.h
Go to the documentation of this file.
1
36
37#ifndef DRIVER_APA102C_H
38#define DRIVER_APA102C_H
39
40#include <stdint.h>
41#include <stdio.h>
42#include <string.h>
43
44#ifdef __cplusplus
45extern "C" {
46#endif
47
53
58
62typedef struct apa102c_handle_s
63{
64 uint8_t (*spi_init)(void);
65 uint8_t (*spi_deinit)(void);
66 uint8_t (*spi_write_cmd)(uint8_t *buf, uint16_t len);
67 void (*delay_ms)(uint32_t ms);
68 void (*debug_print)(const char *const fmt, ...);
69 uint8_t inited;
71
87
91
98
105#define DRIVER_APA102C_LINK_INIT(HANDLE, STRUCTURE) memset(HANDLE, 0, sizeof(STRUCTURE))
106
113#define DRIVER_APA102C_LINK_SPI_INIT(HANDLE, FUC) (HANDLE)->spi_init = FUC
114
121#define DRIVER_APA102C_LINK_SPI_DEINIT(HANDLE, FUC) (HANDLE)->spi_deinit = FUC
122
129#define DRIVER_APA102C_LINK_SPI_WRITE_COMMAND(HANDLE, FUC) (HANDLE)->spi_write_cmd = FUC
130
137#define DRIVER_APA102C_LINK_DELAY_MS(HANDLE, FUC) (HANDLE)->delay_ms = FUC
138
145#define DRIVER_APA102C_LINK_DEBUG_PRINT(HANDLE, FUC) (HANDLE)->debug_print = FUC
146
150
157
169#define APA102C_COLOR(RED, GREEN, BLUE, BRIGHTNESS) ((uint32_t)(0xE | ((BRIGHTNESS) & 0x1F)) << 24) | \
170 ((uint32_t)((BLUE) & 0xFF) << 16) | \
171 ((uint32_t)((GREEN) & 0xFF) << 8) | \
172 ((uint32_t)((RED) & 0xFF) << 0)
173
182uint8_t apa102c_info(apa102c_info_t *info);
183
194uint8_t apa102c_init(apa102c_handle_t *handle);
195
206uint8_t apa102c_deinit(apa102c_handle_t *handle);
207
225uint8_t apa102c_write(apa102c_handle_t *handle, uint32_t *color, uint32_t len, uint8_t *temp, uint32_t temp_len);
226
242uint8_t apa102c_write_off(apa102c_handle_t *handle, uint32_t len, uint8_t *temp, uint32_t temp_len);
243
247
254
267uint8_t apa102c_set_reg(apa102c_handle_t *handle, uint8_t *buf, uint16_t len);
268
272
276
277#ifdef __cplusplus
278}
279#endif
280
281#endif
uint8_t apa102c_info(apa102c_info_t *info)
get chip's information
uint8_t apa102c_init(apa102c_handle_t *handle)
initialize the chip
uint8_t apa102c_deinit(apa102c_handle_t *handle)
close the chip
uint8_t apa102c_write(apa102c_handle_t *handle, uint32_t *color, uint32_t len, uint8_t *temp, uint32_t temp_len)
write color frame
uint8_t apa102c_write_off(apa102c_handle_t *handle, uint32_t len, uint8_t *temp, uint32_t temp_len)
write off frame
struct apa102c_info_s apa102c_info_t
apa102c information structure definition
struct apa102c_handle_s apa102c_handle_t
apa102c handle structure definition
uint8_t apa102c_set_reg(apa102c_handle_t *handle, uint8_t *buf, uint16_t len)
set the chip register
apa102c handle structure definition
uint8_t(* spi_init)(void)
void(* delay_ms)(uint32_t ms)
void(* debug_print)(const char *const fmt,...)
uint8_t(* spi_deinit)(void)
uint8_t(* spi_write_cmd)(uint8_t *buf, uint16_t len)
apa102c information structure definition
float supply_voltage_max_v
uint32_t driver_version
char manufacturer_name[32]
float supply_voltage_min_v