1
0
mirror of https://bitbucket.org/librepilot/librepilot.git synced 2024-11-28 06:24:10 +01:00

LP-512 Cleaned up buzzer configuration and usage for boards with dedicated buzzer port.

This commit is contained in:
Vladimir Zidar 2017-06-01 18:10:08 +02:00
parent e8b7aacd99
commit 8ddd8a029e
14 changed files with 85 additions and 30 deletions

View File

@ -42,6 +42,18 @@
#define ALARM_LED_OFF()
#endif
#ifdef PIOS_BUZZER_ALARM
#define ALARM_BUZZER_ON() \
{ if (buzzer_enabled) { PIOS_LED_On(PIOS_BUZZER_ALARM); } \
}
#define ALARM_BUZZER_OFF() \
{ if (buzzer_enabled) { PIOS_LED_Off(PIOS_BUZZER_ALARM); } \
}
#else
#define ALARM_BUZZER_ON()
#define ALARM_BUZZER_OFF()
#endif
#ifdef PIOS_LED_HEARTBEAT
#define HEARTBEAT_LED_ON() PIOS_LED_On(PIOS_LED_HEARTBEAT)
#define HEARTBEAT_LED_OFF() PIOS_LED_Off(PIOS_LED_HEARTBEAT)
@ -135,9 +147,10 @@ static volatile FlightStatusData currentFlightStatus;
static volatile bool started = false;
static volatile pios_notify_notification nextNotification = NOTIFY_NONE;
#ifdef PIOS_LED_ALARM
#if defined(PIOS_LED_ALARM) || defined(PIOS_BUZZER_ALARM)
static bool handleAlarms(uint16_t *r_pattern, uint16_t *b_pattern);
#endif // PIOS_LED_ALARM
#endif // PIOS_LED_ALARM || PIOS_BUZZER_ALARM
static bool handleNotifications(pios_notify_notification runningNotification, uint16_t *r_pattern, uint16_t *b_pattern);
static void handleFlightMode(uint16_t *r_pattern, uint16_t *b_pattern);
static void handleHeartbeat(uint16_t *r_pattern, uint16_t *b_pattern);
@ -163,6 +176,10 @@ void NotificationOnboardLedsRun()
static uint8_t lastFlightMode = -1;
static bool forceShowFlightMode = false;
static pios_notify_notification runningNotification = NOTIFY_NONE;
#ifdef PIOS_BUZZER_ALARM
static bool buzzer_enabled = false;
#endif
static enum {
STATUS_NOTIFY,
STATUS_ALARM,
@ -206,6 +223,7 @@ void NotificationOnboardLedsRun()
if (cycleCount & 0x10) {
HEARTBEAT_LED_OFF();
ALARM_LED_OFF();
ALARM_BUZZER_OFF();
cycleCount = 0x0;
forceShowFlightMode = false;
// Notification has been just shown, cleanup
@ -213,6 +231,9 @@ void NotificationOnboardLedsRun()
runningNotification = NOTIFY_NONE;
}
status = (status + 1) % STATUS_LENGHT;
#ifdef PIOS_BUZZER_ALARM
buzzer_enabled = true; /* This is the place where we update buzzer_enabled status based on (not yet implemented) NotificationSettings.Buzzer config */
#endif
}
if (status == STATUS_NOTIFY) {
@ -224,7 +245,7 @@ void NotificationOnboardLedsRun()
// Handles Alarm display
if (status == STATUS_ALARM) {
#ifdef PIOS_LED_ALARM
#if defined(PIOS_LED_ALARM) || defined(PIOS_BUZZER_ALARM)
if (!cycleCount && !handleAlarms(&r_pattern, &b_pattern)) {
// no alarms, advance
status++;
@ -252,14 +273,16 @@ void NotificationOnboardLedsRun()
}
if (r_pattern & 0x1) {
ALARM_LED_ON();
ALARM_BUZZER_ON();
} else {
ALARM_LED_OFF();
ALARM_BUZZER_OFF();
}
r_pattern >>= 1;
b_pattern >>= 1;
}
#if defined(PIOS_LED_ALARM)
#if defined(PIOS_LED_ALARM) || defined(PIOS_BUZZER_ALARM)
static bool handleAlarms(uint16_t *r_pattern, uint16_t *b_pattern)
{
if (currentAlarmLevel == SYSTEMALARMS_ALARM_OK) {
@ -269,7 +292,7 @@ static bool handleAlarms(uint16_t *r_pattern, uint16_t *b_pattern)
*r_pattern = BLINK_R_ALARM_PATTERN(currentAlarmLevel);
return true;
}
#endif /* PIOS_LED_ALARM */
#endif /* PIOS_LED_ALARM || PIOS_BUZZER_ALARM */
static bool handleNotifications(pios_notify_notification runningNotification, uint16_t *r_pattern, uint16_t *b_pattern)

View File

@ -124,12 +124,17 @@ int32_t PIOS_SYS_Reset(void)
PIOS_IRQ_Disable();
// turn off all board LEDs
#if defined(PIOS_LED_HEARTBEAT)
#ifdef PIOS_INCLUDE_LED
# ifdef PIOS_LED_HEARTBEAT
PIOS_LED_Off(PIOS_LED_HEARTBEAT);
#endif /* PIOS_LED_HEARTBEAT */
#if defined(PIOS_LED_ALARM)
# endif /* PIOS_LED_HEARTBEAT */
# ifdef PIOS_LED_ALARM
PIOS_LED_Off(PIOS_LED_ALARM);
#endif /* PIOS_LED_ALARM */
# endif /* PIOS_LED_ALARM */
# ifdef PIOS_BUZZER_ALARM
PIOS_LED_Off(PIOS_BUZZER_ALARM);
# endif /* PIOS_BUZZER_ALARM */
#endif /* PIOS_INCLUDE_LED */
/* Reset STM32 */
NVIC_SystemReset();

View File

@ -97,12 +97,17 @@ int32_t PIOS_SYS_Reset(void)
PIOS_IRQ_Disable();
// turn off all board LEDs
#if defined(PIOS_LED_HEARTBEAT)
#ifdef PIOS_INCLUDE_LED
# ifdef PIOS_LED_HEARTBEAT
PIOS_LED_Off(PIOS_LED_HEARTBEAT);
#endif /* PIOS_LED_HEARTBEAT */
#if defined(PIOS_LED_ALARM)
# endif /* PIOS_LED_HEARTBEAT */
# ifdef PIOS_LED_ALARM
PIOS_LED_Off(PIOS_LED_ALARM);
#endif /* PIOS_LED_ALARM */
# endif /* PIOS_LED_ALARM */
# ifdef PIOS_BUZZER_ALARM
PIOS_LED_Off(PIOS_BUZZER_ALARM);
# endif /* PIOS_BUZZER_ALARM */
#endif /* PIOS_INCLUDE_LED */
RCC_APB2PeriphResetCmd(0xffffffff, DISABLE);
RCC_APB1PeriphResetCmd(0xffffffff, DISABLE);

View File

@ -155,13 +155,17 @@ int32_t PIOS_SYS_Reset(void)
PIOS_IRQ_Disable();
// turn off all board LEDs
#if defined(PIOS_INCLUDE_LED) && defined(PIOS_LED_HEARTBEAT)
#ifdef PIOS_INCLUDE_LED
# ifdef PIOS_LED_HEARTBEAT
PIOS_LED_Off(PIOS_LED_HEARTBEAT);
#endif /* PIOS_LED_HEARTBEAT */
#if defined(PIOS_INCLUDE_LED) && defined(PIOS_LED_ALARM)
# endif /* PIOS_LED_HEARTBEAT */
# ifdef PIOS_LED_ALARM
PIOS_LED_Off(PIOS_LED_ALARM);
#endif /* PIOS_LED_ALARM */
# endif /* PIOS_LED_ALARM */
# ifdef PIOS_BUZZER_ALARM
PIOS_LED_Off(PIOS_BUZZER_ALARM);
# endif /* PIOS_BUZZER_ALARM */
#endif /* PIOS_INCLUDE_LED */
/* XXX F10x port resets most (but not all) peripherals ... do we care? */
/* Reset STM32 */

View File

@ -204,12 +204,17 @@ int32_t PIOS_SYS_Reset(void)
PIOS_IRQ_Disable();
// turn off all board LEDs
#if defined(PIOS_LED_HEARTBEAT)
#ifdef PIOS_INCLUDE_LED
# ifdef PIOS_LED_HEARTBEAT
PIOS_LED_Off(PIOS_LED_HEARTBEAT);
#endif /* PIOS_LED_HEARTBEAT */
#if defined(PIOS_LED_ALARM)
# endif /* PIOS_LED_HEARTBEAT */
# ifdef PIOS_LED_ALARM
PIOS_LED_Off(PIOS_LED_ALARM);
#endif /* PIOS_LED_ALARM */
# endif /* PIOS_LED_ALARM */
# ifdef PIOS_BUZZER_ALARM
PIOS_LED_Off(PIOS_BUZZER_ALARM);
# endif /* PIOS_BUZZER_ALARM */
#endif /* PIOS_INCLUDE_LED */
/* XXX F10x port resets most (but not all) peripherals ... do we care? */

View File

@ -53,7 +53,7 @@ static const struct pios_gpio pios_leds[] = {
},
.active_low = true
},
[PIOS_LED_BUZZER] = { /* not really LED, but buzzer! */
[PIOS_BUZZER_ALARM] = {
.pin = {
.gpio = GPIOA,
.init = {

View File

@ -86,7 +86,7 @@
// ------------------------
#define PIOS_LED_HEARTBEAT 0
#define PIOS_LED_ALARM 1
#define PIOS_LED_BUZZER 2
#define PIOS_BUZZER_ALARM 2
// -------------------------
// System Settings

View File

@ -44,7 +44,19 @@ static const struct pios_gpio pios_leds[] = {
.GPIO_PuPd = GPIO_PuPd_NOPULL,
},
},
// .remap = GPIO_Remap_SWJ_JTAGDisable,
.active_low = false
},
[PIOS_BUZZER_ALARM] = {
.pin = {
.gpio = GPIOC,
.init = {
.GPIO_Pin = GPIO_Pin_15,
.GPIO_Mode = GPIO_Mode_OUT,
.GPIO_OType = GPIO_OType_PP,
.GPIO_Speed = GPIO_Speed_50MHz,
.GPIO_PuPd = GPIO_PuPd_NOPULL,
},
},
.active_low = false
},
};

View File

@ -84,6 +84,7 @@
// PIOS_LED
// ------------------------
#define PIOS_LED_HEARTBEAT 0
#define PIOS_BUZZER_ALARM 1
// -------------------------
// System Settings

View File

@ -44,7 +44,7 @@ static const struct pios_gpio pios_leds[] = {
},
.active_low = true
},
[PIOS_LED_ALARM] = { /* not really LED, but buzzer! */
[PIOS_BUZZER_ALARM] = {
.pin = {
.gpio = GPIOC,
.init = {

View File

@ -85,7 +85,7 @@
// PIOS_LED
// ------------------------
#define PIOS_LED_HEARTBEAT 0
#define PIOS_LED_ALARM 1
#define PIOS_BUZZER_ALARM 1
// -------------------------
// System Settings

View File

@ -53,7 +53,7 @@ static const struct pios_gpio pios_leds[] = {
},
.active_low = false
},
[PIOS_LED_BUZZER] = { /* not really LED, but buzzer! (or PB2 ??) */
[PIOS_BUZZER_ALARM] = { /* (or PB2 ??) */
.pin = {
.gpio = GPIOC,
.init = {

View File

@ -63,7 +63,7 @@ uintptr_t pios_user_fs_id = 0;
uint32_t pios_ws2811_id;
#endif
void FlightBatterySettingsDataOverrideDefaults(FlightBatterySettingsData * data)
void FlightBatterySettingsDataOverrideDefaults(FlightBatterySettingsData *data)
{
data->SensorCalibrations.VoltageFactor = 8.8f;
data->SensorCalibrations.CurrentFactor = 0.07f;

View File

@ -58,7 +58,7 @@
// ------------------------
#define PIOS_LED_HEARTBEAT 0
#define PIOS_LED_ALARM 1
#define PIOS_LED_BUZZER 2
#define PIOS_BUZZER_ALARM 2
// -------------------------
// System Settings