HPM SDK
HPMicro Software Development Kit
hpm_i2c_drv.h
Go to the documentation of this file.
1 /*
2  * Copyright (c) 2021-2024 HPMicro
3  *
4  * SPDX-License-Identifier: BSD-3-Clause
5  *
6  */
7 
8 #ifndef HPM_I2C_DRV_H
9 #define HPM_I2C_DRV_H
10 #include "hpm_common.h"
11 #include "hpm_i2c_regs.h"
12 #include "hpm_soc_feature.h"
13 
24 enum {
31 };
32 
33 /* convert data count value into register(CTRL[DATACNT] and CTRL[DATACNT_HIGH] if exist) */
34 /* x range from 1 to I2C_SOC_TRANSFER_COUNT_MAX */
35 /* 0 for I2C_SOC_TRANSFER_COUNT_MAX */
36 #define I2C_DATACNT_MAP(x) (((x) == I2C_SOC_TRANSFER_COUNT_MAX) ? 0 : x)
37 
41 #define I2C_CMD_NO_ACTION (I2C_CMD_CMD_SET(0))
42 #define I2C_CMD_ISSUE_DATA_TRANSMISSION (I2C_CMD_CMD_SET(1))
43 #define I2C_CMD_ACK (I2C_CMD_CMD_SET(2))
44 #define I2C_CMD_NACK (I2C_CMD_CMD_SET(3))
45 #define I2C_CMD_CLEAR_FIFO (I2C_CMD_CMD_SET(4))
46 #define I2C_CMD_RESET (I2C_CMD_CMD_SET(5))
47 
51 #define I2C_DIR_MASTER_WRITE (0U)
52 #define I2C_DIR_MASTER_READ (1U)
53 #define I2C_DIR_SLAVE_READ (0U)
54 #define I2C_DIR_SLAVE_WRITE (1U)
55 
59 #define I2C_EVENT_TRANSACTION_COMPLETE I2C_INTEN_CMPL_MASK
60 #define I2C_EVENT_BYTE_RECEIVED I2C_INTEN_BYTERECV_MASK
61 #define I2C_EVENT_BYTE_TRANSMIT I2C_INTEN_BYTETRANS_MASK
62 #define I2C_EVENT_START_CONDITION I2C_INTEN_START_MASK
63 #define I2C_EVENT_STOP_CONDITION I2C_INTEN_STOP_MASK
64 #define I2C_EVENT_LOSS_ARBITRATION I2C_INTEN_ARBLOSE_MASK
65 #define I2C_EVENT_ADDRESS_HIT I2C_INTEN_ADDRHIT_MASK
66 #define I2C_EVENT_FIFO_HALF I2C_INTEN_FIFOHALF_MASK
67 #define I2C_EVENT_FIFO_FULL I2C_INTEN_FIFOFULL_MASK
68 #define I2C_EVENT_FIFO_EMPTY I2C_INTEN_FIFOEMPTY_MASK
69 
70 #define I2C_EVENT_ALL_MASK (I2C_INTEN_CMPL_MASK \
71  | I2C_INTEN_BYTERECV_MASK \
72  | I2C_INTEN_BYTETRANS_MASK \
73  | I2C_INTEN_START_MASK \
74  | I2C_INTEN_STOP_MASK \
75  | I2C_INTEN_ARBLOSE_MASK \
76  | I2C_INTEN_ADDRHIT_MASK \
77  | I2C_INTEN_FIFOHALF_MASK \
78  | I2C_INTEN_FIFOFULL_MASK \
79  | I2C_INTEN_FIFOEMPTY_MASK)
83 #define I2C_STATUS_LINE_SDA I2C_STATUS_LINESDA_MASK
84 #define I2C_STATUS_LINE_SCL I2C_STATUS_LINESCL_MASK
85 #define I2C_STATUS_GENERAL_CALL I2C_STATUS_GENCALL_MASK
86 #define I2C_STATUS_BUS_BUSY I2C_STATUS_BUSBUSY_MASK
87 #define I2C_STATUS_ACK I2C_STATUS_ACK_MASK
88 
89 #define I2C_WR 0x0000 /* not operable with read flags*/
90 #define I2C_RD (1u << 0) /* not operable with write flags*/
91 #define I2C_ADDR_10BIT (1u << 2) /* this is a ten bit chip address */
92 #define I2C_NO_START (1u << 4) /* no start phase */
93 #define I2C_NO_ADDRESS (1u << 5) /* no address phase */
94 #define I2C_NO_READ_ACK (1u << 6) /* when I2C reading, we do not ACK */
95 #define I2C_NO_STOP (1u << 7) /* no stop phase */
96 #define I2C_WRITE_CHECK_ACK (1u << 8) /* when I2C writing, need check the slave returns ack */
97 
101 typedef struct {
103  uint8_t i2c_mode;
104 } i2c_config_t;
105 
109 typedef enum i2c_mode {
114 
121 typedef enum i2c_seq_transfer_opt {
126 
127 #ifdef __cplusplus
128 extern "C" {
129 #endif
130 
136 static inline void i2c_respond_Nack(I2C_Type *ptr)
137 {
138  ptr->CMD = I2C_CMD_NACK;
139 }
140 
146 static inline void i2c_respond_ack(I2C_Type *ptr)
147 {
148  ptr->CMD = I2C_CMD_ACK;
149 }
150 
156 static inline void i2c_clear_fifo(I2C_Type *ptr)
157 {
158  ptr->CMD = I2C_CMD_CLEAR_FIFO;
159 }
160 
169 static inline uint16_t i2c_get_data_count(I2C_Type *ptr)
170 {
171  uint32_t i2c_ctrl = ptr->CTRL;
172 #ifdef I2C_CTRL_DATACNT_HIGH_MASK
173  return (I2C_CTRL_DATACNT_HIGH_GET(i2c_ctrl) << 8U) + I2C_CTRL_DATACNT_GET(i2c_ctrl);
174 #else
175  return I2C_CTRL_DATACNT_GET(i2c_ctrl);
176 #endif
177 }
178 
185 static inline bool i2c_fifo_is_full(I2C_Type *ptr)
186 {
187  return ptr->STATUS & I2C_STATUS_FIFOFULL_MASK;
188 }
189 
199 static inline bool i2c_fifo_is_half(I2C_Type *ptr)
200 {
201  return ptr->STATUS & I2C_STATUS_FIFOHALF_MASK;
202 }
203 
210 static inline bool i2c_fifo_is_empty(I2C_Type *ptr)
211 {
212  return ptr->STATUS & I2C_STATUS_FIFOEMPTY_MASK;
213 }
214 
224 static inline bool i2c_is_writing(I2C_Type *ptr)
225 {
226  return (ptr->CTRL & I2C_CTRL_DIR_MASK);
227 }
228 
238 static inline bool i2c_is_reading(I2C_Type *ptr)
239 {
240  return !i2c_is_writing(ptr);
241 }
242 
252 static inline bool i2c_get_line_sda_status(I2C_Type *ptr)
253 {
254  return I2C_STATUS_LINESDA_GET(ptr->STATUS);
255 }
256 
266 static inline bool i2c_get_line_scl_status(I2C_Type *ptr)
267 {
268  return I2C_STATUS_LINESCL_GET(ptr->STATUS);
269 }
270 
279 static inline void i2c_clear_status(I2C_Type *ptr, uint32_t mask)
280 {
281  ptr->STATUS = mask;
282 }
283 
292 static inline uint32_t i2c_get_status(I2C_Type *ptr)
293 {
294  return ptr->STATUS;
295 }
296 
305 static inline uint32_t i2c_get_irq_setting(I2C_Type *ptr)
306 {
307  return ptr->INTEN;
308 }
309 
318 static inline void i2c_disable_irq(I2C_Type *ptr, uint32_t mask)
319 {
320  ptr->INTEN &= ~mask;
321 }
322 
331 static inline void i2c_enable_irq(I2C_Type *ptr, uint32_t mask)
332 {
333  ptr->INTEN |= mask;
334 }
335 
343 static inline void i2c_disable_auto_ack(I2C_Type *ptr)
344 {
346 }
347 
355 static inline void i2c_enable_auto_ack(I2C_Type *ptr)
356 {
358 }
359 
370 static inline void i2c_enable_10bit_address_mode(I2C_Type *ptr, bool enable)
371 {
372  ptr->SETUP |= I2C_SETUP_ADDRESSING_SET(enable);
373 }
374 
386  uint32_t src_clk_in_hz,
387  i2c_config_t *config);
388 
404  const uint16_t device_address,
405  uint8_t *addr,
406  uint32_t addr_size_in_byte,
407  uint8_t *buf,
408  const uint32_t size_in_byte);
409 
425  const uint16_t device_address,
426  uint8_t *addr,
427  uint32_t addr_size_in_byte,
428  uint8_t *buf,
429  const uint32_t size_in_byte);
430 
444  const uint16_t device_address,
445  uint8_t *buf,
446  const uint32_t size);
447 
459 hpm_stat_t i2c_master_start_dma_write(I2C_Type *i2c_ptr, const uint16_t device_address, uint32_t size);
460 
472 hpm_stat_t i2c_master_start_dma_read(I2C_Type *i2c_ptr, const uint16_t device_address, uint32_t size);
473 
487  const uint16_t device_address,
488  uint8_t *buf,
489  const uint32_t size);
501 hpm_stat_t i2c_init_slave(I2C_Type *ptr, uint32_t src_clk_in_hz,
502  i2c_config_t *config, const uint16_t slave_address);
503 
515 hpm_stat_t i2c_slave_read(I2C_Type *ptr, uint8_t *buf, const uint32_t size);
516 
528 hpm_stat_t i2c_slave_write(I2C_Type *ptr, uint8_t *buf, const uint32_t size);
529 
535 void i2c_reset(I2C_Type *ptr);
536 
542 static inline void i2c_dma_enable(I2C_Type *ptr)
543 {
544  ptr->SETUP |= I2C_SETUP_DMAEN_MASK;
545 }
546 
552 static inline void i2c_dma_disable(I2C_Type *ptr)
553 {
554  ptr->SETUP &= ~I2C_SETUP_DMAEN_MASK;
555 }
556 
566 hpm_stat_t i2c_slave_dma_transfer(I2C_Type *ptr, const uint32_t size);
567 
574 static inline void i2c_write_byte(I2C_Type *ptr, uint8_t data)
575 {
576  ptr->DATA = I2C_DATA_DATA_SET(data);
577 }
578 
585 static inline uint8_t i2c_read_byte(I2C_Type *ptr)
586 {
587  return (uint8_t)I2C_DATA_DATA_GET(ptr->DATA);
588 }
589 
598 static inline uint8_t i2c_get_direction(I2C_Type *ptr)
599 {
600  return (uint8_t)I2C_CTRL_DIR_GET(ptr->CTRL);
601 }
602 
612 hpm_stat_t i2c_master_configure_transfer(I2C_Type *i2c_ptr, const uint16_t device_address, uint32_t size, bool read);
613 
625 hpm_stat_t i2c_master_seq_transmit_check_ack(I2C_Type *ptr, const uint16_t device_address,
626  uint8_t *buf, const uint32_t size, i2c_seq_transfer_opt_t opt, bool ack_check);
627 
638 #define i2c_master_seq_transmit(ptr, device_address, buf, size, opt) i2c_master_seq_transmit_check_ack(ptr, device_address, buf, size, opt, false)
639 
650 hpm_stat_t i2c_master_seq_receive(I2C_Type *ptr, const uint16_t device_address,
651  uint8_t *buf, const uint32_t size, i2c_seq_transfer_opt_t opt);
652 
653 #if defined(HPM_IP_FEATURE_I2C_SUPPORT_RESET) && (HPM_IP_FEATURE_I2C_SUPPORT_RESET == 1)
660 static inline void i2c_gen_reset_signal(I2C_Type *ptr, uint8_t clk_len)
661 {
662  ptr->CTRL = (ptr->CTRL & ~I2C_CTRL_RESET_LEN_MASK) | I2C_CTRL_RESET_LEN_SET(clk_len) \
664 }
665 #endif
666 
677 hpm_stat_t i2c_master_transfer(I2C_Type *ptr, const uint16_t device_address,
678  uint8_t *buf, const uint32_t size, uint16_t flags);
679 
690 static inline hpm_stat_t i2c_set_data_count(I2C_Type *ptr, uint32_t size)
691 {
694  }
695 #ifdef I2C_CTRL_DATACNT_HIGH_MASK
698 #else
699  ptr->CTRL &= ~I2C_CTRL_DATACNT_MASK;
701 #endif
702  return status_success;
703 }
704 
713 {
715 }
716 
725 static inline void i2c_master_set_slave_address(I2C_Type *ptr, uint16_t address)
726 {
727  ptr->ADDR = I2C_ADDR_ADDR_SET(address);
728 }
729 
735 static inline void i2c_master_enable_start_phase(I2C_Type *ptr)
736 {
738 }
739 
745 static inline void i2c_master_disable_start_phase(I2C_Type *ptr)
746 {
748 }
749 
755 static inline void i2c_master_enable_addr_phase(I2C_Type *ptr)
756 {
758 }
759 
765 static inline void i2c_master_disable_addr_phase(I2C_Type *ptr)
766 {
768 }
769 
775 static inline void i2c_master_enable_data_phase(I2C_Type *ptr)
776 {
778 }
779 
785 static inline void i2c_master_disable_data_phase(I2C_Type *ptr)
786 {
788 }
789 
795 static inline void i2c_master_enable_stop_phase(I2C_Type *ptr)
796 {
798 }
799 
805 static inline void i2c_master_disable_stop_phase(I2C_Type *ptr)
806 {
808 }
809 
816 static inline void i2c_set_direction(I2C_Type *ptr, bool direction)
817 {
818  ptr->CTRL = (ptr->CTRL & ~I2C_CTRL_DIR_MASK) | I2C_CTRL_DIR_SET(direction);
819 }
820 
825 #ifdef __cplusplus
826 }
827 #endif
828 
829 #endif /* HPM_I2C_DRV_H */
830 
#define I2C_SOC_TRANSFER_COUNT_MAX
Definition: hpm_soc_feature.h:39
#define I2C_DATA_DATA_GET(x)
Definition: hpm_i2c_regs.h:336
#define I2C_STATUS_FIFOHALF_MASK
Definition: hpm_i2c_regs.h:292
#define I2C_CTRL_DATACNT_SET(x)
Definition: hpm_i2c_regs.h:455
#define I2C_STATUS_FIFOEMPTY_MASK
Definition: hpm_i2c_regs.h:310
#define I2C_CTRL_DATACNT_MASK
Definition: hpm_i2c_regs.h:453
#define I2C_CTRL_RESET_HOLD_SCKIN_MASK
Definition: hpm_i2c_regs.h:368
#define I2C_STATUS_LINESDA_GET(x)
Definition: hpm_i2c_regs.h:167
#define I2C_CTRL_PHASE_ADDR_MASK
Definition: hpm_i2c_regs.h:401
#define I2C_CTRL_DATACNT_HIGH_GET(x)
Definition: hpm_i2c_regs.h:351
#define I2C_STATUS_FIFOFULL_MASK
Definition: hpm_i2c_regs.h:301
#define I2C_CTRL_DATACNT_GET(x)
Definition: hpm_i2c_regs.h:456
#define I2C_CTRL_DATACNT_HIGH_MASK
Definition: hpm_i2c_regs.h:348
#define I2C_CTRL_DIR_MASK
Definition: hpm_i2c_regs.h:439
#define I2C_CTRL_RESET_LEN_MASK
Definition: hpm_i2c_regs.h:358
#define I2C_DATA_DATA_SET(x)
Definition: hpm_i2c_regs.h:335
#define I2C_ADDR_ADDR_SET(x)
Definition: hpm_i2c_regs.h:323
#define I2C_CTRL_RESET_LEN_SET(x)
Definition: hpm_i2c_regs.h:360
#define I2C_CTRL_RESET_ON_MASK
Definition: hpm_i2c_regs.h:379
#define I2C_CTRL_PHASE_DATA_MASK
Definition: hpm_i2c_regs.h:412
#define I2C_CTRL_DIR_SET(x)
Definition: hpm_i2c_regs.h:441
#define I2C_CTRL_DIR_GET(x)
Definition: hpm_i2c_regs.h:442
#define I2C_CTRL_DATACNT_HIGH_SET(x)
Definition: hpm_i2c_regs.h:350
#define I2C_SETUP_ADDRESSING_SET(x)
Definition: hpm_i2c_regs.h:573
#define I2C_CTRL_PHASE_START_MASK
Definition: hpm_i2c_regs.h:390
#define I2C_SETUP_DMAEN_MASK
Definition: hpm_i2c_regs.h:547
#define I2C_CTRL_PHASE_STOP_MASK
Definition: hpm_i2c_regs.h:423
#define I2C_STATUS_LINESCL_GET(x)
Definition: hpm_i2c_regs.h:178
uint32_t hpm_stat_t
Definition: hpm_common.h:126
#define MAKE_STATUS(group, code)
Definition: hpm_common.h:135
@ status_invalid_argument
Definition: hpm_common.h:182
@ status_success
Definition: hpm_common.h:180
@ status_group_i2c
Definition: hpm_common.h:140
static void i2c_clear_fifo(I2C_Type *ptr)
clear I2C fifo
Definition: hpm_i2c_drv.h:156
hpm_stat_t i2c_master_start_dma_write(I2C_Type *i2c_ptr, const uint16_t device_address, uint32_t size)
I2C master start write data by DMA.
Definition: hpm_i2c_drv.c:719
static bool i2c_get_line_scl_status(I2C_Type *ptr)
get i2c scl line status
Definition: hpm_i2c_drv.h:266
static void i2c_respond_ack(I2C_Type *ptr)
respond ACK
Definition: hpm_i2c_drv.h:146
#define I2C_CMD_NACK
Definition: hpm_i2c_drv.h:44
hpm_stat_t i2c_init_slave(I2C_Type *ptr, uint32_t src_clk_in_hz, i2c_config_t *config, const uint16_t slave_address)
I2C slave initialization.
Definition: hpm_i2c_drv.c:559
hpm_stat_t i2c_master_write(I2C_Type *ptr, const uint16_t device_address, uint8_t *buf, const uint32_t size)
I2C master write data to certain slave device.
Definition: hpm_i2c_drv.c:466
#define I2C_EVENT_BYTE_RECEIVED
Definition: hpm_i2c_drv.h:60
hpm_stat_t i2c_master_address_write(I2C_Type *ptr, const uint16_t device_address, uint8_t *addr, uint32_t addr_size_in_byte, uint8_t *buf, const uint32_t size_in_byte)
I2C master write data to specific address of certain slave device.
Definition: hpm_i2c_drv.c:280
hpm_stat_t i2c_slave_dma_transfer(I2C_Type *ptr, const uint32_t size)
I2C slave dma transfer data.
Definition: hpm_i2c_drv.c:794
enum i2c_seq_transfer_opt i2c_seq_transfer_opt_t
I2c sequential transfer options.
static void i2c_set_direction(I2C_Type *ptr, bool direction)
set i2c transaction direction
Definition: hpm_i2c_drv.h:816
#define I2C_CMD_ISSUE_DATA_TRANSMISSION
Definition: hpm_i2c_drv.h:42
static void i2c_write_byte(I2C_Type *ptr, uint8_t data)
I2C write byte into FIFO.
Definition: hpm_i2c_drv.h:574
i2c_seq_transfer_opt
I2c sequential transfer options.
Definition: hpm_i2c_drv.h:121
hpm_stat_t i2c_master_seq_transmit_check_ack(I2C_Type *ptr, const uint16_t device_address, uint8_t *buf, const uint32_t size, i2c_seq_transfer_opt_t opt, bool ack_check)
sequential transmit in master I2C mode an amount of data and checks ACK in blocking
Definition: hpm_i2c_drv.c:851
static hpm_stat_t i2c_set_data_count(I2C_Type *ptr, uint32_t size)
Set the I2C data transfer count.
Definition: hpm_i2c_drv.h:690
static void i2c_master_disable_stop_phase(I2C_Type *ptr)
Disable stop phase at the transaction.
Definition: hpm_i2c_drv.h:805
static void i2c_gen_reset_signal(I2C_Type *ptr, uint8_t clk_len)
generate SCL clock as reset signal
Definition: hpm_i2c_drv.h:660
static void i2c_master_disable_start_phase(I2C_Type *ptr)
Disable start phase at the transaction.
Definition: hpm_i2c_drv.h:745
static bool i2c_fifo_is_half(I2C_Type *ptr)
check if I2C FIFO is half
Definition: hpm_i2c_drv.h:199
static void i2c_master_enable_addr_phase(I2C_Type *ptr)
Enable address phase at the transaction.
Definition: hpm_i2c_drv.h:755
static uint16_t i2c_get_data_count(I2C_Type *ptr)
check data count
Definition: hpm_i2c_drv.h:169
static void i2c_master_enable_data_phase(I2C_Type *ptr)
Enable data phase at the transaction.
Definition: hpm_i2c_drv.h:775
static void i2c_enable_auto_ack(I2C_Type *ptr)
enable auto ack
Definition: hpm_i2c_drv.h:355
static bool i2c_is_reading(I2C_Type *ptr)
check if I2C is reading
Definition: hpm_i2c_drv.h:238
static void i2c_disable_auto_ack(I2C_Type *ptr)
disable auto ack
Definition: hpm_i2c_drv.h:343
hpm_stat_t i2c_master_address_read(I2C_Type *ptr, const uint16_t device_address, uint8_t *addr, uint32_t addr_size_in_byte, uint8_t *buf, const uint32_t size_in_byte)
I2C master read data from specific address of certain slave device.
Definition: hpm_i2c_drv.c:161
static void i2c_dma_enable(I2C_Type *ptr)
Enable i2c DMA.
Definition: hpm_i2c_drv.h:542
#define I2C_DATACNT_MAP(x)
Definition: hpm_i2c_drv.h:36
static void i2c_respond_Nack(I2C_Type *ptr)
respond NACK
Definition: hpm_i2c_drv.h:136
static void i2c_master_issue_data_transmission(I2C_Type *ptr)
Trigger the I2C controller to issue a data transmission command.
Definition: hpm_i2c_drv.h:712
static bool i2c_fifo_is_empty(I2C_Type *ptr)
check if I2C FIFO is empty
Definition: hpm_i2c_drv.h:210
static void i2c_dma_disable(I2C_Type *ptr)
Disable i2c DMA.
Definition: hpm_i2c_drv.h:552
static bool i2c_get_line_sda_status(I2C_Type *ptr)
get i2c sda line status
Definition: hpm_i2c_drv.h:252
static void i2c_master_disable_data_phase(I2C_Type *ptr)
Disable data phase at the transaction.
Definition: hpm_i2c_drv.h:785
static uint32_t i2c_get_irq_setting(I2C_Type *ptr)
i2c get interrupts setting
Definition: hpm_i2c_drv.h:305
static uint32_t i2c_get_status(I2C_Type *ptr)
get status
Definition: hpm_i2c_drv.h:292
#define I2C_CMD_ACK
Definition: hpm_i2c_drv.h:43
hpm_stat_t i2c_init_master(I2C_Type *ptr, uint32_t src_clk_in_hz, i2c_config_t *config)
I2C master initialization.
Definition: hpm_i2c_drv.c:135
static uint8_t i2c_get_direction(I2C_Type *ptr)
I2C get direction.
Definition: hpm_i2c_drv.h:598
void i2c_reset(I2C_Type *ptr)
reset I2C
Definition: hpm_i2c_drv.c:128
i2c_mode
I2C mode.
Definition: hpm_i2c_drv.h:109
static void i2c_master_enable_stop_phase(I2C_Type *ptr)
Enable stop phase at the transaction.
Definition: hpm_i2c_drv.h:795
hpm_stat_t i2c_master_read(I2C_Type *ptr, const uint16_t device_address, uint8_t *buf, const uint32_t size)
I2C master read data from certain slave device.
Definition: hpm_i2c_drv.c:374
static void i2c_disable_irq(I2C_Type *ptr, uint32_t mask)
disable interrupts
Definition: hpm_i2c_drv.h:318
static void i2c_master_disable_addr_phase(I2C_Type *ptr)
Disable address phase at the transaction.
Definition: hpm_i2c_drv.h:765
static void i2c_clear_status(I2C_Type *ptr, uint32_t mask)
clear status
Definition: hpm_i2c_drv.h:279
static bool i2c_fifo_is_full(I2C_Type *ptr)
check if I2C FIFO is full
Definition: hpm_i2c_drv.h:185
static uint8_t i2c_read_byte(I2C_Type *ptr)
I2C read byte into FIFO.
Definition: hpm_i2c_drv.h:585
hpm_stat_t i2c_master_seq_receive(I2C_Type *ptr, const uint16_t device_address, uint8_t *buf, const uint32_t size, i2c_seq_transfer_opt_t opt)
sequential receive in master I2C mode an amount of data in blocking
Definition: hpm_i2c_drv.c:956
static bool i2c_is_writing(I2C_Type *ptr)
check if I2C is writing
Definition: hpm_i2c_drv.h:224
#define I2C_CMD_CLEAR_FIFO
Definition: hpm_i2c_drv.h:45
static void i2c_enable_10bit_address_mode(I2C_Type *ptr, bool enable)
enable 10 bit address mode
Definition: hpm_i2c_drv.h:370
hpm_stat_t i2c_master_configure_transfer(I2C_Type *i2c_ptr, const uint16_t device_address, uint32_t size, bool read)
I2C master configure transfer setting.
Definition: hpm_i2c_drv.c:816
static void i2c_enable_irq(I2C_Type *ptr, uint32_t mask)
enable interrupts
Definition: hpm_i2c_drv.h:331
static void i2c_master_enable_start_phase(I2C_Type *ptr)
Enable start phase at the transaction.
Definition: hpm_i2c_drv.h:735
enum i2c_mode i2c_mode_t
I2C mode.
hpm_stat_t i2c_master_transfer(I2C_Type *ptr, const uint16_t device_address, uint8_t *buf, const uint32_t size, uint16_t flags)
data transfer on master I2C mode in blocking
Definition: hpm_i2c_drv.c:1048
static void i2c_master_set_slave_address(I2C_Type *ptr, uint16_t address)
Set the slave address for I2C master mode.
Definition: hpm_i2c_drv.h:725
hpm_stat_t i2c_master_start_dma_read(I2C_Type *i2c_ptr, const uint16_t device_address, uint32_t size)
I2C master start read data by DMA.
Definition: hpm_i2c_drv.c:757
hpm_stat_t i2c_slave_read(I2C_Type *ptr, uint8_t *buf, const uint32_t size)
I2C slave read data.
Definition: hpm_i2c_drv.c:652
hpm_stat_t i2c_slave_write(I2C_Type *ptr, uint8_t *buf, const uint32_t size)
I2C slave write data.
Definition: hpm_i2c_drv.c:587
@ i2c_next_frame
Definition: hpm_i2c_drv.h:123
@ i2c_last_frame
Definition: hpm_i2c_drv.h:124
@ i2c_frist_frame
Definition: hpm_i2c_drv.h:122
@ status_i2c_invalid_data
Definition: hpm_i2c_drv.h:26
@ status_i2c_transmit_not_completed
Definition: hpm_i2c_drv.h:28
@ status_i2c_no_addr_hit
Definition: hpm_i2c_drv.h:27
@ status_i2c_no_ack
Definition: hpm_i2c_drv.h:25
@ status_i2c_bus_busy
Definition: hpm_i2c_drv.h:29
@ status_i2c_not_supported
Definition: hpm_i2c_drv.h:30
@ i2c_mode_fast_plus
Definition: hpm_i2c_drv.h:112
@ i2c_mode_normal
Definition: hpm_i2c_drv.h:110
@ i2c_mode_fast
Definition: hpm_i2c_drv.h:111
static void size
Definition: hpm_math.h:6938
static hpm_stat_t read(void *ops, hpm_serial_nor_transfer_seq_t *cmd_seq)
Definition: hpm_serial_nor_host_spi.c:309
Definition: hpm_i2c_regs.h:12
__RW uint32_t STATUS
Definition: hpm_i2c_regs.h:16
__RW uint32_t CMD
Definition: hpm_i2c_regs.h:20
__RW uint32_t DATA
Definition: hpm_i2c_regs.h:18
__RW uint32_t CTRL
Definition: hpm_i2c_regs.h:19
__RW uint32_t ADDR
Definition: hpm_i2c_regs.h:17
__RW uint32_t SETUP
Definition: hpm_i2c_regs.h:21
__RW uint32_t INTEN
Definition: hpm_i2c_regs.h:15
I2C config.
Definition: hpm_i2c_drv.h:101
uint8_t i2c_mode
Definition: hpm_i2c_drv.h:103
bool is_10bit_addressing
Definition: hpm_i2c_drv.h:102