1
0
mirror of https://bitbucket.org/librepilot/librepilot.git synced 2025-02-20 10:54:14 +01:00

REVONANO - Add support for WS2811 led on servo output 1.

To free timer1, a unused timer (9) is assigned on the fly to servo out 1 to leave pin mappings unchanged. A better approach should be implemented Later (jira 1035)
This commit is contained in:
Alessio Morale 2015-05-03 22:01:43 +02:00
parent 28ffaa068f
commit d521ce6023
4 changed files with 22 additions and 15 deletions

View File

@ -961,7 +961,10 @@ static const struct pios_tim_clock_cfg tim_3_cfg = {
*/
#include <pios_servo_priv.h>
#include <pios_servo_config.h>
static const struct pios_tim_channel pios_tim_servoport_all_pins[] = {
static const struct pios_tim_channel dummmy_timer =
TIM_SERVO_CHANNEL_CONFIG(TIM9, 1, E, 5); // dummy unused timer + gpio. Hack to free tim1
static struct pios_tim_channel pios_tim_servoport_all_pins[] = {
// TIMER, CHANNEL, GPIO, PIN
TIM_SERVO_CHANNEL_CONFIG(TIM1, 3, A, 10),
TIM_SERVO_CHANNEL_CONFIG(TIM2, 2, B, 3),
@ -1176,9 +1179,9 @@ void DMA2_Stream1_IRQHandler(void) __attribute__((alias("PIOS_WS2811_irq_handler
// pins will be reconfigured as _OUT so the alternate function is disabled.
const struct pios_ws2811_pin_cfg pios_ws2811_pin_cfg[] = {
[HWSETTINGS_WS2811LED_OUT_SERVOOUT1] = {
.gpio = GPIOB,
.gpio = GPIOA,
.gpioInit = {
.GPIO_Pin = GPIO_Pin_0,
.GPIO_Pin = GPIO_Pin_10,
.GPIO_Speed = GPIO_Speed_25MHz,
.GPIO_Mode = GPIO_Mode_OUT,
.GPIO_OType = GPIO_OType_PP,

View File

@ -48,6 +48,7 @@ MODULES += PathFollower
#MODULES += Osd/osdoutout
#MODULES += Logging
MODULES += Telemetry
MODULES += Notify
OPTMODULES += ComUsbBridge
@ -90,7 +91,7 @@ ifndef TESTAPP
SRC += $(FLIGHTLIB)/WorldMagModel.c
SRC += $(FLIGHTLIB)/insgps13state.c
CPPSRC += $(FLIGHTLIB)/mini_cpp.cpp
SRC += $(FLIGHTLIB)/lednotification.c
SRC += $(FLIGHTLIB)/auxmagsupport.c
## UAVObjects
include ./UAVObjects.inc

View File

@ -97,7 +97,7 @@
#define PIOS_SENSOR_RATE 500.0f
// #define PIOS_INCLUDE_WS2811
#define PIOS_INCLUDE_WS2811
/* #define PIOS_INCLUDE_HCSR04 */

View File

@ -696,6 +696,19 @@ void PIOS_Board_Init(void)
pios_rcvr_group_map[MANUALCONTROLSETTINGS_CHANNELGROUPS_GCS] = pios_gcsrcvr_rcvr_id;
#endif /* PIOS_INCLUDE_GCSRCVR */
#ifdef PIOS_INCLUDE_WS2811
#include <pios_ws2811.h>
HwSettingsWS2811LED_OutOptions ws2811_pin_settings;
HwSettingsWS2811LED_OutGet(&ws2811_pin_settings);
// No other choices but servo pin 1 on nano
if (ws2811_pin_settings != HWSETTINGS_WS2811LED_OUT_DISABLED) {
pios_tim_servoport_all_pins[0] = dummmy_timer; // free timer 1
PIOS_WS2811_Init(&pios_ws2811_cfg, &pios_ws2811_pin_cfg[0]);
}
#endif // PIOS_INCLUDE_WS2811
#ifndef PIOS_ENABLE_DEBUG_PINS
// pios_servo_cfg points to the correct configuration based on input port settings
PIOS_Servo_Init(pios_servo_cfg);
@ -721,16 +734,6 @@ void PIOS_Board_Init(void)
PIOS_MS5611_Register();
#endif
#ifdef PIOS_INCLUDE_WS2811
#include <pios_ws2811.h>
HwSettingsWS2811LED_OutOptions ws2811_pin_settings;
HwSettingsWS2811LED_OutGet(&ws2811_pin_settings);
if (ws2811_pin_settings != HWSETTINGS_WS2811LED_OUT_DISABLED && ws2811_pin_settings < NELEMENTS(pios_ws2811_pin_cfg)) {
PIOS_WS2811_Init(&pios_ws2811_cfg, &pios_ws2811_pin_cfg[ws2811_pin_settings]);
}
#endif // PIOS_INCLUDE_WS2811
#ifdef PIOS_INCLUDE_ADC
uint8_t adc_config[HWSETTINGS_ADCROUTING_NUMELEM];
HwSettingsADCRoutingArrayGet(adc_config);