libopencm3
A free/libre/open-source firmware library for various ARM Cortex-M3 microcontrollers.
prs_common.c
Go to the documentation of this file.
1/** @addtogroup prs_file PRS peripheral API
2 * @ingroup peripheral_apis
3 * @brief EFM32 Peripheral Reflex System (PRS).
4 * The Peripheral Reflex System (PRS) system is a network which allows the
5 * different peripheral modules to communicate directly with each other
6 * without involving the CPU.
7 */
8/*
9 * This file is part of the libopencm3 project.
10 *
11 * Copyright (C) 2015 Kuldeep Singh Dhaka <kuldeepdhaka9@gmail.com>
12 *
13 * This library is free software: you can redistribute it and/or modify
14 * it under the terms of the GNU Lesser 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 library is distributed in the hope that it will be useful,
19 * but WITHOUT ANY WARRANTY; without even the implied warranty of
20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 * GNU Lesser General Public License for more details.
22 *
23 * You should have received a copy of the GNU Lesser General Public License
24 * along with this library. If not, see <http://www.gnu.org/licenses/>.
25 */
26
28
29/**@{*/
30
31/**
32 * Enable PRS output to GPIO.
33 * @param[in] ch Channel (use PRS_CHx)
34 * @see prs_set_output_loc()
35 */
37{
39}
40
41/**
42 * Disable PRS output to GPIO.
43 * @param[in] ch Channel (use PRS_CHx)
44 * @see prs_set_output_loc()
45 */
47{
48 PRS_ROUTE &= ~PRS_ROUTE_CHxPEN(ch);
49}
50
51/**
52 * Location of the PRS to be output on GPIO.
53 * @param[in] loc location (use PRS_ROUTE_LOCATION_LOCx)
54 * @see prs_set_output_loc()
55 */
56void prs_set_output_loc(uint32_t loc)
57{
58 PRS_ROUTE = (PRS_ROUTE & ~PRS_ROUTE_LOCATION_MASK) | loc;
59}
60
61/**
62 * Generate software pulse.
63 * @param[in] ch Channel (use PRS_CHx)
64 * @note the final output is dependent on "software level" value of the channel
65 * @see prs_software_level_high()
66 * @see prs_software_level_low()
67 */
69{
71}
72
73/**
74 * HIGH is XOR'ed with the corresponding bit in the software-pulse and
75 * the PRS input signal to generate.
76 * @param[in] ch Channel (use PRS_CHx)
77 * @see prs_software_level_low()
78 * @see prs_software_pulse()
79 */
81{
83}
84
85/**
86 * LOW is XOR'ed with the corresponding bit in the software-pulse and
87 * the PRS input signal to generate.
88 * @param[in] ch Channel (use PRS_CHx)
89 * @see prs_software_level_high()
90 * @see prs_software_pulse()
91 */
93{
94 PRS_SWLEVEL &= ~PRS_SWLEVEL_CHxLEVEL(ch);
95}
96
97/**
98 * disable synchronization of this channel reflex signal
99 * @param[in] ch Channel (use PRS_CHx)
100 * @see prs_disable_async()
101 */
103{
105}
106
107/**
108 * enable synchronization of this channel reflex signal
109 * @param[in] ch Channel (use PRS_CHx)
110 * @see prs_disable_async()
111 */
113{
114 PRS_CHx_CTRL(ch) &= ~PRS_CH_CTRL_ASYNC;
115}
116
117/**
118 * Edge detection for the channel
119 * @param[in] ch Channel (use PRS_CHx)
120 * @param[in] edge Edge (use PRS_CH_CTRL_EDSEL_*)
121 */
122void prs_set_edge(enum prs_ch ch, uint32_t edge)
123{
124 PRS_CHx_CTRL(ch) = (PRS_CHx_CTRL(ch) & ~PRS_CH_CTRL_EDSEL_MASK) | edge;
125}
126
127/**
128 * Source for the channel
129 * @param[in] ch Channel (use PRS_CHx)
130 * @param[in] source Source (use PRS_CH_CTRL_SOURCESEL_*)
131 * @see prs_set_signal()
132 */
133void prs_set_source(enum prs_ch ch, uint32_t source)
134{
135 PRS_CHx_CTRL(ch) = (PRS_CHx_CTRL(ch) & ~PRS_CH_CTRL_SOURCESEL_MASK)
136 | source;
137}
138
139/**
140 * Source for the channel
141 * @param[in] ch Channel (use PRS_CHx)
142 * @param[in] signal Signal (use PRS_CH_CTRL_SIGSEL_*)
143 * @see prs_set_source()
144 */
145void prs_set_signal(enum prs_ch ch, uint32_t signal)
146{
147 PRS_CHx_CTRL(ch) = (PRS_CHx_CTRL(ch) & ~PRS_CH_CTRL_SIGSEL_MASK)
148 | signal;
149}
150
151/**@}*/
prs_ch
Definition: prs_common.h:331
#define PRS_SWPULSE_CHxPULSE(x)
Definition: prs_common.h:47
#define PRS_ROUTE
Definition: prs_common.h:31
#define PRS_CH_CTRL_ASYNC
Definition: prs_common.h:92
#define PRS_SWPULSE
Definition: prs_common.h:29
#define PRS_ROUTE_CHxPEN(x)
Definition: prs_common.h:85
#define PRS_CHx_CTRL(x)
Definition: prs_common.h:32
#define PRS_SWLEVEL_CHxLEVEL(x)
Definition: prs_common.h:62
#define PRS_SWLEVEL
Definition: prs_common.h:30
void prs_disable_async(enum prs_ch ch)
enable synchronization of this channel reflex signal
Definition: prs_common.c:112
void prs_software_pulse(enum prs_ch ch)
Generate software pulse.
Definition: prs_common.c:68
void prs_enable_async(enum prs_ch ch)
disable synchronization of this channel reflex signal
Definition: prs_common.c:102
void prs_set_edge(enum prs_ch ch, uint32_t edge)
Edge detection for the channel.
Definition: prs_common.c:122
void prs_software_level_low(enum prs_ch ch)
LOW is XOR'ed with the corresponding bit in the software-pulse and the PRS input signal to generate.
Definition: prs_common.c:92
void prs_set_source(enum prs_ch ch, uint32_t source)
Source for the channel.
Definition: prs_common.c:133
void prs_set_signal(enum prs_ch ch, uint32_t signal)
Source for the channel.
Definition: prs_common.c:145
void prs_enable_gpio_output(enum prs_ch ch)
Enable PRS output to GPIO.
Definition: prs_common.c:36
void prs_set_output_loc(uint32_t loc)
Location of the PRS to be output on GPIO.
Definition: prs_common.c:56
void prs_disable_gpio_output(enum prs_ch ch)
Disable PRS output to GPIO.
Definition: prs_common.c:46
void prs_software_level_high(enum prs_ch ch)
HIGH is XOR'ed with the corresponding bit in the software-pulse and the PRS input signal to generate.
Definition: prs_common.c:80