Quentin Roche / ST_I2S

Dependents:   X_NUCLEO_CCA02M1

Fork of ST_I2S by ST

Committer:
Wolfgang Betz
Date:
Thu Dec 22 11:10:10 2016 +0100
Revision:
9:c4c2240e06d6
Parent:
4:21603d68bcf7
Child:
10:1a612c2e4a85
Separate platform-independent from platform-dependent code

Who changed what in which revision?

UserRevisionLine numberNew contents of line
Wolfgang Betz 0:752e74bf5ef1 1 #include "drivers/I2S.h"
Wolfgang Betz 0:752e74bf5ef1 2 #include "platform/critical.h"
Wolfgang Betz 0:752e74bf5ef1 3 #include "platform/mbed_assert.h"
Wolfgang Betz 0:752e74bf5ef1 4
Wolfgang Betz 0:752e74bf5ef1 5 #if DEVICE_I2S
Wolfgang Betz 0:752e74bf5ef1 6
Wolfgang Betz 0:752e74bf5ef1 7 namespace mbed {
Wolfgang Betz 0:752e74bf5ef1 8
Wolfgang Betz 0:752e74bf5ef1 9 /* betzw - WAS
Wolfgang Betz 9:c4c2240e06d6 10 #if TRANSACTION_QUEUE_SIZE_I2S
Wolfgang Betz 9:c4c2240e06d6 11 CircularBuffer<Transaction<I2S>, TRANSACTION_QUEUE_SIZE_I2S> I2S::_transaction_buffer;
Wolfgang Betz 9:c4c2240e06d6 12 #endif
Wolfgang Betz 0:752e74bf5ef1 13 */
Wolfgang Betz 0:752e74bf5ef1 14
Wolfgang Betz 9:c4c2240e06d6 15 I2S* I2S::_owner = NULL;
Wolfgang Betz 9:c4c2240e06d6 16 SingletonPtr<PlatformMutex> I2S::_mutex; // intentional class level lock!
Wolfgang Betz 0:752e74bf5ef1 17
Wolfgang Betz 9:c4c2240e06d6 18 rtos::Thread I2S::I2sBhHandler::_i2s_bh_daemon;
Wolfgang Betz 9:c4c2240e06d6 19 events::EventQueue I2S::I2sBhHandler::_i2s_bh_queue;
Wolfgang Betz 0:752e74bf5ef1 20
Wolfgang Betz 9:c4c2240e06d6 21 void I2S::lock() {
Wolfgang Betz 0:752e74bf5ef1 22 #ifdef NDEBUG
Wolfgang Betz 9:c4c2240e06d6 23 _mutex->lock(); // intentional class level lock!
Wolfgang Betz 0:752e74bf5ef1 24 #else
Wolfgang Betz 9:c4c2240e06d6 25 osStatus ret = _mutex->lock(); // intentional class level lock!
Wolfgang Betz 9:c4c2240e06d6 26 MBED_ASSERT(ret == osOK);
Wolfgang Betz 0:752e74bf5ef1 27 #endif
Wolfgang Betz 9:c4c2240e06d6 28 }
Wolfgang Betz 0:752e74bf5ef1 29
Wolfgang Betz 9:c4c2240e06d6 30 void I2S::unlock() {
Wolfgang Betz 0:752e74bf5ef1 31 #ifdef NDEBUG
Wolfgang Betz 9:c4c2240e06d6 32 _mutex->unlock(); // intentional class level lock!
Wolfgang Betz 0:752e74bf5ef1 33 #else
Wolfgang Betz 9:c4c2240e06d6 34 osStatus ret = _mutex->unlock(); // intentional class level lock!
Wolfgang Betz 9:c4c2240e06d6 35 MBED_ASSERT(ret == osOK);
Wolfgang Betz 0:752e74bf5ef1 36 #endif
Wolfgang Betz 9:c4c2240e06d6 37 }
Wolfgang Betz 0:752e74bf5ef1 38
Wolfgang Betz 9:c4c2240e06d6 39 I2S::I2S(PinName dpin, PinName clk, PinName wsel, PinName fdpin, PinName mck) :
Wolfgang Betz 0:752e74bf5ef1 40 _i2s(),
Wolfgang Betz 9:c4c2240e06d6 41 _irq_tx(this), _irq_rx(this),
Wolfgang Betz 9:c4c2240e06d6 42 _priority(MEDIUM),
Wolfgang Betz 9:c4c2240e06d6 43 _dbits(16),
Wolfgang Betz 9:c4c2240e06d6 44 _fbits(16),
Wolfgang Betz 9:c4c2240e06d6 45 _polarity(0),
Wolfgang Betz 9:c4c2240e06d6 46 _protocol(PHILIPS),
Wolfgang Betz 9:c4c2240e06d6 47 _mode(MASTER_TX),
Wolfgang Betz 9:c4c2240e06d6 48 _circular(false),
Wolfgang Betz 9:c4c2240e06d6 49 _hz(44100) {
Wolfgang Betz 9:c4c2240e06d6 50 lock();
Wolfgang Betz 9:c4c2240e06d6 51 /* Init instance */
Wolfgang Betz 9:c4c2240e06d6 52 i2s_init(&_i2s, dpin, clk, wsel, fdpin, mck, _mode);
Wolfgang Betz 9:c4c2240e06d6 53 acquire();
Wolfgang Betz 0:752e74bf5ef1 54 #if TRANSACTION_QUEUE_SIZE_I2S
Wolfgang Betz 9:c4c2240e06d6 55 /* Init bottom half daemon */
Wolfgang Betz 9:c4c2240e06d6 56 I2sBhHandler::init();
Wolfgang Betz 0:752e74bf5ef1 57 #endif
Wolfgang Betz 9:c4c2240e06d6 58 unlock();
Wolfgang Betz 9:c4c2240e06d6 59 }
Wolfgang Betz 0:752e74bf5ef1 60
Wolfgang Betz 9:c4c2240e06d6 61 int I2S::format(int dbits, int fbits, int polarity) {
Wolfgang Betz 9:c4c2240e06d6 62 lock();
Wolfgang Betz 9:c4c2240e06d6 63 if (i2s_active(&_i2s)) {
Wolfgang Betz 9:c4c2240e06d6 64 unlock();
Wolfgang Betz 9:c4c2240e06d6 65 return -1;
Wolfgang Betz 9:c4c2240e06d6 66 }
Wolfgang Betz 9:c4c2240e06d6 67 _dbits = dbits;
Wolfgang Betz 9:c4c2240e06d6 68 _fbits = fbits;
Wolfgang Betz 9:c4c2240e06d6 69 _polarity = polarity;
Wolfgang Betz 9:c4c2240e06d6 70 I2S::_owner = NULL; // Not that elegant, but works. rmeyer
Wolfgang Betz 9:c4c2240e06d6 71 acquire();
Wolfgang Betz 9:c4c2240e06d6 72 unlock();
Wolfgang Betz 9:c4c2240e06d6 73 return 0;
Wolfgang Betz 0:752e74bf5ef1 74 }
Wolfgang Betz 0:752e74bf5ef1 75
Wolfgang Betz 9:c4c2240e06d6 76 int I2S::audio_frequency(unsigned int hz) {
Wolfgang Betz 9:c4c2240e06d6 77 lock();
Wolfgang Betz 9:c4c2240e06d6 78 if (i2s_active(&_i2s)) {
Wolfgang Betz 9:c4c2240e06d6 79 unlock();
Wolfgang Betz 9:c4c2240e06d6 80 return -1;
Wolfgang Betz 9:c4c2240e06d6 81 }
Wolfgang Betz 9:c4c2240e06d6 82 _hz = hz;
Wolfgang Betz 9:c4c2240e06d6 83 I2S::_owner = NULL; // Not that elegant, but works. rmeyer
Wolfgang Betz 9:c4c2240e06d6 84 acquire();
Wolfgang Betz 9:c4c2240e06d6 85 unlock();
Wolfgang Betz 9:c4c2240e06d6 86 return 0;
Wolfgang Betz 0:752e74bf5ef1 87 }
Wolfgang Betz 0:752e74bf5ef1 88
Wolfgang Betz 9:c4c2240e06d6 89 int I2S::set_protocol(i2s_bitorder_t protocol) {
Wolfgang Betz 9:c4c2240e06d6 90 lock();
Wolfgang Betz 9:c4c2240e06d6 91 if (i2s_active(&_i2s)) {
Wolfgang Betz 9:c4c2240e06d6 92 unlock();
Wolfgang Betz 9:c4c2240e06d6 93 return -1;
Wolfgang Betz 9:c4c2240e06d6 94 }
Wolfgang Betz 9:c4c2240e06d6 95 _protocol = protocol;
Wolfgang Betz 9:c4c2240e06d6 96 I2S::_owner = NULL; // Not that elegant, but works. rmeyer
Wolfgang Betz 9:c4c2240e06d6 97 acquire();
Wolfgang Betz 9:c4c2240e06d6 98 unlock();
Wolfgang Betz 9:c4c2240e06d6 99 return 0;
Wolfgang Betz 0:752e74bf5ef1 100 }
Wolfgang Betz 0:752e74bf5ef1 101
Wolfgang Betz 9:c4c2240e06d6 102 int I2S::set_mode(i2s_mode_t mode, bool circular) {
Wolfgang Betz 9:c4c2240e06d6 103 lock();
Wolfgang Betz 9:c4c2240e06d6 104 if (i2s_active(&_i2s)) {
Wolfgang Betz 9:c4c2240e06d6 105 unlock();
Wolfgang Betz 9:c4c2240e06d6 106 return -1;
Wolfgang Betz 9:c4c2240e06d6 107 }
Wolfgang Betz 9:c4c2240e06d6 108 _mode = mode;
Wolfgang Betz 9:c4c2240e06d6 109 _circular = circular;
Wolfgang Betz 9:c4c2240e06d6 110 I2S::_owner = NULL; // Not that elegant, but works. rmeyer
Wolfgang Betz 9:c4c2240e06d6 111 acquire();
Wolfgang Betz 9:c4c2240e06d6 112 unlock();
Wolfgang Betz 9:c4c2240e06d6 113 return 0;
Wolfgang Betz 0:752e74bf5ef1 114 }
Wolfgang Betz 9:c4c2240e06d6 115
Wolfgang Betz 9:c4c2240e06d6 116 int I2S::harmonize(I2S &dev_i2s_1, I2S &dev_i2s_2) {
Wolfgang Betz 9:c4c2240e06d6 117 dev_i2s_1.lock();
Wolfgang Betz 9:c4c2240e06d6 118 if (i2s_active(&dev_i2s_1._i2s)) {
Wolfgang Betz 9:c4c2240e06d6 119 dev_i2s_1.unlock();
Wolfgang Betz 9:c4c2240e06d6 120 return -1;
Wolfgang Betz 9:c4c2240e06d6 121 }
Wolfgang Betz 9:c4c2240e06d6 122
Wolfgang Betz 9:c4c2240e06d6 123 dev_i2s_2.lock();
Wolfgang Betz 9:c4c2240e06d6 124 if (i2s_active(&dev_i2s_2._i2s)) {
Wolfgang Betz 9:c4c2240e06d6 125 dev_i2s_1.unlock();
Wolfgang Betz 9:c4c2240e06d6 126 return -1;
Wolfgang Betz 9:c4c2240e06d6 127 }
Wolfgang Betz 9:c4c2240e06d6 128
Wolfgang Betz 9:c4c2240e06d6 129 uint32_t hz1 = dev_i2s_1._hz;
Wolfgang Betz 9:c4c2240e06d6 130 uint32_t hz2 = dev_i2s_2._hz;
Wolfgang Betz 9:c4c2240e06d6 131 int8_t ret = i2s_harmonize(&dev_i2s_1._i2s, &hz1, &dev_i2s_2._i2s, &hz2);
Wolfgang Betz 0:752e74bf5ef1 132
Wolfgang Betz 9:c4c2240e06d6 133 if(ret == 0) {
Wolfgang Betz 9:c4c2240e06d6 134 dev_i2s_1.audio_frequency(hz1);
Wolfgang Betz 9:c4c2240e06d6 135 dev_i2s_2.audio_frequency(hz2);
Wolfgang Betz 9:c4c2240e06d6 136 }
Wolfgang Betz 9:c4c2240e06d6 137
Wolfgang Betz 9:c4c2240e06d6 138 dev_i2s_2.unlock();
Wolfgang Betz 9:c4c2240e06d6 139 dev_i2s_1.unlock();
Wolfgang Betz 9:c4c2240e06d6 140
Wolfgang Betz 9:c4c2240e06d6 141 return ret;
Wolfgang Betz 9:c4c2240e06d6 142 }
Wolfgang Betz 9:c4c2240e06d6 143
Wolfgang Betz 9:c4c2240e06d6 144 void I2S::abort_transfer()
Wolfgang Betz 9:c4c2240e06d6 145 {
Wolfgang Betz 9:c4c2240e06d6 146 lock();
Wolfgang Betz 9:c4c2240e06d6 147 i2s_abort_asynch(&_i2s);
Wolfgang Betz 0:752e74bf5ef1 148 #if TRANSACTION_QUEUE_SIZE_I2S
Wolfgang Betz 9:c4c2240e06d6 149 dequeue_transaction();
Wolfgang Betz 0:752e74bf5ef1 150 #endif
Wolfgang Betz 9:c4c2240e06d6 151 unlock();
Wolfgang Betz 9:c4c2240e06d6 152 }
Wolfgang Betz 0:752e74bf5ef1 153
Wolfgang Betz 0:752e74bf5ef1 154
Wolfgang Betz 9:c4c2240e06d6 155 void I2S::clear_transfer_buffer()
Wolfgang Betz 9:c4c2240e06d6 156 {
Wolfgang Betz 0:752e74bf5ef1 157 #if TRANSACTION_QUEUE_SIZE_I2S
Wolfgang Betz 9:c4c2240e06d6 158 lock();
Wolfgang Betz 9:c4c2240e06d6 159 _transaction_buffer.reset();
Wolfgang Betz 9:c4c2240e06d6 160 unlock();
Wolfgang Betz 0:752e74bf5ef1 161 #endif
Wolfgang Betz 9:c4c2240e06d6 162 }
Wolfgang Betz 0:752e74bf5ef1 163
Wolfgang Betz 9:c4c2240e06d6 164 void I2S::abort_all_transfers()
Wolfgang Betz 9:c4c2240e06d6 165 {
Wolfgang Betz 9:c4c2240e06d6 166 lock();
Wolfgang Betz 9:c4c2240e06d6 167 clear_transfer_buffer();
Wolfgang Betz 9:c4c2240e06d6 168 abort_transfer();
Wolfgang Betz 9:c4c2240e06d6 169 unlock();
Wolfgang Betz 9:c4c2240e06d6 170 }
Wolfgang Betz 0:752e74bf5ef1 171
Wolfgang Betz 9:c4c2240e06d6 172 int I2S::get_transfer_status()
Wolfgang Betz 9:c4c2240e06d6 173 {
Wolfgang Betz 9:c4c2240e06d6 174 lock();
Wolfgang Betz 9:c4c2240e06d6 175 if (i2s_active(&_i2s)) {
Wolfgang Betz 9:c4c2240e06d6 176 unlock();
Wolfgang Betz 9:c4c2240e06d6 177 return -1;
Wolfgang Betz 9:c4c2240e06d6 178 }
Wolfgang Betz 9:c4c2240e06d6 179 unlock();
Wolfgang Betz 9:c4c2240e06d6 180 return 0;
Wolfgang Betz 0:752e74bf5ef1 181 }
Wolfgang Betz 0:752e74bf5ef1 182
Wolfgang Betz 9:c4c2240e06d6 183 unsigned int I2S::get_module()
Wolfgang Betz 9:c4c2240e06d6 184 {
Wolfgang Betz 9:c4c2240e06d6 185 return i2s_get_module(&_i2s);
Wolfgang Betz 9:c4c2240e06d6 186 }
Wolfgang Betz 0:752e74bf5ef1 187
Wolfgang Betz 9:c4c2240e06d6 188 int I2S::set_dma_priority(i2s_dma_prio_t prio)
Wolfgang Betz 9:c4c2240e06d6 189 {
Wolfgang Betz 9:c4c2240e06d6 190 lock();
Wolfgang Betz 9:c4c2240e06d6 191 if (i2s_active(&_i2s)) {
Wolfgang Betz 9:c4c2240e06d6 192 unlock();
Wolfgang Betz 9:c4c2240e06d6 193 return -1;
Wolfgang Betz 9:c4c2240e06d6 194 }
Wolfgang Betz 9:c4c2240e06d6 195 _priority = prio;
Wolfgang Betz 9:c4c2240e06d6 196 unlock();
Wolfgang Betz 9:c4c2240e06d6 197 return 0;
Wolfgang Betz 0:752e74bf5ef1 198 }
Wolfgang Betz 0:752e74bf5ef1 199
Wolfgang Betz 9:c4c2240e06d6 200 int I2S::queue_transfer(const void *tx_buffer, int tx_length, void *rx_buffer, int rx_length, const event_callback_t& callback, int event)
Wolfgang Betz 9:c4c2240e06d6 201 { // betzw: MUST be called with lock held!
Wolfgang Betz 0:752e74bf5ef1 202 #if TRANSACTION_QUEUE_SIZE_I2S
Wolfgang Betz 9:c4c2240e06d6 203 transaction_t t;
Wolfgang Betz 0:752e74bf5ef1 204
Wolfgang Betz 9:c4c2240e06d6 205 t.tx_buffer = const_cast<void *>(tx_buffer);
Wolfgang Betz 9:c4c2240e06d6 206 t.tx_length = tx_length;
Wolfgang Betz 9:c4c2240e06d6 207 t.rx_buffer = rx_buffer;
Wolfgang Betz 9:c4c2240e06d6 208 t.rx_length = rx_length;
Wolfgang Betz 9:c4c2240e06d6 209 t.event = event;
Wolfgang Betz 9:c4c2240e06d6 210 t.callback = callback;
Wolfgang Betz 9:c4c2240e06d6 211 t.width = 16;
Wolfgang Betz 9:c4c2240e06d6 212 Transaction<I2S> transaction(this, t);
Wolfgang Betz 9:c4c2240e06d6 213 core_util_critical_section_enter();
Wolfgang Betz 9:c4c2240e06d6 214 if (_transaction_buffer.full()) {
Wolfgang Betz 9:c4c2240e06d6 215 core_util_critical_section_enter();
Wolfgang Betz 9:c4c2240e06d6 216 return -1; // the buffer is full
Wolfgang Betz 9:c4c2240e06d6 217 } else {
Wolfgang Betz 9:c4c2240e06d6 218 _transaction_buffer.push(transaction);
Wolfgang Betz 9:c4c2240e06d6 219 core_util_critical_section_exit();
Wolfgang Betz 9:c4c2240e06d6 220 // betzw - seems to be redundant - WAS: dequeue_transaction();
Wolfgang Betz 9:c4c2240e06d6 221 return 0;
Wolfgang Betz 9:c4c2240e06d6 222 }
Wolfgang Betz 9:c4c2240e06d6 223 #else
Wolfgang Betz 9:c4c2240e06d6 224 return -1;
Wolfgang Betz 9:c4c2240e06d6 225 #endif
Wolfgang Betz 0:752e74bf5ef1 226 }
Wolfgang Betz 0:752e74bf5ef1 227
Wolfgang Betz 0:752e74bf5ef1 228
Wolfgang Betz 9:c4c2240e06d6 229 // ignore the fact that there are multiple physical i2s's, and always update if it wasn't us last
Wolfgang Betz 9:c4c2240e06d6 230 void I2S::acquire() { // betzw: MUST be called with lock held!
Wolfgang Betz 9:c4c2240e06d6 231 if (_owner != this) {
Wolfgang Betz 9:c4c2240e06d6 232 i2s_format(&_i2s, _dbits, _fbits, _polarity);
Wolfgang Betz 9:c4c2240e06d6 233 i2s_audio_frequency(&_i2s, _hz);
Wolfgang Betz 9:c4c2240e06d6 234 i2s_set_protocol(&_i2s, _protocol);
Wolfgang Betz 9:c4c2240e06d6 235 i2s_set_mode(&_i2s, _mode);
Wolfgang Betz 9:c4c2240e06d6 236 _owner = this;
Wolfgang Betz 9:c4c2240e06d6 237 }
Wolfgang Betz 0:752e74bf5ef1 238 }
Wolfgang Betz 0:752e74bf5ef1 239
Wolfgang Betz 9:c4c2240e06d6 240 void I2S::start_transfer(const void *tx_buffer, int tx_length, void *rx_buffer, int rx_length,
Wolfgang Betz 9:c4c2240e06d6 241 const event_callback_t& callback, int event)
Wolfgang Betz 9:c4c2240e06d6 242 { // betzw: MUST be called with lock held!
Wolfgang Betz 0:752e74bf5ef1 243 acquire();
Wolfgang Betz 9:c4c2240e06d6 244 _callback = callback;
Wolfgang Betz 9:c4c2240e06d6 245 _irq_tx.callback(&I2S::irq_handler_asynch_tx);
Wolfgang Betz 9:c4c2240e06d6 246 _irq_rx.callback(&I2S::irq_handler_asynch_rx);
Wolfgang Betz 9:c4c2240e06d6 247 i2s_transfer(&_i2s,
Wolfgang Betz 9:c4c2240e06d6 248 const_cast<void *>(tx_buffer), tx_length, rx_buffer, rx_length,
Wolfgang Betz 9:c4c2240e06d6 249 _circular, _priority,
Wolfgang Betz 9:c4c2240e06d6 250 _irq_tx.entry(), _irq_rx.entry(),
Wolfgang Betz 9:c4c2240e06d6 251 event);
Wolfgang Betz 9:c4c2240e06d6 252 }
Wolfgang Betz 0:752e74bf5ef1 253
Wolfgang Betz 0:752e74bf5ef1 254 #if TRANSACTION_QUEUE_SIZE_I2S
Wolfgang Betz 0:752e74bf5ef1 255
Wolfgang Betz 9:c4c2240e06d6 256 void I2S::start_transaction(transaction_t *data)
Wolfgang Betz 9:c4c2240e06d6 257 { // betzw: MUST be called with lock held!
Wolfgang Betz 9:c4c2240e06d6 258 start_transfer(data->tx_buffer, data->tx_length, data->rx_buffer, data->rx_length, data->callback, data->event);
Wolfgang Betz 9:c4c2240e06d6 259 }
Wolfgang Betz 0:752e74bf5ef1 260
Wolfgang Betz 9:c4c2240e06d6 261 void I2S::dequeue_transaction()
Wolfgang Betz 9:c4c2240e06d6 262 {
Wolfgang Betz 9:c4c2240e06d6 263 lock();
Wolfgang Betz 9:c4c2240e06d6 264 if (!i2s_active(&_i2s)) {
Wolfgang Betz 9:c4c2240e06d6 265 Transaction<I2S> t;
Wolfgang Betz 9:c4c2240e06d6 266 if (_transaction_buffer.pop(t)) {
Wolfgang Betz 0:752e74bf5ef1 267 I2S* obj = t.get_object();
Wolfgang Betz 0:752e74bf5ef1 268 transaction_t* data = t.get_transaction();
Wolfgang Betz 0:752e74bf5ef1 269 MBED_ASSERT(obj == this); // betzw: what if 'obj' is NOT equal to 'this'?
Wolfgang Betz 0:752e74bf5ef1 270 obj->start_transaction(data);
Wolfgang Betz 9:c4c2240e06d6 271 }
Wolfgang Betz 9:c4c2240e06d6 272 }
Wolfgang Betz 9:c4c2240e06d6 273 unlock();
Wolfgang Betz 0:752e74bf5ef1 274 }
Wolfgang Betz 0:752e74bf5ef1 275
Wolfgang Betz 0:752e74bf5ef1 276 #endif
Wolfgang Betz 0:752e74bf5ef1 277
Wolfgang Betz 9:c4c2240e06d6 278 void I2S::irq_handler_asynch_rx(void)
Wolfgang Betz 9:c4c2240e06d6 279 {
Wolfgang Betz 9:c4c2240e06d6 280 int event = i2s_irq_handler_asynch(&_i2s, I2S_RX_EVENT);
Wolfgang Betz 9:c4c2240e06d6 281 if (_callback && (event & I2S_EVENT_ALL)) {
Wolfgang Betz 9:c4c2240e06d6 282 I2sBhHandler::i2s_defer_function(_callback, event & I2S_EVENT_ALL);
Wolfgang Betz 9:c4c2240e06d6 283 }
Wolfgang Betz 0:752e74bf5ef1 284 #if TRANSACTION_QUEUE_SIZE_I2S
Wolfgang Betz 9:c4c2240e06d6 285 if (event & I2S_EVENT_INTERNAL_TRANSFER_COMPLETE) {
Wolfgang Betz 9:c4c2240e06d6 286 I2sBhHandler::i2s_defer_function(Callback<void()>(this, &I2S::dequeue_transaction));
Wolfgang Betz 9:c4c2240e06d6 287 }
Wolfgang Betz 0:752e74bf5ef1 288 #endif
Davide Aliprandi 4:21603d68bcf7 289 }
Davide Aliprandi 4:21603d68bcf7 290
Wolfgang Betz 9:c4c2240e06d6 291 void I2S::irq_handler_asynch_tx(void)
Davide Aliprandi 4:21603d68bcf7 292 {
Wolfgang Betz 9:c4c2240e06d6 293 int event = i2s_irq_handler_asynch(&_i2s, I2S_TX_EVENT);
Wolfgang Betz 9:c4c2240e06d6 294 if (_callback && (event & I2S_EVENT_ALL)) {
Wolfgang Betz 9:c4c2240e06d6 295 I2sBhHandler::i2s_defer_function(_callback, event & I2S_EVENT_ALL);
Wolfgang Betz 9:c4c2240e06d6 296 }
Wolfgang Betz 9:c4c2240e06d6 297 #if TRANSACTION_QUEUE_SIZE_I2S
Wolfgang Betz 9:c4c2240e06d6 298 if (event & I2S_EVENT_INTERNAL_TRANSFER_COMPLETE) {
Wolfgang Betz 9:c4c2240e06d6 299 I2sBhHandler::i2s_defer_function(Callback<void()>(this, &I2S::dequeue_transaction));
Wolfgang Betz 9:c4c2240e06d6 300 }
Wolfgang Betz 9:c4c2240e06d6 301 #endif
Davide Aliprandi 4:21603d68bcf7 302 }
Davide Aliprandi 4:21603d68bcf7 303
Wolfgang Betz 0:752e74bf5ef1 304 } // namespace mbed
Wolfgang Betz 0:752e74bf5ef1 305
Wolfgang Betz 0:752e74bf5ef1 306 #endif