File tree Expand file tree Collapse file tree 4 files changed +34
-20
lines changed
Expand file tree Collapse file tree 4 files changed +34
-20
lines changed Original file line number Diff line number Diff line change 11require "machine"
2+ require "numeric-ext"
23require "watchdog"
34Watchdog . disable
45require "shell"
Original file line number Diff line number Diff line change 1313
1414#if !defined(HEAP_SIZE )
1515 #if defined(PICO_RP2040 )
16- #if defined(USE_WIFI )
17- #define HEAP_SIZE (1024 * 140)
18- #else
19- #define HEAP_SIZE (1024 * 174)
20- #endif
16+ #define RAM_SIZE_KB 264
2117 #elif defined(PICO_RP2350 )
22- #if defined(USE_WIFI )
23- #define HEAP_SIZE (1024 * (150 + 200))
24- #else
25- #define HEAP_SIZE (1024 * (194 + 200))
26- #endif
18+ #define RAM_SIZE_KB 524
2719 #else
28- #error "Unknown board "
20+ #error "PICO_RP2040 or PICO_RP2350 must be defined "
2921 #endif
22+ // Compiling a big Ruby code may need more stack size
23+ #define BASIC_STACK_SIZE_KB 80
24+ #define WIFI_STACK_SIZE_KB 60
25+ #if defined(USE_WIFI )
26+ #define STACK_SIZE_KB (BASIC_STACK_SIZE_KB + WIFI_STACK_SIZE_KB)
27+ #else
28+ #define STACK_SIZE_KB BASIC_STACK_SIZE_KB
29+ #endif
30+ #define HEAP_SIZE_KB (RAM_SIZE_KB - STACK_SIZE_KB)
31+ #define HEAP_SIZE (HEAP_SIZE_KB * 1024)
3032#endif
3133
3234#if defined(R2P2_ALLOC_LIBC )
33- #define heap_pool NULL
35+ #define heap_pool NULL
3436#else
35- static uint8_t heap_pool [HEAP_SIZE ] __attribute__((aligned (8 )));
37+ static uint8_t heap_pool [HEAP_SIZE ] __attribute__((aligned (8 )));
3638#endif
3739
38- mrb_state * global_mrb = NULL ;
40+ #if defined(PICORB_VM_MRUBY )
41+ mrb_state * global_mrb = NULL ;
42+ #endif
3943
4044int
4145main (void )
4246{
4347 stdio_init_all ();
4448 printf ("R2P2 PicoRuby starting...\n" );
45- printf ("HEAP_SIZE : %d bytes \n" , HEAP_SIZE );
49+ printf ("Heap size : %d KB \n" , HEAP_SIZE_KB );
4650 board_init ();
4751
4852 int ret = 0 ;
Original file line number Diff line number Diff line change 11#include <pico/stdlib.h>
2+ #include <stdio.h>
23
34//--------------------------------------------------------------------+
45// Device callbacks
56//--------------------------------------------------------------------+
67
78// Invoked when device is mounted
8- void tud_mount_cb (void )
9+ void
10+ tud_mount_cb (void )
911{
12+ printf ("USB mounted!\n" );
1013}
1114
1215// Invoked when device is unmounted
13- void tud_umount_cb (void )
16+ void
17+ tud_umount_cb (void )
1418{
19+ printf ("USB unmounted!\n" );
1520}
1621
1722// Invoked when usb bus is suspended
1823// remote_wakeup_en : if host allow us to perform remote wakeup
1924// Within 7ms, device must draw an average of current less than 2.5 mA from bus
20- void tud_suspend_cb (bool remote_wakeup_en )
25+ void
26+ tud_suspend_cb (bool remote_wakeup_en )
2127{
2228 (void ) remote_wakeup_en ;
29+ printf ("USB suspended!\n" );
2330}
2431
2532// Invoked when usb bus is resumed
26- void tud_resume_cb (void )
33+ void
34+ tud_resume_cb (void )
2735{
36+ printf ("USB resumed!\n" );
2837}
2938
You can’t perform that action at this time.
0 commit comments