Skip to content

Commit f4591db

Browse files
committed
Merge branch 'upstream_master' into dev_kl46z
2 parents d9ed7ab + 17bdeb4 commit f4591db

File tree

191 files changed

+5318
-9667
lines changed

Some content is hidden

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

191 files changed

+5318
-9667
lines changed

.gitignore

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,11 @@
11
*.py[cod]
22

3+
# Distribution dir
4+
dist
5+
6+
# MANIFEST file
7+
MANIFEST
8+
39
# Private settings
410
private_settings.py
511

@@ -53,4 +59,4 @@ uVision Project/
5359
debug.log
5460

5561
# Ignore OS X Desktop Services Store files
56-
.DS_Store
62+
.DS_Store

MANIFEST

Lines changed: 96 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,96 @@
1+
# file GENERATED by distutils, do NOT edit
2+
LICENSE
3+
setup.py
4+
workspace_tools/__init__.py
5+
workspace_tools/__init__.pyc
6+
workspace_tools/autotest.py
7+
workspace_tools/build.py
8+
workspace_tools/build_api.py
9+
workspace_tools/build_release.py
10+
workspace_tools/client.py
11+
workspace_tools/export_test.py
12+
workspace_tools/hooks.py
13+
workspace_tools/libraries.py
14+
workspace_tools/make.py
15+
workspace_tools/options.py
16+
workspace_tools/patch.py
17+
workspace_tools/paths.py
18+
workspace_tools/project.py
19+
workspace_tools/server.py
20+
workspace_tools/settings.py
21+
workspace_tools/size.py
22+
workspace_tools/syms.py
23+
workspace_tools/synch.py
24+
workspace_tools/targets.py
25+
workspace_tools/tests.py
26+
workspace_tools/utils.py
27+
workspace_tools/data/__init__.py
28+
workspace_tools/data/example_test_spec.json
29+
workspace_tools/data/support.py
30+
workspace_tools/data/rpc/RPCClasses.h
31+
workspace_tools/data/rpc/class.cpp
32+
workspace_tools/dev/__init__.py
33+
workspace_tools/dev/dsp_fir.py
34+
workspace_tools/dev/rpc_classes.py
35+
workspace_tools/export/__init__.py
36+
workspace_tools/export/codered.py
37+
workspace_tools/export/codered_lpc1768_cproject.tmpl
38+
workspace_tools/export/codered_lpc1768_project.tmpl
39+
workspace_tools/export/codered_lpc4088_cproject.tmpl
40+
workspace_tools/export/codered_lpc4088_project.tmpl
41+
workspace_tools/export/codesourcery.py
42+
workspace_tools/export/codesourcery_lpc1768.tmpl
43+
workspace_tools/export/ds5_5.py
44+
workspace_tools/export/ds5_5_lpc11u24.cproject.tmpl
45+
workspace_tools/export/ds5_5_lpc11u24.launch.tmpl
46+
workspace_tools/export/ds5_5_lpc11u24.project.tmpl
47+
workspace_tools/export/ds5_5_lpc1768.cproject.tmpl
48+
workspace_tools/export/ds5_5_lpc1768.launch.tmpl
49+
workspace_tools/export/ds5_5_lpc1768.project.tmpl
50+
workspace_tools/export/exporters.py
51+
workspace_tools/export/gcc_arm_lpc1768.tmpl
52+
workspace_tools/export/gccarm.py
53+
workspace_tools/export/iar.ewp.tmpl
54+
workspace_tools/export/iar.eww.tmpl
55+
workspace_tools/export/iar.py
56+
workspace_tools/export/uvision4.py
57+
workspace_tools/export/uvision4_kl25z.uvopt.tmpl
58+
workspace_tools/export/uvision4_kl25z.uvproj.tmpl
59+
workspace_tools/export/uvision4_lpc1114.uvopt.tmpl
60+
workspace_tools/export/uvision4_lpc1114.uvproj.tmpl
61+
workspace_tools/export/uvision4_lpc11c24.uvopt.tmpl
62+
workspace_tools/export/uvision4_lpc11c24.uvproj.tmpl
63+
workspace_tools/export/uvision4_lpc11u24.uvopt.tmpl
64+
workspace_tools/export/uvision4_lpc11u24.uvproj.tmpl
65+
workspace_tools/export/uvision4_lpc1347.uvopt.tmpl
66+
workspace_tools/export/uvision4_lpc1347.uvproj.tmpl
67+
workspace_tools/export/uvision4_lpc1768.uvopt.tmpl
68+
workspace_tools/export/uvision4_lpc1768.uvproj.tmpl
69+
workspace_tools/export/uvision4_lpc4088.uvopt.tmpl
70+
workspace_tools/export/uvision4_lpc4088.uvproj.tmpl
71+
workspace_tools/export/uvision4_lpc812.uvopt.tmpl
72+
workspace_tools/export/uvision4_lpc812.uvproj.tmpl
73+
workspace_tools/host_tests/__init__.py
74+
workspace_tools/host_tests/echo.py
75+
workspace_tools/host_tests/host_test.py
76+
workspace_tools/host_tests/mbedrpc.py
77+
workspace_tools/host_tests/net_test.py
78+
workspace_tools/host_tests/rpc.py
79+
workspace_tools/host_tests/tcpecho_client.py
80+
workspace_tools/host_tests/tcpecho_server.py
81+
workspace_tools/host_tests/tcpecho_server_loop.py
82+
workspace_tools/host_tests/udpecho_client.py
83+
workspace_tools/host_tests/udpecho_server.py
84+
workspace_tools/host_tests/example/BroadcastReceive.py
85+
workspace_tools/host_tests/example/BroadcastSend.py
86+
workspace_tools/host_tests/example/MulticastReceive.py
87+
workspace_tools/host_tests/example/MulticastSend.py
88+
workspace_tools/host_tests/example/TCPEchoClient.py
89+
workspace_tools/host_tests/example/TCPEchoServer.py
90+
workspace_tools/host_tests/example/UDPEchoClient.py
91+
workspace_tools/host_tests/example/UDPEchoServer.py
92+
workspace_tools/host_tests/example/__init__.py
93+
workspace_tools/toolchains/__init__.py
94+
workspace_tools/toolchains/arm.py
95+
workspace_tools/toolchains/gcc.py
96+
workspace_tools/toolchains/iar.py

