CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutSign UpSign In
Ardupilot

Real-time collaboration for Jupyter Notebooks, Linux Terminals, LaTeX, VS Code, R IDE, and more,
all in one place. Commercial Alternative to JupyterHub.

GitHub Repository: Ardupilot/ardupilot
Path: blob/master/Tools/Linux_HAL_Essentials/pru/pwmpru/prucomm.h
Views: 1800
1
/*
2
* prucomm.h - structure definitions for communication
3
*
4
*/
5
#pragma once
6
7
#include "pru_defs.h"
8
9
struct pwm_config {
10
u32 hi_cycles;
11
u32 hi_err;
12
u32 lo_cycles;
13
u32 lo_err;
14
};
15
16
/* maximum (PRU0 + PRU1) */
17
#define MAX_PWMS 12
18
19
/* mask of the possibly enabled PWMs (due to h/w) */
20
/* 14, 15 are not routed out for PRU1 */
21
#define PWM_EN_MASK ( \
22
BIT( 0)|BIT( 1)|BIT( 2)|BIT( 3)|BIT( 4)|BIT( 5)|BIT( 6)|BIT( 7)| \
23
BIT( 8)|BIT( 9)|BIT(10)|BIT(11)|BIT(12) \
24
)
25
26
#define MIN_PWM_PULSE PRU_us(4)
27
28
struct pwm_multi_config {
29
u32 enmask; /* enable mask */
30
u32 offmsk; /* state when pwm is off */
31
u32 hilo[MAX_PWMS][2];
32
};
33
34
#define PWM_CMD_MAGIC 0xf00fbaaf
35
#define PWM_REPLY_MAGIC 0xbaaff00f
36
#define PWM_CMD_CONFIG 0 /* full configuration in one go */
37
#define PWM_CMD_ENABLE 1 /* enable a pwm */
38
#define PWM_CMD_DISABLE 2 /* disable a pwm */
39
#define PWM_CMD_MODIFY 3 /* modify a pwm */
40
#define PWM_CMD_SET 4 /* set a pwm output explicitly */
41
#define PWM_CMD_CLR 5 /* clr a pwm output explicitly */
42
#define PWM_CMD_TEST 6 /* various crap */
43
44
struct pwm_cmd {
45
u32 magic;
46
u32 enmask; /* enable mask */
47
u32 offmsk; /* state when pwm is off */
48
u32 periodhi[MAX_PWMS][2];
49
u32 hilo_read[MAX_PWMS][2];
50
u32 enmask_read;
51
};
52
struct pwm_cmd_l{
53
u32 enmask;
54
u32 offmsk;
55
u32 hilo[MAX_PWMS][2];
56
};
57
58
59
struct cxt {
60
u32 cnt;
61
u32 next;
62
u32 enmask;
63
u32 stmask;
64
u32 setmsk;
65
u32 clrmsk;
66
u32 deltamin;
67
u32 *next_hi_lo;
68
};
69
70
71
/* the command is at the start of shared DPRAM */
72
#define PWM_CMD ((volatile struct pwm_cmd *)DPRAM_SHARED)
73
74