1 | /* |
---|
2 | * COPYRIGHT (c) 1989-2011. |
---|
3 | * On-Line Applications Research Corporation (OAR). |
---|
4 | * |
---|
5 | * The license and distribution terms for this file may be |
---|
6 | * found in the file LICENSE in this distribution or at |
---|
7 | * http://www.rtems.com/license/LICENSE. |
---|
8 | * |
---|
9 | * $Id$ |
---|
10 | */ |
---|
11 | |
---|
12 | #include "multiio.h" |
---|
13 | #include "rtd6425.h" |
---|
14 | #include <stdint.h> |
---|
15 | #include <rtems.h> |
---|
16 | |
---|
17 | int rtems_multiio_initialize(void) |
---|
18 | { |
---|
19 | /* |
---|
20 | * Initialize the RTD6425 module to use IRQ 11 and 7. This is sofware |
---|
21 | * programmable. Ours is jumpered for 0x300 base address. |
---|
22 | * We use discrete input interrupts so enable all of the |
---|
23 | * as edge triggered on 1. |
---|
24 | */ |
---|
25 | rtd6425_initialize(0x300, 10, 11); |
---|
26 | rtd6425_enable_dio_interrupt(); |
---|
27 | |
---|
28 | /* XXX - Enabling all interrupts atm |
---|
29 | { int i; |
---|
30 | for (i=1 ; i<=RTD6425_DISCRETE_IO_BITS ; i++ ) |
---|
31 | rtd6425_dio_enab_bit_int(i, 1); |
---|
32 | } |
---|
33 | */ |
---|
34 | return 0; |
---|
35 | } |
---|
36 | |
---|
37 | const char *rtems_multiio_get_name(void) |
---|
38 | { |
---|
39 | return "RTD6425"; |
---|
40 | } |
---|
41 | |
---|
42 | /* |
---|
43 | * ADC |
---|
44 | */ |
---|
45 | int rtems_adc_get_maximum(void) |
---|
46 | { |
---|
47 | return RTD6425_ADCs; |
---|
48 | } |
---|
49 | |
---|
50 | float rtems_adc_get_channel_voltage(int adc) |
---|
51 | { |
---|
52 | return rtd6425_adc_get_channel_voltage(adc); |
---|
53 | } |
---|
54 | |
---|
55 | /* |
---|
56 | * DAC |
---|
57 | */ |
---|
58 | int rtems_dac_get_maximum(void) |
---|
59 | { |
---|
60 | return RTD6425_DACs; |
---|
61 | } |
---|
62 | |
---|
63 | float rtems_dac_get_minimum_voltage(void) |
---|
64 | { |
---|
65 | return RTD6425_VOLTAGE_MINIMUM; |
---|
66 | } |
---|
67 | |
---|
68 | float rtems_dac_get_maximum_voltage(void) |
---|
69 | { |
---|
70 | return RTD6425_VOLTAGE_MAXIMUM; |
---|
71 | } |
---|
72 | |
---|
73 | int rtems_set_dac_voltage(int dac, float voltage) |
---|
74 | { |
---|
75 | rtd6425_set_dac_voltage(dac, voltage); |
---|
76 | return 0; |
---|
77 | } |
---|
78 | |
---|
79 | /* |
---|
80 | * Discrete Outputs |
---|
81 | */ |
---|
82 | int rtems_dout_get_maximum(void) |
---|
83 | { |
---|
84 | return RTD6425_DISCRETE_IO_BITS; |
---|
85 | } |
---|
86 | |
---|
87 | int rtems_set_dout(int dout, int value) |
---|
88 | { |
---|
89 | rtd6425_dio_write_bit(dout, value); |
---|
90 | return 0; |
---|
91 | } |
---|
92 | |
---|
93 | /* |
---|
94 | * Discrete Inputs |
---|
95 | */ |
---|
96 | int rtems_din_get_maximum(void) |
---|
97 | { |
---|
98 | return RTD6425_DISCRETE_IO_BITS; |
---|
99 | } |
---|
100 | |
---|
101 | int rtems_din_get(int din) |
---|
102 | { |
---|
103 | return rtd6425_dio_read_bit(din); |
---|
104 | } |
---|
105 | |
---|
106 | int rtems_din_flush_buffered_interrupts(void) |
---|
107 | { |
---|
108 | rtd6425_flush_buffered_ints(); |
---|
109 | return 0; |
---|
110 | } |
---|
111 | |
---|
112 | int rtems_din_wait_interrupt_with_timestamp( |
---|
113 | int milliseconds, |
---|
114 | struct timespec *timestamp |
---|
115 | ) |
---|
116 | { |
---|
117 | rtems_status_code sc; |
---|
118 | |
---|
119 | sc = rtd6425_wait_dio_int_with_timestamp(milliseconds, timestamp); |
---|
120 | return sc; |
---|
121 | } |
---|
122 | |
---|