Skip to content

Commit b9d0c7a

Browse files
committed
Fix test
1 parent d7232ec commit b9d0c7a

File tree

9 files changed

+53
-28
lines changed

9 files changed

+53
-28
lines changed

CMakeLists.txt

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -10,13 +10,15 @@ add_definitions(
1010
-DMRBC_REQUIRE_32BIT_ALIGNMENT
1111
-DMAX_REGS_SIZE=256
1212
-DMAX_VM_COUNT=255
13-
-DMAX_SYMBOLS_COUNT=1000
13+
-DMAX_SYMBOLS_COUNT=2000
1414
-DMRBC_CONVERT_CRLF
1515
-DMRBC_USE_MATH
1616
-DPICORBC_PTR_SIZE=4
1717
)
18-
if(PRK_NO_MSC)
19-
add_definitions(-DPRK_NO_MSC)
18+
if(PICORUBY_NO_MSC)
19+
add_definitions(-DPICORUBY_NO_MSC)
20+
else()
21+
add_definitions(-DPICORUBY_MSC_FLASH)
2022
endif()
2123

2224
#####################################################
@@ -30,7 +32,7 @@ set (PRK_BUILDDATE ${CMAKE_BUILDDATE})
3032
set (PRK_REVISION ${CMAKE_REVISION})
3133
configure_file ("${CMAKE_SOURCE_DIR}/include/version.h.in" "${CMAKE_SOURCE_DIR}/include/version.h")
3234

