Skip to content

Commit c4bf11c

Browse files
committed
Merge branch 'master' of https://github.com/mbedmicro/mbed
Conflicts: workspace_tools/targets.py
2 parents 0d58363 + 77a973c commit c4bf11c

File tree

19 files changed

+61
-127
lines changed

19 files changed

+61
-127
lines changed

libraries/USBDevice/USBDevice/USBHAL_LPC11U.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -668,17 +668,17 @@ void USBHAL::usbisr(void) {
668668
if (LPC_USB->DEVCMDSTAT & DSUS_C) {
669669
// Suspend status changed
670670
LPC_USB->DEVCMDSTAT = devCmdStat | DSUS_C;
671-
if((LPC_USB->DEVCMDSTAT & DSUS) != 0) {
671+
if (LPC_USB->DEVCMDSTAT & DSUS) {
672672
suspendStateChanged(1);
673+
} else {
674+
suspendStateChanged(0);
673675
}
674676
}
675677

676678
if (LPC_USB->DEVCMDSTAT & DRES_C) {
677679
// Bus reset
678680
LPC_USB->DEVCMDSTAT = devCmdStat | DRES_C;
679681

680-
suspendStateChanged(0);
681-
682682
// Disable endpoints > 0
683683
disableEndpoints();
684684

libraries/mbed/api/I2C.h

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -141,15 +141,15 @@ class I2C {
141141
*
142142
* @param address 8/10 bit I2c slave address
143143
* @param tx_buffer The TX buffer with data to be transfered
144-
* @param tx_length The length of TX buffer
144+
* @param tx_length The length of TX buffer in bytes
145145
* @param rx_buffer The RX buffer which is used for received data
146-
* @param rx_length The length of RX buffer
146+
* @param rx_length The length of RX buffer in bytes
147147
* @param event The logical OR of events to modify
148148
* @param callback The event callback function
149149
* @param repeated Repeated start, true - do not send stop at end
150150
* @return Zero if the transfer has started, or -1 if I2C peripheral is busy
151151
*/
152-
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);
152+
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);
153153

154154
/** Abort the on-going I2C transfer
155155
*/

libraries/mbed/api/SPI.h

Lines changed: 19 additions & 46 deletions
Original file line numberDiff line numberDiff line change
@@ -115,48 +115,21 @@ class SPI {
115115
*
116116
* @param tx_buffer The TX buffer with data to be transfered. If NULL is passed,
117117
* the default SPI value is sent
118-
* @param tx_length The length of TX buffer
118+
* @param tx_length The length of TX buffer in bytes
119119
* @param rx_buffer The RX buffer which is used for received data. If NULL is passed,
120120
* received data are ignored
121-
* @param rx_length The length of RX buffer
121+
* @param rx_length The length of RX buffer in bytes
122122
* @param callback The event callback function
123-
* @param event The logical OR of events to modify
124-
* @return Zero if the transfer has started, or -1 if SPI peripheral is busy
125-
*/
126-
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) {
127-
return transfer(tx_buffer, tx_length, rx_buffer, rx_length, 8, callback, event);
128-
}
129-
130-
/** Start non-blocking SPI transfer using 16bit buffers.
131-
*
132-
* @param tx_buffer The TX buffer with data to be transfered. If NULL is passed,
133-
* the default SPI value is sent
134-
* @param tx_length The length of TX buffer
135-
* @param rx_buffer The RX buffer which is used for received data. If NULL is passed,
136-
* received data are ignored
137-
* @param rx_length The length of RX buffer
138-
* @param callback The event callback function
139-
* @param event The logical OR of events to modify
140-
* @return Zero if the transfer has started, or -1 if SPI peripheral is busy
141-
*/
142-
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) {
143-
return transfer(tx_buffer, tx_length, rx_buffer, rx_length, 16, callback, event);
144-
}
145-
146-
/** Start non-blocking SPI transfer using 32bit buffers.
147-
*
148-
* @param tx_buffer The TX buffer with data to be transfered. If NULL is passed,
149-
* the default SPI value is sent
150-
* @param tx_length The length of TX buffer
151-
* @param rx_buffer The RX buffer which is used for received data. If NULL is passed,
152-
* received data are ignored
153-
* @param rx_length The length of RX buffer
154-
* @param callback The event callback function
155-
* @param event The logical OR of events to modify
123+
* @param event The logical OR of events to modify. Look at spi hal header file for SPI events.
156124
* @return Zero if the transfer has started, or -1 if SPI peripheral is busy
157125
*/
158-
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) {
159-
return transfer((void *)tx_buffer, tx_length, (void *)rx_buffer, rx_length, 32, callback, event);
126+
template<typename Type>
127+
int transfer(const Type *tx_buffer, int tx_length, Type *rx_buffer, int rx_length, const event_callback_t& callback, int event = SPI_EVENT_COMPLETE) {
128+
if (spi_active(&_spi)) {
129+
return queue_transfer(tx_buffer, tx_length, rx_buffer, rx_length, sizeof(Type)*8, callback, event);
130+
}
131+
start_transfer(tx_buffer, tx_length, rx_buffer, rx_length, sizeof(Type)*8, callback, event);
132+
return 0;
160133
}
161134

162135
/** Abort the on-going SPI transfer, and continue with transfer's in the queue if any.
@@ -188,45 +161,45 @@ class SPI {
188161
*
189162
* @param tx_buffer The TX buffer with data to be transfered. If NULL is passed,
190163
* the default SPI value is sent
191-
* @param tx_length The length of TX buffer
164+
* @param tx_length The length of TX buffer in bytes
192165
* @param rx_buffer The RX buffer which is used for received data. If NULL is passed,
193166
* received data are ignored
194-
* @param rx_length The length of RX buffer
167+
* @param rx_length The length of RX buffer in bytes
195168
* @param bit_width The buffers element width
196169
* @param callback The event callback function
197170
* @param event The logical OR of events to modify
198171
* @return Zero if the transfer has started or was added to the queue, or -1 if SPI peripheral is busy/buffer is full
199172
*/
200-
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);
173+
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);
201174

