drivers/comedi/drivers/dac02.c
Source file repositories/reference/linux-study-clean/drivers/comedi/drivers/dac02.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/comedi/drivers/dac02.c- Extension
.c- Size
- 3745 bytes
- Lines
- 138
- Domain
- Driver Families
- Bucket
- drivers/comedi
- Inferred role
- Driver Families: implementation source
- Status
- source implementation candidate
Why This File Exists
Repeatable hardware-adapter layer. Deep compatibility for every driver is out of scope; this atlas records patterns, probe lifecycles, bus glue, IRQ/DMA usage, and links back to core abstractions.
- Repeatable hardware-adapter layer. Deep compatibility for every driver is out of scope; this atlas records patterns, probe lifecycles, bus glue, IRQ/DMA usage, and links back to core abstractions.
- Defines or uses C structs; map object ownership, embedded links, reference counts, and lock ownership.
Dependency Surface
linux/module.hlinux/comedi/comedidev.h
Detected Declarations
function dac02_ao_insn_writefunction dac02_attach
Annotated Snippet
// SPDX-License-Identifier: GPL-2.0+
/*
* dac02.c
* Comedi driver for DAC02 compatible boards
* Copyright (C) 2014 H Hartley Sweeten <hsweeten@visionengravers.com>
*
* Based on the poc driver
* Copyright (C) 2000 Frank Mori Hess <fmhess@users.sourceforge.net>
* Copyright (C) 2001 David A. Schleef <ds@schleef.org>
*
* COMEDI - Linux Control and Measurement Device Interface
* Copyright (C) 1998 David A. Schleef <ds@schleef.org>
*/
/*
* Driver: dac02
* Description: Comedi driver for DAC02 compatible boards
* Devices: [Keithley Metrabyte] DAC-02 (dac02)
* Author: H Hartley Sweeten <hsweeten@visionengravers.com>
* Updated: Tue, 11 Mar 2014 11:27:19 -0700
* Status: unknown
*
* Configuration options:
* [0] - I/O port base
*/
#include <linux/module.h>
#include <linux/comedi/comedidev.h>
/*
* The output range is selected by jumpering pins on the I/O connector.
*
* Range Chan # Jumper pins Output
* ------------- ------ ------------- -----------------
* 0 to 5V 0 21 to 22 24
* 1 15 to 16 18
* 0 to 10V 0 20 to 22 24
* 1 14 to 16 18
* +/-5V 0 21 to 22 23
* 1 15 to 16 17
* +/-10V 0 20 to 22 23
* 1 14 to 16 17
* 4 to 20mA 0 21 to 22 25
* 1 15 to 16 19
* AC reference 0 In on pin 22 24 (2-quadrant)
* In on pin 22 23 (4-quadrant)
* 1 In on pin 16 18 (2-quadrant)
* In on pin 16 17 (4-quadrant)
*/
static const struct comedi_lrange das02_ao_ranges = {
6, {
UNI_RANGE(5),
UNI_RANGE(10),
BIP_RANGE(5),
BIP_RANGE(10),
RANGE_mA(4, 20),
RANGE_ext(0, 1)
}
};
/*
* Register I/O map
*/
#define DAC02_AO_LSB(x) (0x00 + ((x) * 2))
#define DAC02_AO_MSB(x) (0x01 + ((x) * 2))
static int dac02_ao_insn_write(struct comedi_device *dev,
struct comedi_subdevice *s,
struct comedi_insn *insn,
unsigned int *data)
{
unsigned int chan = CR_CHAN(insn->chanspec);
unsigned int range = CR_RANGE(insn->chanspec);
unsigned int val;
int i;
for (i = 0; i < insn->n; i++) {
val = data[i];
s->readback[chan] = val;
/*
* Unipolar outputs are true binary encoding.
* Bipolar outputs are complementary offset binary
* (that is, 0 = +full scale, maxdata = -full scale).
*/
if (comedi_range_is_bipolar(s, range))
val = s->maxdata - val;
/*
Annotation
- Immediate include surface: `linux/module.h`, `linux/comedi/comedidev.h`.
- Detected declarations: `function dac02_ao_insn_write`, `function dac02_attach`.
- Atlas domain: Driver Families / drivers/comedi.
- Implementation status: source implementation candidate.
Implementation Notes
- This generated page is the file-by-file coverage layer; curated subsystem chapters should link here when they synthesize a multi-file control flow.
- Core OS pages should be promoted from atlas-only to deep-reviewed when they explain data structures, invariants, locking, lifecycle, and C implementation snippets.
- Driver-family pages are intentionally pattern-oriented unless they are part of the selected PCIe/NVMe representative device path.