mirror of
https://github.com/esp-rs/esp-hal.git
synced 2025-09-27 04:10:28 +00:00
Make BLE work on ESP32-C2 with 26 MHz Xtal (#4062)
* Make BLE work on ESP32-C2 with 26 MHz Xtal * CHANGELOG.md
This commit is contained in:
parent
445f6fc1ad
commit
7248d3d7d2
@ -188,10 +188,14 @@ pub(super) fn ble_rtc_clk_init() {
|
||||
w.lp_timer_sel_rtc_slow().clear_bit()
|
||||
});
|
||||
|
||||
// assume 40MHz xtal
|
||||
let divider = match crate::rtc_cntl::RtcClock::xtal_freq() {
|
||||
XtalClock::_26M => 129,
|
||||
XtalClock::_40M => 249,
|
||||
};
|
||||
|
||||
MODEM_CLKRST::regs()
|
||||
.modem_lp_timer_conf()
|
||||
.modify(|_, w| unsafe { w.lp_timer_clk_div_num().bits(249) });
|
||||
.modify(|_, w| unsafe { w.lp_timer_clk_div_num().bits(divider) });
|
||||
|
||||
MODEM_CLKRST::regs().etm_clk_conf().modify(|_, w| {
|
||||
w.etm_clk_active().set_bit();
|
||||
|
@ -47,6 +47,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
|
||||
- Fixed a BLE panic caused by unimplemented functions (#3762)
|
||||
- Fixed the BLE stack crashing in certain cases (#3854)
|
||||
- `ADC2` now cannot be used simultaneously with `radio` on ESP32 (#3876)
|
||||
- BLE on ESP32-C2 with 26MHz xtal (#4062)
|
||||
|
||||
### Removed
|
||||
|
||||
|
@ -1055,8 +1055,27 @@ pub(crate) fn ble_init() {
|
||||
|
||||
self::ble_os_adapter_chip_specific::ble_rtc_clk_init();
|
||||
|
||||
#[cfg(esp32c2)]
|
||||
let mut cfg = ble_os_adapter_chip_specific::BLE_CONFIG;
|
||||
|
||||
#[cfg(not(esp32c2))]
|
||||
let cfg = ble_os_adapter_chip_specific::BLE_CONFIG;
|
||||
|
||||
#[cfg(esp32c2)]
|
||||
{
|
||||
use esp_hal::clock::Clock;
|
||||
|
||||
let xtal = crate::hal::rtc_cntl::RtcClock::xtal_freq();
|
||||
let mhz = xtal.mhz() as u8;
|
||||
|
||||
cfg.main_xtal_freq = mhz;
|
||||
|
||||
if mhz == 26 {
|
||||
cfg.rtc_freq = 40000;
|
||||
cfg.main_xtal_freq = 26;
|
||||
}
|
||||
}
|
||||
|
||||
let res = esp_register_ext_funcs(&G_OSI_FUNCS as *const ExtFuncsT);
|
||||
if res != 0 {
|
||||
panic!("esp_register_ext_funcs returned {}", res);
|
||||
|
Loading…
x
Reference in New Issue
Block a user