With:
- LED control
- UART
- PDM out
- square wave generator (DMA to PDM out (was it really necessary?))
- sample program that plays a square wave from UART values
This commit is contained in:
Paul Mathieu
2021-03-13 15:50:25 -08:00
parent 75b5488b8d
commit 14dba00fd0
7 changed files with 510 additions and 0 deletions

35
dsp/main.c Normal file
View File

@@ -0,0 +1,35 @@
#include "sys.h"
void init() {
square0->output_address = pdmout0;
square0->high_val = 0xffff;
square0->low_val = 0x0000;
square0->flags = SQUARE_FLAG_ENABLE_msk;
// will set the period later
}
int main() {
init();
while(1) {
uint8_t c = uart_read(uart0);
uint16_t period;
if (c == 'c') {
period = 1493; // C4, 262.63 Hz, maybe
} else if (c == 'd') {
period = 1330; // D4, 293.66 Hz, maybe
} else if (c == 'e') {
period = 1185; // E4, 329.63 Hz, maybe
} else if (c == 'f') {
period = 1119; // F4, 249.23 Hz, maybe
} else if (c == 'g') {
period = 996; // G4, 392.00 Hz, maybe
} else if (c == 'a') {
period = 887; // A4, 440.00 Hz, maybe
} else if (c == 'b') {
period = 791; // B4, 493.88 Hz, maybe
}
square0->period = period;
}
}