Skip to content

Commit 8ef4c2e

Browse files
committed
Merge pull request #4 from mbedmicro/master
Update my fork with original
2 parents 45f2ca6 + 58bac00 commit 8ef4c2e

File tree

905 files changed

+222352
-7180
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

905 files changed

+222352
-7180
lines changed

libraries/USBDevice/USBDevice/USBEndpoints.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ typedef enum {
4141
#include "USBEndpoints_LPC17_LPC23.h"
4242
#elif defined(TARGET_LPC11UXX) || defined(TARGET_LPC1347) || defined (TARGET_LPC11U6X) || defined (TARGET_LPC1549)
4343
#include "USBEndpoints_LPC11U.h"
44-
#elif defined(TARGET_KL25Z) | defined(TARGET_KL43Z) | defined(TARGET_KL46Z) | defined(TARGET_K20D50M) | defined(TARGET_K64F) | defined(TARGET_K22F) | defined(TARGET_TEENSY3_1)
44+
#elif defined(TARGET_KL25Z) | defined(TARGET_KL26Z) | defined(TARGET_KL43Z) | defined(TARGET_KL46Z) | defined(TARGET_K20D50M) | defined(TARGET_K64F) | defined(TARGET_K22F) | defined(TARGET_TEENSY3_1)
4545
#include "USBEndpoints_KL25Z.h"
4646
#elif defined (TARGET_STM32F4)
4747
#include "USBEndpoints_STM32F4.h"

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/CMakeLists.txt

Lines changed: 112 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,112 @@
1+
#
2+
# mbed-2 yotta-compatible build system
3+
#
4+
5+
# make sure necessary features are enabled:
6+
project(mbed-classic)
7+
enable_language(ASM)
8+
9+
# override compilation flags:
10+
if(CMAKE_C_COMPILER_ID MATCHES GNU)
11+
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -std=gnu99")
12+
endif()
13+
14+
# the mbed.a library is built from two sets of source files + include
15+
# directories:
16+
#
17+
# MBED_COMMON_SOURCES: the source files that are the same for all targets,
18+
# these are easily found by globbing:
19+
#
20+
file(GLOB MBED_COMMON_SOURCES "common/*.cpp" "common/*.c")
21+
#
22+
# (always include the hal header directory, too)
23+
set(MBED_COMMON_INCLUDE_DIRS "hal")
24+
25+
# and MBED_TARGET_SOURCES: these depend on which target we are building for. To
26+
# find these we need to walk the directories in targets/, and wherever we see a
27+
# TARGET_<something> name, recurse only if <something> matches what we're
28+
# currently building for
29+
macro(mbed_find_target_dirs PARENT_DIRECTORY SOURCES_LIST INCLUDES_LIST)
30+
# append this directory to the search path:
31+
list(APPEND ${INCLUDES_LIST} "${PARENT_DIRECTORY}")
32+
# add all source files in this directory to the sources list:
33+
file(GLOB sources "${PARENT_DIRECTORY}/*.cpp" "${PARENT_DIRECTORY}/*.c" "${PARENT_DIRECTORY}/*.s" "${PARENT_DIRECTORY}/*.S" )
34+
list(APPEND ${SOURCES_LIST} ${sources})
35+
36+
# get a list of all subdirectories that we want to recurse into:
37+
file(GLOB dir_children RELATIVE "${PARENT_DIRECTORY}" "${PARENT_DIRECTORY}/*")
38+
set(matching_subdirs "")
39+
foreach(child ${dir_children})
40+
if(IS_DIRECTORY "${PARENT_DIRECTORY}/${child}")
41+
# is this directory name a magic one?
42+
if("${child}" MATCHES "^TARGET_")
43+
# target-magic: recurse if the MBED_LEGACY_TARGET_DEFINITIONS **list**
44+
# contains a matching value:
45+
foreach(legacy_magic_def ${MBED_LEGACY_TARGET_DEFINITIONS})
46+
# we could probably unroll the list into a single regex if
47+
# this is a performance problem:
48+
if("${child}" MATCHES "^TARGET_${legacy_magic_def}$")
49+
list(APPEND matching_subdirs ${child})
50+
break()
51+
endif()
52+
endforeach()
53+
elseif("${child}" MATCHES "^TOOLCHAIN_")
54+
# toolchain-magic: (recurse if the MBED_LEGACY_TOOLCHAIN matches
55+
# this name)
56+
if("${child}" MATCHES "^TOOLCHAIN_${MBED_LEGACY_TOOLCHAIN}$")
57+
list(APPEND matching_subdirs "${child}")
58+
endif()
59+
else()
60+
# not special: always recurse into this directory
61+
list(APPEND matching_subdirs "${child}")
62+
endif()
63+
endif()
64+
endforeach()
65+
#message("matching_subdirs: ${matching_subdirs}")
66+
67+
# recurse:
68+
foreach(subdir ${matching_subdirs})
69+
mbed_find_target_dirs("${PARENT_DIRECTORY}/${subdir}" ${SOURCES_LIST} ${INCLUDES_LIST})
70+
endforeach()
71+
endmacro()
72+
73+
set(MBED_TARGET_SOURCES "")
74+
set(MBED_TARGET_INCLUDE_DIRS "")
75+
mbed_find_target_dirs("${CMAKE_CURRENT_SOURCE_DIR}/targets" MBED_TARGET_SOURCES MBED_TARGET_INCLUDE_DIRS)
76+
#message("found target sources: ${MBED_TARGET_SOURCES}")
77+
#message("found target include dirs: ${MBED_TARGET_INCLUDE_DIRS}")
78+
79+
# unfortunately, for ARMCC, the startup code needs to be provided as an object
80+
# on the command line (not as part of an archive). To do this we override the
81+
# CMake add_executable command.
82+
if(CMAKE_C_COMPILER_ID STREQUAL "ARMCC")
83+
set(MBED_TARGET_STARTUP_CODE_SOURCES "")
84+
foreach(src ${MBED_TARGET_SOURCES})
85+
if("${src}" MATCHES .*startup_.*\\.[sS])
86+
LIST(APPEND MBED_TARGET_STARTUP_CODE_SOURCES "${src}")
87+
endif()
88+
endforeach()
89+
add_library(mbed_classic_startupcod OBJECT ${MBED_TARGET_STARTUP_CODE_SOURCES})
90+
macro (add_executable _name)
91+
_add_executable(${ARGV} $<TARGET_OBJECTS:mbed_classic_startupcod>)
92+
endmacro()
93+
endif()
94+
95+
# we have to append any target-specific include dirs to the global include dirs
96+
# list, so that any indirect includes (e.g. via mbed.h) of files in those
97+
# directories will work:
98+
# (non-target-specific include dirs are listed in extraIncludes in module.json)
99+
foreach(dir ${MBED_TARGET_INCLUDE_DIRS})
100+
set_property(GLOBAL APPEND PROPERTY YOTTA_GLOBAL_INCLUDE_DIRS ${dir})
101+
endforeach()
102+
103+
# finally, we can construct a library using the determined set of include paths
104+
# + source files. Note that the library name must match the name of the yotta
105+
# module (defined in module.json) for this module to link properly with other
106+
# yotta modules.
107+
include_directories(${MBED_COMMON_INCLUDE_DIRS})
108+
include_directories(${MBED_TARGET_INCLUDE_DIRS})
109+
add_library(mbed-classic
110+
${MBED_COMMON_SOURCES}
111+
${MBED_TARGET_SOURCES}
112+
)

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 103
2020

2121
#include "platform.h"
2222

libraries/mbed/api/mbed_assert.h

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,8 +23,7 @@ extern "C" {
2323
/** Internal mbed assert function which is invoked when MBED_ASSERT macro failes.
2424
* This function is active only if NDEBUG is not defined prior to including this
2525
* assert header file.
26-
* In case of MBED_ASSERT failing condition, the assertation message is printed
27-
* to stderr and mbed_die() is called.
26+
* In case of MBED_ASSERT failing condition, error() is called with the assertation message.
2827
* @param expr Expresion to be checked.
2928
* @param file File where assertation failed.
3029
* @param line Failing assertation line number.

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

0 commit comments

Comments
 (0)