mbed library sources

Dependents:   Encrypted my_mbed lklk CyaSSL_DTLS_Cellular ... more

Superseded

This library was superseded by mbed-dev - https://os.mbed.com/users/mbed_official/code/mbed-dev/.

Development branch of the mbed library sources. This library is kept in synch with the latest changes from the mbed SDK and it is not guaranteed to work.

If you are looking for a stable and tested release, please import one of the official mbed library releases:

Import librarymbed

The official Mbed 2 C/C++ SDK provides the software platform and libraries to build your applications.

Files at this revision

API Documentation at this revision

Comitter:
mbed_official
Date:
Wed Jun 10 10:00:08 2015 +0100
Parent:
562:9f26fcd0c9ce
Child:
564:24a7119bd73a
Commit message:
Synchronized with git revision 4778e33fa11602202ae3a57ced5d026e8053cedf

Full URL: https://github.com/mbedmicro/mbed/commit/4778e33fa11602202ae3a57ced5d026e8053cedf/

Fix asynch methods constness

Changed in this revision

api/I2C.h Show annotated file Show diff for this revision Revisions of this file
api/SPI.h Show annotated file Show diff for this revision Revisions of this file
api/SerialBase.h Show annotated file Show diff for this revision Revisions of this file
common/I2C.cpp Show annotated file Show diff for this revision Revisions of this file
common/SPI.cpp Show annotated file Show diff for this revision Revisions of this file
common/SerialBase.cpp Show annotated file Show diff for this revision Revisions of this file
hal/i2c_api.h Show annotated file Show diff for this revision Revisions of this file
hal/serial_api.h Show annotated file Show diff for this revision Revisions of this file
hal/spi_api.h Show annotated file Show diff for this revision Revisions of this file
targets/hal/TARGET_Silicon_Labs/TARGET_EFM32/i2c_api.c Show annotated file Show diff for this revision Revisions of this file
targets/hal/TARGET_Silicon_Labs/TARGET_EFM32/serial_api.c Show annotated file Show diff for this revision Revisions of this file
targets/hal/TARGET_Silicon_Labs/TARGET_EFM32/spi_api.c Show annotated file Show diff for this revision Revisions of this file
--- a/api/I2C.h	Tue Jun 09 15:30:08 2015 +0100
+++ b/api/I2C.h	Wed Jun 10 10:00:08 2015 +0100
@@ -149,7 +149,7 @@
      * @param repeated Repeated start, true - do not send stop at end
      * @return Zero if the transfer has started, or -1 if I2C peripheral is busy
      */
-    int transfer(int address, char *tx_buffer, int tx_length, char *rx_buffer, int rx_length, const event_callback_t& callback, int event = I2C_EVENT_TRANSFER_COMPLETE, bool repeated = false);
+    int transfer(int address, const char *tx_buffer, int tx_length, char *rx_buffer, int rx_length, const event_callback_t& callback, int event = I2C_EVENT_TRANSFER_COMPLETE, bool repeated = false);
 
     /** Abort the on-going I2C transfer
      */
--- a/api/SPI.h	Tue Jun 09 15:30:08 2015 +0100
+++ b/api/SPI.h	Wed Jun 10 10:00:08 2015 +0100
@@ -123,7 +123,7 @@
      * @param event     The logical OR of events to modify
      * @return Zero if the transfer has started, or -1 if SPI peripheral is busy
      */
