aboutsummaryrefslogtreecommitdiff
path: root/stm32/inc/stm32f4_adc.h
blob: c7884a96293011e05736cd51cf6cd8431aae4cb0 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
/*---------------------------------------------------------------------------*\

  FILE........: stm32f4_adc.h
  AUTHOR......: David Rowe
  DATE CREATED: 30 May 2014

  Two channel FIFO buffered ADC driver module for STM32F4.

\*---------------------------------------------------------------------------*/

/*
  Copyright (C) 2014 David Rowe

  All rights reserved.

  This program is free software; you can redistribute it and/or modify
  it under the terms of the GNU Lesser General Public License version 2.1, as
  published by the Free Software Foundation.  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 Lesser General Public License
  along with this program; if not, see <http://www.gnu.org/licenses/>.
*/

#ifndef __STM32F4_ADC__
#define __STM32F4_ADC__

#define ADC_BUF_SZ   320

/* divisors for various sample rates */

#define ADC_FS_8KHZ 10500
#define ADC_FS_16KHZ 5250
#define ADC_FS_48KHZ 1750
#define ADC_FS_96KHZ 875

void adc_open(int fs_divisor, int fifo_sz, short *buf1, short *buf2);
int adc1_read(short buf[], int n); /* ADC1 Pin PA1 */
int adc2_read(short buf[], int n); /* ADC2 Pin PA2 */
int adc1_samps();
int adc2_samps();

#endif