Skip to content

Commit 66f7806

Browse files
author
Sven Hädrich
committed
Fixup
1 parent 3c68548 commit 66f7806

File tree

3 files changed

+48
-52
lines changed

3 files changed

+48
-52
lines changed

drivers/dali/Kconfig

+1-1
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ config DALI
1111

1212
if DALI
1313

14-
config MAX_FRAMES_IN_QUEUE
14+
config DALI_MAX_FRAMES_IN_QUEUE
1515
int "Max frames in DALI recv queue"
1616
default 3
1717
range 1 16

drivers/dali/dali_lpc11u6x.c

+26-28
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55

66
#define DT_DRV_COMPAT nxp_dali
77

8-
#include <zephyr/drivers/dali.h> /* api */
8+
#include <zephyr/drivers/dali.h> /* api */
99
#include <zephyr/drivers/dali/lpc11u6x.h> /* chip register definitions */
1010
#include <zephyr/drivers/dali/std.h> /* constants from DALI standard */
1111

@@ -104,7 +104,7 @@ struct dali_lpc11u6x_data {
104104
struct k_work rx_work;
105105
enum rx_counter_event rx_event;
106106
struct k_msgq rx_queue;
107-
char rx_buffer[CONFIG_MAX_FRAMES_IN_QUEUE * sizeof(struct dali_frame)];
107+
char rx_buffer[CONFIG_DALI_MAX_FRAMES_IN_QUEUE * sizeof(struct dali_frame)];
108108
uint32_t rx_data;
109109
uint32_t rx_timestamp;
110110
uint8_t rx_frame_length;
@@ -1048,7 +1048,7 @@ static int init(const struct device *dev)
10481048

10491049
/* initialize receive queue */
10501050
k_msgq_init(&data->rx_queue, data->rx_buffer, sizeof(struct dali_frame),
1051-
CONFIG_MAX_FRAMES_IN_QUEUE);
1051+
CONFIG_DALI_MAX_FRAMES_IN_QUEUE);
10521052

10531053
/* initialize peripherals */
10541054
mcu_setup_peripheral_clock();
@@ -1143,7 +1143,7 @@ static void dali_lpc11u6x_abort(const struct device *dev)
11431143
tx_slot_reset_all(data);
11441144
}
11451145

