-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathspo256.c
82 lines (59 loc) · 1.57 KB
/
spo256.c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
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
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
/**
* SPO256 -AL2
* samples from https://www.cpcwiki.eu/index.php/SP0256_Allophones
*
* Pico code Derek Woodroffe 4/5/2022
*
*/
//pico SDK includes
#include <stdio.h>
#include "pico/stdlib.h"
#include "hardware/pwm.h"
//program includes
#include "allophones.c"
#include "allophoneDefs.h"
//must be pins on the same slice
#define soundIO1 15
#define soundIO2 14
#define rate 90
uint PWMslice;
void PlayAllophone(int al){
int b,s;
uint8_t v;
s=allophonesizeCorrected[al];
for(b=0;b<s;b++){
v=allophoneindex[al][b]; //get delta value
sleep_us(rate);
pwm_set_both_levels(PWMslice,v,~v);
}
}
void PlayAllophones(uint8_t *alist,int listlength){
int a;
for(a=0;a<listlength;a++){
PlayAllophone(alist[a]);
}
}
void SetPWM(void){
gpio_init(soundIO1);
gpio_set_dir(soundIO1,GPIO_OUT);
gpio_set_function(soundIO1, GPIO_FUNC_PWM);
gpio_init(soundIO2);
gpio_set_dir(soundIO2,GPIO_OUT);
gpio_set_function(soundIO2, GPIO_FUNC_PWM);
PWMslice=pwm_gpio_to_slice_num (soundIO1);
pwm_set_clkdiv(PWMslice,16);
pwm_set_both_levels(PWMslice,0x80,0x80);
pwm_set_output_polarity(PWMslice,true,false);
pwm_set_wrap (PWMslice, 256);
pwm_set_enabled(PWMslice,true);
}
int main() {
stdio_init_all();
SetPWM();
uint8_t alist[] ={HH,EH,LL,AX,OW,PA5,WW,OR,LL,DD1};
//uint8_t alist[] ={AR,PA5,SS,SS,IY,PA5,TT2,WH,EH,EH,NN1,PA2,PA3,TT2,IY,PA5,FF,OR,PA3,TT2,IY,PA5};
printf("Starting");
PlayAllophones(alist,sizeof(alist));
//wait....
while(1);
}//main