0
mirror of https://github.com/OneOfEleven/uv-k5-firmware-custom.git synced 2025-06-19 06:39:49 +03:00

Fixed FM radio key presses, now nice to use the FM radio

This commit is contained in:
OneOfEleven
2023-10-11 17:22:34 +01:00
parent 46a082ef05
commit 2f076587b4
7 changed files with 83 additions and 76 deletions

View File

@ -34,8 +34,7 @@ static const uint16_t BK1080_RegisterTable[] =
0x0200, 0x0000,
};
static bool gIsInitBK1080;
bool is_init;
uint16_t BK1080_BaseFrequency;
uint16_t BK1080_FrequencyDeviation;
@ -47,7 +46,7 @@ void BK1080_Init(uint16_t Frequency, bool bDoScan)
{
GPIO_ClearBit(&GPIOB->DATA, GPIOB_PIN_BK1080);
if (!gIsInitBK1080)
if (!is_init)
{
for (i = 0; i < ARRAY_SIZE(BK1080_RegisterTable); i++)
BK1080_WriteRegister(i, BK1080_RegisterTable[i]);
@ -59,7 +58,7 @@ void BK1080_Init(uint16_t Frequency, bool bDoScan)
SYSTEM_DelayMs(60);
gIsInitBK1080 = true;
is_init = true;
}
else
{
@ -67,11 +66,9 @@ void BK1080_Init(uint16_t Frequency, bool bDoScan)
}
BK1080_WriteRegister(BK1080_REG_05_SYSTEM_CONFIGURATION2, 0x0A5F);
BK1080_WriteRegister(BK1080_REG_03_CHANNEL, Frequency - 760);
SYSTEM_DelayMs(10);
BK1080_WriteRegister(BK1080_REG_03_CHANNEL, (Frequency - 760) | 0x8000);
BK1080_WriteRegister(BK1080_REG_03_CHANNEL, Frequency - 760);
// SYSTEM_DelayMs(10);
BK1080_WriteRegister(BK1080_REG_03_CHANNEL, (Frequency - 760) | (1u << 15));
}
else
{
@ -83,7 +80,6 @@ void BK1080_Init(uint16_t Frequency, bool bDoScan)
uint16_t BK1080_ReadRegister(BK1080_Register_t Register)
{
uint8_t Value[2];
I2C_Start();
I2C_Write(0x80);
I2C_Write((Register << 1) | I2C_READ);
@ -110,9 +106,9 @@ void BK1080_Mute(bool Mute)
void BK1080_SetFrequency(uint16_t Frequency)
{
BK1080_WriteRegister(BK1080_REG_03_CHANNEL, Frequency - 760);
SYSTEM_DelayMs(10);
BK1080_WriteRegister(BK1080_REG_03_CHANNEL, (Frequency - 760) | 0x8000);
BK1080_WriteRegister(BK1080_REG_03_CHANNEL, Frequency - 760);
// SYSTEM_DelayMs(10);
BK1080_WriteRegister(BK1080_REG_03_CHANNEL, (Frequency - 760) | (1u << 15));
}
void BK1080_GetFrequencyDeviation(uint16_t Frequency)

View File

@ -19,17 +19,18 @@
#include <stdbool.h>
#include <stdint.h>
#include "driver/bk1080-regs.h"
extern uint16_t BK1080_BaseFrequency;
extern uint16_t BK1080_FrequencyDeviation;
void BK1080_Init(uint16_t Frequency, bool bDoScan);
void BK1080_Init(uint16_t Frequency, bool bDoScan);
uint16_t BK1080_ReadRegister(BK1080_Register_t Register);
void BK1080_WriteRegister(BK1080_Register_t Register, uint16_t Value);
void BK1080_Mute(bool Mute);
void BK1080_SetFrequency(uint16_t Frequency);
void BK1080_GetFrequencyDeviation(uint16_t Frequency);
void BK1080_WriteRegister(BK1080_Register_t Register, uint16_t Value);
void BK1080_Mute(bool Mute);
void BK1080_SetFrequency(uint16_t Frequency);
void BK1080_GetFrequencyDeviation(uint16_t Frequency);
#endif

View File

@ -804,7 +804,8 @@ void BK4819_SetAF(BK4819_af_type_t AF)
// AF Output Inverse Mode = Inverse
// Undocumented bits 0x2040
//
BK4819_WriteRegister(BK4819_REG_47, 0x6040 | (AF << 8));
// BK4819_WriteRegister(BK4819_REG_47, 0x6040 | (AF << 8));
BK4819_WriteRegister(BK4819_REG_47, (6u << 12) | (AF << 8) | (1u << 6));
}
void BK4819_RX_TurnOn(void)
@ -823,7 +824,7 @@ void BK4819_RX_TurnOn(void)
// Enable XTAL
// Enable Band Gap
//
BK4819_WriteRegister(BK4819_REG_37, 0x1F0F); // 0001111100001111
BK4819_WriteRegister(BK4819_REG_37, 0x1F0F); // 0001 1111 0000 1111
// Turn off everything
BK4819_WriteRegister(BK4819_REG_30, 0);
@ -1034,6 +1035,7 @@ void BK4819_PlaySingleTone(const unsigned int tone_Hz, const unsigned int delay,
{
GPIO_ClearBit(&GPIOC->DATA, GPIOC_PIN_AUDIO_PATH);
BK4819_SetAF(BK4819_AF_MUTE);
// BK4819_SetAF(g_rx_vfo->am_mode ? BK4819_AF_AM : BK4819_AF_FM);
}
BK4819_WriteRegister(BK4819_REG_70, 0x0000);

View File

@ -45,9 +45,9 @@ typedef enum BK4819_af_type_e BK4819_af_type_t;
enum BK4819_filter_bandwidth_e
{
BK4819_FILTER_BW_WIDE = 0,
BK4819_FILTER_BW_NARROW,
BK4819_FILTER_BW_NARROWER
BK4819_FILTER_BW_WIDE = 0, // 25kHz
BK4819_FILTER_BW_NARROW, // 12.5kHz
BK4819_FILTER_BW_NARROWER // 6.25kHz
};
typedef enum BK4819_filter_bandwidth_e BK4819_filter_bandwidth_t;