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 "mio_io.h" |
---|
14 | #include <stdint.h> |
---|
15 | #include <rtems.h> |
---|
16 | |
---|
17 | int rtems_multiio_initialize(void) |
---|
18 | { |
---|
19 | /* |
---|
20 | * Initialize the PCMMIO module to use IRQ6. Ours is jumpered for 0x300 |
---|
21 | * base address. We use discrete input interrupts so enable all of the |
---|
22 | * as edge triggered on 1. |
---|
23 | */ |
---|
24 | pcmmio_initialize(0x300, 6); |
---|
25 | enable_dio_interrupt(); |
---|
26 | { int i; |
---|
27 | for (i=1 ; i<=48 ; i++ ) |
---|
28 | dio_enab_bit_int(i, 1); |
---|
29 | } |
---|
30 | |
---|
31 | return 0; |
---|
32 | } |
---|
33 | |
---|
34 | const char *rtems_multiio_get_name(void) |
---|
35 | { |
---|
36 | return "Winsystems"; |
---|
37 | } |
---|
38 | |
---|
39 | /* |
---|
40 | * ADC |
---|
41 | */ |
---|
42 | int rtems_adc_get_maximum(void) |
---|
43 | { |
---|
44 | return 16; |
---|
45 | } |
---|
46 | |
---|
47 | float rtems_adc_get_channel_voltage(int adc) |
---|
48 | { |
---|
49 | return adc_get_channel_voltage(adc); |
---|
50 | } |
---|
51 | |
---|
52 | /* |
---|
53 | * DAC |
---|
54 | */ |
---|
55 | int rtems_dac_get_maximum(void) |
---|
56 | { |
---|
57 | return 8; |
---|
58 | } |
---|
59 | |
---|
60 | float rtems_dac_get_minimum_voltage(void) |
---|
61 | { |
---|
62 | return -10.0; |
---|
63 | } |
---|
64 | |
---|
65 | float rtems_dac_get_maximum_voltage(void) |
---|
66 | { |
---|
67 | return 10.0; |
---|
68 | } |
---|
69 | |
---|
70 | int rtems_set_dac_voltage(int dac, float voltage) |
---|
71 | { |
---|
72 | set_dac_voltage(dac, voltage); |
---|
73 | return 0; |
---|
74 | } |
---|
75 | |
---|
76 | /* |
---|
77 | * Discrete Outputs |
---|
78 | */ |
---|
79 | int rtems_dout_get_maximum(void) |
---|
80 | { |
---|
81 | return 48; |
---|
82 | } |
---|
83 | |
---|
84 | int rtems_set_dout(int dout, int value) |
---|
85 | { |
---|
86 | dio_write_bit(dout+1, value); |
---|
87 | return 0; |
---|
88 | } |
---|
89 | |
---|
90 | /* |
---|
91 | * Discrete Inputs |
---|
92 | */ |
---|
93 | int rtems_din_get_maximum(void) |
---|
94 | { |
---|
95 | return 48; |
---|
96 | } |
---|
97 | |
---|
98 | int rtems_din_get(int din) |
---|
99 | { |
---|
100 | return dio_read_bit(din+1); |
---|
101 | } |
---|
102 | |
---|
103 | int rtems_din_flush_buffered_interrupts(void) |
---|
104 | { |
---|
105 | flush_buffered_ints(); |
---|
106 | return 0; |
---|
107 | } |
---|
108 | |
---|
109 | int rtems_din_wait_interrupt_with_timestamp( |
---|
110 | int milliseconds, |
---|
111 | struct timespec *timestamp |
---|
112 | ) |
---|
113 | { |
---|
114 | (void) wait_dio_int_with_timestamp(milliseconds, timestamp); |
---|
115 | return 0; |
---|
116 | } |
---|
117 | |
---|