我通过查阅bouffalolab/bouffalo_sdk (github.com)后,在bouffalo_sdk/drivers/soc/bl616/std/include/hardware/hbn_reg.h at master · bouffalolab/bouffalo_sdk (github.com)找到了该寄存器的定义:
/* 0x204 : xtal32k */
union {
struct {
uint32_t reserved_0_1 : 2; /* [ 1: 0], rsvd, 0x0 */
uint32_t xtal32k_ext_sel : 1; /* [ 2], r/w, 0x0 */
uint32_t xtal32k_amp_ctrl : 2; /* [ 4: 3], r/w, 0x1 */
uint32_t xtal32k_reg : 2; /* [ 6: 5], r/w, 0x1 */
uint32_t xtal32k_outbuf_stre : 1; /* [ 7], r/w, 0x0 */
uint32_t xtal32k_otf_short : 1; /* [ 8], r/w, 0x0 */
uint32_t xtal32k_inv_stre : 2; /* [10: 9], r/w, 0x1 */
uint32_t xtal32k_capbank : 6; /* [16:11], r/w, 0x20 */
uint32_t xtal32k_ac_cap_short : 1; /* [ 17], r/w, 0x0 */
uint32_t pu_xtal32k_buf : 1; /* [ 18], r/w, 0x1 */
uint32_t pu_xtal32k : 1; /* [ 19], r/w, 0x0 */
uint32_t xtal32k_lowv_en : 1; /* [ 20], r/w, 0x0 */
uint32_t xtal32k_hiz_en : 1; /* [ 21], r/w, 0x1 */
uint32_t dten_xtal32k : 1; /* [ 22], r/w, 0x0 */
uint32_t ten_xtal32k : 1; /* [ 23], r/w, 0x0 */
uint32_t reserved_24_31 : 8; /* [31:24], rsvd, 0x0 */
} BF;
uint32_t WORD;
} xtal32k;
根据该定义,我将pu_xtal32k置1后是否就代表着已经使能xtal?例如这样:
// 获取外设
let peripherals = get_peripherals();
let hbn = peripherals.HBN;
// 配置MCU时钟源
// 使能xtal32k
hbn.xtal32k
.modify(|r, w| unsafe { w.bits(r.bits() | (1 << 19)) });