-    virtual int transfer(uint8_t *tx_buffer, int tx_length, uint8_t *rx_buffer, int rx_length, const event_callback_t& callback, int event = SPI_EVENT_COMPLETE) {
+    virtual int transfer(const uint8_t *tx_buffer, int tx_length, uint8_t *rx_buffer, int rx_length, const event_callback_t& callback, int event = SPI_EVENT_COMPLETE) {
         return transfer(tx_buffer, tx_length, rx_buffer, rx_length, 8, callback, event);
     }
 
@@ -139,7 +139,7 @@
      * @param event     The logical OR of events to modify
      * @return Zero if the transfer has started, or -1 if SPI peripheral is busy
      */
-    virtual int transfer(uint16_t *tx_buffer, int tx_length, uint16_t *rx_buffer, int rx_length, const event_callback_t& callback, int event = SPI_EVENT_COMPLETE) {
+    virtual int transfer(const uint16_t *tx_buffer, int tx_length, uint16_t *rx_buffer, int rx_length, const event_callback_t& callback, int event = SPI_EVENT_COMPLETE) {
         return transfer(tx_buffer, tx_length, rx_buffer, rx_length, 16, callback, event);
     }
 
@@ -155,7 +155,7 @@
      * @param event     The logical OR of events to modify
      * @return Zero if the transfer has started, or -1 if SPI peripheral is busy
      */
-    virtual int transfer(uint32_t *tx_buffer, int tx_length, uint32_t *rx_buffer, int rx_length, const event_callback_t& callback, int event = SPI_EVENT_COMPLETE)  {
+    virtual int transfer(const uint32_t *tx_buffer, int tx_length, uint32_t *rx_buffer, int rx_length, const event_callback_t& callback, int event = SPI_EVENT_COMPLETE)  {
         return transfer((void *)tx_buffer, tx_length, (void *)rx_buffer, rx_length, 32, callback, event);
     }
 
@@ -197,7 +197,7 @@
      * @param event     The logical OR of events to modify
      * @return Zero if the transfer has started or was added to the queue, or -1 if SPI peripheral is busy/buffer is full
     */
-    int transfer(void *tx_buffer, int tx_length, void *rx_buffer, int rx_length, unsigned char bit_width, const event_callback_t& callback, int event);
+    int transfer(const void *tx_buffer, int tx_length, void *rx_buffer, int rx_length, unsigned char bit_width, const event_callback_t& callback, int event);
 
     /**
      *
@@ -212,7 +212,7 @@
      * @param event     The logical OR of events to modify
      * @return Zero if a transfer was added to the queue, or -1 if the queue is full
     */
-    int queue_transfer(void *tx_buffer, int tx_length, void *rx_buffer, int rx_length, unsigned char bit_width, const event_callback_t& callback, int event);
+    int queue_transfer(const void *tx_buffer, int tx_length, void *rx_buffer, int rx_length, unsigned char bit_width, const event_callback_t& callback, int event);
 
     /** Configures a callback, spi peripheral and initiate a new transfer
      *
@@ -226,7 +226,7 @@
      * @param callback  The event callback function
      * @param event     The logical OR of events to modify
     */
-    void start_transfer(void *tx_buffer, int tx_length, void *rx_buffer, int rx_length, unsigned char bit_width, const event_callback_t& callback, int event);
+    void start_transfer(const void *tx_buffer, int tx_length, void *rx_buffer, int rx_length, unsigned char bit_width, const event_callback_t& callback, int event);
 
 #if TRANSACTION_QUEUE_SIZE_SPI
 
--- a/api/SerialBase.h	Tue Jun 09 15:30:08 2015 +0100
+++ b/api/SerialBase.h	Wed Jun 10 10:00:08 2015 +0100
@@ -135,7 +135,7 @@
      *  @param callback The event callback function
      *  @param event    The logical OR of TX events
      */
-    int write(uint8_t *buffer, int length, const event_callback_t& callback, int event = SERIAL_EVENT_TX_COMPLETE);
+    int write(const uint8_t *buffer, int length, const event_callback_t& callback, int event = SERIAL_EVENT_TX_COMPLETE);
 
     /** Begin asynchronous write using 16bit buffer. The completition invokes registered TX event callback
      *
@@ -144,7 +144,7 @@
      *  @param callback The event callback function
      *  @param event    The logical OR of TX events
      */
-    int write(uint16_t *buffer, int length, const event_callback_t& callback, int event = SERIAL_EVENT_TX_COMPLETE);
+    int write(const uint16_t *buffer, int length, const event_callback_t& callback, int event = SERIAL_EVENT_TX_COMPLETE);
 
     /** Abort the on-going write transfer
      */
@@ -190,7 +190,7 @@
 
 protected:
     void start_read(void *buffer, int buffer_size, char buffer_width, const event_callback_t& callback, int event, unsigned char char_match);
-    void start_write(void *buffer, int buffer_size, char buffer_width, const event_callback_t& callback, int event);
+    void start_write(const void *buffer, int buffer_size, char buffer_width, const event_callback_t& callback, int event);
     void interrupt_handler_asynch(void);
 #endif
 
--- a/common/I2C.cpp	Tue Jun 09 15:30:08 2015 +0100
+++ b/common/I2C.cpp	Wed Jun 10 10:00:08 2015 +0100
@@ -92,7 +92,7 @@
 
 #if DEVICE_I2C_ASYNCH
 
-int I2C::transfer(int address, char *tx_buffer, int tx_length, char *rx_buffer, int rx_length, const event_callback_t& callback, int event, bool repeated)
+int I2C::transfer(int address, const char *tx_buffer, int tx_length, char *rx_buffer, int rx_length, const event_callback_t& callback, int event, bool repeated)
 {
     if (i2c_active(&_i2c)) {
         return -1; // transaction ongoing
--- a/common/SPI.cpp	Tue Jun 09 15:30:08 2015 +0100
+++ b/common/SPI.cpp	Wed Jun 10 10:00:08 2015 +0100
@@ -68,7 +68,7 @@
 
 #if DEVICE_SPI_ASYNCH
 
-int SPI::transfer(void *tx_buffer, int tx_length, void *rx_buffer, int rx_length, unsigned char bit_width, const event_callback_t& callback, int event)
+int SPI::transfer(const void *tx_buffer, int tx_length, void *rx_buffer, int rx_length, unsigned char bit_width, const event_callback_t& callback, int event)
 {
     if (spi_active(&_spi)) {
         return queue_transfer(tx_buffer, tx_length, rx_buffer, rx_length, bit_width, callback, event);
@@ -108,12 +108,12 @@
     return  0;
 }
 
-int SPI::queue_transfer(void *tx_buffer, int tx_length, void *rx_buffer, int rx_length, unsigned char bit_width, const event_callback_t& callback, int event)
+int SPI::queue_transfer(const void *tx_buffer, int tx_length, void *rx_buffer, int rx_length, unsigned char bit_width, const event_callback_t& callback, int event)
 {
 #if TRANSACTION_QUEUE_SIZE_SPI
     transaction_t t;
 
-    t.tx_buffer = tx_buffer;
+    t.tx_buffer = const_cast<void *>(tx_buffer);
     t.tx_length = tx_length;
     t.rx_buffer = rx_buffer;
     t.rx_length = rx_length;
@@ -132,7 +132,7 @@
 #endif
 }
 
-void SPI::start_transfer(void *tx_buffer, int tx_length, void *rx_buffer, int rx_length, unsigned char bit_width, const event_callback_t& callback, int event)
+void SPI::start_transfer(const void *tx_buffer, int tx_length, void *rx_buffer, int rx_length, unsigned char bit_width, const event_callback_t& callback, int event)
 {
     aquire();
     _callback = callback;
--- a/common/SerialBase.cpp	Tue Jun 09 15:30:08 2015 +0100
+++ b/common/SerialBase.cpp	Wed Jun 10 10:00:08 2015 +0100
@@ -110,7 +110,7 @@
 
 #if DEVICE_SERIAL_ASYNCH
 
-int SerialBase::write(uint8_t *buffer, int length, const event_callback_t& callback, int event)
+int SerialBase::write(const uint8_t *buffer, int length, const event_callback_t& callback, int event)
 {
     if (serial_tx_active(&_serial)) {
         return -1; // transaction ongoing
@@ -119,7 +119,7 @@
     return 0;
 }
 
-int SerialBase::write(uint16_t *buffer, int length, const event_callback_t& callback, int event)
+int SerialBase::write(const uint16_t *buffer, int length, const event_callback_t& callback, int event)
 {
     if (serial_tx_active(&_serial)) {
         return -1; // transaction ongoing
@@ -128,7 +128,7 @@
     return 0;
 }
 
-void SerialBase::start_write(void *buffer, int buffer_size, char buffer_width, const event_callback_t& callback, int event)
+void SerialBase::start_write(const void *buffer, int buffer_size, char buffer_width, const event_callback_t& callback, int event)
 {
     _tx_callback = callback;
 
--- a/hal/i2c_api.h	Tue Jun 09 15:30:08 2015 +0100
+++ b/hal/i2c_api.h	Wed Jun 10 10:00:08 2015 +0100
@@ -191,7 +191,7 @@
  *  @param handler   The I2C IRQ handler to be set
  *  @param hint      DMA hint usage
  */
-void i2c_transfer_asynch(i2c_t *obj, void *tx, size_t tx_length, void *rx, size_t rx_length, uint32_t address, uint32_t stop, uint32_t handler, uint32_t event, DMAUsage hint);
+void i2c_transfer_asynch(i2c_t *obj, const void *tx, size_t tx_length, void *rx, size_t rx_length, uint32_t address, uint32_t stop, uint32_t handler, uint32_t event, DMAUsage hint);
 
 /** The asynchronous IRQ handler
  *  @param obj The I2C object which holds the transfer information
--- a/hal/serial_api.h	Tue Jun 09 15:30:08 2015 +0100
+++ b/hal/serial_api.h	Wed Jun 10 10:00:08 2015 +0100
@@ -237,7 +237,7 @@
  * @param hint      A suggestion for how to use DMA with this transfer
  * @return Returns number of data transfered, or 0 otherwise
  */
-int serial_tx_asynch(serial_t *obj, void *tx, size_t tx_length, uint8_t tx_width, uint32_t handler, uint32_t event, DMAUsage hint);
+int serial_tx_asynch(serial_t *obj, const void *tx, size_t tx_length, uint8_t tx_width, uint32_t handler, uint32_t event, DMAUsage hint);
 
 /** Begin asynchronous RX transfer (enable interrupt for data collecting)
  *  The used buffer is specified in the serial object - rx_buff
--- a/hal/spi_api.h	Tue Jun 09 15:30:08 2015 +0100
+++ b/hal/spi_api.h	Wed Jun 10 10:00:08 2015 +0100
@@ -169,7 +169,7 @@
  * @param[in] handler   SPI interrupt handler
  * @param[in] hint      A suggestion for how to use DMA with this transfer
  */
-void spi_master_transfer(spi_t *obj, void *tx, size_t tx_length, void *rx, size_t rx_length, uint8_t bit_width, uint32_t handler, uint32_t event, DMAUsage hint);
+void spi_master_transfer(spi_t *obj, const void *tx, size_t tx_length, void *rx, size_t rx_length, uint8_t bit_width, uint32_t handler, uint32_t event, DMAUsage hint);
 
 /** The asynchronous IRQ handler
  *
--- a/targets/hal/TARGET_Silicon_Labs/TARGET_EFM32/i2c_api.c	Tue Jun 09 15:30:08 2015 +0100
+++ b/targets/hal/TARGET_Silicon_Labs/TARGET_EFM32/i2c_api.c	Wed Jun 10 10:00:08 2015 +0100
@@ -426,7 +426,7 @@
  *  @param handler The I2C IRQ handler to be set
  *  @param hint    DMA hint usage
  */
-void i2c_transfer_asynch(i2c_t *obj, void *tx, size_t tx_length, void *rx, size_t rx_length, uint32_t address, uint32_t stop, uint32_t handler, uint32_t event, DMAUsage hint)
+void i2c_transfer_asynch(i2c_t *obj, const void *tx, size_t tx_length, void *rx, size_t rx_length, uint32_t address, uint32_t stop, uint32_t handler, uint32_t event, DMAUsage hint)
 {
     I2C_TransferReturn_TypeDef retval;
     if(i2c_active(obj)) return;
@@ -440,7 +440,7 @@
     if((tx_length > 0) && (rx_length == 0)) {
         obj->i2c.xfer.flags = I2C_FLAG_WRITE;
         //Store buffer info
-        obj->i2c.xfer.buf[0].data = tx;
+        obj->i2c.xfer.buf[0].data = (void *)tx;
         obj->i2c.xfer.buf[0].len  = (uint16_t) tx_length;
     } else if ((tx_length == 0) && (rx_length > 0)) {
         obj->i2c.xfer.flags = I2C_FLAG_READ;
@@ -450,7 +450,7 @@
     } else if ((tx_length > 0) && (rx_length > 0)) {
         obj->i2c.xfer.flags = I2C_FLAG_WRITE_READ;
         //Store buffer info
-        obj->i2c.xfer.buf[0].data = tx;
+        obj->i2c.xfer.buf[0].data = (void *)tx;
         obj->i2c.xfer.buf[0].len  = (uint16_t) tx_length;
         obj->i2c.xfer.buf[1].data = rx;
         obj->i2c.xfer.buf[1].len  = (uint16_t) rx_length;
--- a/targets/hal/TARGET_Silicon_Labs/TARGET_EFM32/serial_api.c	Tue Jun 09 15:30:08 2015 +0100
+++ b/targets/hal/TARGET_Silicon_Labs/TARGET_EFM32/serial_api.c	Wed Jun 10 10:00:08 2015 +0100
@@ -1262,14 +1262,14 @@
  * @param hint A suggestion for how to use DMA with this transfer
  * @return Returns number of data transfered, or 0 otherwise
  */
-int serial_tx_asynch(serial_t *obj, void *tx, size_t tx_length, uint8_t tx_width, uint32_t handler, uint32_t event, DMAUsage hint)
+int serial_tx_asynch(serial_t *obj, const void *tx, size_t tx_length, uint8_t tx_width, uint32_t handler, uint32_t event, DMAUsage hint)
 {
     // Check that a buffer has indeed been set up
     MBED_ASSERT(tx != (void*)0);
     if(tx_length == 0) return 0;
 
     // Set up buffer
-    serial_tx_buffer_set(obj, tx, tx_length, tx_width);
+    serial_tx_buffer_set(obj, (void *)tx, tx_length, tx_width);
 
     // Set up events
     serial_tx_enable_event(obj, SERIAL_EVENT_TX_ALL, false);
--- a/targets/hal/TARGET_Silicon_Labs/TARGET_EFM32/spi_api.c	Tue Jun 09 15:30:08 2015 +0100
+++ b/targets/hal/TARGET_Silicon_Labs/TARGET_EFM32/spi_api.c	Wed Jun 10 10:00:08 2015 +0100
@@ -399,7 +399,7 @@
     }
 }
 
-void spi_buffer_set(spi_t *obj, void *tx, uint32_t tx_length, void *rx, uint32_t rx_length, uint8_t bit_width)
+void spi_buffer_set(spi_t *obj, const void *tx, uint32_t tx_length, void *rx, uint32_t rx_length, uint8_t bit_width)
 {
     uint32_t i;
     uint16_t *tx_ptr = (uint16_t *) tx;
@@ -407,7 +407,7 @@
     tx_length *= (bit_width >> 3);
     rx_length *= (bit_width >> 3);
 
-    obj->tx_buff.buffer = tx;
+    obj->tx_buff.buffer = (void *)tx;
     obj->rx_buff.buffer = rx;
     obj->tx_buff.length = tx_length;
     obj->rx_buff.length = rx_length;
@@ -761,7 +761,7 @@
 *   * tx_length: how many bytes will get sent.
 *   * rx_length: how many bytes will get received. If > tx_length, TX will get padded with n lower bits of SPI_FILL_WORD.
 ******************************************/
-static void spi_activate_dma(spi_t *obj, void* rxdata, void* txdata, int tx_length, int rx_length)
+static void spi_activate_dma(spi_t *obj, void* rxdata, const void* txdata, int tx_length, int rx_length)
 {
     /* DMA descriptors */
     DMA_CfgDescr_TypeDef rxDescrCfg;
@@ -822,7 +822,7 @@
                             true,
                             false,
                             (obj->spi.bits <= 8 ? (void *)&(obj->spi.spi->TXDATA) : (void *)&(obj->spi.spi->TXDOUBLE)), //When frame size > 9, point to TXDOUBLE
-                            (txdata == 0 ? &fill_word : txdata), // When there is nothing to transmit, point to static fill word
+                            (txdata == 0 ? &fill_word : (void *)txdata), // When there is nothing to transmit, point to static fill word
                             (obj->spi.bits <= 8 ? tx_length - 1 : (tx_length / 2) - 1)); // When using TXDOUBLE, recalculate transfer length
     } else {
         /* Frame size == 9 */
@@ -860,7 +860,7 @@
                             true,
                             false,
                             (void *)&(obj->spi.spi->TXDATAX), //When frame size > 9, point to TXDOUBLE
-                            (txdata == 0 ? &fill_word : txdata), // When there is nothing to transmit, point to static fill word
+                            (txdata == 0 ? &fill_word : (void *)txdata), // When there is nothing to transmit, point to static fill word
                             (tx_length / 2) - 1); // When using TXDOUBLE, recalculate transfer length
     }
 }
@@ -882,7 +882,7 @@
 *                 If the previous transfer has kept the channel, that channel will continue to get used.
 *
 ********************************************************************/
-void spi_master_transfer_dma(spi_t *obj, void *txdata, void *rxdata, int tx_length, int rx_length, void* cb, DMAUsage hint)
+void spi_master_transfer_dma(spi_t *obj, const void *txdata, void *rxdata, int tx_length, int rx_length, void* cb, DMAUsage hint)
 {
     /* Init DMA here to include it in the power figure */
     dma_init();
@@ -930,7 +930,7 @@
  * @param[in] handler   SPI interrupt handler
  * @param[in] hint      A suggestion for how to use DMA with this transfer
  */
-void spi_master_transfer(spi_t *obj, void *tx, size_t tx_length, void *rx, size_t rx_length, uint8_t bit_width, uint32_t handler, uint32_t event, DMAUsage hint)
+void spi_master_transfer(spi_t *obj, const void *tx, size_t tx_length, void *rx, size_t rx_length, uint8_t bit_width, uint32_t handler, uint32_t event, DMAUsage hint)
 {
     if( spi_active(obj) ) return;