Skip to content

Commit 12b6b78

Browse files
committed
Merge remote-tracking branch 'micropython/master'
2 parents eda3338 + 67d52d8 commit 12b6b78

File tree

160 files changed

+714
-51527
lines changed

Some content is hidden

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

160 files changed

+714
-51527
lines changed

.travis.yml

+1
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,7 @@ script:
4747
- (cd tests && MICROPY_CPYTHON3=python3.4 MICROPY_MICROPYTHON=../unix/micropython_coverage ./run-tests)
4848
- (cd tests && MICROPY_CPYTHON3=python3.4 MICROPY_MICROPYTHON=../unix/micropython_coverage ./run-tests -d thread)
4949
- (cd tests && MICROPY_CPYTHON3=python3.4 MICROPY_MICROPYTHON=../unix/micropython_coverage ./run-tests --emit native)
50+
- (cd tests && MICROPY_CPYTHON3=python3.4 MICROPY_MICROPYTHON=../unix/micropython_coverage ./run-tests --via-mpy -d basics)
5051

5152
after_success:
5253
- (cd unix && coveralls --root .. --build-root . --gcov $(which gcov) --gcov-options '\-o build-coverage/' --include py --include extmod)

README.md

+1-5
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,8 @@
1-
[![Build Status][travis-img]][travis-repo] [![Coverage Status][coveralls-img]][coveralls-repo] [![Issue Stats][istats-pr-img]][istats-pr-repo] [![Issue Stats][istats-issue-img]][istats-issue-repo]
1+
[![Build Status][travis-img]][travis-repo] [![Coverage Status][coveralls-img]][coveralls-repo]
22
[travis-img]: https://travis-ci.org/micropython/micropython.png?branch=master
33
[travis-repo]: https://travis-ci.org/micropython/micropython
44
[coveralls-img]: https://coveralls.io/repos/micropython/micropython/badge.png?branch=master
55
[coveralls-repo]: https://coveralls.io/r/micropython/micropython?branch=master
6-
[istats-pr-img]: http://issuestats.com/github/micropython/micropython/badge/pr
7-
[istats-pr-repo]: http://issuestats.com/github/micropython/micropython
8-
[istats-issue-img]: http://issuestats.com/github/micropython/micropython/badge/issue
9-
[istats-issue-repo]: http://issuestats.com/github/micropython/micropython
106

117
The MicroPython project
128
=======================

cc3200/mods/modmachine.c

