@@ -59,7 +59,7 @@ static int nu_int_i2c_poll_tran_heatbeat_timeout(const struct device *dev, uint3
59
59
static int nu_int_i2c_is_trsn_done (const struct device * dev );
60
60
static int nu_int_i2c_is_tran_started (const struct device * dev );
61
61
static int nu_int_i2c_addr2data (int address , int read );
62
- #ifdef CONFIG_I2C_SLAVE
62
+ #ifdef CONFIG_I2C_TARGET
63
63
/* Convert zephyr address to BSP address. */
64
64
static int nu_int_i2c_addr2bspaddr (int address );
65
65
static void nu_int_i2c_enable_slave_if_registered (const struct device * dev );
@@ -76,7 +76,7 @@ static int nu_int_i2c_set_int(const struct device *dev, int inten);
76
76
#define TRANCTRL_LASTDATANAKED (1 << 2) // Last data NACKed
77
77
#define TRANCTRL_RECVDATA (1 << 3) // Receive data available
78
78
79
- #ifdef CONFIG_I2C_SLAVE
79
+ #ifdef CONFIG_I2C_TARGET
80
80
#define NoData 0 // the slave has not been addressed
81
81
#define ReadAddressed 1 // the master has requested a read from this slave (slave = transmitter)
82
82
#define WriteGeneral 2 // the master is writing to all slave
@@ -110,8 +110,8 @@ struct i2c_numaker_data {
110
110
struct k_sem lock ;
111
111
struct k_sem xfer_sync ;
112
112
uint32_t dev_config ;
113
- #ifdef CONFIG_I2C_SLAVE
114
- struct i2c_slave_config * slave_config ;
113
+ #ifdef CONFIG_I2C_TARGET
114
+ struct i2c_target_config * slave_config ;
115
115
#endif
116
116
117
117
struct {
@@ -120,7 +120,7 @@ struct i2c_numaker_data {
120
120
char * tran_pos ;
121
121
char * tran_end ;
122
122
int inten ;
123
- #ifdef CONFIG_I2C_SLAVE
123
+ #ifdef CONFIG_I2C_TARGET
124
124
int slaveaddr_state ;
125
125
#endif
126
126
} i2c ;
@@ -165,7 +165,7 @@ static int i2c_numaker_configure(const struct device *dev,
165
165
k_sem_take (& data -> lock , K_FOREVER );
166
166
nu_int_i2c_disable_int (dev );
167
167
168
- #ifdef CONFIG_I2C_SLAVE
168
+ #ifdef CONFIG_I2C_TARGET
169
169
if (nu_int_i2c_is_slave_busy (dev )) {
170
170
LOG_ERR ("Reconfigure with slave being busy" );
171
171
err = - EBUSY ;
@@ -286,7 +286,7 @@ static int i2c_numaker_transfer(const struct device *dev, struct i2c_msg *msgs,
286
286
/* Do I2C stop to release bus ownership */
287
287
nu_int_i2c_stop (dev );
288
288
289
- #ifdef CONFIG_I2C_SLAVE
289
+ #ifdef CONFIG_I2C_TARGET
290
290
/* Enable slave mode if any slave registered */
291
291
nu_int_i2c_enable_slave_if_registered (dev );
292
292
#endif
@@ -299,15 +299,15 @@ static int i2c_numaker_transfer(const struct device *dev, struct i2c_msg *msgs,
299
299
return err ;
300
300
}
301
301
302
- #ifdef CONFIG_I2C_SLAVE
302
+ #ifdef CONFIG_I2C_TARGET
303
303
static int i2c_numaker_slave_register (const struct device * dev ,
304
- struct i2c_slave_config * slave_config )
304
+ struct i2c_target_config * slave_config )
305
305
{
306
306
if (!slave_config ) {
307
307
return - EINVAL ;
308
308
}
309
309
310
- if (slave_config -> flags & I2C_SLAVE_FLAGS_ADDR_10_BITS ) {
310
+ if (slave_config -> flags & I2C_ADDR_10_BITS ) {
311
311
LOG_ERR ("10-bits address not supported" );
312
312
return - ENOTSUP ;
313
313
}
@@ -347,7 +347,7 @@ static int i2c_numaker_slave_register(const struct device *dev,
347
347
}
348
348
349
349
static int i2c_numaker_slave_unregister (const struct device * dev ,
350
- struct i2c_slave_config * slave_config )
350
+ struct i2c_target_config * slave_config )
351
351
{
352
352
if (!slave_config ) {
353
353
return - EINVAL ;
@@ -411,9 +411,9 @@ static void i2c_numaker_isr(const struct device *dev)
411
411
const struct i2c_numaker_config * config = dev -> config ;
412
412
struct i2c_numaker_data * data = dev -> data ;
413
413
I2C_T * i2c_base = config -> i2c_base ;
414
- #ifdef CONFIG_I2C_SLAVE
415
- struct i2c_slave_config * slave_config = data -> slave_config ;
416
- const struct i2c_slave_callbacks * slave_callbacks = slave_config ? slave_config -> callbacks : NULL ;
414
+ #ifdef CONFIG_I2C_TARGET
415
+ struct i2c_target_config * slave_config = data -> slave_config ;
416
+ const struct i2c_target_callbacks * slave_callbacks = slave_config ? slave_config -> callbacks : NULL ;
417
417
int err = 0 ;
418
418
uint8_t data_tran ;
419
419
#endif
@@ -501,7 +501,7 @@ static void i2c_numaker_isr(const struct device *dev)
501
501
502
502
//case 0x00: // Bus error
503
503
504
- #ifdef CONFIG_I2C_SLAVE
504
+ #ifdef CONFIG_I2C_TARGET
505
505
// Slave Transmit
506
506
case 0xB8 : // Slave Transmit Data ACK
507
507
case 0xA8 : // Slave Transmit Address ACK
@@ -671,7 +671,7 @@ static void i2c_numaker_isr(const struct device *dev)
671
671
nu_int_i2c_disable_int (dev );
672
672
}
673
673
break ;
674
- #endif /* CONFIG_I2C_SLAVE */
674
+ #endif /* CONFIG_I2C_TARGET */
675
675
676
676
case 0xF8 : // Bus Released
677
677
break ;
@@ -739,7 +739,7 @@ static int i2c_numaker_init(const struct device *dev)
739
739
740
740
SYS_ResetModule (config -> id_rst );
741
741
742
- err = i2c_numaker_configure (dev , I2C_MODE_MASTER | i2c_map_dt_bitrate (config -> bitrate ));
742
+ err = i2c_numaker_configure (dev , I2C_MODE_CONTROLLER | i2c_map_dt_bitrate (config -> bitrate ));
743
743
if (err != 0 ) {
744
744
goto cleanup ;
745
745
}
@@ -756,9 +756,9 @@ static const struct i2c_driver_api i2c_numaker_driver_api = {
756
756
.configure = i2c_numaker_configure ,
757
757
.get_config = i2c_numaker_get_config ,
758
758
.transfer = i2c_numaker_transfer ,
759
- #ifdef CONFIG_I2C_SLAVE
760
- .slave_register = i2c_numaker_slave_register ,
761
- .slave_unregister = i2c_numaker_slave_unregister ,
759
+ #ifdef CONFIG_I2C_TARGET
760
+ .target_register = i2c_numaker_slave_register ,
761
+ .target_unregister = i2c_numaker_slave_unregister ,
762
762
#endif
763
763
.recover_bus = i2c_numaker_recover_bus ,
764
764
};
@@ -831,7 +831,7 @@ static void nu_int_i2c_fsm_reset(const struct device *dev, uint32_t i2c_ctl)
831
831
data -> i2c .tran_ctrl = 0 ;
832
832
833
833
I2C_SET_CONTROL_REG (i2c_base , i2c_ctl );
834
- #ifdef CONFIG_I2C_SLAVE
834
+ #ifdef CONFIG_I2C_TARGET
835
835
data -> i2c .slaveaddr_state = NoData ;
836
836
#endif
837
837
}
@@ -1014,7 +1014,7 @@ static int nu_int_i2c_addr2data(int address, int read)
1014
1014
return read ? ((address << 1 ) | 1 ) : (address << 1 );
1015
1015
}
1016
1016
1017
- #ifdef CONFIG_I2C_SLAVE
1017
+ #ifdef CONFIG_I2C_TARGET
1018
1018
static int nu_int_i2c_addr2bspaddr (int address )
1019
1019
{
1020
1020
return address ;
0 commit comments