[cc1101] Use Hz and cv.frequency instead of kHz (#12313)
CI / Create common environment (push) Has been cancelled
CI / Check pylint (push) Has been cancelled
CI / Run script/ci-custom (push) Has been cancelled
CI / Run pytest (macOS-latest, 3.11) (push) Has been cancelled
CI / Run pytest (ubuntu-latest, 3.11) (push) Has been cancelled
CI / Run pytest (ubuntu-latest, 3.13) (push) Has been cancelled
CI / Run pytest (windows-latest, 3.11) (push) Has been cancelled
CI / Determine which jobs to run (push) Has been cancelled
CI / Run integration tests (push) Has been cancelled
CI / Run C++ unit tests (push) Has been cancelled
CI / Run script/clang-tidy for ESP32 IDF (push) Has been cancelled
CI / Run script/clang-tidy for ESP8266 (push) Has been cancelled
CI / Run script/clang-tidy for ZEPHYR (push) Has been cancelled
CI / Run script/clang-tidy for ESP32 Arduino (push) Has been cancelled
CI / Run script/clang-tidy for ESP32 Arduino 1/4 (push) Has been cancelled
CI / Run script/clang-tidy for ESP32 Arduino 2/4 (push) Has been cancelled
CI / Run script/clang-tidy for ESP32 Arduino 3/4 (push) Has been cancelled
CI / Run script/clang-tidy for ESP32 Arduino 4/4 (push) Has been cancelled
CI / Test components batch (${{ matrix.components }}) (push) Has been cancelled
CI / pre-commit.ci lite (push) Has been cancelled
CI / Build target branch for memory impact (push) Has been cancelled
CI / Build PR branch for memory impact (push) Has been cancelled
CI / Comment memory impact (push) Has been cancelled
CI / CI Status (push) Has been cancelled

This commit is contained in:
Jonathan Swoboda
2025-12-05 22:32:20 -05:00
committed by GitHub
parent 6716194e47
commit 6220427524
4 changed files with 18 additions and 19 deletions
+5 -5
View File
@@ -152,12 +152,12 @@ CONFIG_MAP = {
CONF_OUTPUT_POWER: cv.float_range(min=-30.0, max=11.0), CONF_OUTPUT_POWER: cv.float_range(min=-30.0, max=11.0),
CONF_RX_ATTENUATION: cv.enum(RX_ATTENUATION, upper=False), CONF_RX_ATTENUATION: cv.enum(RX_ATTENUATION, upper=False),
CONF_DC_BLOCKING_FILTER: cv.boolean, CONF_DC_BLOCKING_FILTER: cv.boolean,
CONF_FREQUENCY: cv.float_range(min=300000.0, max=928000.0), CONF_FREQUENCY: cv.All(cv.frequency, cv.float_range(min=300000000, max=928000000)),
CONF_IF_FREQUENCY: cv.float_range(min=25, max=788), CONF_IF_FREQUENCY: cv.All(cv.frequency, cv.float_range(min=25000, max=788000)),
CONF_FILTER_BANDWIDTH: cv.float_range(min=58.0, max=812.0), CONF_FILTER_BANDWIDTH: cv.All(cv.frequency, cv.float_range(min=58000, max=812000)),
CONF_CHANNEL: cv.uint8_t, CONF_CHANNEL: cv.uint8_t,
CONF_CHANNEL_SPACING: cv.float_range(min=25, max=405), CONF_CHANNEL_SPACING: cv.All(cv.frequency, cv.float_range(min=25000, max=405000)),
CONF_FSK_DEVIATION: cv.float_range(min=1.5, max=381), CONF_FSK_DEVIATION: cv.All(cv.frequency, cv.float_range(min=1500, max=381000)),
CONF_MSK_DEVIATION: cv.int_range(min=1, max=8), CONF_MSK_DEVIATION: cv.int_range(min=1, max=8),
CONF_SYMBOL_RATE: cv.float_range(min=600, max=500000), CONF_SYMBOL_RATE: cv.float_range(min=600, max=500000),
CONF_SYNC_MODE: cv.enum(SYNC_MODE, upper=False), CONF_SYNC_MODE: cv.enum(SYNC_MODE, upper=False),
+8 -9
View File
@@ -160,18 +160,17 @@ void CC1101Component::dump_config() {
"4-FSK", "UNUSED", "UNUSED", "MSK"}; "4-FSK", "UNUSED", "UNUSED", "MSK"};
int32_t freq = static_cast<int32_t>(this->state_.FREQ2 << 16 | this->state_.FREQ1 << 8 | this->state_.FREQ0) * int32_t freq = static_cast<int32_t>(this->state_.FREQ2 << 16 | this->state_.FREQ1 << 8 | this->state_.FREQ0) *
XTAL_FREQUENCY / (1 << 16); XTAL_FREQUENCY / (1 << 16);
float symbol_rate = float symbol_rate = (((256.0f + this->state_.DRATE_M) * (1 << this->state_.DRATE_E)) / (1 << 28)) * XTAL_FREQUENCY;
(((256.0f + this->state_.DRATE_M) * (1 << this->state_.DRATE_E)) / (1 << 28)) * XTAL_FREQUENCY * 1000.0f;
float bw = XTAL_FREQUENCY / (8.0f * (4 + this->state_.CHANBW_M) * (1 << this->state_.CHANBW_E)); float bw = XTAL_FREQUENCY / (8.0f * (4 + this->state_.CHANBW_M) * (1 << this->state_.CHANBW_E));
ESP_LOGCONFIG(TAG, "CC1101:"); ESP_LOGCONFIG(TAG, "CC1101:");
LOG_PIN(" CS Pin: ", this->cs_); LOG_PIN(" CS Pin: ", this->cs_);
ESP_LOGCONFIG(TAG, ESP_LOGCONFIG(TAG,
" Chip ID: 0x%04X\n" " Chip ID: 0x%04X\n"
" Frequency: %" PRId32 " kHz\n" " Frequency: %" PRId32 " Hz\n"
" Channel: %u\n" " Channel: %u\n"
" Modulation: %s\n" " Modulation: %s\n"
" Symbol Rate: %.0f baud\n" " Symbol Rate: %.0f baud\n"
" Filter Bandwidth: %.1f kHz\n" " Filter Bandwidth: %.1f Hz\n"
" Output Power: %.1f dBm", " Output Power: %.1f dBm",
this->chip_id_, freq, this->state_.CHANNR, MODULATION_NAMES[this->state_.MOD_FORMAT & 0x07], this->chip_id_, freq, this->state_.CHANNR, MODULATION_NAMES[this->state_.MOD_FORMAT & 0x07],
symbol_rate, bw, this->output_power_effective_); symbol_rate, bw, this->output_power_effective_);
@@ -289,13 +288,13 @@ void CC1101Component::set_output_power(float value) {
int32_t freq = static_cast<int32_t>(this->state_.FREQ2 << 16 | this->state_.FREQ1 << 8 | this->state_.FREQ0) * int32_t freq = static_cast<int32_t>(this->state_.FREQ2 << 16 | this->state_.FREQ1 << 8 | this->state_.FREQ0) *
XTAL_FREQUENCY / (1 << 16); XTAL_FREQUENCY / (1 << 16);
uint8_t a = 0xC0; uint8_t a = 0xC0;
if (freq >= 300000 && freq <= 348000) { if (freq >= 300000000 && freq <= 348000000) {
a = PowerTableItem::find(PA_TABLE_315, sizeof(PA_TABLE_315) / sizeof(PA_TABLE_315[0]), value); a = PowerTableItem::find(PA_TABLE_315, sizeof(PA_TABLE_315) / sizeof(PA_TABLE_315[0]), value);
} else if (freq >= 378000 && freq <= 464000) { } else if (freq >= 378000000 && freq <= 464000000) {
a = PowerTableItem::find(PA_TABLE_433, sizeof(PA_TABLE_433) / sizeof(PA_TABLE_433[0]), value); a = PowerTableItem::find(PA_TABLE_433, sizeof(PA_TABLE_433) / sizeof(PA_TABLE_433[0]), value);
} else if (freq >= 779000 && freq < 900000) { } else if (freq >= 779000000 && freq < 900000000) {
a = PowerTableItem::find(PA_TABLE_868, sizeof(PA_TABLE_868) / sizeof(PA_TABLE_868[0]), value); a = PowerTableItem::find(PA_TABLE_868, sizeof(PA_TABLE_868) / sizeof(PA_TABLE_868[0]), value);
} else if (freq >= 900000 && freq <= 928000) { } else if (freq >= 900000000 && freq <= 928000000) {
a = PowerTableItem::find(PA_TABLE_915, sizeof(PA_TABLE_915) / sizeof(PA_TABLE_915[0]), value); a = PowerTableItem::find(PA_TABLE_915, sizeof(PA_TABLE_915) / sizeof(PA_TABLE_915[0]), value);
} }
@@ -401,7 +400,7 @@ void CC1101Component::set_msk_deviation(uint8_t value) {
void CC1101Component::set_symbol_rate(float value) { void CC1101Component::set_symbol_rate(float value) {
uint8_t e; uint8_t e;
uint32_t m; uint32_t m;
split_float(value * (1 << 28) / (XTAL_FREQUENCY * 1000), 8, e, m); split_float(value * (1 << 28) / XTAL_FREQUENCY, 8, e, m);
this->state_.DRATE_E = e; this->state_.DRATE_E = e;
this->state_.DRATE_M = static_cast<uint8_t>(m); this->state_.DRATE_M = static_cast<uint8_t>(m);
if (this->initialized_) { if (this->initialized_) {
+1 -1
View File
@@ -4,7 +4,7 @@
namespace esphome::cc1101 { namespace esphome::cc1101 {
static constexpr float XTAL_FREQUENCY = 26000; static constexpr float XTAL_FREQUENCY = 26000000;
static constexpr uint8_t BUS_BURST = 0x40; static constexpr uint8_t BUS_BURST = 0x40;
static constexpr uint8_t BUS_READ = 0x80; static constexpr uint8_t BUS_READ = 0x80;
+4 -4
View File
@@ -1,11 +1,11 @@
cc1101: cc1101:
id: transceiver id: transceiver
cs_pin: ${cs_pin} cs_pin: ${cs_pin}
frequency: 433920 frequency: 433.92MHz
if_frequency: 153 if_frequency: 153kHz
filter_bandwidth: 203 filter_bandwidth: 203kHz
channel: 0 channel: 0
channel_spacing: 200 channel_spacing: 200kHz
symbol_rate: 5000 symbol_rate: 5000
modulation_type: ASK/OOK modulation_type: ASK/OOK