Skip to content

Commit a82d49d

Browse files
committed
SPI#read, SPI#transfer are not implemented.
1 parent 0d2b457 commit a82d49d

File tree

3 files changed

+11
-20
lines changed

3 files changed

+11
-20
lines changed

README.md

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ You need [esp-idf v5.0](https://docs.espressif.com/projects/esp-idf/en/release-v
99
Add the line below to your `build_config.rb`:
1010

1111
```ruby
12-
conf.gem :github => 'yuuu/mruby-esp32-spi'
12+
conf.gem :github => 'mruby-esp32-api/mruby-esp32-spi'
1313
```
1414

1515
## Examples
@@ -24,10 +24,11 @@ spi.write(0x30, 0x20, 0x00)
2424
spi.write("\x30\xa2")
2525
spi.write(0x30)
2626

27+
# NOT IMPLEMENTED
2728
data = spi.read( 32 )
2829

30+
# NOT IMPLEMENTED
2931
s = spi.transfer([0x30, 0x20], 1)
30-
3132
```
3233

3334
## LICENSE

mrblib/spi.rb

Lines changed: 6 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -41,30 +41,18 @@ def write(outputs)
4141
end
4242

4343
def read(read_bytes)
44-
self.read_bytes = read_bytes
45-
46-
__read(read_bytes)
44+
raise not_inplemented_error('SPI#read')
4745
end
4846

4947
def transfer(outputs, additional_read_bytes = 0)
50-
self.outputs =
51-
if outputs.is_a?(String)
52-
outputs
53-
elsif outputs.is_a?(Array)
54-
outputs.pack("c*")
55-
elsif outputs.is_a?(Integer)
56-
[outputs].pack("c*")
57-
else
58-
raise data_type_error
59-
end
60-
61-
additional_read_bytes.times { self.outputs += "\0" }
62-
63-
__write(self.outputs)
64-
__read(self.outputs.size)
48+
raise not_inplemented_error('SPI#transfer')
6549
end
6650

6751
def data_type_error
6852
TypeError.new("wrong argument type (expected Integer or String or Array<String>)")
6953
end
54+
55+
def not_inplemented_error(name)
56+
NotImplementedError.new("'#{name}' is not implemented")
57+
end
7058
end

src/mruby_esp32_spi.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -114,6 +114,7 @@ mrb_spi_setmode(mrb_state *mrb, mrb_value self) {
114114
);
115115

116116
#ifdef ESP_PLATFORM
117+
/* TODO */
117118
#endif
118119

119120
return self;
@@ -128,6 +129,7 @@ mrb_spi_read(mrb_state *mrb, mrb_value self) {
128129
ESP_LOGI(TAG, "read(%d)", read_bytes);
129130

130131
#ifdef ESP_PLATFORM
132+
/* TODO */
131133
#endif
132134

133135
return self;

0 commit comments

Comments
 (0)