mirror of
https://github.com/opentx/opentx.git
synced 2025-07-24 16:55:20 +03:00
[Horus] I2C audio pot is removed in latest board!
This commit is contained in:
parent
a6a71b8650
commit
677995205d
9 changed files with 25 additions and 200 deletions
|
@ -80,7 +80,6 @@ if(PCB STREQUAL HORUS)
|
|||
sdio_sd.c
|
||||
lcd_driver.cpp
|
||||
delays.c
|
||||
i2c_driver.cpp
|
||||
usb_driver.c
|
||||
pwr_driver.c
|
||||
sdram_driver.c
|
||||
|
|
|
@ -448,7 +448,7 @@ void evalFunctions()
|
|||
break;
|
||||
#endif
|
||||
|
||||
#if defined(CPUARM) && defined(SDCARD)
|
||||
#if defined(VOLUME_CHIP)
|
||||
case FUNC_VOLUME:
|
||||
{
|
||||
getvalue_t raw = getValue(CFN_PARAM(cfn));
|
||||
|
|
|
@ -20,15 +20,15 @@
|
|||
|
||||
#include "../../opentx.h"
|
||||
|
||||
#define RADIO_SETUP_2ND_COLUMN 220
|
||||
#define YEAR_SEPARATOR_OFFSET 42
|
||||
#define MONTH_OFFSET 55
|
||||
#define MONTH_SEPARATOR_OFFSET 79
|
||||
#define DAY_OFFSET 91
|
||||
#define HOUR_SEPARATOR_OFFSET 26
|
||||
#define MINUTE_OFFSET 36
|
||||
#define MINUTE_SEPARATOR_OFFSET 63
|
||||
#define SECOND_OFFSET 75
|
||||
#define RADIO_SETUP_2ND_COLUMN 220
|
||||
#define YEAR_SEPARATOR_OFFSET 42
|
||||
#define MONTH_OFFSET 55
|
||||
#define MONTH_SEPARATOR_OFFSET 79
|
||||
#define DAY_OFFSET 91
|
||||
#define HOUR_SEPARATOR_OFFSET 26
|
||||
#define MINUTE_OFFSET 36
|
||||
#define MINUTE_SEPARATOR_OFFSET 63
|
||||
#define SECOND_OFFSET 75
|
||||
|
||||
#define SLIDER_5POS(y, value, event, attr) { \
|
||||
int8_t tmp = value; \
|
||||
|
@ -48,7 +48,6 @@ enum menuGeneralSetupItems {
|
|||
// ITEM_SETUP_BATT_RANGE,
|
||||
ITEM_SETUP_SOUND_LABEL,
|
||||
ITEM_SETUP_BEEP_MODE,
|
||||
ITEM_SETUP_SPEAKER_VOLUME,
|
||||
ITEM_SETUP_BEEP_VOLUME,
|
||||
ITEM_SETUP_BEEP_LENGTH,
|
||||
ITEM_SETUP_SPEAKER_PITCH,
|
||||
|
@ -110,7 +109,7 @@ bool menuGeneralSetup(evt_t event)
|
|||
}
|
||||
#endif
|
||||
|
||||
MENU(STR_MENURADIOSETUP, menuTabGeneral, e_Setup, ITEM_SETUP_MAX, DEFAULT_SCROLLBAR_X, { 2|NAVIGATION_LINE_BY_LINE, 2|NAVIGATION_LINE_BY_LINE, LABEL(SOUND), 0, 0, 0, 0, 0, 0, 0, CASE_VARIO(LABEL(VARIO)) CASE_VARIO(0) CASE_VARIO(0) CASE_VARIO(0) CASE_VARIO(0) CASE_HAPTIC(LABEL(HAPTIC)) CASE_HAPTIC(0) CASE_HAPTIC(0) CASE_HAPTIC(0) LABEL(ALARMS), 0, 0, 0, CASE_GPS(0) CASE_GPS(0) CASE_PXX(0) 0, 0, CASE_MAVLINK(0) 0, 0, 0, 0, 1/*to force edit mode*/ });
|
||||
MENU(STR_MENURADIOSETUP, menuTabGeneral, e_Setup, ITEM_SETUP_MAX, DEFAULT_SCROLLBAR_X, { 2|NAVIGATION_LINE_BY_LINE, 2|NAVIGATION_LINE_BY_LINE, LABEL(SOUND), 0, 0, 0, 0, 0, 0, CASE_VARIO(LABEL(VARIO)) CASE_VARIO(0) CASE_VARIO(0) CASE_VARIO(0) CASE_VARIO(0) CASE_HAPTIC(LABEL(HAPTIC)) CASE_HAPTIC(0) CASE_HAPTIC(0) CASE_HAPTIC(0) LABEL(ALARMS), 0, 0, 0, CASE_GPS(0) CASE_GPS(0) CASE_PXX(0) 0, 0, CASE_MAVLINK(0) 0, 0, 0, 0, 1/*to force edit mode*/ });
|
||||
|
||||
int sub = menuVerticalPosition;
|
||||
|
||||
|
@ -226,20 +225,6 @@ bool menuGeneralSetup(evt_t event)
|
|||
#endif
|
||||
break;
|
||||
|
||||
case ITEM_SETUP_SPEAKER_VOLUME:
|
||||
{
|
||||
lcdDrawText(MENUS_MARGIN_LEFT, y, STR_SPEAKER_VOLUME);
|
||||
uint8_t b = g_eeGeneral.speakerVolume+VOLUME_LEVEL_DEF;
|
||||
drawSlider(RADIO_SETUP_2ND_COLUMN, y, b, VOLUME_LEVEL_MAX, attr);
|
||||
if (attr) {
|
||||
CHECK_INCDEC_GENVAR(event, b, 0, VOLUME_LEVEL_MAX);
|
||||
if (checkIncDec_Ret) {
|
||||
g_eeGeneral.speakerVolume = (int8_t)b-VOLUME_LEVEL_DEF;
|
||||
}
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
case ITEM_SETUP_BEEP_VOLUME:
|
||||
lcdDrawText(MENUS_MARGIN_LEFT, y, STR_BEEP_VOLUME);
|
||||
SLIDER_5POS(y, g_eeGeneral.beepVolume, event, attr);
|
||||
|
|
|
@ -1049,7 +1049,7 @@ void evalMixes(uint8_t tick10ms)
|
|||
// must be done after mixing because some functions use the inputs/channels values
|
||||
// must be done before limits because of the applyLimit function: it checks for safety switches which would be not initialized otherwise
|
||||
if (tick10ms) {
|
||||
#if defined(CPUARM)
|
||||
#if defined(VOLUME_CHIP)
|
||||
requiredSpeakerVolume = g_eeGeneral.speakerVolume + VOLUME_LEVEL_DEF;
|
||||
#endif
|
||||
|
||||
|
|
|
@ -232,6 +232,10 @@
|
|||
|
||||
#define IS_FAI_FORBIDDEN(idx) (IS_FAI_ENABLED() && idx >= MIXSRC_FIRST_TELEM)
|
||||
|
||||
#if defined(CPUARM) && !defined(PCBHORUS)
|
||||
#define VOLUME_CHIP
|
||||
#endif
|
||||
|
||||
#if defined(SIMU)
|
||||
#ifndef FORCEINLINE
|
||||
#define FORCEINLINE
|
||||
|
|
|
@ -20,12 +20,6 @@
|
|||
|
||||
#include "../../opentx.h"
|
||||
|
||||
const int8_t volumeScale[VOLUME_LEVEL_MAX+1] =
|
||||
{
|
||||
0, 1, 2, 3, 5, 9, 13, 17, 22, 27, 33, 40,
|
||||
64, 82, 96, 105, 112, 117, 120, 122, 124, 125, 126, 127
|
||||
};
|
||||
|
||||
#if !defined(SIMU)
|
||||
bool dacIdle = true;
|
||||
|
||||
|
|
|
@ -124,22 +124,16 @@ void pinCheck(GPIO_TypeDef * gpio, uint32_t pin, uint32_t RCC_AHB1Periph)
|
|||
|
||||
void boardInit()
|
||||
{
|
||||
RCC_AHB1PeriphClockCmd(PWR_RCC_AHB1Periph | LCD_RCC_AHB1Periph | KEYS_RCC_AHB1Periph_GPIO | ADC_RCC_AHB1Periph | I2C_RCC_AHB1Periph | SERIAL_RCC_AHB1Periph | TELEMETRY_RCC_AHB1Periph | AUDIO_RCC_AHB1Periph | HAPTIC_RCC_AHB1Periph, ENABLE);
|
||||
RCC_APB1PeriphClockCmd(INTERRUPT_5MS_APB1Periph | TIMER_2MHz_APB1Periph | I2C_RCC_APB1Periph | SERIAL_RCC_APB1Periph | TELEMETRY_RCC_APB1Periph | AUDIO_RCC_APB1Periph, ENABLE);
|
||||
RCC_AHB1PeriphClockCmd(PWR_RCC_AHB1Periph | LCD_RCC_AHB1Periph | KEYS_RCC_AHB1Periph_GPIO | ADC_RCC_AHB1Periph | SERIAL_RCC_AHB1Periph | TELEMETRY_RCC_AHB1Periph | AUDIO_RCC_AHB1Periph | HAPTIC_RCC_AHB1Periph, ENABLE);
|
||||
RCC_APB1PeriphClockCmd(INTERRUPT_5MS_APB1Periph | TIMER_2MHz_APB1Periph | SERIAL_RCC_APB1Periph | TELEMETRY_RCC_APB1Periph | AUDIO_RCC_APB1Periph, ENABLE);
|
||||
RCC_APB2PeriphClockCmd(LCD_RCC_APB2Periph | ADC_RCC_APB2Periph | HAPTIC_RCC_APB2Periph, ENABLE);
|
||||
|
||||
pwrInit();
|
||||
ledInit();
|
||||
|
||||
i2cInit();
|
||||
if (getVolume() < 0)
|
||||
ledRed();
|
||||
else
|
||||
ledBlue();
|
||||
|
||||
delaysInit();
|
||||
|
||||
// ledRed();
|
||||
// FrSky removed the volume chip in latest board, that's why it doesn't answer!
|
||||
// i2cInit();
|
||||
|
||||
if (0) {
|
||||
// pinCheck(SERIAL_GPIO, SERIAL_GPIO_PIN_TX, SERIAL_RCC_AHB1Periph_GPIO);
|
||||
|
@ -150,17 +144,15 @@ void boardInit()
|
|||
|
||||
serial2Init(0, 0); // default serial mode (None if DEBUG not defined)
|
||||
|
||||
// ledBlue();
|
||||
|
||||
__enable_irq();
|
||||
|
||||
TRACE("Horus started :)");
|
||||
ledBlue();
|
||||
|
||||
keysInit();
|
||||
adcInit();
|
||||
lcdInit();
|
||||
audioInit();
|
||||
i2cInit();
|
||||
init2MhzTimer();
|
||||
init5msTimer();
|
||||
usbInit();
|
||||
|
|
|
@ -281,14 +281,10 @@ void dacStart(void);
|
|||
void dacStop(void);
|
||||
void setSampleRate(uint32_t frequency);
|
||||
|
||||
// I2C driver
|
||||
void i2cInit(void);
|
||||
#define VOLUME_LEVEL_MAX 23
|
||||
#define VOLUME_LEVEL_DEF 12
|
||||
extern const int8_t volumeScale[];
|
||||
void setScaledVolume(uint8_t volume);
|
||||
void setVolume(uint8_t volume);
|
||||
int32_t getVolume(void);
|
||||
// Fake volume driver
|
||||
#define setScaledVolume(...)
|
||||
#define setVolume(...)
|
||||
#define getVolume(...) (-1)
|
||||
|
||||
// Telemetry driver
|
||||
void telemetryPortInit(uint32_t baudrate);
|
||||
|
|
|
@ -1,145 +0,0 @@
|
|||
/*
|
||||
* Copyright (C) OpenTX
|
||||
*
|
||||
* Based on code named
|
||||
* th9x - http://code.google.com/p/th9x
|
||||
* er9x - http://code.google.com/p/er9x
|
||||
* gruvin9x - http://code.google.com/p/gruvin9x
|
||||
*
|
||||
* License GPLv2: http://www.gnu.org/licenses/gpl-2.0.html
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License version 2 as
|
||||
* published by the Free Software Foundation.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*/
|
||||
|
||||
#include "board_horus.h"
|
||||
|
||||
void i2cInit(void)
|
||||
{
|
||||
I2C_DeInit(I2C);
|
||||
|
||||
I2C_InitTypeDef I2C_InitStructure;
|
||||
I2C_InitStructure.I2C_ClockSpeed = I2C_SPEED;
|
||||
I2C_InitStructure.I2C_DutyCycle = I2C_DutyCycle_2;
|
||||
I2C_InitStructure.I2C_OwnAddress1 = 0x00;
|
||||
I2C_InitStructure.I2C_Mode = I2C_Mode_I2C;
|
||||
I2C_InitStructure.I2C_Ack = I2C_Ack_Enable;
|
||||
I2C_InitStructure.I2C_AcknowledgedAddress = I2C_AcknowledgedAddress_7bit;
|
||||
I2C_Init(I2C, &I2C_InitStructure);
|
||||
I2C_Cmd(I2C, ENABLE);
|
||||
|
||||
GPIO_PinAFConfig(I2C_GPIO, I2C_GPIO_PinSource_SCL, I2C_GPIO_AF);
|
||||
GPIO_PinAFConfig(I2C_GPIO, I2C_GPIO_PinSource_SDA, I2C_GPIO_AF);
|
||||
|
||||
GPIO_InitTypeDef GPIO_InitStructure;
|
||||
GPIO_InitStructure.GPIO_Pin = I2C_GPIO_PIN_SCL | I2C_GPIO_PIN_SDA;
|
||||
GPIO_InitStructure.GPIO_Speed = GPIO_Speed_50MHz;
|
||||
GPIO_InitStructure.GPIO_Mode = GPIO_Mode_AF;
|
||||
GPIO_InitStructure.GPIO_OType = GPIO_OType_OD;
|
||||
GPIO_InitStructure.GPIO_PuPd = GPIO_PuPd_UP;
|
||||
GPIO_Init(I2C_GPIO, &GPIO_InitStructure);
|
||||
}
|
||||
|
||||
#define I2C_TIMEOUT_MAX 1000
|
||||
bool I2C_WaitEvent(uint32_t event)
|
||||
{
|
||||
uint32_t timeout = I2C_TIMEOUT_MAX;
|
||||
while (!I2C_CheckEvent(I2C, event)) {
|
||||
if ((timeout--) == 0) return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
bool I2C_WaitEventCleared(uint32_t event)
|
||||
{
|
||||
uint32_t timeout = I2C_TIMEOUT_MAX;
|
||||
while (I2C_CheckEvent(I2C, event)) {
|
||||
if ((timeout--) == 0) return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
int16_t i2cReadRegister(uint8_t address, uint8_t index)
|
||||
{
|
||||
if (!I2C_WaitEventCleared(I2C_FLAG_BUSY))
|
||||
return -1;
|
||||
|
||||
I2C_GenerateSTART(I2C, ENABLE);
|
||||
if (!I2C_WaitEvent(I2C_EVENT_MASTER_MODE_SELECT))
|
||||
return -2;
|
||||
|
||||
I2C_Send7bitAddress(I2C, address, I2C_Direction_Transmitter);
|
||||
if (!I2C_WaitEvent(I2C_EVENT_MASTER_TRANSMITTER_MODE_SELECTED))
|
||||
return -3;
|
||||
|
||||
I2C_SendData(I2C, index);
|
||||
if (!I2C_WaitEvent(I2C_EVENT_MASTER_BYTE_TRANSMITTED))
|
||||
return -4;
|
||||
|
||||
I2C_GenerateSTART(I2C, ENABLE);
|
||||
if (!I2C_WaitEvent(I2C_EVENT_MASTER_MODE_SELECT))
|
||||
return -5;
|
||||
|
||||
I2C_Send7bitAddress(I2C, address, I2C_Direction_Receiver);
|
||||
if (!I2C_WaitEvent(I2C_EVENT_MASTER_RECEIVER_MODE_SELECTED))
|
||||
return -6;
|
||||
|
||||
I2C_AcknowledgeConfig(I2C, DISABLE);
|
||||
if (!I2C_WaitEvent(I2C_EVENT_MASTER_BYTE_RECEIVED))
|
||||
return -7;
|
||||
|
||||
uint8_t result = I2C_ReceiveData(I2C);
|
||||
|
||||
I2C_GenerateSTOP(I2C, ENABLE);
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
void i2cWriteRegister(uint8_t address, uint8_t index, uint8_t data)
|
||||
{
|
||||
if (!I2C_WaitEventCleared(I2C_FLAG_BUSY))
|
||||
return;
|
||||
|
||||
I2C_GenerateSTART(I2C, ENABLE);
|
||||
if (!I2C_WaitEvent(I2C_EVENT_MASTER_MODE_SELECT))
|
||||
return;
|
||||
|
||||
I2C_Send7bitAddress(I2C, address, I2C_Direction_Transmitter);
|
||||
if (!I2C_WaitEvent(I2C_EVENT_MASTER_TRANSMITTER_MODE_SELECTED))
|
||||
return;
|
||||
|
||||
I2C_SendData(I2C, index);
|
||||
if (!I2C_WaitEvent(I2C_EVENT_MASTER_BYTE_TRANSMITTED))
|
||||
return;
|
||||
|
||||
I2C_SendData(I2C, data);
|
||||
if (!I2C_WaitEvent(I2C_EVENT_MASTER_BYTE_TRANSMITTED))
|
||||
return;
|
||||
|
||||
I2C_GenerateSTOP(I2C, ENABLE);
|
||||
}
|
||||
|
||||
void setScaledVolume(uint8_t volume)
|
||||
{
|
||||
if (volume > VOLUME_LEVEL_MAX) {
|
||||
volume = VOLUME_LEVEL_MAX;
|
||||
}
|
||||
|
||||
setVolume(volumeScale[volume]);
|
||||
}
|
||||
|
||||
void setVolume(uint8_t volume)
|
||||
{
|
||||
i2cWriteRegister(I2C_ADDRESS_VOLUME, 0, volume);
|
||||
}
|
||||
|
||||
int32_t getVolume()
|
||||
{
|
||||
return i2cReadRegister(I2C_ADDRESS_VOLUME, 0);
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue