Skip to content

Commit 78baff9

Browse files
committed
feat(hal): add esp32h4 modem_clock hal layer
1 parent dd9613b commit 78baff9

File tree

7 files changed

+671
-2
lines changed

7 files changed

+671
-2
lines changed
Lines changed: 65 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,65 @@
1+
/*
2+
* SPDX-FileCopyrightText: 2025 Espressif Systems (Shanghai) CO LTD
3+
*
4+
* SPDX-License-Identifier: Apache-2.0
5+
*/
6+
7+
// The LL layer for ESP32-H4 LP CLKRST & LP PERI register operations
8+
9+
#pragma once
10+
11+
#include <stdbool.h>
12+
#include <stdlib.h>
13+
#include "soc/soc.h"
14+
#include "soc/lp_clkrst_struct.h"
15+
#include "soc/lpperi_struct.h"
16+
17+
#ifdef __cplusplus
18+
extern "C" {
19+
#endif
20+
21+
__attribute__((always_inline))
22+
static inline void lp_clkrst_ll_enable_ble_rtc_timer_slow_osc(lp_clkrst_dev_t *hw, bool en)
23+
{
24+
hw->lpperi.lp_sel_osc_slow = en;
25+
}
26+
27+
__attribute__((always_inline))
28+
static inline void lp_clkrst_ll_enable_ble_rtc_timer_fast_osc(lp_clkrst_dev_t *hw, bool en)
29+
{
30+
hw->lpperi.lp_sel_osc_fast = en;
31+
}
32+
33+
__attribute__((always_inline))
34+
static inline void lp_clkrst_ll_enable_ble_rtc_timer_main_xtal(lp_clkrst_dev_t *hw, bool en)
35+
{
36+
hw->lpperi.lp_sel_xtal = en;
37+
}
38+
39+
__attribute__((always_inline))
40+
static inline void lp_clkrst_ll_enable_ble_rtc_timer_32k_xtal(lp_clkrst_dev_t *hw, bool en)
41+
{
42+
hw->lpperi.lp_sel_xtal32k = en;
43+
}
44+
45+
__attribute__((always_inline))
46+
static inline void lp_clkrst_ll_set_ble_rtc_timer_divisor_value(lp_clkrst_dev_t *hw, uint32_t value)
47+
{
48+
hw->lpperi.lp_bletimer_div_num = value;
49+
}
50+
51+
__attribute__((always_inline))
52+
static inline uint32_t lp_clkrst_ll_get_ble_rtc_timer_divisor_value(lp_clkrst_dev_t *hw)
53+
{
54+
return hw->lpperi.lp_bletimer_div_num;
55+
}
56+
57+
__attribute__((always_inline))
58+
static inline void lp_clkrst_ll_select_modem_32k_clock_source(lp_clkrst_dev_t *hw, uint32_t src)
59+
{
60+
hw->lpperi.lp_bletimer_32k_sel = src;
61+
}
62+
63+
#ifdef __cplusplus
64+
}
65+
#endif
Lines changed: 103 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,103 @@
1+
/*
2+
* SPDX-FileCopyrightText: 2025 Espressif Systems (Shanghai) CO LTD
3+
*
4+
* SPDX-License-Identifier: Apache-2.0
5+
*/
6+
7+
// The LL layer for ESP32-H4 MODEM LPCON register operations
8+
9+
#pragma once
10+
11+
#include <stdlib.h>
12+
#include <stdbool.h>
13+
#include "soc/soc.h"
14+
#include "hal/assert.h"
15+
#include "modem/modem_lpcon_struct.h"
16+
#include "hal/modem_clock_types.h"
17+
18+
#ifdef __cplusplus
19+
extern "C" {
20+
#endif
21+
22+
__attribute__((always_inline))
23+
static inline void modem_lpcon_ll_enable_test_clk(modem_lpcon_dev_t *hw, bool en)
24+
{
25+
hw->test_conf.clk_en = en;
26+
}
27+
28+
__attribute__((always_inline))
29+
static inline void modem_lpcon_ll_enable_coex_lpclk_slow_osc(modem_lpcon_dev_t *hw, bool en)
30+
{
31+
hw->coex_lp_clk_conf.clk_coex_lp_sel_osc_slow = en;
32+
}
33+
34+
__attribute__((always_inline))
35+
static inline void modem_lpcon_ll_enable_coex_lpclk_fast_osc(modem_lpcon_dev_t *hw, bool en)
36+
{
37+
hw->coex_lp_clk_conf.clk_coex_lp_sel_osc_fast = en;
38+
}
39+
40+
__attribute__((always_inline))
41+
static inline void modem_lpcon_ll_enable_coex_lpclk_main_xtal(modem_lpcon_dev_t *hw, bool en)
42+
{
43+
hw->coex_lp_clk_conf.clk_coex_lp_sel_xtal = en;
44+
}
45+
46+
__attribute__((always_inline))
47+
static inline void modem_lpcon_ll_enable_coex_lpclk_32k_xtal(modem_lpcon_dev_t *hw, bool en)
48+
{
49+
hw->coex_lp_clk_conf.clk_coex_lp_sel_xtal32k = en;
50+
}
51+
52+
__attribute__((always_inline))
53+
static inline void modem_lpcon_ll_set_coex_lpclk_divisor_value(modem_lpcon_dev_t *hw, uint32_t value)
54+
{
55+
hw->coex_lp_clk_conf.clk_coex_lp_div_num = value;
56+
}
57+
58+
__attribute__((always_inline))
59+
static inline uint32_t modem_lpcon_ll_get_coex_lpclk_divisor_value(modem_lpcon_dev_t *hw)
60+
{
61+
return hw->coex_lp_clk_conf.clk_coex_lp_div_num;
62+
}
63+
64+
__attribute__((always_inline))
65+
static inline void modem_lpcon_ll_enable_coex_clock(modem_lpcon_dev_t *hw, bool en)
66+
{
67+
hw->clk_conf.clk_coex_en = en;
68+
}
69+
70+
__attribute__((always_inline))
71+
static inline void modem_lpcon_ll_enable_fe_mem_clock(modem_lpcon_dev_t *hw, bool en)
72+
{
73+
}
74+
75+
__attribute__((always_inline))
76+
static inline void modem_lpcon_ll_enable_coex_force_clock(modem_lpcon_dev_t *hw, bool en)
77+
{
78+
hw->clk_conf_force_on.clk_coex_fo = en;
79+
}
80+
81+
__attribute__((always_inline))
82+
static inline void modem_lpcon_ll_reset_coex(modem_lpcon_dev_t *hw)
83+
{
84+
hw->rst_conf.rst_coex = 1;
85+
hw->rst_conf.rst_coex = 0;
86+
}
87+
88+
__attribute__((always_inline))
89+
static inline void modem_lpcon_ll_reset_all(modem_lpcon_dev_t *hw)
90+
{
91+
hw->rst_conf.val = 0xf;
92+
hw->rst_conf.val = 0;
93+
}
94+
95+
__attribute__((always_inline))
96+
static inline uint32_t modem_lpcon_ll_get_date(modem_lpcon_dev_t *hw)
97+
{
98+
return hw->date.val;
99+
}
100+
101+
#ifdef __cplusplus
102+
}
103+
#endif

0 commit comments

Comments
 (0)