質問編集履歴
5
文法の修正
test
CHANGED
File without changes
|
test
CHANGED
@@ -14,7 +14,7 @@
|
|
14
14
|
|
15
15
|
実際に書き込む処理をどのようにpythonでどの用に書き直したらいいのかがわかりません。
|
16
16
|
|
17
|
-
現状のソースコードでは
|
17
|
+
現状のソースコードではエラーもなく実行されますが、音がなりません。
|
18
18
|
|
19
19
|
|
20
20
|
|
@@ -84,6 +84,12 @@
|
|
84
84
|
|
85
85
|
def if_write(addr,data):
|
86
86
|
|
87
|
+
addr = addr.to_bytes(1, 'big')
|
88
|
+
|
89
|
+
data = data.to_bytes(1, 'big')
|
90
|
+
|
91
|
+
|
92
|
+
|
87
93
|
set_ss_pin(0)
|
88
94
|
|
89
95
|
wp.wiringPiSPIDataRW(SPI_CH, addr)
|
@@ -96,11 +102,17 @@
|
|
96
102
|
|
97
103
|
def if_m_write(addr,data,num):
|
98
104
|
|
105
|
+
|
106
|
+
|
107
|
+
addr = addr.to_bytes(1, 'big')
|
108
|
+
|
99
109
|
set_ss_pin(0)
|
100
110
|
|
101
111
|
wp.wiringPiSPIDataRW(SPI_CH, addr)
|
102
112
|
|
103
|
-
for i in range(0,3
|
113
|
+
for i in range(0,35) :
|
114
|
+
|
115
|
+
data[i] = data[i].to_bytes(1, 'big')
|
104
116
|
|
105
117
|
wp.wiringPiSPIDataRW(SPI_CH, data[i])
|
106
118
|
|
@@ -140,11 +152,11 @@
|
|
140
152
|
|
141
153
|
|
142
154
|
|
143
|
-
if_w
|
155
|
+
if_write(0x00,0x01)#CLKEN
|
144
|
-
|
156
|
+
|
145
|
-
if_w
|
157
|
+
if_write(0x01,0x00)#AKRST
|
146
|
-
|
158
|
+
|
147
|
-
if_w
|
159
|
+
if_write(0x1A,0xA3)#soft reset
|
148
160
|
|
149
161
|
delay(1)
|
150
162
|
|
@@ -200,7 +212,7 @@
|
|
200
212
|
|
201
213
|
def set_tone():
|
202
214
|
|
203
|
-
tone_data
|
215
|
+
tone_data =[
|
204
216
|
|
205
217
|
0x81,\
|
206
218
|
|
@@ -224,7 +236,7 @@
|
|
224
236
|
|
225
237
|
delay(1)
|
226
238
|
|
227
|
-
i
|
239
|
+
if_write(0x08,0x00)
|
228
240
|
|
229
241
|
|
230
242
|
|
@@ -286,7 +298,7 @@
|
|
286
298
|
|
287
299
|
set_ch()
|
288
300
|
|
289
|
-
|
301
|
+
|
290
302
|
|
291
303
|
|
292
304
|
|
@@ -300,4 +312,8 @@
|
|
300
312
|
|
301
313
|
|
302
314
|
|
315
|
+
|
316
|
+
|
317
|
+
|
318
|
+
|
303
319
|
```
|
4
書式の修正
test
CHANGED
File without changes
|
test
CHANGED
@@ -58,11 +58,11 @@
|
|
58
58
|
|
59
59
|
if val == 1:
|
60
60
|
|
61
|
-
wp.digital
|
61
|
+
wp.digitalWrite(SS_PIN, wp.GPIO.HIGH)
|
62
62
|
|
63
63
|
else:
|
64
64
|
|
65
|
-
wp.digital
|
65
|
+
wp.digitalWrite(SS_PIN, wp.GPIO.LOW)
|
66
66
|
|
67
67
|
|
68
68
|
|
@@ -72,11 +72,11 @@
|
|
72
72
|
|
73
73
|
if val == 1:
|
74
74
|
|
75
|
-
wp.digital
|
75
|
+
wp.digitalWrite(RST_PIN, wp.GPIO.HIGH)
|
76
76
|
|
77
77
|
else:
|
78
78
|
|
79
|
-
wp.digital
|
79
|
+
wp.digitalWrite(RST_PIN, wp.GPIO.LOW)
|
80
80
|
|
81
81
|
|
82
82
|
|
3
誤字の訂正
test
CHANGED
File without changes
|
test
CHANGED
@@ -58,11 +58,11 @@
|
|
58
58
|
|
59
59
|
if val == 1:
|
60
60
|
|
61
|
-
wp.digitalW
|
61
|
+
wp.digitalRW(SS_PIN, wp.GPIO.HIGH)
|
62
62
|
|
63
63
|
else:
|
64
64
|
|
65
|
-
wp.digitalW
|
65
|
+
wp.digitalRW(SS_PIN, wp.GPIO.LOW)
|
66
66
|
|
67
67
|
|
68
68
|
|
@@ -72,11 +72,11 @@
|
|
72
72
|
|
73
73
|
if val == 1:
|
74
74
|
|
75
|
-
wp.digitalW
|
75
|
+
wp.digitalRW(RST_PIN, wp.GPIO.HIGH)
|
76
76
|
|
77
77
|
else:
|
78
78
|
|
79
|
-
wp.digitalW
|
79
|
+
wp.digitalRW(RST_PIN, wp.GPIO.LOW)
|
80
80
|
|
81
81
|
|
82
82
|
|
@@ -290,10 +290,6 @@
|
|
290
290
|
|
291
291
|
|
292
292
|
|
293
|
-
|
294
|
-
|
295
|
-
print("OK")
|
296
|
-
|
297
293
|
keyon(0x1c,0x11)
|
298
294
|
|
299
295
|
delay(500)
|
2
質問内容の変更
test
CHANGED
File without changes
|
test
CHANGED
@@ -2,10 +2,6 @@
|
|
2
2
|
|
3
3
|
FM音源に興味を持ったのでraspberryPiとYMF825boardを用いてDX7のようなFMシンセを作成しようと考えています。
|
4
4
|
|
5
|
-
電子工作的なことやICの制御などは今回が初めてなので、YMF825の仕様を見てもあまり理解ができず困っています。
|
6
|
-
|
7
|
-
RaspberryPiのSPIの有効化はすんでいます。
|
8
|
-
|
9
5
|
|
10
6
|
|
11
7
|
### 発生している問題・エラーメッセージ
|
@@ -16,13 +12,9 @@
|
|
16
12
|
|
17
13
|
|
18
14
|
|
19
|
-
どのレジスタにどういう流れで書き込みを行っているのかはなんとなく把握できたのですが、
|
20
|
-
|
21
|
-
実際に書き込む処理をどのようにpythonで書き直したらいいのかがわかりません。
|
15
|
+
実際に書き込む処理をどのようにpythonでどの用に書き直したらいいのかがわかりません。
|
22
|
-
|
16
|
+
|
23
|
-
|
17
|
+
現状のソースコードではwp.wiringPiSPIDataRWのところで処理が止まってしまいます。
|
24
|
-
|
25
|
-
|
26
18
|
|
27
19
|
|
28
20
|
|
@@ -30,58 +22,286 @@
|
|
30
22
|
|
31
23
|
|
32
24
|
|
33
|
-
```
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
f
|
68
|
-
|
69
|
-
|
70
|
-
|
71
|
-
|
72
|
-
|
73
|
-
|
74
|
-
|
75
|
-
|
76
|
-
|
77
|
-
|
78
|
-
|
79
|
-
|
80
|
-
|
81
|
-
if
|
82
|
-
|
83
|
-
|
84
|
-
|
85
|
-
|
25
|
+
```python
|
26
|
+
|
27
|
+
import wiringpi as wp
|
28
|
+
|
29
|
+
import time
|
30
|
+
|
31
|
+
#==========================
|
32
|
+
|
33
|
+
SPI_CH = 0 # SPI channel (0 or 1)
|
34
|
+
|
35
|
+
SPI_SPEED = 2000000 #SPI 2MHz
|
36
|
+
|
37
|
+
|
38
|
+
|
39
|
+
SS_PIN = 22
|
40
|
+
|
41
|
+
RST_PIN = 36
|
42
|
+
|
43
|
+
|
44
|
+
|
45
|
+
#setup
|
46
|
+
|
47
|
+
wp.wiringPiSPISetup (SPI_CH, SPI_SPEED)
|
48
|
+
|
49
|
+
wp.wiringPiSetupGpio()
|
50
|
+
|
51
|
+
|
52
|
+
|
53
|
+
|
54
|
+
|
55
|
+
|
56
|
+
|
57
|
+
def set_ss_pin(val):
|
58
|
+
|
59
|
+
if val == 1:
|
60
|
+
|
61
|
+
wp.digitalWrite(SS_PIN, wp.GPIO.HIGH)
|
62
|
+
|
63
|
+
else:
|
64
|
+
|
65
|
+
wp.digitalWrite(SS_PIN, wp.GPIO.LOW)
|
66
|
+
|
67
|
+
|
68
|
+
|
69
|
+
|
70
|
+
|
71
|
+
def set_rst_pin(val):
|
72
|
+
|
73
|
+
if val == 1:
|
74
|
+
|
75
|
+
wp.digitalWrite(RST_PIN, wp.GPIO.HIGH)
|
76
|
+
|
77
|
+
else:
|
78
|
+
|
79
|
+
wp.digitalWrite(RST_PIN, wp.GPIO.LOW)
|
80
|
+
|
81
|
+
|
82
|
+
|
83
|
+
|
84
|
+
|
85
|
+
def if_write(addr,data):
|
86
|
+
|
87
|
+
set_ss_pin(0)
|
88
|
+
|
89
|
+
wp.wiringPiSPIDataRW(SPI_CH, addr)
|
90
|
+
|
91
|
+
wp.wiringPiSPIDataRW(SPI_CH, data)
|
92
|
+
|
93
|
+
set_ss_pin(1)
|
94
|
+
|
95
|
+
|
96
|
+
|
97
|
+
def if_m_write(addr,data,num):
|
98
|
+
|
99
|
+
set_ss_pin(0)
|
100
|
+
|
101
|
+
wp.wiringPiSPIDataRW(SPI_CH, addr)
|
102
|
+
|
103
|
+
for i in range(0,34) :
|
104
|
+
|
105
|
+
wp.wiringPiSPIDataRW(SPI_CH, data[i])
|
106
|
+
|
107
|
+
set_ss_pin(1)
|
108
|
+
|
109
|
+
|
110
|
+
|
111
|
+
|
112
|
+
|
113
|
+
def delay(sec):
|
114
|
+
|
115
|
+
time.sleep(sec/1000)
|
116
|
+
|
117
|
+
|
118
|
+
|
119
|
+
|
120
|
+
|
121
|
+
#init
|
122
|
+
|
123
|
+
def init_825():
|
124
|
+
|
125
|
+
|
126
|
+
|
127
|
+
set_rst_pin(0)
|
128
|
+
|
129
|
+
delay(1)
|
130
|
+
|
131
|
+
set_rst_pin(1)
|
132
|
+
|
133
|
+
|
134
|
+
|
135
|
+
if_write(0x1D,0)#OutPower
|
136
|
+
|
137
|
+
if_write(0x02,0x0E)
|
138
|
+
|
139
|
+
delay(1)
|
140
|
+
|
141
|
+
|
142
|
+
|
143
|
+
if_wirite(0x00,0x01)#CLKEN
|
144
|
+
|
145
|
+
if_wirite(0x01,0x00)#AKRST
|
146
|
+
|
147
|
+
if_wirite(0x1A,0xA3)#soft reset
|
148
|
+
|
149
|
+
delay(1)
|
150
|
+
|
151
|
+
|
152
|
+
|
153
|
+
if_write(0x1A,0x00)
|
154
|
+
|
155
|
+
delay(30)
|
156
|
+
|
157
|
+
|
158
|
+
|
159
|
+
if_write(0x02,0x04)
|
160
|
+
|
161
|
+
delay(1)
|
162
|
+
|
163
|
+
if_write(0x02,0x00)
|
164
|
+
|
165
|
+
|
166
|
+
|
167
|
+
#add
|
168
|
+
|
169
|
+
if_write( 0x19, 0xF0 )#MASTER VOL
|
170
|
+
|
171
|
+
if_write( 0x1B, 0x3F )#interpolation
|
172
|
+
|
173
|
+
if_write( 0x14, 0x00 )#interpolation
|
174
|
+
|
175
|
+
if_write( 0x03, 0x01 )#Analog Gain
|
176
|
+
|
177
|
+
|
178
|
+
|
179
|
+
if_write( 0x08, 0xF6 )
|
180
|
+
|
181
|
+
delay(21);
|
182
|
+
|
183
|
+
if_write( 0x08, 0x00 )
|
184
|
+
|
185
|
+
if_write( 0x09, 0xF8 )
|
186
|
+
|
187
|
+
if_write( 0x0A, 0x00 )
|
188
|
+
|
189
|
+
|
190
|
+
|
191
|
+
if_write( 0x17, 0x40 )
|
192
|
+
|
193
|
+
if_write( 0x18, 0x00 )
|
194
|
+
|
195
|
+
|
196
|
+
|
197
|
+
|
198
|
+
|
199
|
+
#=============
|
200
|
+
|
201
|
+
def set_tone():
|
202
|
+
|
203
|
+
tone_data[35] =[\
|
204
|
+
|
205
|
+
0x81,\
|
206
|
+
|
207
|
+
0,\
|
208
|
+
|
209
|
+
0x01,0x85,\
|
210
|
+
|
211
|
+
0x00,0x7F,0xF4,0xBB,0x00,0x10,0x40,\
|
212
|
+
|
213
|
+
0x00,0xAF,0xA0,0x0E,0x03,0x10,0x40,\
|
214
|
+
|
215
|
+
0x00,0x2F,0xF3,0x9B,0x00,0x20,0x41,\
|
216
|
+
|
217
|
+
0x00,0xAF,0xA0,0x0E,0x01,0x10,0x40,\
|
218
|
+
|
219
|
+
0x80,0x03,0x81,0x80]
|
220
|
+
|
221
|
+
|
222
|
+
|
223
|
+
if_write(0x08,0xF6)
|
224
|
+
|
225
|
+
delay(1)
|
226
|
+
|
227
|
+
id_write(0x08,0x00)
|
228
|
+
|
229
|
+
|
230
|
+
|
231
|
+
if_m_write(0x07,tone_data,35)
|
232
|
+
|
233
|
+
|
234
|
+
|
235
|
+
#=============
|
236
|
+
|
237
|
+
|
238
|
+
|
239
|
+
def set_ch():
|
240
|
+
|
241
|
+
if_write( 0x0F, 0x30 )
|
242
|
+
|
243
|
+
if_write( 0x10, 0x71 )
|
244
|
+
|
245
|
+
if_write( 0x11, 0x00 )
|
246
|
+
|
247
|
+
if_write( 0x12, 0x08 )
|
248
|
+
|
249
|
+
if_write( 0x13, 0x00 )
|
250
|
+
|
251
|
+
|
252
|
+
|
253
|
+
def keyon(fnumh,fnuml):
|
254
|
+
|
255
|
+
if_write( 0x0B, 0x00 )
|
256
|
+
|
257
|
+
if_write( 0x0C, 0x54 )
|
258
|
+
|
259
|
+
if_write( 0x0D, fnumh )
|
260
|
+
|
261
|
+
if_write( 0x0E, fnuml )
|
262
|
+
|
263
|
+
if_write( 0x0F, 0x40 )
|
264
|
+
|
265
|
+
|
266
|
+
|
267
|
+
def keyoff():
|
268
|
+
|
269
|
+
if_write(0x0F,0x00)
|
270
|
+
|
271
|
+
|
272
|
+
|
273
|
+
#==================
|
274
|
+
|
275
|
+
|
276
|
+
|
277
|
+
if __name__ == '__main__' :
|
278
|
+
|
279
|
+
|
280
|
+
|
281
|
+
|
282
|
+
|
283
|
+
init_825()
|
284
|
+
|
285
|
+
set_tone()
|
286
|
+
|
287
|
+
set_ch()
|
288
|
+
|
289
|
+
|
290
|
+
|
291
|
+
|
292
|
+
|
293
|
+
|
294
|
+
|
295
|
+
print("OK")
|
296
|
+
|
297
|
+
keyon(0x1c,0x11)
|
298
|
+
|
299
|
+
delay(500)
|
300
|
+
|
301
|
+
keyoff()
|
302
|
+
|
303
|
+
delay(200)
|
304
|
+
|
305
|
+
|
86
306
|
|
87
307
|
```
|
1
質問内容の修正
test
CHANGED
File without changes
|
test
CHANGED
@@ -3,6 +3,8 @@
|
|
3
3
|
FM音源に興味を持ったのでraspberryPiとYMF825boardを用いてDX7のようなFMシンセを作成しようと考えています。
|
4
4
|
|
5
5
|
電子工作的なことやICの制御などは今回が初めてなので、YMF825の仕様を見てもあまり理解ができず困っています。
|
6
|
+
|
7
|
+
RaspberryPiのSPIの有効化はすんでいます。
|
6
8
|
|
7
9
|
|
8
10
|
|