27
27
28
28
namespace mbed {
29
29
30
- I2C *I2C::_owner = NULL ;
31
- SingletonPtr<PlatformMutex> I2C::_mutex;
32
-
33
30
I2C::I2C (PinName sda, PinName scl) :
34
31
#if DEVICE_I2C_ASYNCH
35
32
_irq (this ), _usage(DMA_USAGE_NEVER), _deep_sleep_locked(false ),
@@ -42,8 +39,6 @@ I2C::I2C(PinName sda, PinName scl) :
42
39
_scl = scl;
43
40
recover (sda, scl);
44
41
i2c_init (&_i2c, _sda, _scl);
45
- // Used to avoid unnecessary frequency updates
46
- _owner = this ;
47
42
unlock ();
48
43
}
49
44
@@ -59,8 +54,6 @@ I2C::I2C(const i2c_pinmap_t &static_pinmap) :
59
54
_scl = static_pinmap.scl_pin ;
60
55
recover (static_pinmap.sda_pin , static_pinmap.scl_pin );
61
56
i2c_init_direct (&_i2c, &static_pinmap);
62
- // Used to avoid unnecessary frequency updates
63
- _owner = this ;
64
57
unlock ();
65
58
}
66
59
@@ -72,26 +65,13 @@ void I2C::frequency(int hz)
72
65
// We want to update the frequency even if we are already the bus owners
73
66
i2c_frequency (&_i2c, _hz);
74
67
75
- // Updating the frequency of the bus we become the owners of it
76
- _owner = this ;
77
- unlock ();
78
- }
79
-
80
- void I2C::aquire ()
81
- {
82
- lock ();
83
- if (_owner != this ) {
84
- i2c_frequency (&_i2c, _hz);
85
- _owner = this ;
86
- }
87
68
unlock ();
88
69
}
89
70
90
71
// write - Master Transmitter Mode
91
72
int I2C::write (int address, const char *data, int length, bool repeated)
92
73
{
93
74
lock ();
94
- aquire ();
95
75
96
76
int stop = (repeated) ? 0 : 1 ;
97
77
int written = i2c_write (&_i2c, address, data, length, stop);
@@ -112,7 +92,6 @@ int I2C::write(int data)
112
92
int I2C::read (int address, char *data, int length, bool repeated)
113
93
{
114
94
lock ();
115
- aquire ();
116
95
117
96
int stop = (repeated) ? 0 : 1 ;
118
97
int read = i2c_read (&_i2c, address, data, length, stop);
@@ -137,7 +116,6 @@ int I2C::read(int ack)
137
116
void I2C::start (void )
138
117
{
139
118
lock ();
140
- aquire ();
141
119
i2c_start (&_i2c);
142
120
unlock ();
143
121
}
@@ -215,7 +193,6 @@ int I2C::transfer(int address, const char *tx_buffer, int tx_length, char *rx_bu
215
193
return -1 ; // transaction ongoing
216
194
}
217
195
lock_deep_sleep ();
218
- aquire ();
219
196
220
197
_callback = callback;
221
198
int stop = (repeated) ? 0 : 1 ;
0 commit comments