diff --git a/libraries/mbed/api/SerialBase.h b/libraries/mbed/api/SerialBase.h index fd5bc3dd1d..eecf98bc69 100644 --- a/libraries/mbed/api/SerialBase.h +++ b/libraries/mbed/api/SerialBase.h @@ -135,7 +135,7 @@ public: * @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 @@ public: * @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 @@ public: 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 diff --git a/libraries/mbed/common/SerialBase.cpp b/libraries/mbed/common/SerialBase.cpp index 2d5ea8c4c5..880a0212e6 100644 --- a/libraries/mbed/common/SerialBase.cpp +++ b/libraries/mbed/common/SerialBase.cpp @@ -110,7 +110,7 @@ void SerialBase::set_flow_control(Flow type, PinName flow1, PinName flow2) { #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 @@ int SerialBase::write(uint8_t *buffer, int length, const event_callback_t& callb 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 @@ int SerialBase::write(uint16_t *buffer, int length, const event_callback_t& call 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; diff --git a/libraries/mbed/hal/serial_api.h b/libraries/mbed/hal/serial_api.h index eee7308cc2..6cf9a4bb5a 100644 --- a/libraries/mbed/hal/serial_api.h +++ b/libraries/mbed/hal/serial_api.h @@ -237,7 +237,7 @@ void serial_set_flow_control(serial_t *obj, FlowControl type, PinName rxflow, Pi * @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 diff --git a/libraries/mbed/targets/hal/TARGET_Silicon_Labs/TARGET_EFM32/serial_api.c b/libraries/mbed/targets/hal/TARGET_Silicon_Labs/TARGET_EFM32/serial_api.c index d2bcf933d6..2094976fa7 100644 --- a/libraries/mbed/targets/hal/TARGET_Silicon_Labs/TARGET_EFM32/serial_api.c +++ b/libraries/mbed/targets/hal/TARGET_Silicon_Labs/TARGET_EFM32/serial_api.c @@ -1262,14 +1262,14 @@ void serial_set_char_match(serial_t *obj, uint8_t char_match) * @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);