MANIFEST.in

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
graft workspace_tools
2+
include __init__.py LICENSE

libraries/USBDevice/USBSerial/USBCDC.cpp

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,7 @@ bool USBCDC::USBCallback_request(void) {
5252
break;
5353
case CDC_SET_LINE_CODING:
5454
transfer->remaining = 7;
55+
transfer->notify = true;
5556
success = true;
5657
terminal_connected = true;
5758
break;
@@ -67,6 +68,31 @@ bool USBCDC::USBCallback_request(void) {
6768
return success;
6869
}
6970

71+
void USBCDC::USBCallback_requestCompleted(uint8_t *buf, uint32_t length) {
72+
// Request of setting line coding has 7 bytes
73+
if (length != 7) {
74+
return;
75+
}
76+
77+
CONTROL_TRANSFER * transfer = getTransferPtr();
78+
79+
/* Process class-specific requests */
80+
if (transfer->setup.bmRequestType.Type == CLASS_TYPE) {
81+
if (transfer->setup.bRequest == CDC_SET_LINE_CODING) {
82+
if (memcmp(cdc_line_coding, buf, 7)) {
83+
memcpy(cdc_line_coding, buf, 7);
84+
85+
int baud = buf[0] + (buf[1] << 8)
86+
+ (buf[2] << 16) + (buf[3] << 24);
87+
int stop = buf[4];
88+
int bits = buf[6];
89+
int parity = buf[5];
90+
91+
lineCodingChanged(baud, bits, parity, stop);
92+
}
93+
}
94+
}
95+
}
7096

7197
// Called in ISR context
7298
// Set configuration. Return false if the

libraries/USBDevice/USBSerial/USBCDC.h

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -99,9 +99,21 @@ class USBCDC: public USBDevice {
9999
* @returns true if successful
100100
*/
101101
bool readEP_NB(uint8_t * buffer, uint32_t * size);
102+
103+
/*
104+
* Called by USBCallback_requestCompleted when CDC line coding is changed
105+
* Warning: Called in ISR
106+
*
107+
* @param baud The baud rate
108+
* @param bits The number of bits in a word (5-8)
109+
* @param parity The parity
110+
* @param stop The number of stop bits (1 or 2)
111+
*/
112+
virtual void lineCodingChanged(int baud, int bits, int parity, int stop) {};
102113

103114
protected:
104115
virtual bool USBCallback_request();
116+
virtual void USBCallback_requestCompleted(uint8_t *buf, uint32_t length);
105117
virtual bool USBCallback_setConfiguration(uint8_t configuration);
106118
volatile bool terminal_connected;
107119

libraries/USBDevice/USBSerial/USBSerial.h

Lines changed: 36 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,9 @@ class USBSerial: public USBCDC, public Stream {
5555
* @param product_release Your preoduct_release (default: 0x0001)
5656
*
5757
*/
58-
USBSerial(uint16_t vendor_id = 0x1f00, uint16_t product_id = 0x2012, uint16_t product_release = 0x0001): USBCDC(vendor_id, product_id, product_release), buf(128){ };
58+
USBSerial(uint16_t vendor_id = 0x1f00, uint16_t product_id = 0x2012, uint16_t product_release = 0x0001): USBCDC(vendor_id, product_id, product_release), buf(128){
59+
settingsChangedCallback = 0;
60+
};
5961

6062

6163
/**
@@ -79,6 +81,22 @@ class USBSerial: public USBCDC, public Stream {
7981
* @returns the number of bytes available
8082
*/
8183
uint8_t available();
84+
85+
/** Determine if there is a character available to read
86+
*
87+
* @returns
88+
* 1 if there is a character available to read,
89+
* 0 otherwise
90+
*/
91+
int readable() { return available() ? 1 : 0; }
92+
93+
/** Determine if there is space available to write a character
94+
*
95+
* @returns
96+
* 1 if there is space to write a character,
97+
* 0 otherwise
98+
*/
99+
int writeable() { return 1; } // always return 1, for write operation is blocking
82100

83101
/**
84102
* Write a block of data.
@@ -110,19 +128,33 @@ class USBSerial: public USBCDC, public Stream {
110128
*
111129
* @param fptr function pointer
112130
*/
113-
void attach(void (*fn)(void)) {
114-
if(fn != NULL) {
115-
rx.attach(fn);
131+
void attach(void (*fptr)(void)) {
132+
if(fptr != NULL) {
133+
rx.attach(fptr);
116134
}
117135
}
118136

137+
/**
138+
* Attach a callback to call when serial's settings are changed.
139+
*
140+
* @param fptr function pointer
141+
*/
142+
void attach(void (*fptr)(int baud, int bits, int parity, int stop)) {
143+
settingsChangedCallback = fptr;
144+
}
119145

120146
protected:
121147
virtual bool EP2_OUT_callback();
148+
virtual void lineCodingChanged(int baud, int bits, int parity, int stop){
149+
if (settingsChangedCallback) {
150+
settingsChangedCallback(baud, bits, parity, stop);
151+
}
152+
}
122153

123154
private:
124155
FunctionPointer rx;
125156
CircBuffer<uint8_t> buf;
157+
void (*settingsChangedCallback)(int baud, int bits, int parity, int stop);
126158
};
127159

128160
#endif

libraries/USBHost/USBHost3GModule/IUSBHostSerial.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,10 @@
3030

3131
#include "IUSBHostSerialListener.h"
3232

33+
// This is needed by some versions of GCC
34+
#undef putc
35+
#undef getc
36+
3337
class IUSBHostSerial {
3438
public:
3539

libraries/USBHost/USBHost3GModule/WANDongle.cpp

Lines changed: 23 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -25,8 +25,8 @@
2525
#define __MODULE__ "WANDongle.cpp"
2626
#endif
2727

28-
#include "core/dbg.h"
29-
#include <cstdint>
28+
#include "dbg.h"
29+
#include <stdint.h>
3030
#include "rtos.h"
3131

3232
#include "WANDongle.h"
@@ -47,7 +47,7 @@ bool WANDongle::tryConnect()
4747
{
4848
//FIXME should run on USB thread
4949

50-
DBG("Trying to connect device");
50+
USB_DBG("Trying to connect device");
5151

5252
if (dev_connected) {
5353
return true;
@@ -61,23 +61,23 @@ bool WANDongle::tryConnect()
6161
{
6262
m_pInitializer = NULL; //Will be set in setVidPid callback
6363

64-
DBG("Enumerate");
64+
USB_DBG("Enumerate");
6565
int ret = host->enumerate(dev, this);
6666
if(ret)
6767
{
6868
return false;
6969
}
7070

71-
DBG("Device has VID:%04x PID:%04x", dev->getVid(), dev->getPid());
71+
USB_DBG("Device has VID:%04x PID:%04x", dev->getVid(), dev->getPid());
7272

7373
if(m_pInitializer) //If an initializer has been found
7474
{
75-
DBG("m_pInitializer=%p", m_pInitializer);
76-
DBG("m_pInitializer->getSerialVid()=%04x", m_pInitializer->getSerialVid());
77-
DBG("m_pInitializer->getSerialPid()=%04x", m_pInitializer->getSerialPid());
75+
USB_DBG("m_pInitializer=%p", m_pInitializer);
76+
USB_DBG("m_pInitializer->getSerialVid()=%04x", m_pInitializer->getSerialVid());
77+
USB_DBG("m_pInitializer->getSerialPid()=%04x", m_pInitializer->getSerialPid());
7878
if ((dev->getVid() == m_pInitializer->getSerialVid()) && (dev->getPid() == m_pInitializer->getSerialPid()))
7979
{
80-
DBG("The dongle is in virtual serial mode");
80+
USB_DBG("The dongle is in virtual serial mode");
8181
host->registerDriver(dev, 0, this, &WANDongle::init);
8282
m_serialCount = m_pInitializer->getSerialPortCount();
8383
if( m_serialCount > WANDONGLE_MAX_SERIAL_PORTS )
@@ -86,13 +86,13 @@ bool WANDongle::tryConnect()
8686
}
8787
for(int j = 0; j < m_serialCount; j++)
8888
{
89-
DBG("Connecting serial port #%d", j+1);
90-
DBG("Ep %p", m_pInitializer->getEp(dev, j, false));
91-
DBG("Ep %p", m_pInitializer->getEp(dev, j, true));
89+
USB_DBG("Connecting serial port #%d", j+1);
90+
USB_DBG("Ep %p", m_pInitializer->getEp(dev, j, false));
91+
USB_DBG("Ep %p", m_pInitializer->getEp(dev, j, true));
9292
m_serial[j].connect( dev, m_pInitializer->getEp(dev, j, false), m_pInitializer->getEp(dev, j, true) );
9393
}
9494

95-
DBG("Device connected");
95+
USB_DBG("Device connected");
9696

9797
dev_connected = true;
9898

@@ -101,16 +101,16 @@ bool WANDongle::tryConnect()
101101
}
102102
else if ((dev->getVid() == m_pInitializer->getMSDVid()) && (dev->getPid() == m_pInitializer->getMSDPid()))
103103
{
104-
DBG("Vodafone K3370 dongle detected in MSD mode");
104+
USB_DBG("Vodafone K3370 dongle detected in MSD mode");
105105
//Try to switch
106106
if( m_pInitializer->switchMode(dev) )
107107
{
108-
DBG("Switched OK");
108+
USB_DBG("Switched OK");
109109
return false; //Will be connected on a next iteration
110110
}
111111
else
112112
{
113-
ERR("Could not switch mode");
113+
USB_ERR("Could not switch mode");
114114
return false;
115115
}
116116
}
@@ -168,21 +168,21 @@ void WANDongle::init()
168168
{
169169
WANDongleInitializer* initializer;
170170

171-
for(unsigned i = 0; i < m_totalInitializers; i++)
171+
for(int i = 0; i < m_totalInitializers; i++)
172172
{
173173
initializer = m_Initializers[i];
174-
DBG("initializer=%p", initializer);
175-
DBG("initializer->getSerialVid()=%04x", initializer->getSerialVid());
176-
DBG("initializer->getSerialPid()=%04x", initializer->getSerialPid());
174+
USB_DBG("initializer=%p", initializer);
175+
USB_DBG("initializer->getSerialVid()=%04x", initializer->getSerialVid());
176+
USB_DBG("initializer->getSerialPid()=%04x", initializer->getSerialPid());
177177
if ((dev->getVid() == initializer->getSerialVid()) && (dev->getPid() == initializer->getSerialPid()))
178178
{
179-
DBG("The dongle is in virtual serial mode");
179+
USB_DBG("The dongle is in virtual serial mode");
180180
m_pInitializer = initializer;
181181
break;
182182
}
183183
else if ((dev->getVid() == initializer->getMSDVid()) && (dev->getPid() == initializer->getMSDPid()))
184184
{
185-
DBG("Dongle detected in MSD mode");
185+
USB_DBG("Dongle detected in MSD mode");
186186
m_pInitializer = initializer;
187187
break;
188188
}
@@ -229,7 +229,7 @@ bool WANDongle::addInitializer(WANDongleInitializer* pInitializer)
229229

230230
WANDongle::~WANDongle()
231231
{
232-
for(unsigned i = 0; i < m_totalInitializers; i++)
232+
for(int i = 0; i < m_totalInitializers; i++)
233233
delete m_Initializers[i];
234234
}
235235

0 commit comments

Comments
 (0)