dRonin  adbada4
dRonin firmware
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Groups Pages
pios_dac.h
Go to the documentation of this file.
1 
12 /*
13  * This program is free software; you can redistribute it and/or modify
14  * it under the terms of the GNU General Public License as published by
15  * the Free Software Foundation; either version 3 of the License, or
16  * (at your option) any later version.
17  *
18  * This program is distributed in the hope that it will be useful, but
19  * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
20  * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
21  * for more details.
22  *
23  * You should have received a copy of the GNU General Public License along
24  * with this program; if not, write to the Free Software Foundation, Inc.,
25  * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
26  *
27  * Additional note on redistribution: The copyright and license notices above
28  * must be maintained in each individual source file that is a derivative work
29  * of this source file; otherwise redistribution is prohibited.
30  */
31 
32 #ifndef _PIOS_DAC_H
33 #define _PIOS_DAC_H
34 
35 #include <stdint.h>
36 #include <stdio.h>
37 
38 #include "stm32f4xx_dac.h"
39 
40 typedef struct dac_dev_s *dac_dev_t;
41 
42 struct pios_dac_cfg {
43  TIM_TypeDef *timer;
44  TIM_TimeBaseInitTypeDef clock_cfg;
45 
46  NVIC_InitTypeDef interrupt;
47 
48  GPIO_TypeDef *gpio;
49  uint16_t gpio_pin;
50 
51  DMA_Stream_TypeDef *dma_stream;
52  uint32_t dma_channel;
53 
54  uint32_t dac_channel;
55  uint32_t dac_trigger;
56  uintptr_t dac_outreg;
57 
58  uint32_t dma_tcif;
59 };
60 
67 int PIOS_DAC_init(dac_dev_t *dev_out,
68  const struct pios_dac_cfg *cfg);
69 
75 
76 typedef bool (*fill_dma_cb)(void *ctx, uint16_t *buf, int len);
77 
86 bool PIOS_DAC_install_callback(dac_dev_t dev, uint8_t priority, fill_dma_cb cb,
87  void *ctx);
88 
89 #endif /* _PIOS_DAC_H */
uint32_t dma_channel
Definition: pios_dac.h:52
uint32_t dac_trigger
Definition: pios_dac.h:55
GPIO_TypeDef * gpio
Definition: pios_dac.h:48
bool PIOS_DAC_install_callback(dac_dev_t dev, uint8_t priority, fill_dma_cb cb, void *ctx)
uint32_t dma_tcif
Definition: pios_dac.h:58
uint32_t dac_channel
Definition: pios_dac.h:54
uint16_t gpio_pin
Definition: pios_dac.h:49
static struct flyingpicmd_cfg_fa cfg
Definition: main.c:49
int PIOS_DAC_init(dac_dev_t *dev_out, const struct pios_dac_cfg *cfg)
Allocate and initialise DAC device.
uintptr_t dac_outreg
Definition: pios_dac.h:56
DMA_Stream_TypeDef * dma_stream
Definition: pios_dac.h:51
NVIC_InitTypeDef interrupt
Definition: pios_dac.h:46
bool(* fill_dma_cb)(void *ctx, uint16_t *buf, int len)
Definition: pios_dac.h:76
struct dac_dev_s * dac_dev_t
Definition: pios_dac.h:40
TIM_TypeDef * timer
Definition: pios_dac.h:43
TIM_TimeBaseInitTypeDef clock_cfg
Definition: pios_dac.h:44
void PIOS_DAC_dma_interrupt_handler(dac_dev_t dev)
Handles a DMA completion interrupt on dma_stream.