summaryrefslogtreecommitdiff
path: root/firmware/target/mips/ingenic_x1000/pwm-x1000.h
diff options
context:
space:
mode:
Diffstat (limited to 'firmware/target/mips/ingenic_x1000/pwm-x1000.h')
-rw-r--r--firmware/target/mips/ingenic_x1000/pwm-x1000.h47
1 files changed, 47 insertions, 0 deletions
diff --git a/firmware/target/mips/ingenic_x1000/pwm-x1000.h b/firmware/target/mips/ingenic_x1000/pwm-x1000.h
new file mode 100644
index 0000000000..0cea266d63
--- /dev/null
+++ b/firmware/target/mips/ingenic_x1000/pwm-x1000.h
@@ -0,0 +1,47 @@
1/***************************************************************************
2 * __________ __ ___.
3 * Open \______ \ ____ ____ | | _\_ |__ _______ ___
4 * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
5 * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
6 * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
7 * \/ \/ \/ \/ \/
8 * $Id$
9 *
10 * Copyright (C) 2021 Aidan MacDonald
11 *
12 * This program is free software; you can redistribute it and/or
13 * modify it under the terms of the GNU General Public License
14 * as published by the Free Software Foundation; either version 2
15 * of the License, or (at your option) any later version.
16 *
17 * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
18 * KIND, either express or implied.
19 *
20 ****************************************************************************/
21
22#ifndef __PWM_X1000_H__
23#define __PWM_X1000_H__
24
25/* Usage:
26 * - There are 5 PWM channels (0-4) corresponding to TCUs 0-4
27 * - Call pwm_init(n) before using channel n
28 * - Call pwm_set_period() to change the period and duty cycle at any time
29 * - Call pwm_enable() and pwm_disable() to turn the output on and off
30 * - Don't allow two threads to control the same channel at the same time
31 * - Don't call pwm_init(), pwm_enable(), or pwm_disable() from an interrupt
32 *
33 * After calling pwm_init(), the channel is essentially in a disabled state so
34 * you will need to call pwm_set_period() and then pwm_enable() to turn it on.
35 * Don't alter the channel's TCU or GPIO pin state after calling pwm_init().
36 *
37 * After calling pwm_disable(), it is safe to use the channel's TCU or GPIO pin
38 * for some other purpose, but you must call pwm_init() before you can use the
39 * channel as PWM output again.
40 */
41
42extern void pwm_init(int chn);
43extern void pwm_set_period(int chn, int period_ns, int duty_ns);
44extern void pwm_enable(int chn);
45extern void pwm_disable(int chn);
46
47#endif /* __PWM_X1000_H__ */