data_acquisition.c 1.55 KB
Newer Older
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
/*
 * Copyright (c) 2021 LAAS-CNRS
 *
 *   This program is free software: you can redistribute it and/or modify
 *   it under the terms of the GNU Lesser General Public License as published by
 *   the Free Software Foundation, either version 2.1 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 Lesser 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 <https://www.gnu.org/licenses/>.
 *
 * SPDX-License-Identifier: LGLPV2.1
 */

/**
 * @author Clément Foucher <clement.foucher@laas.fr>
 */


25
26
27
28
/////
// OwnTech Power API includes

#include "timer.h"
29
30
#include "dma/dma.h"
#include "adc/adc.h"
31
32
33
34
35
36
37
38
#include "data_dispatch/data_dispatch.h"


/////
// Timer

#define TIMER7_LABEL DT_PROP(DT_NODELABEL(timers7), label)
static const struct device* timer7;
39
40
41


/////
42
43
44
45
46
// Private functions


/////
// Public API
47
48
49

void data_acquisition_init()
{
50
51
52
53
54
55
56
57
	/////
	// Initialize peripherals

	// ADC
	adc_init();

	// DMA
	dma_init();
58

59
60
61
	/////
	// Initialize data dispatch
	data_dispatch_init();
62

63
64
65
66
67
68
69
70
71
72
	/////
	// Configure timer for background data dispatch
	timer7 = device_get_binding(TIMER7_LABEL);
	struct timer_config_t timer_cfg =
	{
		.timer_enable_irq = 1,
		.timer_callback   = data_dispatch_do_dispatch
	};
	timer_config(timer7, &timer_cfg);
	timer_start(timer7, 25);
73
}