Separating the PWM C platform ops

classic Classic list List threaded Threaded
2 messages Options
Martin Guy Martin Guy
Reply | Threaded
Open this post in threaded view
|

Separating the PWM C platform ops

Hi, sorry about all this mail, I tend to work on stuff in bursts

Following the splitting of platform_adc_op( id, OPERATION, data) into
6 separate functions, here's the same thing for the 4 similar PWM ops.

It replaces platform_pwm_op( id, op, data ) where
op==PLATFORM_PWM_OP_SET_CLOCK took a frequency and returned a frequency
op==PLATFORM_PWM_OP_GET_CLOCK took nothing returned a frequency
op==PLATFORM_PWM_OP_START and _STOP both took nothing and returned nothing

with
clock = platform_pwm_set_clock( id, clock)
clock = platform_pwm_get_clock( id )
platform_pwm_start( id ) and
platform_pwm_stop( id )

with resulting clarity in the documentation and smaller, faster code.

This does not affect the Lau interface.

I'd appreciate it if the attached patch could be tested on some
platforms other than the avr32s I have.
I've tested compilation of all supported boards except PC and SIM
(which do not have PWM).

My main doubt is on at91sam7x, where I had to replace some lines that
read a machine register whose value was never used.
Before, the compiler was fooled into not optimizing it out by
returning it as the value of a function that was always ignored:
res = AT91C_BASE_PWMC->PWMC_ISR;
return(res)  // ignored
now I have tried to achieve the same effect with a volatile variable:
volatile u32 dummy;
dummy = AT91C_BASE_PWMC->PWMC_ISR;
but can't test this for lack of hardware.
It's in platform_pwm_stop, so if someone with an at91sam7x could test
that pwm output can be stopped and started again successfully with
this patch applied I'd be grateful.

Cheers

    M

_______________________________________________
eLua-dev mailing list
[hidden email]
https://lists.berlios.de/mailman/listinfo/elua-dev

elua-separate-pwm-ops.patch (26K) Download Attachment
jbsnyder jbsnyder
Reply | Threaded
Open this post in threaded view
|

Re: Separating the PWM C platform ops

On Sun, Jul 24, 2011 at 2:52 PM, Martin Guy <[hidden email]> wrote:

> Hi, sorry about all this mail, I tend to work on stuff in bursts
>
> Following the splitting of platform_adc_op( id, OPERATION, data) into
> 6 separate functions, here's the same thing for the 4 similar PWM ops.
>
> It replaces platform_pwm_op( id, op, data ) where
> op==PLATFORM_PWM_OP_SET_CLOCK took a frequency and returned a frequency
> op==PLATFORM_PWM_OP_GET_CLOCK took nothing returned a frequency
> op==PLATFORM_PWM_OP_START and _STOP both took nothing and returned nothing
>
> with
> clock = platform_pwm_set_clock( id, clock)
> clock = platform_pwm_get_clock( id )
> platform_pwm_start( id ) and
> platform_pwm_stop( id )
>
> with resulting clarity in the documentation and smaller, faster code.
>
> This does not affect the Lau interface.
>
> I'd appreciate it if the attached patch could be tested on some
> platforms other than the avr32s I have.
> I've tested compilation of all supported boards except PC and SIM
> (which do not have PWM).
>
> My main doubt is on at91sam7x, where I had to replace some lines that
> read a machine register whose value was never used.
> Before, the compiler was fooled into not optimizing it out by
> returning it as the value of a function that was always ignored:
> res = AT91C_BASE_PWMC->PWMC_ISR;
> return(res)  // ignored
> now I have tried to achieve the same effect with a volatile variable:
> volatile u32 dummy;
> dummy = AT91C_BASE_PWMC->PWMC_ISR;
> but can't test this for lack of hardware.
> It's in platform_pwm_stop, so if someone with an at91sam7x could test
> that pwm output can be stopped and started again successfully with
> this patch applied I'd be grateful.

I don't have an at91sam7x, but I can give it a try on stm32, lm3s & lpc.

>
> Cheers
>
>    M
>
> _______________________________________________
> eLua-dev mailing list
> [hidden email]
> https://lists.berlios.de/mailman/listinfo/elua-dev
>
>
_______________________________________________
eLua-dev mailing list
[hidden email]
https://lists.berlios.de/mailman/listinfo/elua-dev