4 * @brief Meilhaus ME-1600 analog output subdevice class.
5 * @note Copyright (C) 2007 Meilhaus Electronic GmbH (support@meilhaus.de)
6 * @author Guenter Gebhardt
10 * Copyright (C) 2007 Meilhaus Electronic GmbH (support@meilhaus.de)
12 * This file is free software; you can redistribute it and/or modify
13 * it under the terms of the GNU General Public License as published by
14 * the Free Software Foundation; either version 2 of the License, or
15 * (at your option) any later version.
17 * This program is distributed in the hope that it will be useful,
18 * but WITHOUT ANY WARRANTY; without even the implied warranty of
19 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
20 * GNU General Public License for more details.
22 * You should have received a copy of the GNU General Public License
23 * along with this program; if not, write to the Free Software
24 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
30 # include <linux/version.h>
31 # include "mesubdevice.h"
35 # define ME1600_MAX_RANGES 2 /**< Specifies the maximum number of ranges in me1600_ao_subdevice_t::u_ranges und me1600_ao_subdevice_t::i_ranges. */
38 * @brief Defines a entry in the range table.
40 typedef struct me1600_ao_range_entry
{
43 } me1600_ao_range_entry_t
;
45 typedef struct me1600_ao_timeout
{
46 unsigned long start_time
;
48 } me1600_ao_timeout_t
;
50 typedef struct me1600_ao_shadow
{
52 unsigned long *registry
;
55 uint16_t synchronous
; /**< Synchronization list. */
56 uint16_t trigger
; /**< Synchronization flag. */
59 typedef enum ME1600_AO_STATUS
{
61 ao_status_single_configured
,
68 * @brief The ME-1600 analog output subdevice class.
70 typedef struct me1600_ao_subdevice
{
72 me_subdevice_t base
; /**< The subdevice base class. */
75 int ao_idx
; /**< The index of the analog output subdevice on the device. */
77 spinlock_t subdevice_lock
; /**< Spin lock to protect the subdevice from concurrent access. */
78 spinlock_t
*config_regs_lock
; /**< Spin lock to protect configuration registers from concurrent access. */
80 int u_ranges_count
; /**< The number of voltage ranges available on this subdevice. */
81 me1600_ao_range_entry_t u_ranges
[ME1600_MAX_RANGES
]; /**< Array holding the voltage ranges on this subdevice. */
82 int i_ranges_count
; /**< The number of current ranges available on this subdevice. */
83 me1600_ao_range_entry_t i_ranges
[ME1600_MAX_RANGES
]; /**< Array holding the current ranges on this subdevice. */
86 unsigned long uni_bi_reg
; /**< Register for switching between unipoar and bipolar output mode. */
87 unsigned long i_range_reg
; /**< Register for switching between ranges. */
88 unsigned long sim_output_reg
; /**< Register used in order to update all channels simultaneously. */
89 unsigned long current_on_reg
; /**< Register enabling current output on the fourth subdevice. */
91 unsigned long reg_base
;
94 ME1600_AO_STATUS status
;
95 me1600_ao_shadow_t
*ao_regs_shadows
; /**< Addresses and shadows of output's registers. */
96 spinlock_t
*ao_shadows_lock
; /**< Protects the shadow's struct. */
97 int mode
; /**< Mode in witch output should works. */
98 wait_queue_head_t wait_queue
; /**< Wait queue to put on tasks waiting for data to arrive. */
99 me1600_ao_timeout_t timeout
; /**< The timeout for start in blocking and non-blocking mode. */
100 struct workqueue_struct
*me1600_workqueue
;
101 struct delayed_work ao_control_task
;
103 volatile int ao_control_task_flag
; /**< Flag controling reexecuting of control task */
104 } me1600_ao_subdevice_t
;
107 * @brief The constructor to generate a subdevice template instance.
109 * @param reg_base The register base address of the device as returned by the PCI BIOS.
110 * @param ao_idx The index of the analog output subdevice on the device.
111 * @param current Flag indicating that analog output with #ao_idx of 3 is capable of current output.
112 * @param config_regs_lock Pointer to spin lock protecting the configuration registers and from concurrent access.
114 * @return Pointer to new instance on success.\n
117 me1600_ao_subdevice_t
*me1600_ao_constructor(uint32_t reg_base
,
120 spinlock_t
* config_regs_lock
,
121 spinlock_t
* ao_shadows_lock
,
124 struct workqueue_struct
128 #endif //_ME1600_AO_H_