1 /***************************************************************************
3 * Open \______ \ ____ ____ | | _\_ |__ _______ ___
4 * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
5 * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
6 * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
10 * Copyright (C) 2006 by Linus Nielsen Feltzing
12 * All files in this archive are subject to the GNU General Public License.
13 * See the file COPYING in the source tree root for full license agreement.
15 * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
16 * KIND, either express or implied.
18 ****************************************************************************/
27 #define CS_LO and_l(~0x80, &GPIO_OUT)
28 #define CS_HI or_l(0x80, &GPIO_OUT)
29 #define CLK_LO and_l(~0x00400000, &GPIO_OUT)
30 #define CLK_HI or_l(0x00400000, &GPIO_OUT)
31 #define DO (GPIO_READ & 0x80000000)
32 #define DI_LO and_l(~0x00200000, &GPIO_OUT)
33 #define DI_HI or_l(0x00200000, &GPIO_OUT)
40 "move.l #11, %[_x_] \r\n" \
42 "subq.l #1, %[_x_] \r\n" \
48 unsigned short adc_scan(int channel
)
50 int level
= disable_irq_save();
51 unsigned char data
= 0;
56 DI_HI
; /* Start bit */
62 DI_HI
; /* Single channel */
68 if(channel
& 1) /* LSB of channel number */
77 if(channel
& 2) /* MSB of channel number */
88 for(i
= 0;i
< 8;i
++) /* 8 bits of data */
106 or_l(0x80600080, &GPIO_FUNCTION
); /* GPIO7: CS
107 GPIO21: Data In (to the ADC)
109 GPIO31: Data Out (from the ADC) */
110 or_l(0x00600080, &GPIO_ENABLE
);
111 or_l(0x80, &GPIO_OUT
); /* CS high */
112 and_l(~0x00400000, &GPIO_OUT
); /* CLK low */