202175
/**
203176
*
204177
* @param tx_buffer The TX buffer with data to be transfered. If NULL is passed,
205178
* the default SPI value is sent
206-
* @param tx_length The length of TX buffer
179+
* @param tx_length The length of TX buffer in bytes
207180
* @param rx_buffer The RX buffer which is used for received data. If NULL is passed,
208181
* received data are ignored
209-
* @param rx_length The length of RX buffer
182+
* @param rx_length The length of RX buffer in bytes
210183
* @param bit_width The buffers element width
211184
* @param callback The event callback function
212185
* @param event The logical OR of events to modify
213186
* @return Zero if a transfer was added to the queue, or -1 if the queue is full
214187
*/
215-
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);
188+
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);
216189

217190
/** Configures a callback, spi peripheral and initiate a new transfer
218191
*
219192
* @param tx_buffer The TX buffer with data to be transfered. If NULL is passed,
220193
* the default SPI value is sent
221-
* @param tx_length The length of TX buffer
194+
* @param tx_length The length of TX buffer in bytes
222195
* @param rx_buffer The RX buffer which is used for received data. If NULL is passed,
223196
* received data are ignored
224-
* @param rx_length The length of RX buffer
197+
* @param rx_length The length of RX buffer in bytes
225198
* @param bit_width The buffers element width
226199
* @param callback The event callback function
227200
* @param event The logical OR of events to modify
228201
*/
229-
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);
202+
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);
230203

231204
#if TRANSACTION_QUEUE_SIZE_SPI
232205

