sfrp 1.4.0 → 1.5.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/base-library/Base/AVR/ATMEGA8/GPIO.c +18 -0
- data/base-library/Base/AVR/ATMEGA8/GPIO.h +7 -0
- data/base-library/Base/AVR/ATMEGA8/GPIO.sfrp +3 -0
- data/base-library/Base/AVR/ATMEGA8/Timer.c +45 -15
- data/base-library/Base/AVR/ATMEGA8/Timer.h +3 -1
- data/base-library/Base/AVR/ATMEGA8/Timer.sfrp +8 -2
- data/base-library/Base.sfrp +1 -1
- data/lib/sfrp/raw/exception.rb +3 -6
- data/lib/sfrp/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: e9a7c8ab88c8c2982d435d3cdf05f98357cfead9
|
4
|
+
data.tar.gz: cc77e8fe3362408cb92f5fb9f4a8fd8c5a40e894
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: e3f05fb04cb256828eb17e25aa499da775d33860e86650057410e9b192f8071c43809a8cd485b6eccb97fd06a313c3c830e2147901c87718d718a367d82887e9
|
7
|
+
data.tar.gz: 8b8506c2f3d635273386f745a973f2f58734a572282046e773b464697154a779b0a69ec13d5683e75395b4804df9fe33b8dc0a87df958641994fec43d68b7acc
|
@@ -40,6 +40,12 @@ int portB(int port_num, int high_or_low) {
|
|
40
40
|
return 0;
|
41
41
|
}
|
42
42
|
|
43
|
+
int portBs(int output) {
|
44
|
+
DDRB = 0b11111111;
|
45
|
+
PORTB = output;
|
46
|
+
return 0;
|
47
|
+
}
|
48
|
+
|
43
49
|
// PC
|
44
50
|
|
45
51
|
int pinC(int num) {
|
@@ -59,6 +65,12 @@ int portC(int port_num, int high_or_low) {
|
|
59
65
|
return 0;
|
60
66
|
}
|
61
67
|
|
68
|
+
int portCs(int output) {
|
69
|
+
DDRC = 0b11111111;
|
70
|
+
PORTC = output;
|
71
|
+
return 0;
|
72
|
+
}
|
73
|
+
|
62
74
|
// PD
|
63
75
|
|
64
76
|
int pinD(int num) {
|
@@ -77,3 +89,9 @@ int portD(int port_num, int high_or_low) {
|
|
77
89
|
PORTD = (~(1 << port_num) & PORTD) | (high_or_low << port_num);
|
78
90
|
return 0;
|
79
91
|
}
|
92
|
+
|
93
|
+
int portDs(int output) {
|
94
|
+
DDRD = 0b11111111;
|
95
|
+
PORTD = output;
|
96
|
+
return 0;
|
97
|
+
}
|
@@ -5,11 +5,18 @@
|
|
5
5
|
int pinB(int);
|
6
6
|
int posEdgePB(int);
|
7
7
|
int portB(int, int);
|
8
|
+
int portBs(int);
|
8
9
|
|
9
10
|
// PC
|
11
|
+
int pinC(int);
|
12
|
+
int posEdgePC(int);
|
10
13
|
int portC(int, int);
|
14
|
+
int portCs(int);
|
11
15
|
|
12
16
|
// PD
|
17
|
+
int pinD(int);
|
18
|
+
int posEdgePD(int);
|
13
19
|
int portD(int, int);
|
20
|
+
int portDs(int);
|
14
21
|
|
15
22
|
#endif
|
@@ -23,6 +23,7 @@ in @posEdgePB6 from $posEdgePB(6)
|
|
23
23
|
in @posEdgePB7 from $posEdgePB(7)
|
24
24
|
|
25
25
|
foreign portB as $portB(Int, Bool) : Unit
|
26
|
+
foreign portBs as $portBs(Int) : Unit
|
26
27
|
|
27
28
|
-- PC
|
28
29
|
|
@@ -47,6 +48,7 @@ in @posEdgePC6 from $posEdgePC(6)
|
|
47
48
|
in @posEdgePC7 from $posEdgePC(7)
|
48
49
|
|
49
50
|
foreign portC as $portC(Int, Bool) : Unit
|
51
|
+
foreign portCs as $portCs(Int) : Unit
|
50
52
|
|
51
53
|
-- PD
|
52
54
|
|
@@ -71,3 +73,4 @@ in @posEdgePD6 from $posEdgePD(6)
|
|
71
73
|
in @posEdgePD7 from $posEdgePD(7)
|
72
74
|
|
73
75
|
foreign portD as $portD(Int, Bool) : Unit
|
76
|
+
foreign portDs as $portDs(Int) : Unit
|
@@ -1,29 +1,59 @@
|
|
1
1
|
#include<avr/io.h>
|
2
2
|
#include <avr/interrupt.h>
|
3
3
|
|
4
|
-
static unsigned int
|
4
|
+
static unsigned int elapsed_clock_div256 = 0;
|
5
5
|
|
6
6
|
ISR(TIMER0_OVF_vect)
|
7
7
|
{
|
8
|
-
|
8
|
+
elapsed_clock_div256++;
|
9
9
|
}
|
10
10
|
|
11
|
-
void
|
11
|
+
void initialize_timer() {
|
12
|
+
static int flag = 0;
|
13
|
+
if (!flag) {
|
14
|
+
flag = 1;
|
15
|
+
return;
|
16
|
+
}
|
12
17
|
cli();
|
13
18
|
TIMSK = 0b00000001;
|
14
|
-
|
15
|
-
TCCR0 = 0b00000010;
|
19
|
+
TCCR0 = 0b00000001; // No prescaling
|
16
20
|
sei();
|
17
21
|
}
|
18
22
|
|
19
|
-
int
|
20
|
-
static int
|
21
|
-
int
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
return
|
23
|
+
int get_dsec(clk_io_kilohertz) {
|
24
|
+
static unsigned int last = 0;
|
25
|
+
unsigned int current;
|
26
|
+
unsigned int dsec;
|
27
|
+
initialize_timer();
|
28
|
+
|
29
|
+
current = elapsed_clock_div256;
|
30
|
+
dsec = (current - last) / (clk_io_kilohertz * 4); // clk_io_kilohertz * 1024 / 256
|
31
|
+
last = current - (current - last) % (clk_io_kilohertz * 4);
|
32
|
+
return dsec;
|
33
|
+
}
|
34
|
+
|
35
|
+
int get_dmsec(clk_io_kilohertz) {
|
36
|
+
static unsigned int last = 0;
|
37
|
+
unsigned int current;
|
38
|
+
unsigned int dmsec;
|
39
|
+
initialize_timer();
|
40
|
+
|
41
|
+
current = elapsed_clock_div256;
|
42
|
+
dmsec = (current - last) / (clk_io_kilohertz / 2); // clk_io_kilohertz * 1024 / 256 / 8
|
43
|
+
last = current - (current - last) % (clk_io_kilohertz / 2);
|
44
|
+
return dmsec * 125;
|
45
|
+
}
|
46
|
+
|
47
|
+
// This function assumes 0.97656(=1000/1024)msec as 1msec
|
48
|
+
// so accumulates about 2% error.
|
49
|
+
int get_uncertain_dmsec(clk_io_kilohertz) {
|
50
|
+
static unsigned int last = 0;
|
51
|
+
unsigned int current;
|
52
|
+
unsigned int dmsec;
|
53
|
+
initialize_timer();
|
54
|
+
|
55
|
+
current = elapsed_clock_div256;
|
56
|
+
dmsec = (current - last) / (clk_io_kilohertz / 256); // clk_io_kilohertz * 1024 / 256 / 1024
|
57
|
+
last = current - (current - last) % (clk_io_kilohertz / 256);
|
58
|
+
return dmsec;
|
29
59
|
}
|
@@ -1,4 +1,10 @@
|
|
1
1
|
import Base
|
2
2
|
|
3
|
-
foreign
|
4
|
-
in @
|
3
|
+
foreign get_dsec as $getDsec(Int) : Int
|
4
|
+
in @dsec : Int from $getDsec(1024)
|
5
|
+
|
6
|
+
foreign get_dmsec as $getDmsec(Int) : Int
|
7
|
+
in @dmsec : Int from $getDmsec(1024)
|
8
|
+
|
9
|
+
foreign get_uncertain_dmsec as $getUncertainDmsec(Int) : Int
|
10
|
+
in @uncertainDmsec : Int from $getUncertainDmsec(1024)
|
data/base-library/Base.sfrp
CHANGED
data/lib/sfrp/raw/exception.rb
CHANGED
@@ -3,9 +3,8 @@ require 'sfrp/error'
|
|
3
3
|
module SFRP
|
4
4
|
module Raw
|
5
5
|
class NameError < CompileError
|
6
|
-
def initialize(target_str
|
6
|
+
def initialize(target_str)
|
7
7
|
@target_str = target_str
|
8
|
-
@source_position = source_position
|
9
8
|
end
|
10
9
|
|
11
10
|
def message
|
@@ -14,10 +13,9 @@ module SFRP
|
|
14
13
|
end
|
15
14
|
|
16
15
|
class AmbiguousNameError < CompileError
|
17
|
-
def initialize(target_str, selection_strs
|
16
|
+
def initialize(target_str, selection_strs)
|
18
17
|
@target_str = target_str
|
19
18
|
@selection_strs = selection_strs
|
20
|
-
@source_position = source_position
|
21
19
|
end
|
22
20
|
|
23
21
|
def message
|
@@ -27,9 +25,8 @@ module SFRP
|
|
27
25
|
end
|
28
26
|
|
29
27
|
class IllegalSideEffectError < CompileError
|
30
|
-
def initialize(target_str
|
28
|
+
def initialize(target_str)
|
31
29
|
@target_str = target_str
|
32
|
-
@source_position = source_position
|
33
30
|
end
|
34
31
|
|
35
32
|
def message
|
data/lib/sfrp/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: sfrp
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.
|
4
|
+
version: 1.5.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Kensuke Sawada
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2016-12-
|
11
|
+
date: 2016-12-24 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|