1 // Copyright (C) 2022 Beken Corporation
2 //
3 // Licensed under the Apache License, Version 2.0 (the "License");
4 // you may not use this file except in compliance with the License.
5 // You may obtain a copy of the License at
6 //
7 // http://www.apache.org/licenses/LICENSE-2.0
8 //
9 // Unless required by applicable law or agreed to in writing, software
10 // distributed under the License is distributed on an "AS IS" BASIS,
11 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 // See the License for the specific language governing permissions and
13 // limitations under the License.
14
15 #include "hal_config.h"
16 #include "i2c_hal.h"
17 #include "i2c_hw.h"
18 #include "i2c_ll.h"
19
20 #if CFG_HAL_DEBUG_I2C
21
i2c0_struct_dump(void)22 static void i2c0_struct_dump(void)
23 {
24 i2c0_hw_t *hw = (i2c0_hw_t *)I2C_LL_REG_BASE(0);
25 SOC_LOGI("base=%x\r\n", (uint32_t)hw);
26
27 SOC_LOGI(" sm_bus_cfg=0x%x value=0x%x\n", &hw->sm_bus_cfg, hw->sm_bus_cfg.v);
28 SOC_LOGI(" idle_cr: %x\n", hw->sm_bus_cfg.idle_cr);
29 SOC_LOGI(" scl_cr: %x\n", hw->sm_bus_cfg.scl_cr);
30 SOC_LOGI(" freq_div: %x\n", hw->sm_bus_cfg.freq_div);
31 SOC_LOGI(" slave_addr: %x\n", hw->sm_bus_cfg.slave_addr);
32 SOC_LOGI(" clk_src: %x\n", hw->sm_bus_cfg.clk_src);
33 SOC_LOGI(" timeout_en: %x\n", hw->sm_bus_cfg.timeout_en);
34 SOC_LOGI(" idle_det_en: %x\n", hw->sm_bus_cfg.idle_det_en);
35 SOC_LOGI(" inh: %x\n", hw->sm_bus_cfg.inh);
36 SOC_LOGI(" en: %x\n", hw->sm_bus_cfg.en);
37
38 SOC_LOGI("\n");
39 SOC_LOGI(" sm_bus_status=0x%x value=0x%x\n", &hw->sm_bus_status, hw->sm_bus_status.v);
40 SOC_LOGI(" sm_int: %x\n", hw->sm_bus_status.sm_int);
41 SOC_LOGI(" scl_timeout: %x\n", hw->sm_bus_status.scl_timeout);
42 SOC_LOGI(" reserved0: %x\n", hw->sm_bus_status.reserved0);
43 SOC_LOGI(" arb_lost: %x\n", hw->sm_bus_status.arb_lost);
44 SOC_LOGI(" rx_fifo_empty: %x\n", hw->sm_bus_status.rx_fifo_empty);
45 SOC_LOGI(" tx_fifo_full: %x\n", hw->sm_bus_status.tx_fifo_full);
46 SOC_LOGI(" int_mode: %x\n", hw->sm_bus_status.int_mode);
47 SOC_LOGI(" ack: %x\n", hw->sm_bus_status.ack);
48 SOC_LOGI(" stop: %x\n", hw->sm_bus_status.stop);
49 SOC_LOGI(" start: %x\n", hw->sm_bus_status.start);
50 SOC_LOGI(" addr_match: %x\n", hw->sm_bus_status.addr_match);
51 SOC_LOGI(" ack_req: %x\n", hw->sm_bus_status.ack_req);
52 SOC_LOGI(" tx_mode: %x\n", hw->sm_bus_status.tx_mode);
53 SOC_LOGI(" master: %x\n", hw->sm_bus_status.master);
54 SOC_LOGI(" busy: %x\n", hw->sm_bus_status.busy);
55 SOC_LOGI(" reserved1: %x\n", hw->sm_bus_status.reserved1);
56
57 SOC_LOGI("\n");
58 SOC_LOGI(" sm_bus_data=0x%x value=0x%x\n", &hw->sm_bus_data, hw->sm_bus_data.v);
59 SOC_LOGI(" data: %x\n", hw->sm_bus_data.data);
60 SOC_LOGI(" reserved: %x\n", hw->sm_bus_data.reserved);
61 }
62
i2c_struct_dump(i2c_id_t id)63 void i2c_struct_dump(i2c_id_t id)
64 {
65 i2c0_struct_dump();
66 }
67
68 #endif
69
70