mirror of
https://github.com/DarkFlippers/unleashed-firmware.git
synced 2024-12-22 21:01:40 +03:00
917410a0a8
* fbt: reworking targets & assets handling WIP * fbt: dist fixes * fbt: moved SD card resources to owning apps * unit_tests: moved resources to app folder * github: updated unit_tests paths * github: packaging fixes * unit_tests: fixes * fbt: assets: internal cleanup * fbt: reworked assets handling * github: unit_tests: reintroducing fixes * minor cleanup * fbt: naming changes to reflect private nature of scons tools * fbt: resources: fixed dist archive paths * docs: updated paths * docs: updated more paths * docs: included "resources" parameter in app manifest docs; updated assets readme * updated gitignore for assets * github: updated action versions * unit_tests: restored timeout; scripts: assets: logging changes * gh: don't upload desktop animations for unit test run Co-authored-by: あく <alleteam@gmail.com>
136 lines
3.2 KiB
C
136 lines
3.2 KiB
C
#include <furi_hal_region.h>
|
|
#include <furi_hal_version.h>
|
|
|
|
const FuriHalRegion furi_hal_region_zero = {
|
|
.country_code = "00",
|
|
.bands_count = 1,
|
|
.bands = {
|
|
{
|
|
.start = 0,
|
|
.end = 1000000000,
|
|
.power_limit = 12,
|
|
.duty_cycle = 50,
|
|
},
|
|
}};
|
|
|
|
const FuriHalRegion furi_hal_region_eu_ru = {
|
|
.country_code = "EU",
|
|
.bands_count = 2,
|
|
.bands = {
|
|
{
|
|
.start = 433050000,
|
|
.end = 434790000,
|
|
.power_limit = 12,
|
|
.duty_cycle = 50,
|
|
},
|
|
{
|
|
.start = 868150000,
|
|
.end = 868550000,
|
|
.power_limit = 12,
|
|
.duty_cycle = 50,
|
|
}}};
|
|
|
|
const FuriHalRegion furi_hal_region_us_ca_au = {
|
|
.country_code = "US",
|
|
.bands_count = 3,
|
|
.bands = {
|
|
{
|
|
.start = 304100000,
|
|
.end = 321950000,
|
|
.power_limit = 12,
|
|
.duty_cycle = 50,
|
|
},
|
|
{
|
|
.start = 433050000,
|
|
.end = 434790000,
|
|
.power_limit = 12,
|
|
.duty_cycle = 50,
|
|
},
|
|
{
|
|
.start = 915000000,
|
|
.end = 928000000,
|
|
.power_limit = 12,
|
|
.duty_cycle = 50,
|
|
}}};
|
|
|
|
const FuriHalRegion furi_hal_region_jp = {
|
|
.country_code = "JP",
|
|
.bands_count = 2,
|
|
.bands = {
|
|
{
|
|
.start = 312000000,
|
|
.end = 315250000,
|
|
.power_limit = 12,
|
|
.duty_cycle = 50,
|
|
},
|
|
{
|
|
.start = 920500000,
|
|
.end = 923500000,
|
|
.power_limit = 12,
|
|
.duty_cycle = 50,
|
|
}}};
|
|
|
|
static const FuriHalRegion* furi_hal_region = NULL;
|
|
|
|
void furi_hal_region_init() {
|
|
FuriHalVersionRegion region = furi_hal_version_get_hw_region();
|
|
|
|
if(region == FuriHalVersionRegionUnknown) {
|
|
furi_hal_region = &furi_hal_region_zero;
|
|
} else if(region == FuriHalVersionRegionEuRu) {
|
|
furi_hal_region = &furi_hal_region_eu_ru;
|
|
} else if(region == FuriHalVersionRegionUsCaAu) {
|
|
furi_hal_region = &furi_hal_region_us_ca_au;
|
|
} else if(region == FuriHalVersionRegionJp) {
|
|
furi_hal_region = &furi_hal_region_jp;
|
|
}
|
|
}
|
|
|
|
const FuriHalRegion* furi_hal_region_get() {
|
|
return furi_hal_region;
|
|
}
|
|
|
|
void furi_hal_region_set(FuriHalRegion* region) {
|
|
furi_hal_region = region;
|
|
}
|
|
|
|
bool furi_hal_region_is_provisioned() {
|
|
return furi_hal_region != NULL;
|
|
}
|
|
|
|
const char* furi_hal_region_get_name() {
|
|
if(furi_hal_region) {
|
|
return furi_hal_region->country_code;
|
|
} else {
|
|
return "--";
|
|
}
|
|
}
|
|
|
|
bool furi_hal_region_is_frequency_allowed(uint32_t frequency) {
|
|
if(!furi_hal_region) {
|
|
return false;
|
|
}
|
|
|
|
const FuriHalRegionBand* band = furi_hal_region_get_band(frequency);
|
|
if(!band) {
|
|
return false;
|
|
}
|
|
|
|
return true;
|
|
}
|
|
|
|
const FuriHalRegionBand* furi_hal_region_get_band(uint32_t frequency) {
|
|
if(!furi_hal_region) {
|
|
return NULL;
|
|
}
|
|
|
|
for(size_t i = 0; i < furi_hal_region->bands_count; i++) {
|
|
if(furi_hal_region->bands[i].start <= frequency &&
|
|
furi_hal_region->bands[i].end >= frequency) {
|
|
return &furi_hal_region->bands[i];
|
|
}
|
|
}
|
|
|
|
return NULL;
|
|
}
|