Skip to content

Commit b4d87d2

Browse files
committed
Drivers: ADC_gecko formatting issues
Took care of a bunch of formatting issues. These should be cleared up now. Signed-off-by: Kim Mansfield <[email protected]>
1 parent 39084bf commit b4d87d2

File tree

2 files changed

+100
-104
lines changed

2 files changed

+100
-104
lines changed

drivers/adc/adc_gecko.c

Lines changed: 99 additions & 99 deletions
Original file line numberDiff line numberDiff line change
@@ -50,23 +50,23 @@ static int get_resolution(uint8_t resolution)
5050
{
5151

5252
switch (resolution) {
53-
case 12:
54-
return adcRes12Bit;
55-
case 8:
56-
return adcRes8Bit;
57-
case 6:
58-
return adcRes6Bit;
59-
case 0:
60-
return adcResOVS;
61-
default:
62-
LOG_ERR("ADC resolution value %d is not valid", resolution);
63-
return -EINVAL;
53+
case 12:
54+
return adcRes12Bit;
55+
case 8:
56+
return adcRes8Bit;
57+
case 6:
58+
return adcRes6Bit;
59+
case 0:
60+
return adcResOVS;
61+
default:
62+
LOG_ERR("ADC resolution value %d is not valid", resolution);
63+
return -EINVAL;
6464
}
6565
}
6666

