Skip to content

Commit 6af34ee

Browse files
ArcaneNibbledlech
authored andcommitted
pbio/drv/rproc/rproc_ev3_pru1.h: Share with PRU project
This makes it much easier to keep the projects in sync.
1 parent af9c1f4 commit 6af34ee

3 files changed

Lines changed: 26 additions & 9 deletions

File tree

lib/pbio/drv/pwm/pwm_ev3.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ static pbio_error_t pbdrv_pwm_tiam1808_set_duty(pbdrv_pwm_dev_t *dev, uint32_t c
2020
return PBIO_SUCCESS;
2121
}
2222

23-
pbdrv_rproc_ev3_pru1_shared_ram.pwms[ch] = value;
23+
pbdrv_rproc_ev3_pru1_shared_ram.pwm_duty_cycle[ch] = value;
2424
return PBIO_SUCCESS;
2525
}
2626

lib/pbio/drv/rproc/rproc_ev3.h

Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -4,18 +4,11 @@
44
#ifndef _INTERNAL_PBDRV_RPROC_EV3_H_
55
#define _INTERNAL_PBDRV_RPROC_EV3_H_
66

7-
#include <stdint.h>
8-
97
// EV3 PRU interfaces and ABI
108
// These need to match the interface expected by the PRU firmware
119

1210
// PRU1 interface
13-
14-
#define PBDRV_RPROC_EV3_PRU1_NUM_PWM_CHANNELS 4
15-
16-
typedef struct {
17-
uint8_t pwms[PBDRV_RPROC_EV3_PRU1_NUM_PWM_CHANNELS];
18-
} pbdrv_rproc_ev3_pru1_shared_ram_t;
11+
#include "rproc_ev3_pru1.h"
1912

2013
extern volatile pbdrv_rproc_ev3_pru1_shared_ram_t pbdrv_rproc_ev3_pru1_shared_ram;
2114

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
// SPDX-License-Identifier: MIT
2+
// Copyright (c) 2025 The Pybricks Authors
3+
4+
#ifndef _INTERNAL_PBDRV_RPROC_EV3_PRU1_H_
5+
#define _INTERNAL_PBDRV_RPROC_EV3_PRU1_H_
6+
7+
#include <stdint.h>
8+
9+
// This file is shared between the PRU1 source code
10+
// and the Pybricks source code. It defines the ABI
11+
// between the two codebases and must be kept in sync.
12+
13+
#define PBDRV_RPROC_EV3_PRU1_NUM_PWM_CHANNELS 4
14+
15+
typedef struct {
16+
union {
17+
// u32 used by the PRU codebase to get more-efficient codegen
18+
uint32_t pwms;
19+
// PWM duty cycle for each channel, range [0-255]
20+
uint8_t pwm_duty_cycle[PBDRV_RPROC_EV3_PRU1_NUM_PWM_CHANNELS];
21+
};
22+
} pbdrv_rproc_ev3_pru1_shared_ram_t;
23+
24+
#endif // _INTERNAL_PBDRV_RPROC_EV3_PRU1_H_

0 commit comments

Comments
 (0)