main.c
56 lines
| 1.7 KiB
| text/x-c
|
CLexer
|
r100 | /*------------------------------------------------------------------------------ | ||
-- 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[512]; | ||||
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<512;i++) | ||||
{ | ||||
data[i]=(int16_t)(2000.0*cos(i/10.0))+2000.0; | ||||
} | ||||
dacopen(PA4); | ||||
dacsetconfig(timer8, 512, DAC1,DAC1_12bit_right_align , 100000,(void*)data); | ||||
return 0; | ||||
} | ||||