@@ -93,8 +93,8 @@ static int i2c_do_trsn(i2c_t *obj, uint32_t i2c_ctl, int sync);
93
93
#define NU_I2C_TIMEOUT_STOP 500000
94
94
static int i2c_poll_status_timeout (i2c_t * obj , int (* is_status )(i2c_t * obj ), uint32_t timeout );
95
95
static int i2c_poll_tran_heatbeat_timeout (i2c_t * obj , uint32_t timeout );
96
- static int i2c_is_stat_int (i2c_t * obj );
97
- static int i2c_is_stop_det (i2c_t * obj );
96
+ // static int i2c_is_stat_int(i2c_t *obj);
97
+ // static int i2c_is_stop_det(i2c_t *obj);
98
98
static int i2c_is_trsn_done (i2c_t * obj );
99
99
static int i2c_is_tran_started (i2c_t * obj );
100
100
static int i2c_addr2data (int address , int read );
@@ -115,6 +115,8 @@ static void i2c_rollback_vector_interrupt(i2c_t *obj);
115
115
#define TRANCTRL_STARTED (1)
116
116
#define TRANCTRL_NAKLASTDATA (1 << 1)
117
117
118
+ uint32_t us_ticker_read (void );
119
+
118
120
void i2c_init (i2c_t * obj , PinName sda , PinName scl )
119
121
{
120
122
uint32_t i2c_sda = pinmap_peripheral (sda , PinMap_I2C_SDA );
@@ -178,8 +180,6 @@ void i2c_frequency(i2c_t *obj, int hz)
178
180
179
181
int i2c_read (i2c_t * obj , int address , char * data , int length , int stop )
180
182
{
181
- int i ;
182
-
183
183
if (i2c_start (obj )) {
184
184
i2c_stop (obj );
185
185
return I2C_ERROR_BUS_BUSY ;
@@ -203,8 +203,6 @@ int i2c_read(i2c_t *obj, int address, char *data, int length, int stop)
203
203
204
204
int i2c_write (i2c_t * obj , int address , const char * data , int length , int stop )
205
205
{
206
- int i ;
207
-
208
206
if (i2c_start (obj )) {
209
207
i2c_stop (obj );
210
208
return I2C_ERROR_BUS_BUSY ;
@@ -306,7 +304,6 @@ static int i2c_addr2bspaddr(int address)
306
304
307
305
static void i2c_enable_int (i2c_t * obj )
308
306
{
309
- I2C_T * i2c_base = (I2C_T * ) NU_MODBASE (obj -> i2c .i2c );
310
307
const struct nu_modinit_s * modinit = get_modinit (obj -> i2c .i2c , i2c_modinit_tab );
311
308
312
309
core_util_critical_section_enter ();
@@ -320,7 +317,6 @@ static void i2c_enable_int(i2c_t *obj)
320
317
321
318
static void i2c_disable_int (i2c_t * obj )
322
319
{
323
- I2C_T * i2c_base = (I2C_T * ) NU_MODBASE (obj -> i2c .i2c );
324
320
const struct nu_modinit_s * modinit = get_modinit (obj -> i2c .i2c , i2c_modinit_tab );
325
321
326
322
core_util_critical_section_enter ();
@@ -334,7 +330,6 @@ static void i2c_disable_int(i2c_t *obj)
334
330
335
331
static int i2c_set_int (i2c_t * obj , int inten )
336
332
{
337
- I2C_T * i2c_base = (I2C_T * ) NU_MODBASE (obj -> i2c .i2c );
338
333
int inten_back ;
339
334
340
335
core_util_critical_section_enter ();
@@ -374,8 +369,6 @@ int i2c_allow_powerdown(void)
374
369
375
370
static int i2c_do_tran (i2c_t * obj , char * buf , int length , int read , int naklastdata )
376
371
{
377
- I2C_T * i2c_base = (I2C_T * ) NU_MODBASE (obj -> i2c .i2c );
378
- int err = 0 ;
379
372
int tran_len = 0 ;
380
373
381
374
i2c_disable_int (obj );
@@ -386,7 +379,6 @@ static int i2c_do_tran(i2c_t *obj, char *buf, int length, int read, int naklastd
386
379
i2c_enable_int (obj );
387
380
388
381
if (i2c_poll_tran_heatbeat_timeout (obj , NU_I2C_TIMEOUT_STAT_INT )) {
389
- err = I2C_ERROR_BUS_BUSY ;
390
382
#if NU_I2C_DEBUG
391
383
MY_I2C_2 = obj -> i2c ;
392
384
while (1 );
@@ -502,7 +494,6 @@ static int i2c_poll_status_timeout(i2c_t *obj, int (*is_status)(i2c_t *obj), uin
502
494
static int i2c_poll_tran_heatbeat_timeout (i2c_t * obj , uint32_t timeout )
503
495
{
504
496
uint32_t t1 , t2 , elapsed = 0 ;
505
- I2C_T * i2c_base = (I2C_T * ) NU_MODBASE (obj -> i2c .i2c );
506
497
int tran_started ;
507
498
char * tran_pos = NULL ;
508
499
char * tran_pos2 = NULL ;
@@ -547,19 +538,22 @@ static int i2c_poll_tran_heatbeat_timeout(i2c_t *obj, uint32_t timeout)
547
538
return (elapsed >= timeout );
548
539
}
549
540
541
+ #if 0
550
542
static int i2c_is_stat_int (i2c_t * obj )
551
543
{
552
544
I2C_T * i2c_base = (I2C_T * ) NU_MODBASE (obj -> i2c .i2c );
553
545
554
546
return !! (i2c_base -> CTL & I2C_CTL_SI_Msk );
555
547
}
556
548
549
+
557
550
static int i2c_is_stop_det (i2c_t * obj )
558
551
{
559
552
I2C_T * i2c_base = (I2C_T * ) NU_MODBASE (obj -> i2c .i2c );
560
553
561
554
return ! (i2c_base -> CTL & I2C_CTL_STO_Msk );
562
555
}
556
+ #endif
563
557
564
558
static int i2c_is_trsn_done (i2c_t * obj )
565
559
{
@@ -578,7 +572,6 @@ static int i2c_is_trsn_done(i2c_t *obj)
578
572
579
573
static int i2c_is_tran_started (i2c_t * obj )
580
574
{
581
- I2C_T * i2c_base = (I2C_T * ) NU_MODBASE (obj -> i2c .i2c );
582
575
int started ;
583
576
int inten_back ;
584
577
@@ -619,7 +612,6 @@ static void i2c_irq(i2c_t *obj)
619
612
{
620
613
I2C_T * i2c_base = (I2C_T * ) NU_MODBASE (obj -> i2c .i2c );
621
614
uint32_t status ;
622
- int data_recv = 0 ;
623
615
624
616
if (I2C_GET_TIMEOUT_FLAG (i2c_base )) {
625
617
I2C_ClearTimeoutFlag (i2c_base );
0 commit comments