33-
if(PRK_NO_MSC)
35+
if(PICORUBY_NO_MSC)
3436
project("prk_firmware-${PRK_VERSION}-${PRK_BUILDDATE}-no_msc")
3537
else()
3638
project("prk_firmware-${PRK_VERSION}-${PRK_BUILDDATE}-${PRK_REVISION}")
@@ -43,6 +45,7 @@ file(GLOB SRCS src/*.c)
4345
add_executable(${PROJECT_NAME}
4446
${SRCS}
4547
${CMAKE_SOURCE_DIR}/lib/picoruby/mrbgems/picoruby-filesystem-fat/ports/rp2040/flash_disk.c
48+
${CMAKE_SOURCE_DIR}/lib/picoruby/mrbgems/picoruby-filesystem-fat/ports/rp2040/msc_disk.c
4649
${CMAKE_SOURCE_DIR}/lib/picoruby/mrbgems/picoruby-gpio/ports/rp2040/gpio.c
4750
${CMAKE_SOURCE_DIR}/lib/picoruby/mrbgems/picoruby-i2c/ports/rp2040/i2c.c
4851
${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)
5962

6063
# Ruby
6164

62-
if(PRK_NO_MSC)
65+
if(PICORUBY_NO_MSC)
6366
add_custom_target(keymap
6467
COMMAND ${RBC} -Bkeymap -o ./keymap.c ../keymap.rb
6568
WORKING_DIRECTORY ${PROJECT_BINARY_DIR}
@@ -96,7 +99,7 @@ add_dependencies(${PROJECT_NAME}
9699
${RUBY_TASK_FILES}
97100
)
98101

99-
if(PRK_NO_MSC)
102+
if(PICORUBY_NO_MSC)
100103
add_dependencies(${PROJECT_NAME}
101104
keymap
102105
)

Gemfile.lock

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,16 +6,16 @@ GEM
66
i18n (>= 1.6, < 2)
77
minitest (>= 5.1)
88
tzinfo (~> 2.0)
9-
concurrent-ruby (1.2.0)
9+
concurrent-ruby (1.2.2)
1010
i18n (1.12.0)
1111
concurrent-ruby (~> 1.0)
12-
minitest (5.17.0)
13-
mrubyc-test (0.9.1)
12+
minitest (5.18.0)
13+
mrubyc-test (0.9.2)
1414
activesupport (~> 7.0)
1515
rufo (~> 0.12)
1616
thor (~> 1.2)
1717
rake (13.0.6)
18-
rufo (0.14.0)
18+
rufo (0.15.1)
1919
thor (1.2.1)
2020
tzinfo (2.0.6)
2121
concurrent-ruby (~> 1.0)

Rakefile

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ end
2626
task :libmruby_no_msc => "lib/picoruby" do
2727
FileUtils.cd "lib/picoruby" do
2828
sh "rake test"
29-
sh "CFLAGS='-DPRK_NO_MSC=1' MRUBY_CONFIG=#{MRUBY_CONFIG} rake"
29+
sh "CFLAGS='-DPICORUBY_NO_MSC=1' MRUBY_CONFIG=#{MRUBY_CONFIG} rake"
3030
end
3131
end
3232

@@ -81,8 +81,8 @@ task :build_with_keymap, ['keyboard_name'] => [:libmruby_no_msc, :test] do |_t,
8181
end
8282
dir = "keyboards/#{args.keyboard_name}"
8383
FileUtils.mkdir_p "#{dir}/build"
84-
#sh "cmake -DPRK_NO_MSC=1 -DCMAKE_BUILD_TYPE=Debug -B #{dir}/build"
85-
sh "#{mruby_config} cmake -DPRK_NO_MSC=1 -B #{dir}/build"
84+
#sh "cmake -DPICORUBY_NO_MSC=1 -DCMAKE_BUILD_TYPE=Debug -B #{dir}/build"
85+
sh "#{mruby_config} cmake -DPICORUBY_NO_MSC=1 -B #{dir}/build"
8686
sh "cmake --build #{dir}/build"
8787
end
8888

@@ -100,7 +100,7 @@ task :test => %i(mrubyc_test)
100100

101101
desc "run unit test for ruby program"
102102
task :mrubyc_test => :setup_test do
103-
sh %q(CFLAGS=-DMAX_SYMBOLS_COUNT=1000 MRUBYCFILE=test/Mrubycfile bundle exec mrubyc-test)
103+
sh %q(MRUBYCFILE=test/Mrubycfile bundle exec mrubyc-test)
104104
end
105105

106106
task :setup_test do

src/keyboard.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -241,7 +241,7 @@ Keyboard_init_sub(mrbc_class *mrbc_class_Keyboard)
241241
mrbc_define_method(0, mrbc_class_Keyboard, "uart_anchor", c_Keyboard_uart_anchor);
242242
mrbc_define_method(0, mrbc_class_Keyboard, "autoreload_ready?", c_autoreload_ready_q);
243243
mrbc_define_method(0, mrbc_class_Keyboard, "autoreload_off", c_autoreload_off);
244-
#ifdef PRK_NO_MSC
244+
#ifdef PICORUBY_NO_MSC
245245
autoreload_state = AUTORELOAD_NONE;
246246
#else
247247
autoreload_state = AUTORELOAD_READY;

src/main.c

Lines changed: 13 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@
2727
/* tasks */
2828
#include "../build/mrb/usb_task.c"
2929

30-
#ifdef PRK_NO_MSC
30+
#ifdef PICORUBY_NO_MSC
3131
#include <keymap.c>
3232
#endif
3333

@@ -41,22 +41,29 @@ int loglevel = LOGLEVEL_WARN;
4141

4242
int autoreload_state; /* from keyboard.h */
4343

44-
#ifndef PRK_NO_MSC
44+
#ifndef PICORUBY_NO_MSC
4545

4646
#ifndef NODE_BOX_SIZE
4747
#define NODE_BOX_SIZE 50
4848
#endif
4949

50-
#endif /* PRK_NO_MSC */
50+
void
51+
tud_msc_write10_complete_cb(uint8_t lun)
52+
{
53+
(void)lun;
54+
autoreload_state = AUTORELOAD_READY;
55+
}
56+
57+
#endif /* PICORUBY_NO_MSC */
5158

5259
static void
5360
prk_init_picoruby(void)
5461
{
5562
/* CONST */
5663
mrbc_sym sym_id = mrbc_str_to_symid("SIZEOF_POINTER");
5764
mrbc_set_const(sym_id, &mrbc_integer_value(PICORBC_PTR_SIZE));
58-
sym_id = mrbc_str_to_symid("PRK_NO_MSC");
59-
#ifdef PRK_NO_MSC
65+
sym_id = mrbc_str_to_symid("PICORUBY_NO_MSC");
66+
#ifdef PICORUBY_NO_MSC
6067
mrbc_set_const(sym_id, &mrbc_true_value());
6168
#else
6269
mrbc_set_const(sym_id, &mrbc_false_value());
@@ -87,7 +94,7 @@ main(void)
8794
tusb_init();
8895
/* Tasks */
8996
mrbc_create_task(usb_task, 0);
90-
#ifdef PRK_NO_MSC
97+
#ifdef PICORUBY_NO_MSC
9198
mrbc_create_task(keymap, 0);
9299
#endif
93100
mrbc_run();

src/usb_descriptors.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ tud_descriptor_device_cb(void)
6060
// Configuration Descriptor
6161
//--------------------------------------------------------------------+
6262

63-
#ifdef PRK_NO_MSC
63+
#ifdef PICORUBY_NO_MSC
6464
#define CONFIG_TOTAL_LEN (TUD_CONFIG_DESC_LEN + TUD_CDC_DESC_LEN + TUD_HID_INOUT_DESC_LEN + TUD_HID_DESC_LEN)
6565
#else
6666
#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
131131
ITF_NUM_CDC_DATA,
132132
ITF_NUM_HID,
133133
ITF_NUM_JOYSTICK,
134-
#ifndef PRK_NO_MSC
134+
#ifndef PICORUBY_NO_MSC
135135
ITF_NUM_MSC,
136136
#endif
137137
ITF_NUM_TOTAL
@@ -145,7 +145,7 @@ uint8_t const desc_fs_configuration[] =
145145
// Interface number, string index, EP notification address and size, EP data address (out, in) and size.
146146
TUD_CDC_DESCRIPTOR(ITF_NUM_CDC, 4, EPNUM_CDC_NOTIF, 8, EPNUM_CDC_OUT, EPNUM_CDC_IN, 64),
147147

148-
#ifndef PRK_NO_MSC
148+
#ifndef PICORUBY_NO_MSC
149149
// Interface number, string index, EP Out & EP In address, EP size
150150
TUD_MSC_DESCRIPTOR(ITF_NUM_MSC, 5, EPNUM_MSC_OUT, EPNUM_MSC_IN, 64),
151151
#endif

test/models/gpio_c.rb

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
class GPIO
2+
IN = 0b000001
3+
OUT = 0b000010
4+
HIGH_Z = 0b000100
5+
PULL_UP = 0b001000
6+
PULL_DOWN = 0b010000
7+
OPEN_DRAIN = 0b100000
8+
def self._init(pin)
9+
end
10+
def self.set_dir_at(pin,flag)
11+
end
12+
def self.pull_up_at(pin)
13+
end
14+
def self.open_drain_at(pin)
15+
end
16+
end
17+

test/tests/keyboard_test.rb

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,7 @@
11
class KeyboardTest < MrubycTestCase
22
# TODO: improve mock functionality of mrubyc-test
33
def define_mocks
4-
kbd = Keyboard.new
5-
mock(kbd).gpio_init(1)
6-
mock(kbd).gpio_set_dir(2)
4+
# mock(GPIO)._init(1)
75
end
86
def setup
97
@kbd = Keyboard.new

0 commit comments

Comments
 (0)