Main Page | Modules | Data Structures | Directories | File List | Data Fields | Globals | Related Pages

# d2a.c

Go to the documentation of this file.

    00001 /*! \file d2a.c \brief Digital-to-Analog Converter Driver for ADuC7000. */
    00002 //*****************************************************************************
    00003 //
    00004 // File Name    : 'd2a.c'
    00005 // Title        : Digital-to-Analog Converter Driver for ADuC7000
    00006 // Author       : Pascal Stang - Copyright (C) 2005
    00007 // Created      : 2/5/2005
    00008 // Revised      : 2/5/2005
    00009 // Version      : 0.1
    00010 // Target MCU   : Analog Devices ADuC7000 ARM Series
    00011 // Editor Tabs  : 4
    00012 //
    00013 // This code is distributed under the GNU Public License
    00014 //      which can be found at http://www.gnu.org/licenses/gpl.txt
    00015 //
    00016 //*****************************************************************************
    00017
    00018 #include "aduc7026.h"
    00019
    00020 #include "global.h"
    00021 #include "d2a.h"
    00022
    00023 // functions
    00024 void d2aInit(void)
    00025 {
    00026     #define DACBYP              (1<<6)
    00027     #define DACCLK              (1<<5)
    00028     #define DACCLR              (1<<4)
    00029     #define DACRANGE_PWRDOWN    (0x00)
    00030     #define DACRANGE_DACREF     (0x01)
    00031     #define DACRANGE_AREF       (0x02)
    00032     #define DACRANGE_AVDD       (0x03)
    00033
    00034     // set DAC to ON, range to 0-AVdd
    00035     DAC0CON |= DACCLR | DACRANGE_AVDD;
    00036     DAC1CON |= DACCLR | DACRANGE_AVDD;
    00037     DAC2CON |= DACCLR | DACRANGE_AVDD;
    00038     DAC3CON |= DACCLR | DACRANGE_AVDD;
    00039 }
    00040
    00041 void d2aSet(int channel, int level)
    00042 {
    00043     DAC->Channel[channel].Data = level<<16;
    00044 }