RTEMS
6.3
Toggle main menu visibility
Loading...
Searching...
No Matches
bsps
arm
atsam
include
bsp
power.h
1
/* SPDX-License-Identifier: BSD-2-Clause */
2
3
/*
4
* Copyright (c) 2016 embedded brains GmbH & Co. KG
5
*
6
* Redistribution and use in source and binary forms, with or without
7
* modification, are permitted provided that the following conditions
8
* are met:
9
* 1. Redistributions of source code must retain the above copyright
10
* notice, this list of conditions and the following disclaimer.
11
* 2. Redistributions in binary form must reproduce the above copyright
12
* notice, this list of conditions and the following disclaimer in the
13
* documentation and/or other materials provided with the distribution.
14
*
15
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
16
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
17
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
18
* ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
19
* LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
20
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
21
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
22
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
23
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
24
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
25
* POSSIBILITY OF SUCH DAMAGE.
26
*/
27
28
#ifndef LIBBSP_ARM_ATSAM_POWER_H
29
#define LIBBSP_ARM_ATSAM_POWER_H
30
31
#include <sys/types.h>
32
33
#include <stdint.h>
34
35
#ifdef __cplusplus
36
extern
"C"
{
37
#endif
/* __cplusplus */
38
42
typedef
enum
{
46
ATSAM_POWER_INIT,
50
ATSAM_POWER_ON,
54
ATSAM_POWER_OFF
55
} atsam_power_state;
56
60
typedef
struct
atsam_power_control
{
64
void (*
handler
)(
65
const
struct
atsam_power_control
*
control
,
66
atsam_power_state state
67
);
71
union
{
72
void
*arg;
73
struct
{
74
uint8_t first;
75
uint8_t last;
76
} peripherals;
77
} data;
78
}
atsam_power_control
;
79
137
void
atsam_power_change_state(
138
const
atsam_power_control
*controls,
139
size_t
n,
140
atsam_power_state state
141
);
142
154
void
atsam_power_handler_peripheral(
155
const
atsam_power_control
*controls,
156
atsam_power_state state
157
);
158
170
void
atsam_power_handler_clock_driver(
171
const
atsam_power_control
*controls,
172
atsam_power_state state
173
);
174
187
void
atsam_power_handler_rtc_driver(
188
const
atsam_power_control
*controls,
189
atsam_power_state state
190
);
191
197
void
atsam_power_handler_sleep_mode(
198
const
atsam_power_control
*controls,
199
atsam_power_state state
200
);
201
209
void
atsam_power_handler_wait_mode(
210
const
atsam_power_control
*controls,
211
atsam_power_state state
212
);
213
220
#define ATSAM_POWER_PERIPHERAL(f, l) \
221
{ \
222
.handler = atsam_power_handler_peripheral, \
223
.data = { .peripherals = { .first = f, .last = l } } \
224
}
225
226
#define ATSAM_POWER_HANDLER(h, a) \
227
{ \
228
.handler = h, \
229
.data = { .arg = a } \
230
}
231
232
#define ATSAM_POWER_CLOCK_DRIVER \
233
{ .handler = atsam_power_handler_clock_driver }
234
235
#define ATSAM_POWER_SLEEP_MODE \
236
{ .handler = atsam_power_handler_sleep_mode }
237
238
#define ATSAM_POWER_WAIT_MODE \
239
{ .handler = atsam_power_handler_wait_mode }
240
246
typedef
struct
{
252
uint32_t interval;
253
} atsam_power_data_rtc_driver;
254
262
#define ATSAM_POWER_RTC_DRIVER(a) \
263
{ \
264
.handler = atsam_power_handler_rtc_driver, \
265
.data = { .arg = a } \
266
}
267
268
#ifdef __cplusplus
269
}
270
#endif
/* __cplusplus */
271
272
#endif
/* LIBBSP_ARM_ATSAM_POWER_H */
atsam_power_control
Control structure for power control handling.
Definition
power.h:60
atsam_power_control::handler
void(*) handler(const struct atsam_power_control *control, atsam_power_state state)
Data pointer to the handler with its desired state.
Definition
power.h:64
control
Definition
intercom.c:87
Generated by
1.18.0