raudi 0.0.1 → 0.0.2
Sign up to get free protection for your applications and to get access to all the features.
- data/.DS_Store +0 -0
- data/.rvmrc +1 -1
- data/bin/raudi +17 -0
- data/configuration/atmega_328.yml +69 -0
- data/configuration/avr.yml +61 -0
- data/lib/.DS_Store +0 -0
- data/lib/raudi.rb +58 -9
- data/lib/raudi/.DS_Store +0 -0
- data/lib/raudi/action_processor.rb +34 -26
- data/lib/raudi/avr.rb +4 -0
- data/lib/raudi/avr/.DS_Store +0 -0
- data/lib/raudi/avr/controller.rb +73 -0
- data/lib/raudi/avr/pin.rb +30 -0
- data/lib/raudi/avr/pin_states.rb +73 -0
- data/lib/raudi/avr/port.rb +36 -0
- data/lib/raudi/avr/timer.rb +49 -0
- data/lib/raudi/core_ext.rb +1 -0
- data/lib/raudi/core_ext/fixnum.rb +16 -0
- data/lib/raudi/info.rb +52 -0
- data/lib/raudi/processing.rb +63 -0
- data/lib/raudi/processing/gpio.rb +25 -0
- data/lib/raudi/processing/int.rb +36 -0
- data/lib/raudi/processing/pcint.rb +35 -0
- data/lib/raudi/processing/timer.rb +56 -0
- data/lib/raudi/proxy/.DS_Store +0 -0
- data/lib/raudi/proxy/controller.rb +65 -0
- data/lib/raudi/proxy/external_interrupt.rb +30 -0
- data/lib/raudi/proxy/gpio.rb +19 -0
- data/lib/raudi/proxy/headers.rb +31 -0
- data/lib/raudi/proxy/timer.rb +61 -0
- data/lib/raudi/source.rb +48 -0
- data/lib/raudi/source/action.rb +16 -0
- data/lib/raudi/source/bit_operations.rb +35 -0
- data/lib/raudi/source/block.rb +44 -0
- data/lib/raudi/source/controller.rb +56 -0
- data/lib/raudi/source/function.rb +50 -0
- data/lib/raudi/source/interrupt.rb +35 -0
- data/lib/raudi/source/variable.rb +31 -0
- data/lib/raudi/state_list.rb +17 -0
- data/raudi.gemspec +3 -0
- data/spec/.DS_Store +0 -0
- data/spec/examples/sample.raudi +5 -0
- data/spec/lib/.DS_Store +0 -0
- data/spec/lib/raudi/.DS_Store +0 -0
- data/spec/lib/raudi/action_processor_spec.rb +35 -0
- data/spec/lib/raudi/avr/controller_spec.rb +13 -0
- data/spec/lib/raudi/avr/pin_spec.rb +70 -0
- data/spec/lib/raudi/avr/timer_spec.rb +22 -0
- data/spec/lib/raudi/info_spec.rb +9 -0
- data/spec/lib/raudi/proxy/external_interrupt_spec.rb +22 -0
- data/spec/lib/raudi/proxy/gpio_spec.rb +18 -0
- data/spec/lib/raudi/proxy/headers_spec.rb +34 -0
- data/spec/lib/raudi/proxy/timer_spec.rb +67 -0
- data/spec/lib/raudi/source/external_interrupt_spec.rb +55 -0
- data/spec/lib/raudi/source/gpio_spec.rb +18 -0
- data/spec/lib/raudi/source/main_structure_spec.rb +19 -0
- data/spec/lib/raudi/source/timer_spec.rb +44 -0
- data/spec/lib/raudi_spec.rb +41 -0
- data/spec/spec_helper.rb +10 -0
- data/spec/support/raudi_spec_helper.rb +27 -0
- metadata +106 -19
- data/examples/actions.raudi +0 -1
- data/examples/config.rb +0 -3
- data/examples/result.c +0 -10
- data/lib/raudi/avr_controller.rb +0 -23
- data/spec/raudi_spec.rb +0 -9
@@ -0,0 +1,44 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe 'Generate timer/counter code' do
|
4
|
+
|
5
|
+
context 'basic setup timer' do
|
6
|
+
|
7
|
+
it 'allow timer 0' do
|
8
|
+
config.activate_timer 0
|
9
|
+
source.should include('TCCR0B |= 1 << CS00;')
|
10
|
+
end
|
11
|
+
|
12
|
+
it 'timer 1 prescale to 64' do
|
13
|
+
config.activate_timer 1, :prescale => 64
|
14
|
+
source.should include('TCCR1B |= 1 << CS10 | 1 << CS11;')
|
15
|
+
end
|
16
|
+
|
17
|
+
end
|
18
|
+
|
19
|
+
context 'with interrupts' do
|
20
|
+
|
21
|
+
it 'basic example' do
|
22
|
+
config.activate_timer 0, :interrupt => true
|
23
|
+
source.should include('ISR(TIMER0_OVF_vect)')
|
24
|
+
source.should include('TIMSK0 |= 1 << TOIE0;')
|
25
|
+
end
|
26
|
+
|
27
|
+
it 'ctc interrupt' do
|
28
|
+
config.activate_timer 1, :a => 12745, :interrupt => true
|
29
|
+
source.should include('ISR(TIMER1_COMPA_vect)')
|
30
|
+
source.should include('TCCR1B |= 1 << CS10 | 1 << WGM12;')
|
31
|
+
end
|
32
|
+
|
33
|
+
end
|
34
|
+
|
35
|
+
context 'basic setup counter' do
|
36
|
+
|
37
|
+
it 'allow counter 0' do
|
38
|
+
config.activate_counter 0
|
39
|
+
source.should include('TCCR0B |= 1 << CS01 | 1 << CS02;')
|
40
|
+
end
|
41
|
+
|
42
|
+
end
|
43
|
+
|
44
|
+
end
|
@@ -0,0 +1,41 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe Raudi do
|
4
|
+
|
5
|
+
it 'provides configuration methods without object' do
|
6
|
+
Raudi.configure :atmega_328 do
|
7
|
+
output :b3, :c3
|
8
|
+
pullup :c2, :d6
|
9
|
+
pc_interrupt :d1, :d2
|
10
|
+
end
|
11
|
+
|
12
|
+
controller = Raudi.controller
|
13
|
+
controller.model_name.should == :atmega_328
|
14
|
+
|
15
|
+
get_pin(:b, 3, controller).should be_output
|
16
|
+
get_pin(:d, 6, controller).should be_pullup
|
17
|
+
get_pin(:d, 2, controller).should be_pcint
|
18
|
+
end
|
19
|
+
|
20
|
+
context 'output in file' do
|
21
|
+
|
22
|
+
it 'use default case' do
|
23
|
+
Raudi.process('spec/examples/sample.raudi').should be_true
|
24
|
+
@expected_file = 'spec/examples/sample.c'
|
25
|
+
end
|
26
|
+
|
27
|
+
%w{--output -o}.each do |variant|
|
28
|
+
it "specify custom output file with argument #{variant}" do
|
29
|
+
@expected_file = 'foo.c'
|
30
|
+
Raudi.process('spec/examples/sample.raudi', variant, @expected_file).should be_true
|
31
|
+
end
|
32
|
+
end
|
33
|
+
|
34
|
+
after :each do
|
35
|
+
File.exists?(@expected_file).should be_true
|
36
|
+
File.delete @expected_file
|
37
|
+
end
|
38
|
+
|
39
|
+
end
|
40
|
+
|
41
|
+
end
|
data/spec/spec_helper.rb
ADDED
@@ -0,0 +1,10 @@
|
|
1
|
+
require 'ruby-debug'
|
2
|
+
require 'support/raudi_spec_helper'
|
3
|
+
|
4
|
+
RSpec.configure do |config|
|
5
|
+
config.include RaudiSpecHelper
|
6
|
+
|
7
|
+
config.treat_symbols_as_metadata_keys_with_true_values = true
|
8
|
+
config.filter_run :focus => true
|
9
|
+
config.run_all_when_everything_filtered = true
|
10
|
+
end
|
@@ -0,0 +1,27 @@
|
|
1
|
+
module RaudiSpecHelper
|
2
|
+
|
3
|
+
def self.included(klass)
|
4
|
+
klass.let(:controller) { Raudi::AVR::Controller.new(:atmega_328) }
|
5
|
+
klass.let(:config){ Raudi::Proxy::Controller.new(controller) }
|
6
|
+
klass.let(:source){ controller.to_c }
|
7
|
+
end
|
8
|
+
|
9
|
+
def klass
|
10
|
+
described_class
|
11
|
+
end
|
12
|
+
|
13
|
+
def get_pin(port, pin, custom_controller = nil)
|
14
|
+
kontroller = custom_controller ? custom_controller : controller
|
15
|
+
kontroller.ports(port).pins(pin)
|
16
|
+
end
|
17
|
+
|
18
|
+
end
|
19
|
+
|
20
|
+
Raudi.action[:main] = <<AVR
|
21
|
+
_delay_ms(delay_time);
|
22
|
+
toggle_pin(PIN3);
|
23
|
+
AVR
|
24
|
+
|
25
|
+
Raudi.action[:setup] = <<AVR
|
26
|
+
int delay_time = 500;
|
27
|
+
AVR
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: raudi
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.2
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,11 +9,11 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2012-
|
12
|
+
date: 2012-05-13 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: rspec
|
16
|
-
requirement:
|
16
|
+
requirement: !ruby/object:Gem::Requirement
|
17
17
|
none: false
|
18
18
|
requirements:
|
19
19
|
- - ! '>='
|
@@ -21,10 +21,15 @@ dependencies:
|
|
21
21
|
version: '2.5'
|
22
22
|
type: :development
|
23
23
|
prerelease: false
|
24
|
-
version_requirements:
|
24
|
+
version_requirements: !ruby/object:Gem::Requirement
|
25
|
+
none: false
|
26
|
+
requirements:
|
27
|
+
- - ! '>='
|
28
|
+
- !ruby/object:Gem::Version
|
29
|
+
version: '2.5'
|
25
30
|
- !ruby/object:Gem::Dependency
|
26
31
|
name: guard-rspec
|
27
|
-
requirement:
|
32
|
+
requirement: !ruby/object:Gem::Requirement
|
28
33
|
none: false
|
29
34
|
requirements:
|
30
35
|
- - ! '>='
|
@@ -32,10 +37,15 @@ dependencies:
|
|
32
37
|
version: '0'
|
33
38
|
type: :development
|
34
39
|
prerelease: false
|
35
|
-
version_requirements:
|
40
|
+
version_requirements: !ruby/object:Gem::Requirement
|
41
|
+
none: false
|
42
|
+
requirements:
|
43
|
+
- - ! '>='
|
44
|
+
- !ruby/object:Gem::Version
|
45
|
+
version: '0'
|
36
46
|
- !ruby/object:Gem::Dependency
|
37
47
|
name: fuubar
|
38
|
-
requirement:
|
48
|
+
requirement: !ruby/object:Gem::Requirement
|
39
49
|
none: false
|
40
50
|
requirements:
|
41
51
|
- - ! '>='
|
@@ -43,10 +53,15 @@ dependencies:
|
|
43
53
|
version: '0'
|
44
54
|
type: :development
|
45
55
|
prerelease: false
|
46
|
-
version_requirements:
|
56
|
+
version_requirements: !ruby/object:Gem::Requirement
|
57
|
+
none: false
|
58
|
+
requirements:
|
59
|
+
- - ! '>='
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: '0'
|
47
62
|
- !ruby/object:Gem::Dependency
|
48
63
|
name: ruby_gntp
|
49
|
-
requirement:
|
64
|
+
requirement: !ruby/object:Gem::Requirement
|
50
65
|
none: false
|
51
66
|
requirements:
|
52
67
|
- - ! '>='
|
@@ -54,27 +69,100 @@ dependencies:
|
|
54
69
|
version: '0'
|
55
70
|
type: :development
|
56
71
|
prerelease: false
|
57
|
-
version_requirements:
|
72
|
+
version_requirements: !ruby/object:Gem::Requirement
|
73
|
+
none: false
|
74
|
+
requirements:
|
75
|
+
- - ! '>='
|
76
|
+
- !ruby/object:Gem::Version
|
77
|
+
version: '0'
|
78
|
+
- !ruby/object:Gem::Dependency
|
79
|
+
name: ruby-debug19
|
80
|
+
requirement: !ruby/object:Gem::Requirement
|
81
|
+
none: false
|
82
|
+
requirements:
|
83
|
+
- - ! '>='
|
84
|
+
- !ruby/object:Gem::Version
|
85
|
+
version: '0'
|
86
|
+
type: :development
|
87
|
+
prerelease: false
|
88
|
+
version_requirements: !ruby/object:Gem::Requirement
|
89
|
+
none: false
|
90
|
+
requirements:
|
91
|
+
- - ! '>='
|
92
|
+
- !ruby/object:Gem::Version
|
93
|
+
version: '0'
|
58
94
|
description: Raudi is adapter for programming avr controller without pain
|
59
95
|
email:
|
60
96
|
- jalkoby91@gmail.com
|
61
|
-
executables:
|
97
|
+
executables:
|
98
|
+
- raudi
|
62
99
|
extensions: []
|
63
100
|
extra_rdoc_files: []
|
64
101
|
files:
|
102
|
+
- .DS_Store
|
65
103
|
- .gitignore
|
66
104
|
- .rvmrc
|
67
105
|
- Gemfile
|
68
106
|
- Guardfile
|
69
107
|
- Rakefile
|
70
|
-
-
|
71
|
-
-
|
72
|
-
-
|
108
|
+
- bin/raudi
|
109
|
+
- configuration/atmega_328.yml
|
110
|
+
- configuration/avr.yml
|
111
|
+
- lib/.DS_Store
|
73
112
|
- lib/raudi.rb
|
113
|
+
- lib/raudi/.DS_Store
|
74
114
|
- lib/raudi/action_processor.rb
|
75
|
-
- lib/raudi/
|
115
|
+
- lib/raudi/avr.rb
|
116
|
+
- lib/raudi/avr/.DS_Store
|
117
|
+
- lib/raudi/avr/controller.rb
|
118
|
+
- lib/raudi/avr/pin.rb
|
119
|
+
- lib/raudi/avr/pin_states.rb
|
120
|
+
- lib/raudi/avr/port.rb
|
121
|
+
- lib/raudi/avr/timer.rb
|
122
|
+
- lib/raudi/core_ext.rb
|
123
|
+
- lib/raudi/core_ext/fixnum.rb
|
124
|
+
- lib/raudi/info.rb
|
125
|
+
- lib/raudi/processing.rb
|
126
|
+
- lib/raudi/processing/gpio.rb
|
127
|
+
- lib/raudi/processing/int.rb
|
128
|
+
- lib/raudi/processing/pcint.rb
|
129
|
+
- lib/raudi/processing/timer.rb
|
130
|
+
- lib/raudi/proxy/.DS_Store
|
131
|
+
- lib/raudi/proxy/controller.rb
|
132
|
+
- lib/raudi/proxy/external_interrupt.rb
|
133
|
+
- lib/raudi/proxy/gpio.rb
|
134
|
+
- lib/raudi/proxy/headers.rb
|
135
|
+
- lib/raudi/proxy/timer.rb
|
136
|
+
- lib/raudi/source.rb
|
137
|
+
- lib/raudi/source/action.rb
|
138
|
+
- lib/raudi/source/bit_operations.rb
|
139
|
+
- lib/raudi/source/block.rb
|
140
|
+
- lib/raudi/source/controller.rb
|
141
|
+
- lib/raudi/source/function.rb
|
142
|
+
- lib/raudi/source/interrupt.rb
|
143
|
+
- lib/raudi/source/variable.rb
|
144
|
+
- lib/raudi/state_list.rb
|
76
145
|
- raudi.gemspec
|
77
|
-
- spec
|
146
|
+
- spec/.DS_Store
|
147
|
+
- spec/examples/sample.raudi
|
148
|
+
- spec/lib/.DS_Store
|
149
|
+
- spec/lib/raudi/.DS_Store
|
150
|
+
- spec/lib/raudi/action_processor_spec.rb
|
151
|
+
- spec/lib/raudi/avr/controller_spec.rb
|
152
|
+
- spec/lib/raudi/avr/pin_spec.rb
|
153
|
+
- spec/lib/raudi/avr/timer_spec.rb
|
154
|
+
- spec/lib/raudi/info_spec.rb
|
155
|
+
- spec/lib/raudi/proxy/external_interrupt_spec.rb
|
156
|
+
- spec/lib/raudi/proxy/gpio_spec.rb
|
157
|
+
- spec/lib/raudi/proxy/headers_spec.rb
|
158
|
+
- spec/lib/raudi/proxy/timer_spec.rb
|
159
|
+
- spec/lib/raudi/source/external_interrupt_spec.rb
|
160
|
+
- spec/lib/raudi/source/gpio_spec.rb
|
161
|
+
- spec/lib/raudi/source/main_structure_spec.rb
|
162
|
+
- spec/lib/raudi/source/timer_spec.rb
|
163
|
+
- spec/lib/raudi_spec.rb
|
164
|
+
- spec/spec_helper.rb
|
165
|
+
- spec/support/raudi_spec_helper.rb
|
78
166
|
homepage: ''
|
79
167
|
licenses: []
|
80
168
|
post_install_message:
|
@@ -95,9 +183,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
95
183
|
version: '0'
|
96
184
|
requirements: []
|
97
185
|
rubyforge_project: raudi
|
98
|
-
rubygems_version: 1.8.
|
186
|
+
rubygems_version: 1.8.24
|
99
187
|
signing_key:
|
100
188
|
specification_version: 3
|
101
189
|
summary: Raudi is adapter for programming avr controller without pain
|
102
|
-
test_files:
|
103
|
-
- spec/raudi_spec.rb
|
190
|
+
test_files: []
|
data/examples/actions.raudi
DELETED
@@ -1 +0,0 @@
|
|
1
|
-
//
|
data/examples/config.rb
DELETED
data/examples/result.c
DELETED
data/lib/raudi/avr_controller.rb
DELETED
@@ -1,23 +0,0 @@
|
|
1
|
-
class AvrController
|
2
|
-
|
3
|
-
class << self
|
4
|
-
|
5
|
-
def define(model_name)
|
6
|
-
Raudi.controller = new(model_name)
|
7
|
-
yield(Raudi.controller) if block_given?
|
8
|
-
end
|
9
|
-
|
10
|
-
end
|
11
|
-
|
12
|
-
attr_accessor :libs
|
13
|
-
|
14
|
-
def initialize(model_name)
|
15
|
-
@model_name = model_name
|
16
|
-
@libs = ['avr/io']
|
17
|
-
end
|
18
|
-
|
19
|
-
def add_lib(lib_name)
|
20
|
-
@libs << lib_name
|
21
|
-
end
|
22
|
-
|
23
|
-
end
|
data/spec/raudi_spec.rb
DELETED