6767
static inline void adc_start_once(const struct device *dev)
6868
{
69-
struct adc_gecko_config *config = (struct adc_gecko_config *)dev->config;
69+
struct adc_gecko_config *config = (struct adc_gecko_config *)dev->config;
7070
ADC_TypeDef *adc_reg = (ADC_TypeDef *)config->base;
7171

7272
/* Start ADC conversion */
@@ -95,7 +95,7 @@ static int adc_get_channel_num(uint8_t id) {
9595

9696
static void adc_select_input(const struct device *dev, uint16_t channel_input)
9797
{
98-
struct adc_gecko_config *config = (struct adc_gecko_config *)dev->config;
98+
struct adc_gecko_config *config = (struct adc_gecko_config *)dev->config;
9999
struct adc_gecko_data *data = dev->data;
100100

101101
config->initSingle_bv.resolution = get_resolution(data->resolution);
@@ -108,33 +108,33 @@ static void adc_select_input(const struct device *dev, uint16_t channel_input)
108108
static void adc_gecko_irq_handler(const struct device *dev)
109109
{
110110
struct adc_gecko_data *data = dev->data;
111-
struct adc_gecko_config *config = (struct adc_gecko_config *)dev->config;
111+
struct adc_gecko_config *config = (struct adc_gecko_config *)dev->config;
112112
uint16_t result;
113113
uint8_t ainsel;
114114

115-
uint32_t flags = ADC_IntGet(ADC0); // get all interrupt flags
116-
if(flags & ADC_IF_SINGLE) {
117-
ADC_IntClear(config->base, flags);
115+
uint32_t flags = ADC_IntGet(ADC0); // get all interrupt flags
116+
if(flags & ADC_IF_SINGLE) {
117+
ADC_IntClear(config->base, flags);
118118

119-
/* Fetch result */
120-
result = adc_get_result(dev);
121-
ainsel = find_lsb_set(data->channels) - 1;
119+
/* Fetch result */
120+
result = adc_get_result(dev);
121+
ainsel = find_lsb_set(data->channels) - 1;
122122

123-
/* Copy to buffer and mark this channel as completed to channels bitmap. */
124-
*data->buf++ = result;
125-
data->channels &= ~(BIT(ainsel));
123+
/* Copy to buffer and mark this channel as completed to channels bitmap. */
124+
*data->buf++ = result;
125+
data->channels &= ~(BIT(ainsel));
126126

127-
/* Notify result if all data gathered. */
128-
if (data->channels == 0) {
129-
adc_context_on_sampling_done(&data->ctx, dev);
130-
return;
131-
}
127+
/* Notify result if all data gathered. */
128+
if (data->channels == 0) {
129+
adc_context_on_sampling_done(&data->ctx, dev);
130+
return;
131+
}
132132

133-
/* Kick next channel conversion */
134-
ainsel = (uint8_t)(find_lsb_set(data->channels) - 1);
133+
/* Kick next channel conversion */
134+
ainsel = (uint8_t)(find_lsb_set(data->channels) - 1);
135135
adc_select_input(dev,ainsel);
136-
adc_start_once(dev);
137-
}
136+
adc_start_once(dev);
137+
}
138138

139139
}
140140

@@ -143,21 +143,21 @@ static int get_reference_voltage(int reference)
143143
int ref;
144144

145145
switch (reference) {
146-
case ADC_REF_INTERNAL:
147-
ref = adcRef2V5;
148-
break;
149-
case ADC_REF_VDD_1:
150-
ref = adcRefVDD;
151-
break;
152-
case ADC_REF_VDD_1_2:
153-
ref = adcRef2V5;
154-
break;
155-
case ADC_REF_VDD_1_4:
156-
ref = adcRef1V25;
157-
break;
158-
default:
159-
ref = -1;
160-
break;
146+
case ADC_REF_INTERNAL:
147+
ref = adcRef2V5;
148+
break;
149+
case ADC_REF_VDD_1:
150+
ref = adcRefVDD;
151+
break;
152+
case ADC_REF_VDD_1_2:
153+
ref = adcRef2V5;
154+
break;
155+
case ADC_REF_VDD_1_4:
156+
ref = adcRef1V25;
157+
break;
158+
default:
159+
ref = -1;
160+
break;
161161
}
162162
return ref;
163163
}
@@ -168,42 +168,42 @@ static int get_acquisition_time(uint16_t acq)
168168

169169
/* Check acquisition time */
170170
switch (acq) {
171-
case ADC_ACQ_TIME(ADC_ACQ_TIME_TICKS, 1):
172-
sample_cycl = adcAcqTime1;
173-
break;
174-
case ADC_ACQ_TIME(ADC_ACQ_TIME_TICKS, 2):
175-
sample_cycl = adcAcqTime2;
176-
break;
177-
case ADC_ACQ_TIME(ADC_ACQ_TIME_TICKS, 4):
178-
sample_cycl = adcAcqTime4;
179-
break;
180-
case ADC_ACQ_TIME(ADC_ACQ_TIME_TICKS, 8):
181-
sample_cycl = adcAcqTime8;
182-
break;
183-
case ADC_ACQ_TIME(ADC_ACQ_TIME_TICKS, 16):
184-
sample_cycl = adcAcqTime16;
185-
break;
186-
case ADC_ACQ_TIME(ADC_ACQ_TIME_TICKS, 32):
187-
sample_cycl = adcAcqTime32;
188-
break;
189-
case ADC_ACQ_TIME(ADC_ACQ_TIME_TICKS, 64):
190-
sample_cycl = adcAcqTime64;
191-
break;
192-
case ADC_ACQ_TIME(ADC_ACQ_TIME_TICKS, 128):
193-
sample_cycl = adcAcqTime128;
194-
break;
195-
case ADC_ACQ_TIME(ADC_ACQ_TIME_TICKS, 256):
196-
sample_cycl = adcAcqTime256;
197-
break;
198-
default:
199-
sample_cycl = 0;
200-
break;
171+
case ADC_ACQ_TIME(ADC_ACQ_TIME_TICKS, 1):
172+
sample_cycl = adcAcqTime1;
173+
break;
174+
case ADC_ACQ_TIME(ADC_ACQ_TIME_TICKS, 2):
175+
sample_cycl = adcAcqTime2;
176+
break;
177+
case ADC_ACQ_TIME(ADC_ACQ_TIME_TICKS, 4):
178+
sample_cycl = adcAcqTime4;
179+
break;
180+
case ADC_ACQ_TIME(ADC_ACQ_TIME_TICKS, 8):
181+
sample_cycl = adcAcqTime8;
182+
break;
183+
case ADC_ACQ_TIME(ADC_ACQ_TIME_TICKS, 16):
184+
sample_cycl = adcAcqTime16;
185+
break;
186+
case ADC_ACQ_TIME(ADC_ACQ_TIME_TICKS, 32):
187+
sample_cycl = adcAcqTime32;
188+
break;
189+
case ADC_ACQ_TIME(ADC_ACQ_TIME_TICKS, 64):
190+
sample_cycl = adcAcqTime64;
191+
break;
192+
case ADC_ACQ_TIME(ADC_ACQ_TIME_TICKS, 128):
193+
sample_cycl = adcAcqTime128;
194+
break;
195+
case ADC_ACQ_TIME(ADC_ACQ_TIME_TICKS, 256):
196+
sample_cycl = adcAcqTime256;
197+
break;
198+
default:
199+
sample_cycl = 0;
200+
break;
201201
}
202202
return sample_cycl;
203203
}
204204

205205
static int adc_gecko_check_buffer_size(const struct device *dev,
206-
const struct adc_sequence *sequence)
206+
const struct adc_sequence *sequence)
207207
{
208208
const struct adc_gecko_config *config = dev->config;
209209
uint8_t channels = 0;
@@ -232,7 +232,7 @@ static int adc_gecko_check_buffer_size(const struct device *dev,
232232
static void adc_context_start_sampling(struct adc_context *ctx)
233233
{
234234
struct adc_gecko_data *data = CONTAINER_OF(ctx, struct adc_gecko_data,
235-
ctx);
235+
ctx);
236236

237237
data->channels = ctx->sequence.channels;
238238
data->repeat_buf = data->buf;
@@ -243,18 +243,18 @@ static void adc_context_start_sampling(struct adc_context *ctx)
243243
}
244244

245245
static void adc_context_update_buffer_pointer(struct adc_context *ctx,
246-
bool repeat_sampling)
246+
bool repeat_sampling)
247247
{
248248
struct adc_gecko_data *data = CONTAINER_OF(ctx, struct adc_gecko_data,
249-
ctx);
249+
ctx);
250250

