Root/Examples/ADC/Test-QT-src/jz_adc_peripheral.cpp

1/* ADC Peripheral.c
2
3Copyright (C) 2010 Carlos Camargo cicamargoba@unal.edu.co
4                               Andres Calderon andres.calderon@emqbit.com
5
6This program is free software; you can redistribute it and/or modify
7it under the terms of the GNU General Public License as published by
8the Free Software Foundation; either version 2 of the License, or
9(at your option) any later version.
10
11This program is distributed in the hope that it will be useful,
12but WITHOUT ANY WARRANTY; without even the implied warranty of
13MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14GNU General Public License for more details.
15
16You should have received a copy of the GNU General Public License
17along with this program; if not, write to the Free Software
18Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */
19
20#include <stdio.h>
21#include <unistd.h>
22
23#include "jz_adc_peripheral.h"
24
25JZ_REG *
26jz_adc_init()
27{
28    JZ_PIO *pio;
29    JZ_REG *virt_addr;
30
31    pio = jz_gpio_map (CS2_PORT);
32    jz_gpio_as_func (pio, CS2_PIN, 0);
33
34    virt_addr = (JZ_REG *) (jz_mmap(0x13010000) + 0x18);
35
36    if (*virt_addr != 0x0FFF7700)
37    {
38        *virt_addr = 0x0FFF7700;
39        printf ("ADC: Configuring CS2 8 bits and 0 WS: %08X\n", *virt_addr);
40    }
41    else
42        printf ("ADC: CS2, already configured: %08X\n", *virt_addr);
43
44    virt_addr = (JZ_REG *) jz_mmap (0x14000000);
45
46    return virt_addr;
47}
48

Archive Download this file

Branches:
master



interactive