File tree Expand file tree Collapse file tree 2 files changed +21
-0
lines changed Expand file tree Collapse file tree 2 files changed +21
-0
lines changed Original file line number Diff line number Diff line change 31
31
#include "usb_mass_storage.h"
32
32
33
33
#include "shared-module/displayio/__init__.h"
34
+ #include "shared-module/network/__init__.h"
34
35
35
36
volatile uint64_t last_finished_tick = 0 ;
36
37
@@ -41,6 +42,9 @@ void run_background_tasks(void) {
41
42
#ifdef CIRCUITPY_DISPLAYIO
42
43
displayio_refresh_display ();
43
44
#endif
45
+ #ifdef MICROPY_PY_NETWORK
46
+ network_module_background ();
47
+ #endif
44
48
usb_msc_background ();
45
49
usb_cdc_background ();
46
50
last_finished_tick = ticks_ms ;
Original file line number Diff line number Diff line change 24
24
* THE SOFTWARE.
25
25
*/
26
26
27
+ #include <stdio.h>
28
+
27
29
#include "py/objlist.h"
28
30
#include "py/runtime.h"
29
31
#include "py/mphal.h"
30
32
#include "py/mperrno.h"
31
33
32
34
#include "shared-bindings/random/__init__.h"
33
35
36
+ #include "shared-module/network/__init__.h"
37
+
34
38
// mod_network_nic_list needs to be declared in mpconfigport.h
35
39
36
40
@@ -41,6 +45,19 @@ void network_module_init(void) {
41
45
void network_module_deinit (void ) {
42
46
}
43
47
48
+ void network_module_background (void ) {
49
+ static uint32_t next_tick = 0 ;
50
+ uint32_t this_tick = ticks_ms ;
51
+ if (this_tick < next_tick ) return ;
52
+ next_tick = this_tick + 1000 ;
53
+
54
+ for (mp_uint_t i = 0 ; i < MP_STATE_PORT (mod_network_nic_list ).len ; i ++ ) {
55
+ mp_obj_t nic = MP_STATE_PORT (mod_network_nic_list ).items [i ];
56
+ mod_network_nic_type_t * nic_type = (mod_network_nic_type_t * )mp_obj_get_type (nic );
57
+ if (nic_type -> timer_tick != NULL ) nic_type -> timer_tick (nic );
58
+ }
59
+ }
60
+
44
61
void network_module_register_nic (mp_obj_t nic ) {
45
62
for (mp_uint_t i = 0 ; i < MP_STATE_PORT (mod_network_nic_list ).len ; i ++ ) {
46
63
if (MP_STATE_PORT (mod_network_nic_list ).items [i ] == nic ) {
You can’t perform that action at this time.
0 commit comments