Landfall

Annotated pkg/devices/lib/pwm/include/pwm-jz4730.h

0:89a1bc19c1fc
2018-05-13 Paul Boddie Added device libraries and programs, configuration files and examples. Also added an installation script and copyright and licensing information.
paul@0 1
/*
paul@0 2
 * (c) 2018 Paul Boddie <paul@boddie.org.uk>
paul@0 3
 *
paul@0 4
 * This program is free software; you can redistribute it and/or
paul@0 5
 * modify it under the terms of the GNU General Public License as
paul@0 6
 * published by the Free Software Foundation; either version 2 of
paul@0 7
 * the License, or (at your option) any later version.
paul@0 8
 *
paul@0 9
 * This program is distributed in the hope that it will be useful,
paul@0 10
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
paul@0 11
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
paul@0 12
 * GNU General Public License for more details.
paul@0 13
 *
paul@0 14
 * You should have received a copy of the GNU General Public License
paul@0 15
 * along with this program; if not, write to the Free Software
paul@0 16
 * Foundation, Inc., 51 Franklin Street, Fifth Floor,
paul@0 17
 * Boston, MA  02110-1301, USA
paul@0 18
 */
paul@0 19
paul@0 20
#pragma once
paul@0 21
paul@0 22
#include <l4/sys/types.h>
paul@0 23
#include <stdint.h>
paul@0 24
paul@0 25
paul@0 26
paul@0 27
/* Value types. */
paul@0 28
paul@0 29
enum Jz4730_pwm_shutdown_mode
paul@0 30
{
paul@0 31
  Jz4730_pwm_shutdown_graceful = 0,
paul@0 32
  Jz4730_pwm_shutdown_abrupt = 1,
paul@0 33
};
paul@0 34
paul@0 35
paul@0 36
paul@0 37
#ifdef __cplusplus
paul@0 38
paul@0 39
#include <l4/devices/hw_register_block.h>
paul@0 40
paul@0 41
/* A simple abstraction for accessing the PWM registers. */
paul@0 42
paul@0 43
class Pwm_jz4730_chip
paul@0 44
{
paul@0 45
private:
paul@0 46
  l4_addr_t _start, _end;
paul@0 47
  Hw::Register_block<32> _regs;
paul@0 48
paul@0 49
public:
paul@0 50
  Pwm_jz4730_chip(l4_addr_t start, l4_addr_t end);
paul@0 51
paul@0 52
  void disable();
paul@0 53
  void enable();
paul@0 54
  void set_shutdown_mode(enum Jz4730_pwm_shutdown_mode mode);
paul@0 55
paul@0 56
  void set_control(uint8_t control);
paul@0 57
  void set_duty(uint16_t duty);
paul@0 58
  void set_period(uint16_t period);
paul@0 59
};
paul@0 60
paul@0 61
#endif /* __cplusplus */
paul@0 62
paul@0 63
paul@0 64
paul@0 65
/* C language interface. */
paul@0 66
paul@0 67
EXTERN_C_BEGIN
paul@0 68
paul@0 69
void *jz4730_pwm_init(l4_addr_t start, l4_addr_t end);
paul@0 70
paul@0 71
void jz4730_pwm_disable(void *pwm);
paul@0 72
void jz4730_pwm_enable(void *pwm);
paul@0 73
void jz4730_pwm_set_shutdown_mode(void *pwm, enum Jz4730_pwm_shutdown_mode mode);
paul@0 74
paul@0 75
void jz4730_pwm_set_control(void *pwm, uint8_t control);
paul@0 76
void jz4730_pwm_set_duty(void *pwm, uint16_t duty);
paul@0 77
void jz4730_pwm_set_period(void *pwm, uint16_t period);
paul@0 78
paul@0 79
EXTERN_C_END