-1
Original file line numberDiff line numberDiff line change
@@ -213,6 +213,5 @@ STATIC MP_DEFINE_CONST_DICT(machine_module_globals, machine_module_globals_table
213213

214214
const mp_obj_module_t machine_module = {
215215
.base = { &mp_type_module },
216-
.name = MP_QSTR_umachine,
217216
.globals = (mp_obj_dict_t*)&machine_module_globals,
218217
};

cc3200/mods/modnetwork.c

-1
Original file line numberDiff line numberDiff line change
@@ -161,7 +161,6 @@ STATIC MP_DEFINE_CONST_DICT(mp_module_network_globals, mp_module_network_globals
161161

162162
const mp_obj_module_t mp_module_network = {
163163
.base = { &mp_type_module },
164-
.name = MP_QSTR_network,
165164
.globals = (mp_obj_dict_t*)&mp_module_network_globals,
166165
};
167166

cc3200/mods/modubinascii.c

-1
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,5 @@ STATIC MP_DEFINE_CONST_DICT(mp_module_binascii_globals, mp_module_binascii_globa
5858

5959
const mp_obj_module_t mp_module_ubinascii = {
6060
.base = { &mp_type_module },
61-
.name = MP_QSTR_ubinascii,
6261
.globals = (mp_obj_dict_t*)&mp_module_binascii_globals,
6362
};

cc3200/mods/moduhashlib.c

-1
Original file line numberDiff line numberDiff line change
@@ -204,7 +204,6 @@ STATIC MP_DEFINE_CONST_DICT(mp_module_hashlib_globals, mp_module_hashlib_globals
204204

205205
const mp_obj_module_t mp_module_uhashlib = {
206206
.base = { &mp_type_module },
207-
.name = MP_QSTR_uhashlib,
208207
.globals = (mp_obj_dict_t*)&mp_module_hashlib_globals,
209208
};
210209

cc3200/mods/moduos.c

-1
Original file line numberDiff line numberDiff line change
@@ -602,6 +602,5 @@ STATIC MP_DEFINE_CONST_DICT(os_module_globals, os_module_globals_table);
602602

603603
const mp_obj_module_t mp_module_uos = {
604604
.base = { &mp_type_module },
605-
.name = MP_QSTR_uos,
606605
.globals = (mp_obj_dict_t*)&os_module_globals,
607606
};

cc3200/mods/modusocket.c

-1
Original file line numberDiff line numberDiff line change
@@ -541,6 +541,5 @@ STATIC MP_DEFINE_CONST_DICT(mp_module_usocket_globals, mp_module_usocket_globals
541541

542542
const mp_obj_module_t mp_module_usocket = {
543543
.base = { &mp_type_module },
544-
.name = MP_QSTR_usocket,
545544
.globals = (mp_obj_dict_t*)&mp_module_usocket_globals,
546545
};

cc3200/mods/modussl.c

-1
Original file line numberDiff line numberDiff line change
@@ -152,7 +152,6 @@ STATIC MP_DEFINE_CONST_DICT(mp_module_ussl_globals, mp_module_ussl_globals_table
152152

153153
const mp_obj_module_t mp_module_ussl = {
154154
.base = { &mp_type_module },
155-
.name = MP_QSTR_ussl,
156155
.globals = (mp_obj_dict_t*)&mp_module_ussl_globals,
157156
};
158157

cc3200/mods/modutime.c

-1
Original file line numberDiff line numberDiff line change
@@ -196,6 +196,5 @@ STATIC MP_DEFINE_CONST_DICT(time_module_globals, time_module_globals_table);
196196

197197
const mp_obj_module_t mp_module_utime = {
198198
.base = { &mp_type_module },
199-
.name = MP_QSTR_utime,
200199
.globals = (mp_obj_dict_t*)&time_module_globals,
201200
};

cc3200/mods/modwipy.c

-1
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,5 @@ STATIC MP_DEFINE_CONST_DICT(wipy_module_globals, wipy_module_globals_table);
2626

2727
const mp_obj_module_t wipy_module = {
2828
.base = { &mp_type_module },
29-
.name = MP_QSTR_wipy,
3029
.globals = (mp_obj_dict_t*)&wipy_module_globals,
3130
};

docs/library/machine.rst

+7-9
Original file line numberDiff line numberDiff line change
@@ -24,17 +24,15 @@ Interrupt related functions
2424
.. function:: disable_irq()
2525

2626
Disable interrupt requests.
27-
Returns the previous IRQ state: ``False``/``True`` for disabled/enabled IRQs
28-
respectively. This return value can be passed to enable_irq to restore
29-
the IRQ to its original state.
27+
Returns the previous IRQ state which should be considered an opaque value.
28+
This return value should be passed to the ``enable_irq`` function to restore
29+
interrupts to their original state, before ``disable_irq`` was called.
3030

31-
.. function:: enable_irq(state=True)
31+
.. function:: enable_irq(state)
3232

33-
Enable interrupt requests.
34-
If ``state`` is ``True`` (the default value) then IRQs are enabled.
35-
If ``state`` is ``False`` then IRQs are disabled. The most common use of
36-
this function is to pass it the value returned by ``disable_irq`` to
37-
exit a critical section.
33+
Re-enable interrupt requests.
34+
The ``state`` parameter should be the value that was returned from the most
35+
recent call to the ``disable_irq`` function.
3836

3937
Power related functions
4038
-----------------------

esp8266/esp_mphal.c

+1-1
Original file line numberDiff line numberDiff line change
@@ -117,7 +117,7 @@ void mp_hal_debug_tx_strn_cooked(void *env, const char *str, uint32_t len) {
117117
}
118118

119119
uint32_t mp_hal_ticks_ms(void) {
120-
return system_get_time() / 1000;
120+
return ((uint64_t)system_time_high_word << 32 | (uint64_t)system_get_time()) / 1000;
121121
}
122122

123123
uint32_t mp_hal_ticks_us(void) {

esp8266/ets_alt_task.c

+12
Original file line numberDiff line numberDiff line change
@@ -110,10 +110,22 @@ bool ets_post(uint8 prio, os_signal_t sig, os_param_t param) {
110110

111111
int ets_loop_iter_disable = 0;
112112

113+
// to implement a 64-bit wide microsecond counter
114+
static uint32_t system_time_prev = 0;
115+
uint32_t system_time_high_word = 0;
116+
113117
bool ets_loop_iter(void) {
114118
if (ets_loop_iter_disable) {
115119
return false;
116120
}
121+
122+
// handle overflow of system microsecond counter
123+
uint32_t system_time_cur = system_get_time();
124+
if (system_time_cur < system_time_prev) {
125+
system_time_high_word += 1; // record overflow of low 32-bits
126+
}
127+
system_time_prev = system_time_cur;
128+
117129
//static unsigned cnt;
118130
bool progress = false;
119131
for (volatile struct task_entry *t = emu_tasks; t < &emu_tasks[MP_ARRAY_SIZE(emu_tasks)]; t++) {

esp8266/ets_alt_task.h

+2
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,4 @@
11
extern int ets_loop_iter_disable;
2+
extern uint32_t system_time_high_word;
3+
24
bool ets_loop_iter(void);

esp8266/modesp.c

-1
Original file line numberDiff line numberDiff line change
@@ -748,6 +748,5 @@ STATIC MP_DEFINE_CONST_DICT(esp_module_globals, esp_module_globals_table);
748748

749749
const mp_obj_module_t esp_module = {
750750
.base = { &mp_type_module },
751-
.name = MP_QSTR_esp,
752751
.globals = (mp_obj_dict_t*)&esp_module_globals,
753752
};

esp8266/modmachine.c

-1
Original file line numberDiff line numberDiff line change
@@ -271,7 +271,6 @@ STATIC MP_DEFINE_CONST_DICT(machine_module_globals, machine_module_globals_table
271271

272272
const mp_obj_module_t mp_module_machine = {
273273
.base = { &mp_type_module },
274-
.name = MP_QSTR_umachine,
275274
.globals = (mp_obj_dict_t*)&machine_module_globals,
276275
};
277276

esp8266/modnetwork.c

-1
Original file line numberDiff line numberDiff line change
@@ -484,6 +484,5 @@ STATIC MP_DEFINE_CONST_DICT(mp_module_network_globals, mp_module_network_globals
484484

485485
const mp_obj_module_t network_module = {
486486
.base = { &mp_type_module },
487-
.name = MP_QSTR_network,
488487
.globals = (mp_obj_dict_t*)&mp_module_network_globals,
489488
};

esp8266/modonewire.c

-1
Original file line numberDiff line numberDiff line change
@@ -117,6 +117,5 @@ STATIC MP_DEFINE_CONST_DICT(onewire_module_globals, onewire_module_globals_table
117117

118118
const mp_obj_module_t onewire_module = {
119119
.base = { &mp_type_module },
120-
.name = MP_QSTR_onewire,
121120
.globals = (mp_obj_dict_t*)&onewire_module_globals,
122121
};

esp8266/moduos.c

-1
Original file line numberDiff line numberDiff line change
@@ -178,6 +178,5 @@ STATIC MP_DEFINE_CONST_DICT(os_module_globals, os_module_globals_table);
178178

179179
const mp_obj_module_t uos_module = {
180180
.base = { &mp_type_module },
181-
.name = MP_QSTR_uos,
182181
.globals = (mp_obj_dict_t*)&os_module_globals,
183182
};

esp8266/modutime.c

-1
Original file line numberDiff line numberDiff line change
@@ -173,6 +173,5 @@ STATIC MP_DEFINE_CONST_DICT(time_module_globals, time_module_globals_table);
173173

174174
const mp_obj_module_t utime_module = {
175175
.base = { &mp_type_module },
176-
.name = MP_QSTR_utime,
177176
.globals = (mp_obj_dict_t*)&time_module_globals,
178177
};

extmod/machine_i2c.c

+8-6
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,9 @@
3434

3535
#if MICROPY_PY_MACHINE_I2C
3636

37+
// Clock stretching limit, so that we don't get stuck.
38+
#define I2C_STRETCH_LIMIT 255
39+
3740
typedef struct _machine_i2c_obj_t {
3841
mp_obj_base_t base;
3942
uint32_t us_delay;
@@ -53,6 +56,11 @@ STATIC void mp_hal_i2c_scl_low(machine_i2c_obj_t *self) {
5356

5457
STATIC void mp_hal_i2c_scl_release(machine_i2c_obj_t *self) {
5558
mp_hal_pin_od_high(self->scl);
59+
mp_hal_i2c_delay(self);
60+
// For clock stretching, wait for the SCL pin to be released, with timeout.
61+
for (int count = I2C_STRETCH_LIMIT; mp_hal_pin_read(self->scl) == 0 && count; --count) {
62+
mp_hal_delay_us_fast(1);
63+
}
5664
}
5765

5866
STATIC void mp_hal_i2c_sda_low(machine_i2c_obj_t *self) {
@@ -71,7 +79,6 @@ STATIC void mp_hal_i2c_start(machine_i2c_obj_t *self) {
7179
mp_hal_i2c_sda_release(self);
7280
mp_hal_i2c_delay(self);
7381
mp_hal_i2c_scl_release(self);
74-
mp_hal_i2c_delay(self);
7582
mp_hal_i2c_sda_low(self);
7683
mp_hal_i2c_delay(self);
7784
}
@@ -81,7 +88,6 @@ STATIC void mp_hal_i2c_stop(machine_i2c_obj_t *self) {
8188
mp_hal_i2c_sda_low(self);
8289
mp_hal_i2c_delay(self);
8390
mp_hal_i2c_scl_release(self);
84-
mp_hal_i2c_delay(self);
8591
mp_hal_i2c_sda_release(self);
8692
mp_hal_i2c_delay(self);
8793
}
@@ -108,14 +114,12 @@ STATIC int mp_hal_i2c_write_byte(machine_i2c_obj_t *self, uint8_t val) {
108114
}
109115
mp_hal_i2c_delay(self);
110116
mp_hal_i2c_scl_release(self);
111-
mp_hal_i2c_delay(self);
112117
mp_hal_i2c_scl_low(self);
113118
}
114119

115120
mp_hal_i2c_sda_release(self);
116121
mp_hal_i2c_delay(self);
117122
mp_hal_i2c_scl_release(self);
118-
mp_hal_i2c_delay(self);
119123

120124
int ret = mp_hal_i2c_sda_read(self);
121125
mp_hal_i2c_delay(self);
@@ -150,7 +154,6 @@ STATIC int mp_hal_i2c_read_byte(machine_i2c_obj_t *self, uint8_t *val, int nack)
150154
uint8_t data = 0;
151155
for (int i = 7; i >= 0; i--) {
152156
mp_hal_i2c_scl_release(self);
153-
mp_hal_i2c_delay(self);
154157
data = (data << 1) | mp_hal_i2c_sda_read(self);
155158
mp_hal_i2c_scl_low(self);
156159
mp_hal_i2c_delay(self);
@@ -163,7 +166,6 @@ STATIC int mp_hal_i2c_read_byte(machine_i2c_obj_t *self, uint8_t *val, int nack)
163166
}
164167
mp_hal_i2c_delay(self);
165168
mp_hal_i2c_scl_release(self);
166-
mp_hal_i2c_delay(self);
167169
mp_hal_i2c_scl_low(self);
168170
mp_hal_i2c_sda_release(self);
169171

extmod/modbtree.c

-1
Original file line numberDiff line numberDiff line change
@@ -387,7 +387,6 @@ STATIC MP_DEFINE_CONST_DICT(mp_module_btree_globals, mp_module_btree_globals_tab
387387

388388
const mp_obj_module_t mp_module_btree = {
389389
.base = { &mp_type_module },
390-
.name = MP_QSTR_btree,
391390
.globals = (mp_obj_dict_t*)&mp_module_btree_globals,
392391
};
393392

extmod/modframebuf.c

-1
Original file line numberDiff line numberDiff line change
@@ -213,7 +213,6 @@ STATIC MP_DEFINE_CONST_DICT(framebuf_module_globals, framebuf_module_globals_tab
213213

214214
const mp_obj_module_t mp_module_framebuf = {
215215
.base = { &mp_type_module },
216-
.name = MP_QSTR_framebuf,
217216
.globals = (mp_obj_dict_t*)&framebuf_module_globals,
218217
};
219218

extmod/modlwip.c

-1
Original file line numberDiff line numberDiff line change
@@ -1309,7 +1309,6 @@ STATIC MP_DEFINE_CONST_DICT(mp_module_lwip_globals, mp_module_lwip_globals_table
13091309

13101310
const mp_obj_module_t mp_module_lwip = {
13111311
.base = { &mp_type_module },
1312-
.name = MP_QSTR_lwip,
13131312
.globals = (mp_obj_dict_t*)&mp_module_lwip_globals,
13141313
};
13151314

extmod/modubinascii.c

+2-3
Original file line numberDiff line numberDiff line change
@@ -208,9 +208,9 @@ MP_DEFINE_CONST_FUN_OBJ_1(mod_binascii_b2a_base64_obj, mod_binascii_b2a_base64);
208208
mp_obj_t mod_binascii_crc32(size_t n_args, const mp_obj_t *args) {
209209
mp_buffer_info_t bufinfo;
210210
mp_get_buffer_raise(args[0], &bufinfo, MP_BUFFER_READ);
211-
uint32_t crc = (n_args > 1) ? mp_obj_get_int(args[1]) : 0;
211+
uint32_t crc = (n_args > 1) ? mp_obj_get_int_truncated(args[1]) : 0;
212212
crc = uzlib_crc32(bufinfo.buf, bufinfo.len, crc ^ 0xffffffff);
213-
return MP_OBJ_NEW_SMALL_INT(crc ^ 0xffffffff);
213+
return mp_obj_new_int_from_uint(crc ^ 0xffffffff);
214214
}
215215
MP_DEFINE_CONST_FUN_OBJ_VAR_BETWEEN(mod_binascii_crc32_obj, 1, 2, mod_binascii_crc32);
216216
#endif
@@ -232,7 +232,6 @@ STATIC MP_DEFINE_CONST_DICT(mp_module_binascii_globals, mp_module_binascii_globa
232232

233233
const mp_obj_module_t mp_module_ubinascii = {
234234
.base = { &mp_type_module },
235-
.name = MP_QSTR_ubinascii,
236235
.globals = (mp_obj_dict_t*)&mp_module_binascii_globals,
237236
};
238237

extmod/moductypes.c

+1-2
Original file line numberDiff line numberDiff line change
@@ -125,7 +125,7 @@ STATIC mp_obj_t uctypes_struct_make_new(const mp_obj_type_t *type, size_t n_args
125125
mp_arg_check_num(n_args, n_kw, 2, 3, false);
126126
mp_obj_uctypes_struct_t *o = m_new_obj(mp_obj_uctypes_struct_t);
127127
o->base.type = type;
128-
o->addr = (void*)(uintptr_t)mp_obj_get_int(args[0]);
128+
o->addr = (void*)(uintptr_t)mp_obj_int_get_truncated(args[0]);
129129
o->desc = args[1];
130130
o->flags = LAYOUT_NATIVE;
131131
if (n_args == 3) {
@@ -710,7 +710,6 @@ STATIC MP_DEFINE_CONST_DICT(mp_module_uctypes_globals, mp_module_uctypes_globals
710710

711711
const mp_obj_module_t mp_module_uctypes = {
712712
.base = { &mp_type_module },
713-
.name = MP_QSTR_uctypes,
714713
.globals = (mp_obj_dict_t*)&mp_module_uctypes_globals,
715714
};
716715

extmod/moduhashlib.c

-1
Original file line numberDiff line numberDiff line change
@@ -151,7 +151,6 @@ STATIC MP_DEFINE_CONST_DICT(mp_module_hashlib_globals, mp_module_hashlib_globals
151151

152152
const mp_obj_module_t mp_module_uhashlib = {
153153
.base = { &mp_type_module },
154-
.name = MP_QSTR_uhashlib,
155154
.globals = (mp_obj_dict_t*)&mp_module_hashlib_globals,
156155
};
157156

extmod/moduheapq.c

-1
Original file line numberDiff line numberDiff line change
@@ -116,7 +116,6 @@ STATIC MP_DEFINE_CONST_DICT(mp_module_uheapq_globals, mp_module_uheapq_globals_t
116116

117117
const mp_obj_module_t mp_module_uheapq = {
118118
.base = { &mp_type_module },
119-
.name = MP_QSTR_uheapq,
120119
.globals = (mp_obj_dict_t*)&mp_module_uheapq_globals,
121120
};
122121

extmod/modujson.c

-1
Original file line numberDiff line numberDiff line change
@@ -260,7 +260,6 @@ STATIC MP_DEFINE_CONST_DICT(mp_module_ujson_globals, mp_module_ujson_globals_tab
260260

261261
const mp_obj_module_t mp_module_ujson = {
262262
.base = { &mp_type_module },
263-
.name = MP_QSTR_ujson,
264263
.globals = (mp_obj_dict_t*)&mp_module_ujson_globals,
265264
};
266265

extmod/modurandom.c

-1
Original file line numberDiff line numberDiff line change
@@ -215,7 +215,6 @@ STATIC MP_DEFINE_CONST_DICT(mp_module_urandom_globals, mp_module_urandom_globals
215215

216216
const mp_obj_module_t mp_module_urandom = {
217217
.base = { &mp_type_module },
218-
.name = MP_QSTR_urandom,
219218
.globals = (mp_obj_dict_t*)&mp_module_urandom_globals,
220219
};
221220

extmod/modure.c

-1
Original file line numberDiff line numberDiff line change
@@ -237,7 +237,6 @@ STATIC MP_DEFINE_CONST_DICT(mp_module_re_globals, mp_module_re_globals_table);
237237

238238
const mp_obj_module_t mp_module_ure = {
239239
.base = { &mp_type_module },
240-
.name = MP_QSTR_ure,
241240
.globals = (mp_obj_dict_t*)&mp_module_re_globals,
242241
};
243242

extmod/modussl_axtls.c

-1
Original file line numberDiff line numberDiff line change
@@ -196,7 +196,6 @@ STATIC MP_DEFINE_CONST_DICT(mp_module_ssl_globals, mp_module_ssl_globals_table);
196196

197197
const mp_obj_module_t mp_module_ussl = {
198198
.base = { &mp_type_module },
199-
.name = MP_QSTR_ussl,
200199
.globals = (mp_obj_dict_t*)&mp_module_ssl_globals,
201200
};
202201

0 commit comments

Comments
 (0)