@@ -75,8 +75,8 @@ static int i2c_do_trsn(i2c_t *obj, uint32_t i2c_ctl, int sync);
75
75
#define NU_I2C_TIMEOUT_STOP 500000
76
76
static int i2c_poll_status_timeout (i2c_t * obj , int (* is_status )(i2c_t * obj ), uint32_t timeout );
77
77
static int i2c_poll_tran_heatbeat_timeout (i2c_t * obj , uint32_t timeout );
78
- static int i2c_is_stat_int (i2c_t * obj );
79
- static int i2c_is_stop_det (i2c_t * obj );
78
+ // static int i2c_is_stat_int(i2c_t *obj);
79
+ // static int i2c_is_stop_det(i2c_t *obj);
80
80
static int i2c_is_trsn_done (i2c_t * obj );
81
81
static int i2c_is_tran_started (i2c_t * obj );
82
82
static int i2c_addr2data (int address , int read );
@@ -98,6 +98,8 @@ static void i2c_rollback_vector_interrupt(i2c_t *obj);
98
98
#define TRANCTRL_STARTED (1)
99
99
#define TRANCTRL_NAKLASTDATA (1 << 1)
100
100
101
+ uint32_t us_ticker_read (void );
102
+
101
103
void i2c_init (i2c_t * obj , PinName sda , PinName scl )
102
104
{
103
105
uint32_t i2c_sda = pinmap_peripheral (sda , PinMap_I2C_SDA );
@@ -161,8 +163,6 @@ void i2c_frequency(i2c_t *obj, int hz)
161
163
162
164
int i2c_read (i2c_t * obj , int address , char * data , int length , int stop )
163
165
{
164
- int i ;
165
-
166
166
if (i2c_start (obj )) {
167
167
i2c_stop (obj );
168
168
return I2C_ERROR_BUS_BUSY ;
@@ -186,8 +186,6 @@ int i2c_read(i2c_t *obj, int address, char *data, int length, int stop)
186
186
187
187
int i2c_write (i2c_t * obj , int address , const char * data , int length , int stop )
188
188
{
189
- int i ;
190
-
191
189
if (i2c_start (obj )) {
192
190
i2c_stop (obj );
193
191
return I2C_ERROR_BUS_BUSY ;
@@ -289,7 +287,6 @@ static int i2c_addr2bspaddr(int address)
289
287
290
288
static void i2c_enable_int (i2c_t * obj )
291
289
{
292
- I2C_T * i2c_base = (I2C_T * ) NU_MODBASE (obj -> i2c .i2c );
293
290
const struct nu_modinit_s * modinit = get_modinit (obj -> i2c .i2c , i2c_modinit_tab );
294
291
295
292
core_util_critical_section_enter ();
@@ -303,7 +300,6 @@ static void i2c_enable_int(i2c_t *obj)
303
300
304
301
static void i2c_disable_int (i2c_t * obj )
305
302
{
306
- I2C_T * i2c_base = (I2C_T * ) NU_MODBASE (obj -> i2c .i2c );
307
303
const struct nu_modinit_s * modinit = get_modinit (obj -> i2c .i2c , i2c_modinit_tab );
308
304
309
305
core_util_critical_section_enter ();
@@ -317,7 +313,6 @@ static void i2c_disable_int(i2c_t *obj)
317
313
318
314
static int i2c_set_int (i2c_t * obj , int inten )
319
315
{
320
- I2C_T * i2c_base = (I2C_T * ) NU_MODBASE (obj -> i2c .i2c );
321
316
int inten_back ;
322
317
323
318
core_util_critical_section_enter ();
@@ -357,8 +352,6 @@ int i2c_allow_powerdown(void)
357
352
358
353
static int i2c_do_tran (i2c_t * obj , char * buf , int length , int read , int naklastdata )
359
354
{
360
- I2C_T * i2c_base = (I2C_T * ) NU_MODBASE (obj -> i2c .i2c );
361
- int err = 0 ;
362
355
int tran_len = 0 ;
363
356
364
357
i2c_disable_int (obj );
@@ -369,7 +362,6 @@ static int i2c_do_tran(i2c_t *obj, char *buf, int length, int read, int naklastd
369
362
i2c_enable_int (obj );
370
363
371
364
if (i2c_poll_tran_heatbeat_timeout (obj , NU_I2C_TIMEOUT_STAT_INT )) {
372
- err = I2C_ERROR_BUS_BUSY ;
373
365
#if NU_I2C_DEBUG
374
366
MY_I2C_2 = obj -> i2c ;
375
367
while (1 );
@@ -485,7 +477,6 @@ static int i2c_poll_status_timeout(i2c_t *obj, int (*is_status)(i2c_t *obj), uin
485
477
static int i2c_poll_tran_heatbeat_timeout (i2c_t * obj , uint32_t timeout )
486
478
{
487
479
uint32_t t1 , t2 , elapsed = 0 ;
488
- I2C_T * i2c_base = (I2C_T * ) NU_MODBASE (obj -> i2c .i2c );
489
480
int tran_started ;
490
481
char * tran_pos = NULL ;
491
482
char * tran_pos2 = NULL ;
@@ -529,6 +520,8 @@ static int i2c_poll_tran_heatbeat_timeout(i2c_t *obj, uint32_t timeout)
529
520
530
521
return (elapsed >= timeout );
531
522
}
523
+
524
+ #if 0
532
525
static int i2c_is_stat_int (i2c_t * obj )
533
526
{
534
527
I2C_T * i2c_base = (I2C_T * ) NU_MODBASE (obj -> i2c .i2c );
@@ -542,6 +535,7 @@ static int i2c_is_stop_det(i2c_t *obj)
542
535
543
536
return ! (i2c_base -> CTL & I2C_CTL_STO_Msk );
544
537
}
538
+ #endif
545
539
546
540
static int i2c_is_trsn_done (i2c_t * obj )
547
541
{
@@ -560,7 +554,6 @@ static int i2c_is_trsn_done(i2c_t *obj)
560
554
561
555
static int i2c_is_tran_started (i2c_t * obj )
562
556
{
563
- I2C_T * i2c_base = (I2C_T * ) NU_MODBASE (obj -> i2c .i2c );
564
557
int started ;
565
558
int inten_back ;
566
559
@@ -589,7 +582,6 @@ static void i2c_irq(i2c_t *obj)
589
582
{
590
583
I2C_T * i2c_base = (I2C_T * ) NU_MODBASE (obj -> i2c .i2c );
591
584
uint32_t status ;
592
- int data_recv = 0 ;
593
585
594
586
if (I2C_GET_TIMEOUT_FLAG (i2c_base )) {
595
587
I2C_ClearTimeoutFlag (i2c_base );
0 commit comments