Switch sub-1GHz band (#349)
* switch band * extract subghz api to files
This commit is contained in:
parent
1b2c31da6f
commit
2fbf427e0a
@ -211,17 +211,17 @@ void tx_config(CC1101* cc1101) {
|
||||
// TODO: reg values not affetcts
|
||||
|
||||
const Band bands[] = {
|
||||
{300., {0x00, 0x00, 0x00}, 0, 255, 74},
|
||||
{301., {0x00, 0x00, 0x00}, 0, 255, 74},
|
||||
{315., {0x00, 0x00, 0x00}, 0, 255, 74},
|
||||
{348., {0x00, 0x00, 0x00}, 0, 255, 74},
|
||||
{386., {0x00, 0x00, 0x00}, 0, 255, 74},
|
||||
{346., {0x00, 0x00, 0x00}, 0, 255, 74},
|
||||
{385., {0x00, 0x00, 0x00}, 0, 255, 74},
|
||||
{433.92, {0x00, 0x00, 0x00}, 0, 255, 74},
|
||||
{438.9, {0x00, 0x00, 0x00}, 0, 255, 74},
|
||||
{464., {0x00, 0x00, 0x00}, 0, 255, 74},
|
||||
{779., {0x00, 0x00, 0x00}, 0, 255, 74},
|
||||
{463., {0x00, 0x00, 0x00}, 0, 255, 74},
|
||||
{781., {0x00, 0x00, 0x00}, 0, 255, 74},
|
||||
{868., {0x00, 0x00, 0x00}, 0, 255, 74},
|
||||
{915., {0x00, 0x00, 0x00}, 0, 255, 74},
|
||||
{928., {0x00, 0x00, 0x00}, 0, 255, 74},
|
||||
{925., {0x00, 0x00, 0x00}, 0, 255, 74},
|
||||
};
|
||||
|
||||
const FreqConfig FREQ_LIST[] = {
|
||||
@ -278,6 +278,7 @@ typedef struct {
|
||||
int16_t last_rssi;
|
||||
size_t tx_level;
|
||||
bool need_cc1101_conf;
|
||||
RfBand rf_band;
|
||||
} State;
|
||||
|
||||
static void render_callback(Canvas* canvas, void* ctx) {
|
||||
@ -328,11 +329,16 @@ static void render_callback(Canvas* canvas, void* ctx) {
|
||||
|
||||
{
|
||||
char buf[24];
|
||||
sprintf(buf, "tx level: %d dBm", TX_LEVELS[state->tx_level].dbm);
|
||||
// sprintf(buf, "tx level: %d dBm", TX_LEVELS[state->tx_level].dbm);
|
||||
sprintf(buf, "RF band: %d", (uint8_t)state->rf_band);
|
||||
|
||||
canvas_set_font(canvas, FontSecondary);
|
||||
if(state->rf_band == RfBandIsolation) {
|
||||
canvas_draw_str(canvas, 2, 63, "RF band: isolation");
|
||||
} else {
|
||||
canvas_draw_str(canvas, 2, 63, buf);
|
||||
}
|
||||
}
|
||||
|
||||
release_mutex((ValueMutex*)ctx, state);
|
||||
}
|
||||
@ -360,6 +366,7 @@ extern "C" int32_t cc1101_workaround(void* p) {
|
||||
_state.need_cc1101_conf = true;
|
||||
_state.last_rssi = 0;
|
||||
_state.tx_level = 0;
|
||||
_state.rf_band = RfBand1;
|
||||
|
||||
ValueMutex state_mutex;
|
||||
if(!init_mutex(&state_mutex, &_state, sizeof(State))) {
|
||||
@ -469,7 +476,11 @@ extern "C" int32_t cc1101_workaround(void* p) {
|
||||
}
|
||||
*/
|
||||
|
||||
if(state->rf_band < RfBand3) {
|
||||
state->rf_band = (RfBand)((uint8_t)state->rf_band + 1);
|
||||
} else {
|
||||
state->active_freq += 0.25;
|
||||
}
|
||||
state->need_cc1101_conf = true;
|
||||
}
|
||||
|
||||
@ -483,7 +494,11 @@ extern "C" int32_t cc1101_workaround(void* p) {
|
||||
}
|
||||
*/
|
||||
|
||||
if(state->rf_band > RfBandIsolation) {
|
||||
state->rf_band = (RfBand)((uint8_t)state->rf_band - 1);
|
||||
} else {
|
||||
state->active_freq -= 0.25;
|
||||
}
|
||||
state->need_cc1101_conf = true;
|
||||
}
|
||||
|
||||
@ -518,6 +533,8 @@ extern "C" int32_t cc1101_workaround(void* p) {
|
||||
gpio_write(&cc1101_g0_gpio, false);
|
||||
}
|
||||
|
||||
api_hal_rf_band_set(state->rf_band);
|
||||
|
||||
state->need_cc1101_conf = false;
|
||||
}
|
||||
|
||||
|
18
firmware/targets/api-hal-include/api-hal-subghz.h
Normal file
18
firmware/targets/api-hal-include/api-hal-subghz.h
Normal file
@ -0,0 +1,18 @@
|
||||
#pragma once
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
typedef enum {
|
||||
RfBandIsolation = 0,
|
||||
RfBand1 = 1,
|
||||
RfBand2 = 2,
|
||||
RfBand3 = 3
|
||||
} RfBand;
|
||||
|
||||
void api_hal_rf_band_set(RfBand band);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
@ -21,5 +21,6 @@ template <unsigned int N> struct STOP_EXTERNING_ME {};
|
||||
#include "api-hal-bt.h"
|
||||
#include "api-hal-spi.h"
|
||||
#include "api-hal-flash.h"
|
||||
#include "api-hal-subghz.h"
|
||||
|
||||
void api_hal_init();
|
||||
|
5
firmware/targets/f4/api-hal/api-hal-subghz.c
Normal file
5
firmware/targets/f4/api-hal/api-hal-subghz.c
Normal file
@ -0,0 +1,5 @@
|
||||
#include "api-hal-subghz.h"
|
||||
|
||||
void api_hal_rf_band_set(RfBand band) {
|
||||
|
||||
}
|
19
firmware/targets/f5/api-hal/api-hal-subghz.c
Normal file
19
firmware/targets/f5/api-hal/api-hal-subghz.c
Normal file
@ -0,0 +1,19 @@
|
||||
#include "api-hal-subghz.h"
|
||||
#include <stm32wbxx_ll_gpio.h>
|
||||
#include "main.h"
|
||||
|
||||
void api_hal_rf_band_set(RfBand band) {
|
||||
if (band == RfBand1) {
|
||||
LL_GPIO_ResetOutputPin(PA_SW_0_GPIO_Port, PA_SW_0_Pin);
|
||||
LL_GPIO_SetOutputPin(PA_SW_1_GPIO_Port, PA_SW_1_Pin);
|
||||
} else if (band == RfBand2) {
|
||||
LL_GPIO_SetOutputPin(PA_SW_0_GPIO_Port, PA_SW_0_Pin);
|
||||
LL_GPIO_ResetOutputPin(PA_SW_1_GPIO_Port, PA_SW_1_Pin);
|
||||
} else if (band == RfBand3) {
|
||||
LL_GPIO_SetOutputPin(PA_SW_0_GPIO_Port, PA_SW_0_Pin);
|
||||
LL_GPIO_SetOutputPin(PA_SW_1_GPIO_Port, PA_SW_1_Pin);
|
||||
} else if (band == RfBandIsolation) {
|
||||
LL_GPIO_ResetOutputPin(PA_SW_0_GPIO_Port, PA_SW_0_Pin);
|
||||
LL_GPIO_ResetOutputPin(PA_SW_1_GPIO_Port, PA_SW_1_Pin);
|
||||
}
|
||||
}
|
@ -12,6 +12,6 @@ if [ ! -f $1 ]; then
|
||||
exit
|
||||
fi
|
||||
|
||||
STM32_Programmer_CLI -c port=swd -d $1 0x1FFF7000
|
||||
STM32_Programmer_CLI -c port=usb1 -d $1 0x1FFF7000
|
||||
|
||||
STM32_Programmer_CLI -c port=swd -r8 0x1FFF7000 8
|
||||
STM32_Programmer_CLI -c port=usb1 -r8 0x1FFF7000 8
|
||||
|
Loading…
Reference in New Issue
Block a user