|
|
/*------------------------------------------------------------------------------
|
|
|
-- This file is a part of the libuc, microcontroler library
|
|
|
-- Copyright (C) 2013, Alexis Jeandet
|
|
|
--
|
|
|
-- This program is free software; you can redistribute it and/or modify
|
|
|
-- it under the terms of the GNU General Public License as published by
|
|
|
-- the Free Software Foundation; either version 3 of the License, or
|
|
|
-- (at your option) any later version.
|
|
|
--
|
|
|
-- This program is distributed in the hope that it will be useful,
|
|
|
-- but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
-- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
-- GNU General Public License for more details.
|
|
|
--
|
|
|
-- You should have received a copy of the GNU General Public License
|
|
|
-- along with this program; if not, write to the Free Software
|
|
|
-- Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
|
|
-------------------------------------------------------------------------------*/
|
|
|
/** @author Alexis Jeandet alexis.jeandet@member.fsf.org
|
|
|
-------------------------------------------------------------------------------*/
|
|
|
/**
|
|
|
* This file is a simple example for the DAC library.
|
|
|
*
|
|
|
*/
|
|
|
|
|
|
#include <stdio.h>
|
|
|
#include <uhandle.h>
|
|
|
#include <dac.h>
|
|
|
#include <timer.h>
|
|
|
#include <gpio.h>
|
|
|
#include <math.h>
|
|
|
int16_t __attribute__ ((aligned (4))) data[4096];
|
|
|
int libuc_main()
|
|
|
{
|
|
|
/**
|
|
|
Depending on the board the printf can be directed on one uart or LCD screen or
|
|
|
any other stream device.
|
|
|
*/
|
|
|
printf("DAC example \n\r");
|
|
|
for(int i=0;i<4096;i++)
|
|
|
{
|
|
|
data[i]=(2048+i)%4096;
|
|
|
}
|
|
|
data[0]=4000;
|
|
|
dacopen(PA4);
|
|
|
dacsetconfig(timer8, 4096, DAC1,DAC1_12bit_right_align , 100000,(void*)&data);
|
|
|
while (1);
|
|
|
return 0;
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|