251251
if (repeat_sampling) {
252252
data->buf = data->repeat_buf;
253253
}
254254
}
255255

256256
static int adc_gecko_channel_setup(const struct device *dev,
257-
const struct adc_channel_cfg *channel_cfg)
257+
const struct adc_channel_cfg *channel_cfg)
258258
{
259259
struct adc_gecko_config *config = (struct adc_gecko_config *)dev->config;
260260
if (channel_cfg->channel_id >= config->num_channels) {
@@ -275,21 +275,21 @@ static int adc_gecko_channel_setup(const struct device *dev,
275275
}
276276

277277
static int adc_gecko_start_read(const struct device *dev,
278-
const struct adc_sequence *sequence)
278+
const struct adc_sequence *sequence)
279279
{
280280
const struct adc_gecko_config *config = dev->config;
281281
struct adc_gecko_data *data = dev->data;
282282
int err;
283283

284284
if (sequence->resolution > ADC_GECKO_MAX_RESOLUTION ||
285-
sequence->resolution == 0) {
285+
sequence->resolution == 0) {
286286
LOG_ERR("unsupported resolution %d", sequence->resolution);
287287
return -ENOTSUP;
288288
}
289289

290290
if (find_msb_set(sequence->channels) > config->num_channels) {
291291
LOG_ERR("unsupported channels in mask: 0x%08x",
292-
sequence->channels);
292+
sequence->channels);
293293
return -ENOTSUP;
294294
}
295295

@@ -306,8 +306,8 @@ static int adc_gecko_start_read(const struct device *dev,
306306
}
307307

308308
static int adc_gecko_read_async(const struct device *dev,
309-
const struct adc_sequence *sequence,
310-
struct k_poll_signal *async)
309+
const struct adc_sequence *sequence,
310+
struct k_poll_signal *async)
311311
{
312312
struct adc_gecko_data *data = dev->data;
313313
int err;
@@ -320,14 +320,14 @@ static int adc_gecko_read_async(const struct device *dev,
320320
}
321321

322322
static int adc_gecko_read(const struct device *dev,
323-
const struct adc_sequence *sequence)
323+
const struct adc_sequence *sequence)
324324
{
325325
return adc_gecko_read_async(dev, sequence, NULL);
326326
}
327327

