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 #pragma once 16 17 #ifdef __cplusplus 18 extern "C" { 19 #endif 20 21 22 typedef volatile struct { 23 /* REG_0x0 */ 24 union { 25 struct { 26 uint32_t idle_cr: 3; /**< bit[0:2] */ 27 uint32_t scl_cr: 3; /**< bit[3:5] */ 28 uint32_t freq_div: 10; /**< bit[6:15] */ 29 uint32_t slave_addr: 10; /**< bit[16:25] */ 30 uint32_t clk_src: 2; /**< bit[26:27] */ 31 uint32_t timeout_en: 1; /**< bit[28] */ 32 uint32_t idle_det_en: 1; /**< bit[29] bus idle detection enable */ 33 uint32_t inh: 1; /**< bit[30] */ 34 uint32_t en: 1; /**< bit[31] */ 35 }; 36 uint32_t v; 37 } sm_bus_cfg; 38 39 /* REG_0x1 */ 40 union { 41 struct { 42 uint32_t sm_int: 1; /**< bit[0] */ 43 uint32_t scl_timeout: 1; /**< bit[1] */ 44 uint32_t reserved0: 1; /**< bit[2] */ 45 uint32_t arb_lost: 1; /**< bit[3] */ 46 uint32_t rx_fifo_empty: 1; /**< bit[4] */ 47 uint32_t tx_fifo_full: 1; /**< bit[5] */ 48 uint32_t int_mode: 2; /**< bit[6:7] */ 49 uint32_t ack: 1; /**< bit[8] */ 50 uint32_t stop: 1; /**< bit[9] */ 51 uint32_t start: 1; /**< bit[10] */ 52 uint32_t addr_match: 1; /**< bit[11] */ 53 uint32_t ack_req: 1; /**< bit[12] */ 54 uint32_t tx_mode: 1; /**< bit[13] */ 55 uint32_t master: 1; /**< bit[14] */ 56 uint32_t busy: 1; /**< bit[15] */ 57 uint32_t reserved1: 16; /**< bit[16:31] */ 58 }; 59 uint32_t v; 60 } sm_bus_status; 61 62 /* REG_0x2 */ 63 union { 64 struct { 65 uint32_t data: 8; /**< bit[0:7] */ 66 uint32_t reserved: 24; /**< bit[8:31] */ 67 }; 68 uint32_t v; 69 } sm_bus_data; 70 } i2c0_hw_t; 71 72 typedef volatile struct { 73 i2c0_hw_t *i2c0_hw; 74 } i2c_hw_t; 75 76 #ifdef __cplusplus 77 } 78 #endif 79 80