libraries/mbed/api/SerialBase.h

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -131,20 +131,20 @@ class SerialBase {
131131
/** Begin asynchronous write using 8bit buffer. The completition invokes registered TX event callback
132132
*
133133
* @param buffer The buffer where received data will be stored
134-
* @param length The buffer length
134+
* @param length The buffer length in bytes
135135
* @param callback The event callback function
136136
* @param event The logical OR of TX events
137137
*/
138-
int write(uint8_t *buffer, int length, const event_callback_t& callback, int event = SERIAL_EVENT_TX_COMPLETE);
138+
int write(const uint8_t *buffer, int length, const event_callback_t& callback, int event = SERIAL_EVENT_TX_COMPLETE);
139139

140140
/** Begin asynchronous write using 16bit buffer. The completition invokes registered TX event callback
141141
*
142142
* @param buffer The buffer where received data will be stored
143-
* @param length The buffer length
143+
* @param length The buffer length in bytes
144144
* @param callback The event callback function
145145
* @param event The logical OR of TX events
146146
*/
147-
int write(uint16_t *buffer, int length, const event_callback_t& callback, int event = SERIAL_EVENT_TX_COMPLETE);
147+
int write(const uint16_t *buffer, int length, const event_callback_t& callback, int event = SERIAL_EVENT_TX_COMPLETE);
148148

149149
/** Abort the on-going write transfer
150150
*/
@@ -153,7 +153,7 @@ class SerialBase {
153153
/** Begin asynchronous reading using 8bit buffer. The completition invokes registred RX event callback.
154154
*
155155
* @param buffer The buffer where received data will be stored
156-
* @param length The buffer length
156+
* @param length The buffer length in bytes
157157
* @param callback The event callback function
158158
* @param event The logical OR of RX events
159159
* @param char_match The matching character
@@ -163,7 +163,7 @@ class SerialBase {
163163
/** Begin asynchronous reading using 16bit buffer. The completition invokes registred RX event callback.
164164
*
165165
* @param buffer The buffer where received data will be stored
166-
* @param length The buffer length
166+
* @param length The buffer length in bytes
167167
* @param callback The event callback function
168168
* @param event The logical OR of RX events
169169
* @param char_match The matching character
@@ -190,7 +190,7 @@ class SerialBase {
190190

191191
protected:
192192
void start_read(void *buffer, int buffer_size, char buffer_width, const event_callback_t& callback, int event, unsigned char char_match);
193-
void start_write(void *buffer, int buffer_size, char buffer_width, const event_callback_t& callback, int event);
193+
void start_write(const void *buffer, int buffer_size, char buffer_width, const event_callback_t& callback, int event);
194194
void interrupt_handler_asynch(void);
195195
#endif
196196

libraries/mbed/api/TimerEvent.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717
#define MBED_TIMEREVENT_H
1818

1919
#include "ticker_api.h"
20+
#include "us_ticker_api.h"
2021

2122
namespace mbed {
2223

libraries/mbed/api/mbed.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616
#ifndef MBED_H
1717
#define MBED_H
1818

19-
#define MBED_LIBRARY_VERSION 100
19+
#define MBED_LIBRARY_VERSION 101
2020

2121
#include "platform.h"
2222

libraries/mbed/common/I2C.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -92,7 +92,7 @@ void I2C::stop(void) {
9292

9393
#if DEVICE_I2C_ASYNCH
9494

95-
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)
95+
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)
9696
{
9797
if (i2c_active(&_i2c)) {
9898
return -1; // transaction ongoing

libraries/mbed/common/SPI.cpp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,7 @@ int SPI::write(int value) {
6868

6969
#if DEVICE_SPI_ASYNCH
7070

71-
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)
71+
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)
7272
{
7373
if (spi_active(&_spi)) {
7474
return queue_transfer(tx_buffer, tx_length, rx_buffer, rx_length, bit_width, callback, event);
@@ -108,12 +108,12 @@ int SPI::set_dma_usage(DMAUsage usage)
108108
return 0;
109109
}
110110

111-
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)
111+
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)
112112
{
113113
#if TRANSACTION_QUEUE_SIZE_SPI
114114
transaction_t t;
115115

116-
t.tx_buffer = tx_buffer;
116+
t.tx_buffer = const_cast<void *>(tx_buffer);
117117
t.tx_length = tx_length;
118118
t.rx_buffer = rx_buffer;
119119
t.rx_length = rx_length;
@@ -132,7 +132,7 @@ int SPI::queue_transfer(void *tx_buffer, int tx_length, void *rx_buffer, int rx_
132132
#endif
133133
}
134134

135-
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)
135+
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)
136136
{
137137
aquire();
138138
_callback = callback;

libraries/mbed/common/SerialBase.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -110,7 +110,7 @@ void SerialBase::set_flow_control(Flow type, PinName flow1, PinName flow2) {
110110

111111
#if DEVICE_SERIAL_ASYNCH
112112

113-
int SerialBase::write(uint8_t *buffer, int length, const event_callback_t& callback, int event)
113+
int SerialBase::write(const uint8_t *buffer, int length, const event_callback_t& callback, int event)
114114
{
115115
if (serial_tx_active(&_serial)) {
116116
return -1; // transaction ongoing
@@ -119,7 +119,7 @@ int SerialBase::write(uint8_t *buffer, int length, const event_callback_t& callb
119119
return 0;
120120
}
121121

122-
int SerialBase::write(uint16_t *buffer, int length, const event_callback_t& callback, int event)
122+
int SerialBase::write(const uint16_t *buffer, int length, const event_callback_t& callback, int event)
123123
{
124124
if (serial_tx_active(&_serial)) {
125125
return -1; // transaction ongoing
@@ -128,7 +128,7 @@ int SerialBase::write(uint16_t *buffer, int length, const event_callback_t& call
128128
return 0;
129129
}
130130

131-
void SerialBase::start_write(void *buffer, int buffer_size, char buffer_width, const event_callback_t& callback, int event)
131+
void SerialBase::start_write(const void *buffer, int buffer_size, char buffer_width, const event_callback_t& callback, int event)
132132
{
133133
_tx_callback = callback;
134134

libraries/mbed/hal/i2c_api.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -191,7 +191,7 @@ void i2c_slave_address(i2c_t *obj, int idx, uint32_t address, uint32_t mask);
191191
* @param handler The I2C IRQ handler to be set
192192
* @param hint DMA hint usage
193193
*/
194-
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);
194+
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);
195195