328328
#ifdef CONFIG_ADC_ASYNC
329329
static int adc_gecko_read_async(const struct device *dev, const struct adc_sequence *sequence,
330-
struct k_poll_signal *async)
330+
struct k_poll_signal *async)
331331
{
332332
return -ENOTSUP;
333333
}
@@ -363,11 +363,11 @@ static int adc_gecko_init(const struct device *dev)
363363

364364
#define IRQ_CONFIGURE_FUNC(idx) \
365365
static void adc_gecko_configure_func_##idx(void) \
366-
{ \
367-
IRQ_CONNECT(ADC0_IRQn, 0, \
368-
adc_gecko_irq_handler, DEVICE_DT_INST_GET(idx), 0); \
369-
irq_enable(ADC0_IRQn); \
370-
}
366+
{ \
367+
IRQ_CONNECT(ADC0_IRQn, 0, \
368+
adc_gecko_irq_handler, DEVICE_DT_INST_GET(idx), 0); \
369+
irq_enable(ADC0_IRQn); \
370+
}
371371

372372
#define IRQ_CONFIGURE_DEFINE(idx) .irq_configure = adc_gecko_configure_func_##idx
373373

@@ -379,14 +379,14 @@ static int adc_gecko_init(const struct device *dev)
379379
.ref_internal = DT_INST_PROP(inst, vref_mv), \
380380
IF_ENABLED(CONFIG_ADC_ASYNC, (.read_async = adc_gecko_read_async,)) \
381381
}; \
382-
\
382+
\
383383
static struct adc_gecko_config adc_gecko_config##inst = { \
384384
.num_channels = ADC_GECKO_CHANNEL_NUM, \
385385
IRQ_CONFIGURE_DEFINE(inst), \
386-
}; \
386+
}; \
387387
static struct adc_gecko_data adc_gecko_data##inst; \
388-
\
388+
\
389389
DEVICE_DT_INST_DEFINE(inst, &adc_gecko_init, NULL, &adc_gecko_data##inst, \
390-
&adc_gecko_config##inst, POST_KERNEL, \
391-
CONFIG_KERNEL_INIT_PRIORITY_DEVICE, &adc_gecko_api);
390+
&adc_gecko_config##inst, POST_KERNEL, \
391+
CONFIG_KERNEL_INIT_PRIORITY_DEVICE, &adc_gecko_api);
392392
DT_INST_FOREACH_STATUS_OKAY(GECKO_ADC_INIT)

dts/bindings/adc/silabs,gecko-adc.yaml

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,6 @@ properties:
1111

1212
num-channels:
1313
type: int
14-
required: false
1514
description:
1615
Number of channels available
1716

@@ -23,13 +22,11 @@ properties:
2322

2423
vbatt-aport:
2524
type: int
26-
required: false
2725
description:
28-
This property selects the ADC channel for battery voltage detection.
26+
This property selects the ADC channel for battery voltage detection.
2927

3028
hwid-aport:
3129
type: int
32-
required: false
3330
description:
3431
This property selects the ADC channel for battery ID detection.
3532

@@ -40,7 +37,6 @@ properties:
4037

4138
vref-mv:
4239
type: int
43-
required: false
4440
default: 3300
4541
description:
4642
Indicate the reference voltage of the ADC in mV.

0 commit comments

Comments
 (0)