1146-
static const struct dali_driver_api dali_lpc11u6x_driver_api = {
1146+
static DEVICE_API(dali, dali_lpc11u6x_driver_api) = {
11471147
.receive = dali_lpc11u6x_receive,
11481148
.send = dali_lpc11u6x_send,
11491149
.abort = dali_lpc11u6x_abort,
@@ -1152,30 +1152,28 @@ static const struct dali_driver_api dali_lpc11u6x_driver_api = {
11521152
/* forward declaration of init */
11531153
static int init_dali_lpc11u6x(const struct device *dev);
11541154

1155-
/* clang-format off */
1156-
#define DALI_LPC11U6X_INST(id) \
1157-
static struct dali_lpc11u6x_data dali_lpc11u6x_data_##id = {0}; \
1158-
static struct dali_lpc11u6x_config dali_lpc11u6x_config_##id = { \
1159-
.tx_rise_fall_delta_us = DT_INST_PROP_OR(id, tx_rise_fall_delta_us, 0), \
1160-
.rx_rise_fall_delta_us = DT_INST_PROP_OR(id, rx_rise_fall_delta_us, 0), \
1161-
.tx_rx_propagation_min_us = DT_INST_PROP_OR(id, tx_rx_propagation_min_us, 1), \
1162-
.tx_rx_propagation_max_us = DT_INST_PROP_OR(id, tx_rx_propagation_max_us, 100), \
1163-
}; \
1164-
DEVICE_DT_INST_DEFINE(id, init_dali_lpc11u6x, NULL, &dali_lpc11u6x_data_##id, \
1165-
&dali_lpc11u6x_config_##id, POST_KERNEL, \
1166-
CONFIG_KERNEL_INIT_PRIORITY_DEVICE, &dali_lpc11u6x_driver_api); \
1167-
static int init_dali_lpc11u6x(const struct device *dev) \
1168-
{ \
1169-
IRQ_CONNECT(DT_IRQ_BY_IDX(DT_DRV_INST(id), 0, irq), \
1170-
DT_IRQ_BY_IDX(DT_DRV_INST(id), 0, priority), tx_IRQHandler, \
1171-
DEVICE_DT_INST_GET(id), 0); \
1172-
irq_enable(DT_IRQ_BY_IDX(DT_DRV_INST(id), 0, irq)); \
1173-
IRQ_CONNECT(DT_IRQ_BY_IDX(DT_DRV_INST(id), 1, irq), \
1174-
DT_IRQ_BY_IDX(DT_DRV_INST(id), 1, priority), dali_rx_IRQHandler, \
1175-
DEVICE_DT_INST_GET(id), 0); \
1176-
irq_enable(DT_IRQ_BY_IDX(DT_DRV_INST(id), 1, irq)); \
1177-
return init(dev); \
1155+
#define DALI_LPC11U6X_INST(id) \
1156+
static struct dali_lpc11u6x_data dali_lpc11u6x_data_##id = {0}; \
1157+
static struct dali_lpc11u6x_config dali_lpc11u6x_config_##id = { \
1158+
.tx_rise_fall_delta_us = DT_INST_PROP_OR(id, tx_rise_fall_delta_us, 0), \
1159+
.rx_rise_fall_delta_us = DT_INST_PROP_OR(id, rx_rise_fall_delta_us, 0), \
1160+
.tx_rx_propagation_min_us = DT_INST_PROP_OR(id, tx_rx_propagation_min_us, 1), \
1161+
.tx_rx_propagation_max_us = DT_INST_PROP_OR(id, tx_rx_propagation_max_us, 100), \
1162+
}; \
1163+
DEVICE_DT_INST_DEFINE(id, init_dali_lpc11u6x, NULL, &dali_lpc11u6x_data_##id, \
1164+
&dali_lpc11u6x_config_##id, POST_KERNEL, \
1165+
CONFIG_KERNEL_INIT_PRIORITY_DEVICE, &dali_lpc11u6x_driver_api); \
1166+
static int init_dali_lpc11u6x(const struct device *dev) \
1167+
{ \
1168+
IRQ_CONNECT(DT_IRQ_BY_IDX(DT_DRV_INST(id), 0, irq), \
1169+
DT_IRQ_BY_IDX(DT_DRV_INST(id), 0, priority), tx_IRQHandler, \
1170+
DEVICE_DT_INST_GET(id), 0); \
1171+
irq_enable(DT_IRQ_BY_IDX(DT_DRV_INST(id), 0, irq)); \
1172+
IRQ_CONNECT(DT_IRQ_BY_IDX(DT_DRV_INST(id), 1, irq), \
1173+
DT_IRQ_BY_IDX(DT_DRV_INST(id), 1, priority), dali_rx_IRQHandler, \
1174+
DEVICE_DT_INST_GET(id), 0); \
1175+
irq_enable(DT_IRQ_BY_IDX(DT_DRV_INST(id), 1, irq)); \
1176+
return init(dev); \
11781177
};
1179-
/* clang-format on */
11801178

11811179
DT_INST_FOREACH_STATUS_OKAY(DALI_LPC11U6X_INST);

drivers/dali/dali_pwm.c

+21-23
Original file line numberDiff line numberDiff line change
@@ -128,7 +128,7 @@ struct dali_pwm_data {
128128
struct pwm_capture_helper capture;
129129
struct pwm_timings_cycles timings;
130130
struct k_msgq frames_queue;
131-
char frames_buffer[CONFIG_MAX_FRAMES_IN_QUEUE * sizeof(struct dali_frame)];
131+
char frames_buffer[CONFIG_DALI_MAX_FRAMES_IN_QUEUE * sizeof(struct dali_frame)];
132132
struct k_sem tx_pwm_sem;
133133
int tx_shift_cyc;
134134
uint32_t bit_time_half_cyc;
@@ -846,7 +846,7 @@ static int dali_pwm_init(const struct device *dev)
846846
LOG_DBG("PWM INIT");
847847

848848
k_msgq_init(&data->frames_queue, data->frames_buffer, sizeof(struct dali_frame),
849-
CONFIG_MAX_FRAMES_IN_QUEUE);
849+
CONFIG_DALI_MAX_FRAMES_IN_QUEUE);
850850

851851
#if defined(CONFIG_DALI_PWM_OWN_THREAD)
852852
ret = k_sem_init(&data->tx_queue_sem, 0, 1);
@@ -929,37 +929,35 @@ static int dali_pwm_init(const struct device *dev)
929929
return 0;
930930
}
931931

932-
static const struct dali_driver_api dali_pwm_driver_api = {
932+
static DEVICE_API(dali, dali_pwm_driver_api) = {
933933
.receive = dali_pwm_recv,
934934
.send = dali_pwm_send,
935935
.abort = dali_pwm_abort,
936936
};
937937

938-
/* clang-format off */
939-
#define DALI_PWM_INST(id) \
940-
BUILD_ASSERT(DT_INST_PROP_OR(id, tx_flank_shift_us, 0) < TX_HALF_BIT_US || \
941-
(DT_INST_PROP_OR(id, tx_flank_shift_us, 0) ^ 0xffffffff) < \
942-
TX_HALF_BIT_US, \
943-
"Edge-shift must be lower than 416us."); \
938+
#define DALI_PWM_INST(id) \
939+
BUILD_ASSERT(DT_INST_PROP_OR(id, tx_flank_shift_us, 0) < TX_HALF_BIT_US || \
940+
(DT_INST_PROP_OR(id, tx_flank_shift_us, 0) ^ 0xffffffff) < \
941+
TX_HALF_BIT_US, \
942+
"Edge-shift must be lower than 416us."); \
944943
static struct dali_pwm_data dali_pwm_data_##id = { \
945-
.backward_frame.signal_length = 0, \
946-
.forward_frame.signal_length = 0, \
947-
.capture.state = PWM_CAPTURE_STATE_IDLE, \
948-
.capture.data = 0, \
949-
.capture.length = 0, \
950-
.frame_finish_work = Z_WORK_DELAYABLE_INITIALIZER(finish_frame_work), \
951-
.no_response_work = Z_WORK_DELAYABLE_INITIALIZER(no_response_work), \
944+
.backward_frame.signal_length = 0, \
945+
.forward_frame.signal_length = 0, \
946+
.capture.state = PWM_CAPTURE_STATE_IDLE, \
947+
.capture.data = 0, \
948+
.capture.length = 0, \
949+
.frame_finish_work = Z_WORK_DELAYABLE_INITIALIZER(finish_frame_work), \
950+
.no_response_work = Z_WORK_DELAYABLE_INITIALIZER(no_response_work), \
952951
}; \
953952
static const struct dali_pwm_config dali_pwm_config_##id = { \
954-
.rx_capture_pwm = PWM_DT_SPEC_INST_GET_BY_IDX(id, 1), \
955-
.tx_pwm = PWM_DT_SPEC_INST_GET_BY_IDX(id, 0), \
956-
.tx_shift_us = DT_INST_PROP_OR(id, tx_flank_shift_us, 0), \
957-
.rx_shift_us = DT_INST_PROP_OR(id, rx_flank_shift_us, 0), \
958-
.tx_rx_propagation_max_us = DT_INST_PROP_OR(id, tx_rx_propagation_max_us, 200), \
953+
.rx_capture_pwm = PWM_DT_SPEC_INST_GET_BY_IDX(id, 1), \
954+
.tx_pwm = PWM_DT_SPEC_INST_GET_BY_IDX(id, 0), \
955+
.tx_shift_us = DT_INST_PROP_OR(id, tx_flank_shift_us, 0), \
956+
.rx_shift_us = DT_INST_PROP_OR(id, rx_flank_shift_us, 0), \
957+
.tx_rx_propagation_max_us = DT_INST_PROP_OR(id, tx_rx_propagation_max_us, 200), \
959958
}; \
960959
DEVICE_DT_INST_DEFINE(id, dali_pwm_init, NULL, &dali_pwm_data_##id, &dali_pwm_config_##id, \
961-
POST_KERNEL, CONFIG_KERNEL_INIT_PRIORITY_DEVICE, \
960+
POST_KERNEL, CONFIG_KERNEL_INIT_PRIORITY_DEVICE, \
962961
&dali_pwm_driver_api);
963-
/* clang-format on */
964962

965963
DT_INST_FOREACH_STATUS_OKAY(DALI_PWM_INST);

0 commit comments

Comments
 (0)