diff --git a/CMakeLists.txt b/CMakeLists.txt index 15c52172..5feaf157 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -10,13 +10,15 @@ add_definitions( -DMRBC_REQUIRE_32BIT_ALIGNMENT -DMAX_REGS_SIZE=256 -DMAX_VM_COUNT=255 - -DMAX_SYMBOLS_COUNT=1000 + -DMAX_SYMBOLS_COUNT=2000 -DMRBC_CONVERT_CRLF -DMRBC_USE_MATH -DPICORBC_PTR_SIZE=4 ) -if(PRK_NO_MSC) - add_definitions(-DPRK_NO_MSC) +if(PICORUBY_NO_MSC) + add_definitions(-DPICORUBY_NO_MSC) +else() + add_definitions(-DPICORUBY_MSC_FLASH) endif() ##################################################### @@ -30,7 +32,7 @@ set (PRK_BUILDDATE ${CMAKE_BUILDDATE}) set (PRK_REVISION ${CMAKE_REVISION}) configure_file ("${CMAKE_SOURCE_DIR}/include/version.h.in" "${CMAKE_SOURCE_DIR}/include/version.h") -if(PRK_NO_MSC) +if(PICORUBY_NO_MSC) project("prk_firmware-${PRK_VERSION}-${PRK_BUILDDATE}-no_msc") else() project("prk_firmware-${PRK_VERSION}-${PRK_BUILDDATE}-${PRK_REVISION}") @@ -43,6 +45,7 @@ file(GLOB SRCS src/*.c) add_executable(${PROJECT_NAME} ${SRCS} ${CMAKE_SOURCE_DIR}/lib/picoruby/mrbgems/picoruby-filesystem-fat/ports/rp2040/flash_disk.c + ${CMAKE_SOURCE_DIR}/lib/picoruby/mrbgems/picoruby-filesystem-fat/ports/rp2040/msc_disk.c ${CMAKE_SOURCE_DIR}/lib/picoruby/mrbgems/picoruby-gpio/ports/rp2040/gpio.c ${CMAKE_SOURCE_DIR}/lib/picoruby/mrbgems/picoruby-i2c/ports/rp2040/i2c.c ${CMAKE_SOURCE_DIR}/lib/picoruby/mrbgems/picoruby-spi/ports/rp2040/spi.c @@ -59,7 +62,7 @@ set(RBC ${CMAKE_CURRENT_SOURCE_DIR}/lib/picoruby/bin/picorbc) # Ruby -if(PRK_NO_MSC) +if(PICORUBY_NO_MSC) add_custom_target(keymap COMMAND ${RBC} -Bkeymap -o ./keymap.c ../keymap.rb WORKING_DIRECTORY ${PROJECT_BINARY_DIR} @@ -96,7 +99,7 @@ add_dependencies(${PROJECT_NAME} ${RUBY_TASK_FILES} ) -if(PRK_NO_MSC) +if(PICORUBY_NO_MSC) add_dependencies(${PROJECT_NAME} keymap ) diff --git a/Gemfile.lock b/Gemfile.lock index ae4ada81..1bf1e358 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -6,16 +6,16 @@ GEM i18n (>= 1.6, < 2) minitest (>= 5.1) tzinfo (~> 2.0) - concurrent-ruby (1.2.0) + concurrent-ruby (1.2.2) i18n (1.12.0) concurrent-ruby (~> 1.0) - minitest (5.17.0) - mrubyc-test (0.9.1) + minitest (5.18.0) + mrubyc-test (0.9.2) activesupport (~> 7.0) rufo (~> 0.12) thor (~> 1.2) rake (13.0.6) - rufo (0.14.0) + rufo (0.15.1) thor (1.2.1) tzinfo (2.0.6) concurrent-ruby (~> 1.0) diff --git a/Rakefile b/Rakefile index 078529fa..e04a095b 100644 --- a/Rakefile +++ b/Rakefile @@ -26,7 +26,7 @@ end task :libmruby_no_msc => "lib/picoruby" do FileUtils.cd "lib/picoruby" do sh "rake test" - sh "CFLAGS='-DPRK_NO_MSC=1' MRUBY_CONFIG=#{MRUBY_CONFIG} rake" + sh "CFLAGS='-DPICORUBY_NO_MSC=1' MRUBY_CONFIG=#{MRUBY_CONFIG} rake" end end @@ -81,8 +81,8 @@ task :build_with_keymap, ['keyboard_name'] => [:libmruby_no_msc, :test] do |_t, end dir = "keyboards/#{args.keyboard_name}" FileUtils.mkdir_p "#{dir}/build" - #sh "cmake -DPRK_NO_MSC=1 -DCMAKE_BUILD_TYPE=Debug -B #{dir}/build" - sh "#{mruby_config} cmake -DPRK_NO_MSC=1 -B #{dir}/build" + #sh "cmake -DPICORUBY_NO_MSC=1 -DCMAKE_BUILD_TYPE=Debug -B #{dir}/build" + sh "#{mruby_config} cmake -DPICORUBY_NO_MSC=1 -B #{dir}/build" sh "cmake --build #{dir}/build" end @@ -100,7 +100,7 @@ task :test => %i(mrubyc_test) desc "run unit test for ruby program" task :mrubyc_test => :setup_test do - sh %q(CFLAGS=-DMAX_SYMBOLS_COUNT=1000 MRUBYCFILE=test/Mrubycfile bundle exec mrubyc-test) + sh %q(MRUBYCFILE=test/Mrubycfile bundle exec mrubyc-test) end task :setup_test do diff --git a/lib/picoruby b/lib/picoruby index 9c06b76d..cc253a6e 160000 --- a/lib/picoruby +++ b/lib/picoruby @@ -1 +1 @@ -Subproject commit 9c06b76dbcc1dd09ef36b58cdfedfb5de57cadad +Subproject commit cc253a6e09199e34fdca7dd54899825fe4203c2a diff --git a/src/keyboard.c b/src/keyboard.c index 5ff198a8..fba7ea52 100644 --- a/src/keyboard.c +++ b/src/keyboard.c @@ -241,7 +241,7 @@ Keyboard_init_sub(mrbc_class *mrbc_class_Keyboard) mrbc_define_method(0, mrbc_class_Keyboard, "uart_anchor", c_Keyboard_uart_anchor); mrbc_define_method(0, mrbc_class_Keyboard, "autoreload_ready?", c_autoreload_ready_q); mrbc_define_method(0, mrbc_class_Keyboard, "autoreload_off", c_autoreload_off); -#ifdef PRK_NO_MSC +#ifdef PICORUBY_NO_MSC autoreload_state = AUTORELOAD_NONE; #else autoreload_state = AUTORELOAD_READY; diff --git a/src/main.c b/src/main.c index e78e51be..04c96ad4 100644 --- a/src/main.c +++ b/src/main.c @@ -27,7 +27,7 @@ /* tasks */ #include "../build/mrb/usb_task.c" -#ifdef PRK_NO_MSC +#ifdef PICORUBY_NO_MSC #include #endif @@ -41,13 +41,20 @@ int loglevel = LOGLEVEL_WARN; int autoreload_state; /* from keyboard.h */ -#ifndef PRK_NO_MSC +#ifndef PICORUBY_NO_MSC #ifndef NODE_BOX_SIZE #define NODE_BOX_SIZE 50 #endif -#endif /* PRK_NO_MSC */ +void +tud_msc_write10_complete_cb(uint8_t lun) +{ + (void)lun; + autoreload_state = AUTORELOAD_READY; +} + +#endif /* PICORUBY_NO_MSC */ static void prk_init_picoruby(void) @@ -55,8 +62,8 @@ prk_init_picoruby(void) /* CONST */ mrbc_sym sym_id = mrbc_str_to_symid("SIZEOF_POINTER"); mrbc_set_const(sym_id, &mrbc_integer_value(PICORBC_PTR_SIZE)); - sym_id = mrbc_str_to_symid("PRK_NO_MSC"); -#ifdef PRK_NO_MSC + sym_id = mrbc_str_to_symid("PICORUBY_NO_MSC"); +#ifdef PICORUBY_NO_MSC mrbc_set_const(sym_id, &mrbc_true_value()); #else mrbc_set_const(sym_id, &mrbc_false_value()); @@ -87,7 +94,7 @@ main(void) tusb_init(); /* Tasks */ mrbc_create_task(usb_task, 0); -#ifdef PRK_NO_MSC +#ifdef PICORUBY_NO_MSC mrbc_create_task(keymap, 0); #endif mrbc_run(); diff --git a/src/usb_descriptors.c b/src/usb_descriptors.c index 248d9d80..3fbf3688 100644 --- a/src/usb_descriptors.c +++ b/src/usb_descriptors.c @@ -60,7 +60,7 @@ tud_descriptor_device_cb(void) // Configuration Descriptor //--------------------------------------------------------------------+ -#ifdef PRK_NO_MSC +#ifdef PICORUBY_NO_MSC #define CONFIG_TOTAL_LEN (TUD_CONFIG_DESC_LEN + TUD_CDC_DESC_LEN + TUD_HID_INOUT_DESC_LEN + TUD_HID_DESC_LEN) #else #define CONFIG_TOTAL_LEN (TUD_CONFIG_DESC_LEN + TUD_CDC_DESC_LEN + TUD_MSC_DESC_LEN + TUD_HID_INOUT_DESC_LEN + TUD_HID_DESC_LEN) @@ -131,7 +131,7 @@ enum ITF_NUM_CDC_DATA, ITF_NUM_HID, ITF_NUM_JOYSTICK, -#ifndef PRK_NO_MSC +#ifndef PICORUBY_NO_MSC ITF_NUM_MSC, #endif ITF_NUM_TOTAL @@ -145,7 +145,7 @@ uint8_t const desc_fs_configuration[] = // Interface number, string index, EP notification address and size, EP data address (out, in) and size. TUD_CDC_DESCRIPTOR(ITF_NUM_CDC, 4, EPNUM_CDC_NOTIF, 8, EPNUM_CDC_OUT, EPNUM_CDC_IN, 64), -#ifndef PRK_NO_MSC +#ifndef PICORUBY_NO_MSC // Interface number, string index, EP Out & EP In address, EP size TUD_MSC_DESCRIPTOR(ITF_NUM_MSC, 5, EPNUM_MSC_OUT, EPNUM_MSC_IN, 64), #endif diff --git a/test/models/gpio_c.rb b/test/models/gpio_c.rb new file mode 100644 index 00000000..f55bee7b --- /dev/null +++ b/test/models/gpio_c.rb @@ -0,0 +1,17 @@ +class GPIO + IN = 0b000001 + OUT = 0b000010 + HIGH_Z = 0b000100 + PULL_UP = 0b001000 + PULL_DOWN = 0b010000 + OPEN_DRAIN = 0b100000 + def self._init(pin) + end + def self.set_dir_at(pin,flag) + end + def self.pull_up_at(pin) + end + def self.open_drain_at(pin) + end +end + diff --git a/test/tests/keyboard_test.rb b/test/tests/keyboard_test.rb index 1fd2fcde..cc6dd87b 100644 --- a/test/tests/keyboard_test.rb +++ b/test/tests/keyboard_test.rb @@ -1,9 +1,7 @@ class KeyboardTest < MrubycTestCase # TODO: improve mock functionality of mrubyc-test def define_mocks - kbd = Keyboard.new - mock(kbd).gpio_init(1) - mock(kbd).gpio_set_dir(2) + # mock(GPIO)._init(1) end def setup @kbd = Keyboard.new