Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Dependents: temp X_NUCLEO_CCA01M1 X_NUCLEO_CCA01M1 X_NUCLEO_CCA02M1
Platform compatibility
This driver has been designed to support a wide range of the Nucleo F4 Family of platforms and MCUs, but not all members of this family support I2S and/or some of the members might require slight modifications to the sources of this driver in order to make it work on those.
This driver has for now been tested only with the following platforms:
Revision 17:7a4a4631672c, committed 2017-01-26
- Comitter:
- Wolfgang Betz
- Date:
- Thu Jan 26 10:37:27 2017 +0100
- Parent:
- 16:04e1abb4cca3
- Child:
- 18:1ccbfe84f550
- Commit message:
- Remove `namespace mbed`
Changed in this revision
| drivers/I2S.cpp | Show annotated file Show diff for this revision Revisions of this file |
| drivers/I2S.h | Show annotated file Show diff for this revision Revisions of this file |
--- a/drivers/I2S.cpp Wed Jan 25 13:56:15 2017 +0100
+++ b/drivers/I2S.cpp Thu Jan 26 10:37:27 2017 +0100
@@ -4,8 +4,6 @@
#if DEVICE_I2S
-namespace mbed {
-
I2S* I2S::_owner = NULL;
SingletonPtr<PlatformMutex> I2S::_mutex; // intentional class level lock!
@@ -187,10 +185,10 @@
return 0;
}
-int I2S::queue_transfer(const void *tx_buffer, int tx_length, void *rx_buffer, int rx_length, const event_callback_t& callback, int event)
+int I2S::queue_transfer(const void *tx_buffer, int tx_length, void *rx_buffer, int rx_length, const mbed::event_callback_t& callback, int event)
{ // betzw: MUST be called with lock held!
#if TRANSACTION_QUEUE_SIZE_I2S
- transaction_t t;
+ mbed::transaction_t t;
t.tx_buffer = const_cast<void *>(tx_buffer);
t.tx_length = tx_length;
@@ -199,7 +197,7 @@
t.event = event;
t.callback = callback;
t.width = 16;
- Transaction<I2S> transaction(this, t);
+ mbed::Transaction<I2S> transaction(this, t);
core_util_critical_section_enter();
if (_transaction_buffer.full()) {
core_util_critical_section_enter();
@@ -227,7 +225,7 @@
}
void I2S::start_transfer(const void *tx_buffer, int tx_length, void *rx_buffer, int rx_length,
- const event_callback_t& callback, int event)
+ const mbed::event_callback_t& callback, int event)
{ // betzw: MUST be called with lock held!
acquire();
_callback = callback;
@@ -242,7 +240,7 @@
#if TRANSACTION_QUEUE_SIZE_I2S
-void I2S::start_transaction(transaction_t *data)
+void I2S::start_transaction(mbed::transaction_t *data)
{ // betzw: MUST be called with lock held!
start_transfer(data->tx_buffer, data->tx_length, data->rx_buffer, data->rx_length, data->callback, data->event);
}
@@ -251,10 +249,10 @@
{
lock();
if (!i2s_active(&_i2s)) {
- Transaction<I2S> t;
+ mbed::Transaction<I2S> t;
if (_transaction_buffer.pop(t)) {
I2S* obj = t.get_object();
- transaction_t* data = t.get_transaction();
+ mbed::transaction_t* data = t.get_transaction();
MBED_ASSERT(obj == this);
obj->start_transaction(data);
}
@@ -272,7 +270,7 @@
}
#if TRANSACTION_QUEUE_SIZE_I2S
if (event & I2S_EVENT_INTERNAL_TRANSFER_COMPLETE) {
- I2sBhHandler::i2s_defer_function(Callback<void()>(this, &I2S::dequeue_transaction));
+ I2sBhHandler::i2s_defer_function(mbed::Callback<void()>(this, &I2S::dequeue_transaction));
}
#endif
}
@@ -285,11 +283,9 @@
}
#if TRANSACTION_QUEUE_SIZE_I2S
if (event & I2S_EVENT_INTERNAL_TRANSFER_COMPLETE) {
- I2sBhHandler::i2s_defer_function(Callback<void()>(this, &I2S::dequeue_transaction));
+ I2sBhHandler::i2s_defer_function(mbed::Callback<void()>(this, &I2S::dequeue_transaction));
}
#endif
}
-} // namespace mbed
-
-#endif
+#endif // DEVICE_I2S
--- a/drivers/I2S.h Wed Jan 25 13:56:15 2017 +0100
+++ b/drivers/I2S.h Thu Jan 26 10:37:27 2017 +0100
@@ -17,8 +17,6 @@
#include "events/EventQueue.h"
-namespace mbed {
-
/** A I2S Master/Slave, used for communicating with I2S slave/master devices
*
* The default format is set to master transmission mode, one-shot (i.e. not circular)
@@ -103,7 +101,7 @@
* -1 if I2S peripheral is busy (or out of resources)
*/
template<typename Type>
- int transfer(const Type *tx_buffer, int tx_length, Type *rx_buffer, int rx_length, const event_callback_t& callback, int event) {
+ int transfer(const Type *tx_buffer, int tx_length, Type *rx_buffer, int rx_length, const mbed::event_callback_t& callback, int event) {
int ret = 0;
lock();
@@ -195,23 +193,23 @@
* @return Zero if a transfer was added to the queue, or -1 if the queue is full
*/
int queue_transfer(const void *tx_buffer, int tx_length, void *rx_buffer, int rx_length,
- const event_callback_t& callback, int event);
+ const mbed::event_callback_t& callback, int event);
/** Configures a callback, i2s peripheral and initiate a new transfer
*
* @param data Transaction data
*/
void start_transfer(const void *tx_buffer, int tx_length, void *rx_buffer, int rx_length,
- const event_callback_t& callback, int event);
+ const mbed::event_callback_t& callback, int event);
class I2sBhHandler {
friend class I2S;
- static void i2s_defer_function(const event_callback_t& bottom_half, int event) {
+ static void i2s_defer_function(const mbed::event_callback_t& bottom_half, int event) {
i2s_bh_queue.call(bottom_half, event);
}
- static void i2s_defer_function(const Callback<void()>& bottom_half) {
+ static void i2s_defer_function(const mbed::Callback<void()>& bottom_half) {
i2s_bh_queue.call(bottom_half);
}
};
@@ -221,14 +219,14 @@
*
* @param data Transaction data
*/
- void start_transaction(transaction_t *data);
+ void start_transaction(mbed::transaction_t *data);
/** Dequeue a transaction
*
*/
void dequeue_transaction();
- CircularBuffer<Transaction<I2S>, TRANSACTION_QUEUE_SIZE_I2S> _transaction_buffer;
+ mbed::CircularBuffer<mbed::Transaction<I2S>, TRANSACTION_QUEUE_SIZE_I2S> _transaction_buffer;
#endif // TRANSACTION_QUEUE_SIZE_I2S
public:
@@ -243,7 +241,7 @@
CThunk<I2S> _irq_tx;
CThunk<I2S> _irq_rx;
- event_callback_t _callback;
+ mbed::event_callback_t _callback;
i2s_dma_prio_t _priority; // DMA priority
void acquire(void);
@@ -260,8 +258,6 @@
unsigned int _hz;
};
-} // namespace mbed
+#endif // DEVICE_I2S
-#endif
-
-#endif
+#endif // MBED_I2S_H