196196
/** The asynchronous IRQ handler
197197
* @param obj The I2C object which holds the transfer information

libraries/mbed/hal/serial_api.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -237,7 +237,7 @@ void serial_set_flow_control(serial_t *obj, FlowControl type, PinName rxflow, Pi
237237
* @param hint A suggestion for how to use DMA with this transfer
238238
* @return Returns number of data transfered, or 0 otherwise
239239
*/
240-
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);
240+
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);
241241

242242
/** Begin asynchronous RX transfer (enable interrupt for data collecting)
243243
* The used buffer is specified in the serial object - rx_buff

libraries/mbed/hal/spi_api.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -169,7 +169,7 @@ uint8_t spi_get_module(spi_t *obj);
169169
* @param[in] handler SPI interrupt handler
170170
* @param[in] hint A suggestion for how to use DMA with this transfer
171171
*/
172-
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);
172+
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);
173173

174174
/** The asynchronous IRQ handler
175175
*

libraries/mbed/targets/cmsis/TARGET_Freescale/TARGET_KLXX/TARGET_KL43Z/TOOLCHAIN_GCC_ARM/sys.cpp

Lines changed: 0 additions & 32 deletions
This file was deleted.

libraries/mbed/targets/hal/TARGET_Silicon_Labs/TARGET_EFM32/i2c_api.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -426,7 +426,7 @@ void i2c_slave_address(i2c_t *obj, int idx, uint32_t address, uint32_t mask)
426426
* @param handler The I2C IRQ handler to be set
427427
* @param hint DMA hint usage
428428
*/
429-
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)
429+
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)
430430
{
431431
I2C_TransferReturn_TypeDef retval;
432432
if(i2c_active(obj)) return;
@@ -440,7 +440,7 @@ void i2c_transfer_asynch(i2c_t *obj, void *tx, size_t tx_length, void *rx, size_
440440
if((tx_length > 0) && (rx_length == 0)) {
441441
obj->i2c.xfer.flags = I2C_FLAG_WRITE;
442442
//Store buffer info
443-
obj->i2c.xfer.buf[0].data = tx;
443+
obj->i2c.xfer.buf[0].data = (void *)tx;
444444
obj->i2c.xfer.buf[0].len = (uint16_t) tx_length;
445445
} else if ((tx_length == 0) && (rx_length > 0)) {
446446
obj->i2c.xfer.flags = I2C_FLAG_READ;
@@ -450,7 +450,7 @@ void i2c_transfer_asynch(i2c_t *obj, void *tx, size_t tx_length, void *rx, size_
450450
} else if ((tx_length > 0) && (rx_length > 0)) {
451451
obj->i2c.xfer.flags = I2C_FLAG_WRITE_READ;
452452
//Store buffer info
453-
obj->i2c.xfer.buf[0].data = tx;
453+
obj->i2c.xfer.buf[0].data = (void *)tx;
454454
obj->i2c.xfer.buf[0].len = (uint16_t) tx_length;
455455
obj->i2c.xfer.buf[1].data = rx;
456456
obj->i2c.xfer.buf[1].len = (uint16_t) rx_length;

libraries/mbed/targets/hal/TARGET_Silicon_Labs/TARGET_EFM32/serial_api.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1262,14 +1262,14 @@ void serial_set_char_match(serial_t *obj, uint8_t char_match)
12621262
* @param hint A suggestion for how to use DMA with this transfer
12631263
* @return Returns number of data transfered, or 0 otherwise
12641264
*/
1265-
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)
1265+
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)
12661266
{
12671267
// Check that a buffer has indeed been set up
12681268
MBED_ASSERT(tx != (void*)0);
12691269
if(tx_length == 0) return 0;
12701270

12711271
// Set up buffer
1272-
serial_tx_buffer_set(obj, tx, tx_length, tx_width);
1272+
serial_tx_buffer_set(obj, (void *)tx, tx_length, tx_width);
12731273

12741274
// Set up events
12751275
serial_tx_enable_event(obj, SERIAL_EVENT_TX_ALL, false);

0 commit comments

Comments
 (0)