Switch sub-1GHz band (#349)

* switch band
* extract subghz api to files
This commit is contained in:
coreglitch
2021-02-25 13:29:00 +03:00
committed by GitHub
parent 1b2c31da6f
commit 2fbf427e0a
8 changed files with 74 additions and 14 deletions

View 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

View File

@@ -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();

View File

@@ -0,0 +1,5 @@
#include "api-hal-subghz.h"
void api_hal_rf_band_set(RfBand band) {
}

View File

@@ -7,4 +7,4 @@ void api_hal_init() {
api_hal_i2c_init();
api_hal_power_init();
api_hal_light_init();
}
}

View 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);
}
}

View File

@@ -7,4 +7,4 @@ void api_hal_init() {
api_hal_i2c_init();
api_hal_power_init();
api_hal_light_init();
}
}