RTEMS 7.0-rc1
Loading...
Searching...
No Matches
raspberrypi-pwm.h
Go to the documentation of this file.
1/* SPDX-License-Identifier: BSD-2-Clause */
2
11/*
12 * Copyright (C) 2025 Shaunak Datar
13 *
14 * Redistribution and use in source and binary forms, with or without
15 * modification, are permitted provided that the following conditions
16 * are met:
17 * 1. Redistributions of source code must retain the above copyright
18 * notice, this list of conditions and the following disclaimer.
19 * 2. Redistributions in binary form must reproduce the above copyright
20 * notice, this list of conditions and the following disclaimer in the
21 * documentation and/or other materials provided with the distribution.
22 *
23 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
24 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
25 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
26 * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
27 * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
28 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
29 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
30 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
31 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
32 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
33 * POSSIBILITY OF SUCH DAMAGE.
34 */
35
36#ifndef LIBBSP_AARCH64_RASPBERRYPI_4_PWM_H
37#define LIBBSP_AARCH64_RASPBERRYPI_4_PWM_H
38
39#include "bsp/raspberrypi.h"
40#include "bsp/rpi-gpio.h"
41#include "bsp/utility.h"
42
43#ifdef __cplusplus
44extern "C" {
45#endif
46
47typedef enum { raspberrypi_pwm0, raspberrypi_pwm1 } raspberrypi_pwm_channel;
48
49typedef enum {
50 raspberrypi_pwm_master0,
51 raspberrypi_pwm_master1
52} raspberrypi_pwm_master;
53
58#define C_MSEN2 BSP_BIT32( 15 )
59#define C_USEF2 BSP_BIT32( 13 )
60#define C_POLA2 BSP_BIT32( 12 )
61#define C_SBIT2 BSP_BIT32( 11 )
62#define C_RPTL2 BSP_BIT32( 10 )
63#define C_MODE2 BSP_BIT32( 9 )
64#define C_PWEN2 BSP_BIT32( 8 )
65#define C_MSEN1 BSP_BIT32( 7 )
66#define C_CLRF BSP_BIT32( 6 )
67#define C_USEF1 BSP_BIT32( 5 )
68#define C_POLA1 BSP_BIT32( 4 )
69#define C_SBIT1 BSP_BIT32( 3 )
70#define C_RPTL1 BSP_BIT32( 2 )
71#define C_MODE1 BSP_BIT32( 1 )
72#define C_PWEN1 BSP_BIT32( 0 )
81rtems_status_code rpi_pwm_set_clock( uint32_t divisor );
82
92 raspberrypi_pwm_master master,
93 raspberrypi_pwm_channel channel,
94 uint32_t data
95);
96
108 raspberrypi_pwm_master master,
109 raspberrypi_pwm_channel channel,
110 uint32_t range,
111 uint32_t data
112);
113
114#ifdef __cplusplus
115}
116#endif /* __cplusplus */
117
118#endif /* LIBBSP_AARCH64_RASPBERRYPI_4_PWM_H */
rtems_status_code
This enumeration provides status codes for directives of the Classic API.
Definition: status.h:85
This header file provides utility macros for BSPs.
rtems_status_code rpi_pwm_set_data(raspberrypi_pwm_master master, raspberrypi_pwm_channel channel, uint32_t data)
Update duty-cycle register.
Definition: raspberrypi-pwm.c:113
rtems_status_code rpi_pwm_set_clock(uint32_t divisor)
Set PWM clock divider.
Definition: raspberrypi-pwm.c:54
rtems_status_code rpi_pwm_init(raspberrypi_pwm_master master, raspberrypi_pwm_channel channel, uint32_t range, uint32_t data)
Main PWM initialization function. This functions sets up the PWM master, channel, duty cycle and GPIO...
Definition: raspberrypi-pwm.c:164