Skip to content

Commit 7e03ea0

Browse files
committed
pbio/drv/pwm/pwm_ev3: Reimplement using PRU
1 parent 967009e commit 7e03ea0

File tree

2 files changed

+7
-10
lines changed

2 files changed

+7
-10
lines changed

lib/pbio/drv/pwm/pwm_ev3.c

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,12 @@ typedef struct shared_ram {
3232
static volatile shared_ram *const pru1_shared_ram = (volatile shared_ram *)PRU1_SHARED_RAM_ADDR;
3333

3434
static pbio_error_t pbdrv_pwm_tiam1808_set_duty(pbdrv_pwm_dev_t *dev, uint32_t ch, uint32_t value) {
35-
// TODO: Reimplement this function to use the PRU
35+
// Blue not available.
36+
if (ch == 0xff) {
37+
return PBIO_SUCCESS;
38+
}
39+
40+
pru1_shared_ram->pwms[ch] = value;
3641
return PBIO_SUCCESS;
3742
}
3843

@@ -52,12 +57,6 @@ void pbdrv_pwm_tiam1808_init(pbdrv_pwm_dev_t *devs) {
5257
TimerPeriodSet(SOC_TMR_0_REGS, TMR_TIMER34, 256 * 256 - 1);
5358
TimerEnable(SOC_TMR_0_REGS, TMR_TIMER34, TMR_ENABLE_CONT);
5459

55-
// TODO: Remove this test code
56-
pru1_shared_ram->pwms[0] = 0x20; // R
57-
pru1_shared_ram->pwms[1] = 0xc0; // G
58-
pru1_shared_ram->pwms[2] = 0x10; // R
59-
pru1_shared_ram->pwms[3] = 0xf0; // G
60-
6160
// Enable PRU1 and load its firmware
6261
PSCModuleControl(SOC_PSC_0_REGS, HW_PSC_PRU, PSC_POWERDOMAIN_ALWAYS_ON, PSC_MDCTL_NEXT_ENABLE);
6362
PRUSSDRVPruDisable(1);

lib/pbio/platform/ev3/platform.c

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,7 @@ const pbdrv_led_dual_platform_data_t pbdrv_led_dual_platform_data[PBDRV_CONFIG_L
8686
};
8787

8888
static const pbdrv_led_pwm_platform_color_t pbdrv_led_pwm_color = {
89-
// TODO: PWM not yet implemented, so these values not used.
89+
// TODO: Calibrate these numbers, as well as .scale_factor
9090
.r_factor = 1000,
9191
.g_factor = 170,
9292
.b_factor = 200,
@@ -106,7 +106,6 @@ const pbdrv_led_pwm_platform_data_t pbdrv_led_pwm_platform_data[PBDRV_CONFIG_LED
106106
// Blue not available.
107107
.b_id = PWM_DEV_0,
108108
.b_ch = 0xff,
109-
// TODO: PWM not yet implemented, so these values not used.
110109
.scale_factor = 35,
111110
},
112111
{
@@ -119,7 +118,6 @@ const pbdrv_led_pwm_platform_data_t pbdrv_led_pwm_platform_data[PBDRV_CONFIG_LED
119118
// Blue not available.
120119
.b_id = PWM_DEV_0,
121120
.b_ch = 0xff,
122-
// TODO: PWM not yet implemented, so these values not used.
123121
.scale_factor = 35,
124122
},
125123
};

0 commit comments

Comments
 (0)