kopia lustrzana https://github.com/micropython/micropython
Porównaj commity
7 Commity
98d4170fc4
...
ce491ab0d1
Autor | SHA1 | Data |
---|---|---|
Vonasmic | ce491ab0d1 | |
stijn | 40f7e9ce20 | |
Michiel W. Beijen | 3129b69e0f | |
Simon Wood | 19844b4983 | |
J. Neuschäfer | f76cf29402 | |
Angus Gratton | d11ca092f7 | |
iabdalkader | 53d0050255 |
|
@ -88,10 +88,11 @@ jobs:
|
||||||
(cd ports/unix && gcov -o build-coverage/py ../../py/*.c || true)
|
(cd ports/unix && gcov -o build-coverage/py ../../py/*.c || true)
|
||||||
(cd ports/unix && gcov -o build-coverage/extmod ../../extmod/*.c || true)
|
(cd ports/unix && gcov -o build-coverage/extmod ../../extmod/*.c || true)
|
||||||
- name: Upload coverage to Codecov
|
- name: Upload coverage to Codecov
|
||||||
uses: codecov/codecov-action@v3
|
uses: codecov/codecov-action@v4
|
||||||
with:
|
with:
|
||||||
fail_ci_if_error: true
|
fail_ci_if_error: true
|
||||||
verbose: true
|
verbose: true
|
||||||
|
token: ${{ secrets.CODECOV_TOKEN }}
|
||||||
- name: Print failures
|
- name: Print failures
|
||||||
if: failure()
|
if: failure()
|
||||||
run: tests/run-tests.py --print-failures
|
run: tests/run-tests.py --print-failures
|
||||||
|
|
|
@ -130,15 +130,25 @@ Methods
|
||||||
|
|
||||||
Second argument is a memoryview to read the USB control request
|
Second argument is a memoryview to read the USB control request
|
||||||
data for this stage. The memoryview is only valid until the
|
data for this stage. The memoryview is only valid until the
|
||||||
callback function returns.
|
callback function returns. Data in this memoryview will be the same
|
||||||
|
across each of the three stages of a single transfer.
|
||||||
|
|
||||||
|
A successful transfer consists of this callback being called in sequence
|
||||||
|
for the three stages. Generally speaking, if a device wants to do
|
||||||
|
something in response to a control request then it's best to wait until
|
||||||
|
the ACK stage to confirm the host controller completed the transfer as
|
||||||
|
expected.
|
||||||
|
|
||||||
The callback should return one of the following values:
|
The callback should return one of the following values:
|
||||||
|
|
||||||
- ``False`` to stall the endpoint and reject the transfer.
|
- ``False`` to stall the endpoint and reject the transfer. It won't
|
||||||
|
proceed to any remaining stages.
|
||||||
- ``True`` to continue the transfer to the next stage.
|
- ``True`` to continue the transfer to the next stage.
|
||||||
- A buffer object to provide data for this stage of the transfer.
|
- A buffer object can be returned at the SETUP stage when the transfer
|
||||||
This should be a writable buffer for an ``OUT`` direction transfer, or a
|
will send or receive additional data. Typically this is the case when
|
||||||
readable buffer with data for an ``IN`` direction transfer.
|
the ``wLength`` field in the request has a non-zero value. This should
|
||||||
|
be a writable buffer for an ``OUT`` direction transfer, or a readable
|
||||||
|
buffer with data for an ``IN`` direction transfer.
|
||||||
|
|
||||||
- ``xfer_cb`` - This callback is called whenever a non-control
|
- ``xfer_cb`` - This callback is called whenever a non-control
|
||||||
transfer submitted by calling :func:`USBDevice.submit_xfer` completes.
|
transfer submitted by calling :func:`USBDevice.submit_xfer` completes.
|
||||||
|
|
|
@ -1 +1 @@
|
||||||
Subproject commit 277efd50fcc637e2e2e87c9aa50c06acc9080970
|
Subproject commit 89424753e18ed58b7d8041085c9d2e1d162f09ca
|
|
@ -37,7 +37,7 @@ You can also build the standard CMake way. The final firmware is found in
|
||||||
the top-level of the CMake build directory (`build` by default) and is
|
the top-level of the CMake build directory (`build` by default) and is
|
||||||
called `firmware.uf2`.
|
called `firmware.uf2`.
|
||||||
|
|
||||||
If you are using a different board other than a Rasoberry Pi Pico, then you should
|
If you are using a board other than a Raspberry Pi Pico, you should
|
||||||
pass the board name to the build; e.g. for Raspberry Pi Pico W:
|
pass the board name to the build; e.g. for Raspberry Pi Pico W:
|
||||||
|
|
||||||
$ make BOARD=RPI_PICO_W submodules
|
$ make BOARD=RPI_PICO_W submodules
|
||||||
|
|
|
@ -127,10 +127,10 @@ static void mp_machine_lightsleep(size_t n_args, const mp_obj_t *args) {
|
||||||
|
|
||||||
const uint32_t xosc_hz = XOSC_MHZ * 1000000;
|
const uint32_t xosc_hz = XOSC_MHZ * 1000000;
|
||||||
|
|
||||||
uint32_t my_interrupts = save_and_disable_interrupts();
|
uint32_t my_interrupts = mp_thread_begin_atomic_section();
|
||||||
#if MICROPY_PY_NETWORK_CYW43
|
#if MICROPY_PY_NETWORK_CYW43
|
||||||
if (cyw43_has_pending && cyw43_poll != NULL) {
|
if (cyw43_has_pending && cyw43_poll != NULL) {
|
||||||
restore_interrupts(my_interrupts);
|
mp_thread_end_atomic_section(my_interrupts);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
@ -165,8 +165,15 @@ static void mp_machine_lightsleep(size_t n_args, const mp_obj_t *args) {
|
||||||
} else {
|
} else {
|
||||||
uint32_t sleep_en0 = clocks_hw->sleep_en0;
|
uint32_t sleep_en0 = clocks_hw->sleep_en0;
|
||||||
uint32_t sleep_en1 = clocks_hw->sleep_en1;
|
uint32_t sleep_en1 = clocks_hw->sleep_en1;
|
||||||
|
bool timer3_enabled = irq_is_enabled(3);
|
||||||
|
|
||||||
clocks_hw->sleep_en0 = CLOCKS_SLEEP_EN0_CLK_RTC_RTC_BITS;
|
clocks_hw->sleep_en0 = CLOCKS_SLEEP_EN0_CLK_RTC_RTC_BITS;
|
||||||
if (use_timer_alarm) {
|
if (use_timer_alarm) {
|
||||||
|
// Make sure ALARM3/IRQ3 is enabled on _this_ core
|
||||||
|
timer_hw->inte |= 1 << 3;
|
||||||
|
if (!timer3_enabled) {
|
||||||
|
irq_set_enabled(3, true);
|
||||||
|
}
|
||||||
// Use timer alarm to wake.
|
// Use timer alarm to wake.
|
||||||
clocks_hw->sleep_en1 = CLOCKS_SLEEP_EN1_CLK_SYS_TIMER_BITS;
|
clocks_hw->sleep_en1 = CLOCKS_SLEEP_EN1_CLK_SYS_TIMER_BITS;
|
||||||
timer_hw->alarm[3] = timer_hw->timerawl + delay_ms * 1000;
|
timer_hw->alarm[3] = timer_hw->timerawl + delay_ms * 1000;
|
||||||
|
@ -177,6 +184,9 @@ static void mp_machine_lightsleep(size_t n_args, const mp_obj_t *args) {
|
||||||
scb_hw->scr |= M0PLUS_SCR_SLEEPDEEP_BITS;
|
scb_hw->scr |= M0PLUS_SCR_SLEEPDEEP_BITS;
|
||||||
__wfi();
|
__wfi();
|
||||||
scb_hw->scr &= ~M0PLUS_SCR_SLEEPDEEP_BITS;
|
scb_hw->scr &= ~M0PLUS_SCR_SLEEPDEEP_BITS;
|
||||||
|
if (!timer3_enabled) {
|
||||||
|
irq_set_enabled(3, false);
|
||||||
|
}
|
||||||
clocks_hw->sleep_en0 = sleep_en0;
|
clocks_hw->sleep_en0 = sleep_en0;
|
||||||
clocks_hw->sleep_en1 = sleep_en1;
|
clocks_hw->sleep_en1 = sleep_en1;
|
||||||
}
|
}
|
||||||
|
@ -186,7 +196,7 @@ static void mp_machine_lightsleep(size_t n_args, const mp_obj_t *args) {
|
||||||
|
|
||||||
// Bring back all clocks.
|
// Bring back all clocks.
|
||||||
clocks_init();
|
clocks_init();
|
||||||
restore_interrupts(my_interrupts);
|
mp_thread_end_atomic_section(my_interrupts);
|
||||||
}
|
}
|
||||||
|
|
||||||
NORETURN static void mp_machine_deepsleep(size_t n_args, const mp_obj_t *args) {
|
NORETURN static void mp_machine_deepsleep(size_t n_args, const mp_obj_t *args) {
|
||||||
|
|
28
py/obj.h
28
py/obj.h
|
@ -753,20 +753,20 @@ typedef struct _mp_obj_full_type_t {
|
||||||
// Do not use these directly, instead use MP_DEFINE_CONST_OBJ_TYPE.
|
// Do not use these directly, instead use MP_DEFINE_CONST_OBJ_TYPE.
|
||||||
// Generated with:
|
// Generated with:
|
||||||
// for i in range(13):
|
// for i in range(13):
|
||||||
// print(f"#define MP_DEFINE_CONST_OBJ_TYPE_NARGS_{i}(_struct_type, _typename, _name, _flags{''.join(f', f{j+1}, v{j+1}' for j in range(i))}) const _struct_type _typename = {{ .base = {{ &mp_type_type }}, .name = _name, .flags = _flags{''.join(f', .slot_index_##f{j+1} = {j+1}' for j in range(i))}{', .slots = { ' + ''.join(f'v{j+1}, ' for j in range(i)) + '}' if i else '' } }}")
|
// print(f"#define MP_DEFINE_CONST_OBJ_TYPE_NARGS_{i}(_struct_type, _typename, _name, _flags{''.join(f', f{j+1}, v{j+1}' for j in range(i))}) const _struct_type _typename = {{ .base = {{ &mp_type_type }}, .flags = _flags, .name = _name{''.join(f', .slot_index_##f{j+1} = {j+1}' for j in range(i))}{', .slots = { ' + ''.join(f'v{j+1}, ' for j in range(i)) + '}' if i else '' } }}")
|
||||||
#define MP_DEFINE_CONST_OBJ_TYPE_NARGS_0(_struct_type, _typename, _name, _flags) const _struct_type _typename = { .base = { &mp_type_type }, .name = _name, .flags = _flags }
|
#define MP_DEFINE_CONST_OBJ_TYPE_NARGS_0(_struct_type, _typename, _name, _flags) const _struct_type _typename = { .base = { &mp_type_type }, .flags = _flags, .name = _name }
|
||||||
#define MP_DEFINE_CONST_OBJ_TYPE_NARGS_1(_struct_type, _typename, _name, _flags, f1, v1) const _struct_type _typename = { .base = { &mp_type_type }, .name = _name, .flags = _flags, .slot_index_##f1 = 1, .slots = { v1, } }
|
#define MP_DEFINE_CONST_OBJ_TYPE_NARGS_1(_struct_type, _typename, _name, _flags, f1, v1) const _struct_type _typename = { .base = { &mp_type_type }, .flags = _flags, .name = _name, .slot_index_##f1 = 1, .slots = { v1, } }
|
||||||
#define MP_DEFINE_CONST_OBJ_TYPE_NARGS_2(_struct_type, _typename, _name, _flags, f1, v1, f2, v2) const _struct_type _typename = { .base = { &mp_type_type }, .name = _name, .flags = _flags, .slot_index_##f1 = 1, .slot_index_##f2 = 2, .slots = { v1, v2, } }
|
#define MP_DEFINE_CONST_OBJ_TYPE_NARGS_2(_struct_type, _typename, _name, _flags, f1, v1, f2, v2) const _struct_type _typename = { .base = { &mp_type_type }, .flags = _flags, .name = _name, .slot_index_##f1 = 1, .slot_index_##f2 = 2, .slots = { v1, v2, } }
|
||||||
#define MP_DEFINE_CONST_OBJ_TYPE_NARGS_3(_struct_type, _typename, _name, _flags, f1, v1, f2, v2, f3, v3) const _struct_type _typename = { .base = { &mp_type_type }, .name = _name, .flags = _flags, .slot_index_##f1 = 1, .slot_index_##f2 = 2, .slot_index_##f3 = 3, .slots = { v1, v2, v3, } }
|
#define MP_DEFINE_CONST_OBJ_TYPE_NARGS_3(_struct_type, _typename, _name, _flags, f1, v1, f2, v2, f3, v3) const _struct_type _typename = { .base = { &mp_type_type }, .flags = _flags, .name = _name, .slot_index_##f1 = 1, .slot_index_##f2 = 2, .slot_index_##f3 = 3, .slots = { v1, v2, v3, } }
|
||||||
#define MP_DEFINE_CONST_OBJ_TYPE_NARGS_4(_struct_type, _typename, _name, _flags, f1, v1, f2, v2, f3, v3, f4, v4) const _struct_type _typename = { .base = { &mp_type_type }, .name = _name, .flags = _flags, .slot_index_##f1 = 1, .slot_index_##f2 = 2, .slot_index_##f3 = 3, .slot_index_##f4 = 4, .slots = { v1, v2, v3, v4, } }
|
#define MP_DEFINE_CONST_OBJ_TYPE_NARGS_4(_struct_type, _typename, _name, _flags, f1, v1, f2, v2, f3, v3, f4, v4) const _struct_type _typename = { .base = { &mp_type_type }, .flags = _flags, .name = _name, .slot_index_##f1 = 1, .slot_index_##f2 = 2, .slot_index_##f3 = 3, .slot_index_##f4 = 4, .slots = { v1, v2, v3, v4, } }
|
||||||
#define MP_DEFINE_CONST_OBJ_TYPE_NARGS_5(_struct_type, _typename, _name, _flags, f1, v1, f2, v2, f3, v3, f4, v4, f5, v5) const _struct_type _typename = { .base = { &mp_type_type }, .name = _name, .flags = _flags, .slot_index_##f1 = 1, .slot_index_##f2 = 2, .slot_index_##f3 = 3, .slot_index_##f4 = 4, .slot_index_##f5 = 5, .slots = { v1, v2, v3, v4, v5, } }
|
#define MP_DEFINE_CONST_OBJ_TYPE_NARGS_5(_struct_type, _typename, _name, _flags, f1, v1, f2, v2, f3, v3, f4, v4, f5, v5) const _struct_type _typename = { .base = { &mp_type_type }, .flags = _flags, .name = _name, .slot_index_##f1 = 1, .slot_index_##f2 = 2, .slot_index_##f3 = 3, .slot_index_##f4 = 4, .slot_index_##f5 = 5, .slots = { v1, v2, v3, v4, v5, } }
|
||||||
#define MP_DEFINE_CONST_OBJ_TYPE_NARGS_6(_struct_type, _typename, _name, _flags, f1, v1, f2, v2, f3, v3, f4, v4, f5, v5, f6, v6) const _struct_type _typename = { .base = { &mp_type_type }, .name = _name, .flags = _flags, .slot_index_##f1 = 1, .slot_index_##f2 = 2, .slot_index_##f3 = 3, .slot_index_##f4 = 4, .slot_index_##f5 = 5, .slot_index_##f6 = 6, .slots = { v1, v2, v3, v4, v5, v6, } }
|
#define MP_DEFINE_CONST_OBJ_TYPE_NARGS_6(_struct_type, _typename, _name, _flags, f1, v1, f2, v2, f3, v3, f4, v4, f5, v5, f6, v6) const _struct_type _typename = { .base = { &mp_type_type }, .flags = _flags, .name = _name, .slot_index_##f1 = 1, .slot_index_##f2 = 2, .slot_index_##f3 = 3, .slot_index_##f4 = 4, .slot_index_##f5 = 5, .slot_index_##f6 = 6, .slots = { v1, v2, v3, v4, v5, v6, } }
|
||||||
#define MP_DEFINE_CONST_OBJ_TYPE_NARGS_7(_struct_type, _typename, _name, _flags, f1, v1, f2, v2, f3, v3, f4, v4, f5, v5, f6, v6, f7, v7) const _struct_type _typename = { .base = { &mp_type_type }, .name = _name, .flags = _flags, .slot_index_##f1 = 1, .slot_index_##f2 = 2, .slot_index_##f3 = 3, .slot_index_##f4 = 4, .slot_index_##f5 = 5, .slot_index_##f6 = 6, .slot_index_##f7 = 7, .slots = { v1, v2, v3, v4, v5, v6, v7, } }
|
#define MP_DEFINE_CONST_OBJ_TYPE_NARGS_7(_struct_type, _typename, _name, _flags, f1, v1, f2, v2, f3, v3, f4, v4, f5, v5, f6, v6, f7, v7) const _struct_type _typename = { .base = { &mp_type_type }, .flags = _flags, .name = _name, .slot_index_##f1 = 1, .slot_index_##f2 = 2, .slot_index_##f3 = 3, .slot_index_##f4 = 4, .slot_index_##f5 = 5, .slot_index_##f6 = 6, .slot_index_##f7 = 7, .slots = { v1, v2, v3, v4, v5, v6, v7, } }
|
||||||
#define MP_DEFINE_CONST_OBJ_TYPE_NARGS_8(_struct_type, _typename, _name, _flags, f1, v1, f2, v2, f3, v3, f4, v4, f5, v5, f6, v6, f7, v7, f8, v8) const _struct_type _typename = { .base = { &mp_type_type }, .name = _name, .flags = _flags, .slot_index_##f1 = 1, .slot_index_##f2 = 2, .slot_index_##f3 = 3, .slot_index_##f4 = 4, .slot_index_##f5 = 5, .slot_index_##f6 = 6, .slot_index_##f7 = 7, .slot_index_##f8 = 8, .slots = { v1, v2, v3, v4, v5, v6, v7, v8, } }
|
#define MP_DEFINE_CONST_OBJ_TYPE_NARGS_8(_struct_type, _typename, _name, _flags, f1, v1, f2, v2, f3, v3, f4, v4, f5, v5, f6, v6, f7, v7, f8, v8) const _struct_type _typename = { .base = { &mp_type_type }, .flags = _flags, .name = _name, .slot_index_##f1 = 1, .slot_index_##f2 = 2, .slot_index_##f3 = 3, .slot_index_##f4 = 4, .slot_index_##f5 = 5, .slot_index_##f6 = 6, .slot_index_##f7 = 7, .slot_index_##f8 = 8, .slots = { v1, v2, v3, v4, v5, v6, v7, v8, } }
|
||||||
#define MP_DEFINE_CONST_OBJ_TYPE_NARGS_9(_struct_type, _typename, _name, _flags, f1, v1, f2, v2, f3, v3, f4, v4, f5, v5, f6, v6, f7, v7, f8, v8, f9, v9) const _struct_type _typename = { .base = { &mp_type_type }, .name = _name, .flags = _flags, .slot_index_##f1 = 1, .slot_index_##f2 = 2, .slot_index_##f3 = 3, .slot_index_##f4 = 4, .slot_index_##f5 = 5, .slot_index_##f6 = 6, .slot_index_##f7 = 7, .slot_index_##f8 = 8, .slot_index_##f9 = 9, .slots = { v1, v2, v3, v4, v5, v6, v7, v8, v9, } }
|
#define MP_DEFINE_CONST_OBJ_TYPE_NARGS_9(_struct_type, _typename, _name, _flags, f1, v1, f2, v2, f3, v3, f4, v4, f5, v5, f6, v6, f7, v7, f8, v8, f9, v9) const _struct_type _typename = { .base = { &mp_type_type }, .flags = _flags, .name = _name, .slot_index_##f1 = 1, .slot_index_##f2 = 2, .slot_index_##f3 = 3, .slot_index_##f4 = 4, .slot_index_##f5 = 5, .slot_index_##f6 = 6, .slot_index_##f7 = 7, .slot_index_##f8 = 8, .slot_index_##f9 = 9, .slots = { v1, v2, v3, v4, v5, v6, v7, v8, v9, } }
|
||||||
#define MP_DEFINE_CONST_OBJ_TYPE_NARGS_10(_struct_type, _typename, _name, _flags, f1, v1, f2, v2, f3, v3, f4, v4, f5, v5, f6, v6, f7, v7, f8, v8, f9, v9, f10, v10) const _struct_type _typename = { .base = { &mp_type_type }, .name = _name, .flags = _flags, .slot_index_##f1 = 1, .slot_index_##f2 = 2, .slot_index_##f3 = 3, .slot_index_##f4 = 4, .slot_index_##f5 = 5, .slot_index_##f6 = 6, .slot_index_##f7 = 7, .slot_index_##f8 = 8, .slot_index_##f9 = 9, .slot_index_##f10 = 10, .slots = { v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, } }
|
#define MP_DEFINE_CONST_OBJ_TYPE_NARGS_10(_struct_type, _typename, _name, _flags, f1, v1, f2, v2, f3, v3, f4, v4, f5, v5, f6, v6, f7, v7, f8, v8, f9, v9, f10, v10) const _struct_type _typename = { .base = { &mp_type_type }, .flags = _flags, .name = _name, .slot_index_##f1 = 1, .slot_index_##f2 = 2, .slot_index_##f3 = 3, .slot_index_##f4 = 4, .slot_index_##f5 = 5, .slot_index_##f6 = 6, .slot_index_##f7 = 7, .slot_index_##f8 = 8, .slot_index_##f9 = 9, .slot_index_##f10 = 10, .slots = { v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, } }
|
||||||
#define MP_DEFINE_CONST_OBJ_TYPE_NARGS_11(_struct_type, _typename, _name, _flags, f1, v1, f2, v2, f3, v3, f4, v4, f5, v5, f6, v6, f7, v7, f8, v8, f9, v9, f10, v10, f11, v11) const _struct_type _typename = { .base = { &mp_type_type }, .name = _name, .flags = _flags, .slot_index_##f1 = 1, .slot_index_##f2 = 2, .slot_index_##f3 = 3, .slot_index_##f4 = 4, .slot_index_##f5 = 5, .slot_index_##f6 = 6, .slot_index_##f7 = 7, .slot_index_##f8 = 8, .slot_index_##f9 = 9, .slot_index_##f10 = 10, .slot_index_##f11 = 11, .slots = { v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, } }
|
#define MP_DEFINE_CONST_OBJ_TYPE_NARGS_11(_struct_type, _typename, _name, _flags, f1, v1, f2, v2, f3, v3, f4, v4, f5, v5, f6, v6, f7, v7, f8, v8, f9, v9, f10, v10, f11, v11) const _struct_type _typename = { .base = { &mp_type_type }, .flags = _flags, .name = _name, .slot_index_##f1 = 1, .slot_index_##f2 = 2, .slot_index_##f3 = 3, .slot_index_##f4 = 4, .slot_index_##f5 = 5, .slot_index_##f6 = 6, .slot_index_##f7 = 7, .slot_index_##f8 = 8, .slot_index_##f9 = 9, .slot_index_##f10 = 10, .slot_index_##f11 = 11, .slots = { v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, } }
|
||||||
#define MP_DEFINE_CONST_OBJ_TYPE_NARGS_12(_struct_type, _typename, _name, _flags, f1, v1, f2, v2, f3, v3, f4, v4, f5, v5, f6, v6, f7, v7, f8, v8, f9, v9, f10, v10, f11, v11, f12, v12) const _struct_type _typename = { .base = { &mp_type_type }, .name = _name, .flags = _flags, .slot_index_##f1 = 1, .slot_index_##f2 = 2, .slot_index_##f3 = 3, .slot_index_##f4 = 4, .slot_index_##f5 = 5, .slot_index_##f6 = 6, .slot_index_##f7 = 7, .slot_index_##f8 = 8, .slot_index_##f9 = 9, .slot_index_##f10 = 10, .slot_index_##f11 = 11, .slot_index_##f12 = 12, .slots = { v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, } }
|
#define MP_DEFINE_CONST_OBJ_TYPE_NARGS_12(_struct_type, _typename, _name, _flags, f1, v1, f2, v2, f3, v3, f4, v4, f5, v5, f6, v6, f7, v7, f8, v8, f9, v9, f10, v10, f11, v11, f12, v12) const _struct_type _typename = { .base = { &mp_type_type }, .flags = _flags, .name = _name, .slot_index_##f1 = 1, .slot_index_##f2 = 2, .slot_index_##f3 = 3, .slot_index_##f4 = 4, .slot_index_##f5 = 5, .slot_index_##f6 = 6, .slot_index_##f7 = 7, .slot_index_##f8 = 8, .slot_index_##f9 = 9, .slot_index_##f10 = 10, .slot_index_##f11 = 11, .slot_index_##f12 = 12, .slots = { v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, } }
|
||||||
|
|
||||||
// Because the mp_obj_type_t instances are in (zero-initialised) ROM, we take
|
// Because the mp_obj_type_t instances are in (zero-initialised) ROM, we take
|
||||||
// slot_index_foo=0 to mean that the slot is unset. This also simplifies checking
|
// slot_index_foo=0 to mean that the slot is unset. This also simplifies checking
|
||||||
|
|
|
@ -56,14 +56,14 @@ void mp_obj_fun_bc_attr(mp_obj_t self_in, qstr attr, mp_obj_t *dest);
|
||||||
#if MICROPY_EMIT_NATIVE
|
#if MICROPY_EMIT_NATIVE
|
||||||
|
|
||||||
static inline mp_obj_t mp_obj_new_fun_native(const mp_obj_t *def_args, const void *fun_data, const mp_module_context_t *mc, struct _mp_raw_code_t *const *child_table) {
|
static inline mp_obj_t mp_obj_new_fun_native(const mp_obj_t *def_args, const void *fun_data, const mp_module_context_t *mc, struct _mp_raw_code_t *const *child_table) {
|
||||||
mp_obj_fun_bc_t *o = MP_OBJ_TO_PTR(mp_obj_new_fun_bc(def_args, (const byte *)fun_data, mc, child_table));
|
mp_obj_fun_bc_t *o = (mp_obj_fun_bc_t *)MP_OBJ_TO_PTR(mp_obj_new_fun_bc(def_args, (const byte *)fun_data, mc, child_table));
|
||||||
o->base.type = &mp_type_fun_native;
|
o->base.type = &mp_type_fun_native;
|
||||||
return MP_OBJ_FROM_PTR(o);
|
return MP_OBJ_FROM_PTR(o);
|
||||||
}
|
}
|
||||||
|
|
||||||
static inline mp_obj_t mp_obj_new_fun_viper(const void *fun_data, const mp_module_context_t *mc, struct _mp_raw_code_t *const *child_table) {
|
static inline mp_obj_t mp_obj_new_fun_viper(const void *fun_data, const mp_module_context_t *mc, struct _mp_raw_code_t *const *child_table) {
|
||||||
mp_obj_fun_bc_t *o = mp_obj_malloc(mp_obj_fun_bc_t, &mp_type_fun_viper);
|
mp_obj_fun_bc_t *o = mp_obj_malloc(mp_obj_fun_bc_t, &mp_type_fun_viper);
|
||||||
o->bytecode = fun_data;
|
o->bytecode = (const byte *)fun_data;
|
||||||
o->context = mc;
|
o->context = mc;
|
||||||
o->child_table = child_table;
|
o->child_table = child_table;
|
||||||
return MP_OBJ_FROM_PTR(o);
|
return MP_OBJ_FROM_PTR(o);
|
||||||
|
@ -101,9 +101,9 @@ static inline void *mp_obj_fun_native_get_generator_resume(const mp_obj_fun_bc_t
|
||||||
|
|
||||||
#if MICROPY_EMIT_INLINE_ASM
|
#if MICROPY_EMIT_INLINE_ASM
|
||||||
static inline mp_obj_t mp_obj_new_fun_asm(size_t n_args, const void *fun_data, mp_uint_t type_sig) {
|
static inline mp_obj_t mp_obj_new_fun_asm(size_t n_args, const void *fun_data, mp_uint_t type_sig) {
|
||||||
mp_obj_fun_asm_t *o = mp_obj_malloc(mp_obj_fun_asm_t, &mp_type_fun_asm);
|
mp_obj_fun_asm_t *o = (mp_obj_fun_asm_t *)mp_obj_malloc(mp_obj_fun_asm_t, &mp_type_fun_asm);
|
||||||
o->n_args = n_args;
|
o->n_args = n_args;
|
||||||
o->fun_data = fun_data;
|
o->fun_data = (const byte *)fun_data;
|
||||||
o->type_sig = type_sig;
|
o->type_sig = type_sig;
|
||||||
return MP_OBJ_FROM_PTR(o);
|
return MP_OBJ_FROM_PTR(o);
|
||||||
}
|
}
|
||||||
|
|
|
@ -295,6 +295,7 @@ static bool runtime_dev_control_xfer_cb(uint8_t rhport, uint8_t stage, tusb_cont
|
||||||
mp_obj_usb_device_t *usbd = MP_OBJ_TO_PTR(MP_STATE_VM(usbd));
|
mp_obj_usb_device_t *usbd = MP_OBJ_TO_PTR(MP_STATE_VM(usbd));
|
||||||
tusb_dir_t dir = request->bmRequestType_bit.direction;
|
tusb_dir_t dir = request->bmRequestType_bit.direction;
|
||||||
mp_buffer_info_t buf_info;
|
mp_buffer_info_t buf_info;
|
||||||
|
bool result;
|
||||||
|
|
||||||
if (!usbd) {
|
if (!usbd) {
|
||||||
return false;
|
return false;
|
||||||
|
@ -319,7 +320,7 @@ static bool runtime_dev_control_xfer_cb(uint8_t rhport, uint8_t stage, tusb_cont
|
||||||
|
|
||||||
// Check if callback returned any data to submit
|
// Check if callback returned any data to submit
|
||||||
if (mp_get_buffer(cb_res, &buf_info, dir == TUSB_DIR_IN ? MP_BUFFER_READ : MP_BUFFER_RW)) {
|
if (mp_get_buffer(cb_res, &buf_info, dir == TUSB_DIR_IN ? MP_BUFFER_READ : MP_BUFFER_RW)) {
|
||||||
bool result = tud_control_xfer(USBD_RHPORT,
|
result = tud_control_xfer(USBD_RHPORT,
|
||||||
request,
|
request,
|
||||||
buf_info.buf,
|
buf_info.buf,
|
||||||
buf_info.len);
|
buf_info.len);
|
||||||
|
@ -328,17 +329,21 @@ static bool runtime_dev_control_xfer_cb(uint8_t rhport, uint8_t stage, tusb_cont
|
||||||
// Keep buffer object alive until the transfer completes
|
// Keep buffer object alive until the transfer completes
|
||||||
usbd->xfer_data[0][dir] = cb_res;
|
usbd->xfer_data[0][dir] = cb_res;
|
||||||
}
|
}
|
||||||
|
|
||||||
return result;
|
|
||||||
} else {
|
} else {
|
||||||
// Expect True or False to stall or continue
|
// Expect True or False to stall or continue
|
||||||
|
result = mp_obj_is_true(cb_res);
|
||||||
|
|
||||||
if (stage == CONTROL_STAGE_ACK) {
|
if (stage == CONTROL_STAGE_SETUP && result) {
|
||||||
|
// If no additional data but callback says to continue transfer then
|
||||||
|
// queue a status response.
|
||||||
|
tud_control_status(rhport, request);
|
||||||
|
} else if (stage == CONTROL_STAGE_ACK) {
|
||||||
// Allow data to be GCed once it's no longer in use
|
// Allow data to be GCed once it's no longer in use
|
||||||
usbd->xfer_data[0][dir] = mp_const_none;
|
usbd->xfer_data[0][dir] = mp_const_none;
|
||||||
}
|
}
|
||||||
return mp_obj_is_true(cb_res);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
static bool runtime_dev_xfer_cb(uint8_t rhport, uint8_t ep_addr, xfer_result_t result, uint32_t xferred_bytes) {
|
static bool runtime_dev_xfer_cb(uint8_t rhport, uint8_t ep_addr, xfer_result_t result, uint32_t xferred_bytes) {
|
||||||
|
|
Ładowanie…
Reference in New Issue