66#if PBDRV_CONFIG_PWM_TIAM1808
77
88#include <stdio.h>
9+ #include <string.h>
910
1011#include <pbdrv/pwm.h>
1112#include <pbdrv/gpio.h>
1920#include <tiam1808/timer.h>
2021
2122#include "../drv/pwm/pwm.h"
23+ #include "../../drv/led/led_pwm.h"
2224#include "../../drv/pwm/pwm_ev3.h"
2325#include "../../drv/gpio/gpio_ev3.h"
2426
@@ -32,7 +34,12 @@ typedef struct shared_ram {
3234static volatile shared_ram * const pru1_shared_ram = (volatile shared_ram * )PRU1_SHARED_RAM_ADDR ;
3335
3436static 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
37+ // Blue not available.
38+ if (ch == PBDRV_LED_PWM_CHANNEL_INVALID ) {
39+ return PBIO_SUCCESS ;
40+ }
41+
42+ pru1_shared_ram -> pwms [ch ] = value ;
3643 return PBIO_SUCCESS ;
3744}
3845
@@ -52,11 +59,8 @@ void pbdrv_pwm_tiam1808_init(pbdrv_pwm_dev_t *devs) {
5259 TimerPeriodSet (SOC_TMR_0_REGS , TMR_TIMER34 , 256 * 256 - 1 );
5360 TimerEnable (SOC_TMR_0_REGS , TMR_TIMER34 , TMR_ENABLE_CONT );
5461
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
62+ // Clear shared command memory
63+ memset ((void * )pru1_shared_ram , 0 , sizeof (shared_ram ));
6064
6165 // Enable PRU1 and load its firmware
6266 PSCModuleControl (SOC_PSC_0_REGS , HW_PSC_PRU , PSC_POWERDOMAIN_ALWAYS_ON , PSC_MDCTL_NEXT_ENABLE );
0 commit comments