mirror of
https://github.com/PX4/PX4-Autopilot.git
synced 2026-06-04 21:23:57 +08:00
PX4 System change to Remove #ifdefs from the IO timers
Update the comment, to explain how to achive a different perescale value. Added PX4_IO_TIMER_ALTERNATE_RATE one board agnostic ifdef PX4_IO_TIMER_ALTERNATE_RATE that is non board specific. N.B. I would like to eliminate PX4_IO_TIMER_ALTERNATE_RATE as well, but I need crazyflie HW to validate that the startup script can just set the rate on the PWM to 3921 fast enough to not effect the motors.
This commit is contained in:
committed by
Lorenz Meier
parent
b2b9a0be9f
commit
2d451991af
@@ -379,11 +379,15 @@ static int allocate_channel(unsigned channel, io_timer_channel_mode_t mode)
|
|||||||
|
|
||||||
static int timer_set_rate(unsigned timer, unsigned rate)
|
static int timer_set_rate(unsigned timer, unsigned rate)
|
||||||
{
|
{
|
||||||
#if defined(CONFIG_ARCH_BOARD_CRAZYFLIE)
|
#if defined(PX4_IO_TIMER_ALTERNATE_RATE)
|
||||||
/* configure the timer to update at 328.125 kHz (recommended) */
|
|
||||||
rARR(timer) = 255;
|
/* Override the rate to a constant that could be provided by the board */
|
||||||
|
|
||||||
|
rARR(timer) = PX4_IO_TIMER_ALTERNATE_RATE;
|
||||||
#else
|
#else
|
||||||
|
|
||||||
/* configure the timer to update at the desired rate */
|
/* configure the timer to update at the desired rate */
|
||||||
|
|
||||||
rARR(timer) = 1000000 / rate;
|
rARR(timer) = 1000000 / rate;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
@@ -432,15 +436,12 @@ int io_timer_init_timer(unsigned timer)
|
|||||||
rBDTR(timer) = ATIM_BDTR_MOE;
|
rBDTR(timer) = ATIM_BDTR_MOE;
|
||||||
}
|
}
|
||||||
|
|
||||||
#if defined(CONFIG_ARCH_BOARD_CRAZYFLIE)
|
/* If the timer clock source provided as clock_freq is the STM32_APBx_TIMx_CLKIN
|
||||||
/* configure the timer to free-run at timer frequency */
|
* then configure the timer to free-run at 1MHz.
|
||||||
rPSC(timer) = 0;
|
* Otherwize, other frequencies are attainable by adjusting .clock_freq accordingly.
|
||||||
#else
|
*/
|
||||||
/* configure the timer to free-run at 1MHz */
|
|
||||||
|
|
||||||
rPSC(timer) = (io_timers[timer].clock_freq / 1000000) - 1;
|
rPSC(timer) = (io_timers[timer].clock_freq / 1000000) - 1;
|
||||||
#endif
|
|
||||||
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Note we do the Standard PWM Out init here
|
* Note we do the Standard PWM Out init here
|
||||||
|
|||||||
@@ -37,8 +37,9 @@
|
|||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include <nuttx/config.h>
|
#include <px4_config.h>
|
||||||
|
|
||||||
|
#include <board_config.h>
|
||||||
|
|
||||||
#include <sys/types.h>
|
#include <sys/types.h>
|
||||||
#include <stdint.h>
|
#include <stdint.h>
|
||||||
@@ -60,7 +61,6 @@
|
|||||||
#include <drivers/stm32/drv_io_timer.h>
|
#include <drivers/stm32/drv_io_timer.h>
|
||||||
|
|
||||||
|
|
||||||
#include <board_config.h>
|
|
||||||
|
|
||||||
#if defined(BOARD_HAS_LED_PWM)
|
#if defined(BOARD_HAS_LED_PWM)
|
||||||
#define REG(_tmr, _reg) (*(volatile uint32_t *)(led_pwm_timers[_tmr].base + _reg))
|
#define REG(_tmr, _reg) (*(volatile uint32_t *)(led_pwm_timers[_tmr].base + _reg))
|
||||||
|
|||||||
Reference in New Issue
Block a user