Skip to content

Commit cf56903

Browse files
falojkartben
authored andcommitted
driver: adc: add MCP3561/2/4R driver
Add driver for the microchip MCP3561/2/4R ADC. Registers lock and CRCCFG protection mecanism is not implemented. Tested on an MCP3564R. Signed-off-by: Johan Lafon <[email protected]>
1 parent 1207880 commit cf56903

File tree

7 files changed

+1512
-0
lines changed

7 files changed

+1512
-0
lines changed

drivers/adc/CMakeLists.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ zephyr_library_sources_ifdef(CONFIG_ADC_STM32WB0 adc_stm32wb0.c)
2424
zephyr_library_sources_ifdef(CONFIG_ADC_XEC adc_mchp_xec.c)
2525
zephyr_library_sources_ifdef(CONFIG_ADC_LMP90XXX adc_lmp90xxx.c)
2626
zephyr_library_sources_ifdef(CONFIG_ADC_MCP320X adc_mcp320x.c)
27+
zephyr_library_sources_ifdef(CONFIG_ADC_MCP356XR adc_mcp356xr.c)
2728
zephyr_library_sources_ifdef(CONFIG_ADC_NPCX adc_npcx.c)
2829
zephyr_library_sources_ifdef(CONFIG_USERSPACE adc_handlers.c)
2930
zephyr_library_sources_ifdef(CONFIG_ADC_CC32XX adc_cc32xx.c)

drivers/adc/Kconfig

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -80,6 +80,8 @@ source "drivers/adc/Kconfig.lmp90xxx"
8080

8181
source "drivers/adc/Kconfig.mcp320x"
8282

83+
source "drivers/adc/Kconfig.mcp356xr"
84+
8385
source "drivers/adc/Kconfig.npcx"
8486

8587
source "drivers/adc/Kconfig.cc32xx"

drivers/adc/Kconfig.mcp356xr

Lines changed: 60 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,60 @@
1+
# Copyright (c) 2024 Syslinbit SCOP SAS
2+
# SPDX-License-Identifier: Apache-2.0
3+
4+
config ADC_MCP356XR
5+
bool "MCP3561R/2R/4R driver"
6+
default y
7+
depends on DT_HAS_MICROCHIP_MCP356XR_ENABLED
8+
select SPI
9+
select ADC_CONFIGURABLE_INPUTS
10+
help
11+
Enable MCP3561R/2R/4R ADC driver.
12+
13+
if ADC_MCP356XR
14+
15+
config ADC_MCP356XR_THREAD_STACK_SIZE
16+
int "Stack size for the ADC thread"
17+
default 512
18+
help
19+
Size of the stack used for the internal ADC thread.
20+
21+
config ADC_MCP356XR_THREAD_PRIORITY
22+
int "Priority for the ADC thread"
23+
default 0
24+
help
25+
Priority level for the internal ADC thread.
26+
27+
config ADC_MCP356XR_ADC_CHANNEL_COUNT
28+
int "Number of ADC channels"
29+
range 1 32
30+
default 1
31+
help
32+
Number of ADC channels the driver must support. Each channel
33+
requires 3 bytes of RAM to store the ADC settings to be used
34+
for this channel.
35+
36+
config ADC_MCP356XR_USE_READ_CRC
37+
bool "Use CRC to check data received from the ADC"
38+
default y
39+
help
40+
Enables the use of CRC on read communications to check integrity
41+
of received data from the ADC.
42+
43+
config ADC_MCP356XR_POLL
44+
bool "Poll the ADC instead of using the IRQ pin"
45+
help
46+
Regularly poll the ADC to retrieve status flags instead of
47+
waiting for the ADC triggered IRQ. Useful in case the IRQ
48+
pin of the ADC is not wired.
49+
50+
if ADC_MCP356XR_POLL
51+
config ADC_MCP356XR_POLLING_PERIOD_MS
52+
int "Time to wait between two ADC polling in milliseconds"
53+
default 1
54+
help
55+
Time the driver's internal acquisition thread will wait
56+
between two ADC polling (in milliseconds).
57+
58+
endif #ADC_MCP356XR_POLL
59+
60+
endif # ADC_MCP356XR

0 commit comments

Comments
 (0)