This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #include "pca.h" | |
| int main(void) | |
| { | |
| // initialize timer 0 as a tone generator | |
| // TDELAY_IMPLEMENT_T0_INT must be set to 1 in config.h | |
| beeper_init(E_TIMER0); | |
| while (1) { | |
| beeper_beep(E_TIMER0, 1000, 9000); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| ISR(TIMER0_COMPA_vect, ISR_NOBLOCK) { | |
| if (g_tail != g_head) { | |
| OCR1AH = 0x00; | |
| OCR1BH = 0x00; | |
| #if MODE == MODE_8K_16B | |
| uint16_t sample = (0x8000 + (p[(g_tail >> 6)].samples[g_tail & 0x3f])); | |
| OCR1AL = sample >> 8 ; | |
| OCR1BL = (sample) & 0xff; | |
| #else |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| static void serial_collect_samples(void *a_data __attribute__((unused))) { | |
| struct packet *data = (struct packet *)a_data; | |
| uint8_t size = 0x00; | |
| uint16_t buffs = (PWM_SAMPLES_BUFFER*PWM_BUFFERS); | |
| uint16_t avail = (buffs + g_head - g_tail) % buffs; | |
| if (avail > 192) { | |
| serial_poll_send("WAIT", 4); | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #define PWM_SAMPLES_BUFFER 64 | |
| #define PWM_BUFFERS 4 | |
| struct packet { | |
| uint16_t crc16; | |
| uint8_t num; | |
| uint8_t samples[PWM_SAMPLES_BUFFER]; | |
| }; | |
| static volatile struct packet p[PWM_BUFFERS]; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #include "beeper.h" | |
| #include "notes.h" | |
| #include "serial.h" | |
| #include "slip.h" | |
| #include <avr/io.h> | |
| #include <util/delay.h> | |
| struct note { | |
| uint16_t note; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| struct note { | |
| uint16_t note; | |
| uint16_t duration; | |
| }; | |
| struct packet { | |
| uint16_t crc16; | |
| unsigned char num; | |
| struct note notes[4]; | |
| }; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| while (1) { | |
| my @alsa_event = MIDI::ALSA::input(); | |
| # last event -> exit | |
| last if ($alsa_event[0] == SND_SEQ_EVENT_PORT_UNSUBSCRIBED()); | |
| # midi event to midi score event | |
| my @score_event = MIDI::ALSA::alsa2scoreevent( @alsa_event ); | |
| # filter out empty events |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| int main(int argc, char const *argv[]) { | |
| g_fd = 0x00; | |
| struct response *resp; | |
| struct timer_data *data; | |
| uint8_t buff[8] = {0x00}; | |
| uint16_t crc = 0x00; | |
| if (argc <= 3) { | |
| fprintf(stderr, "host_slip <prescaler> <ocr> <st_max>\n"); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #define BAUD_2400 B2400 | |
| #define BAUD_4800 B4800 | |
| #define BAUD_9600 B9600 | |
| #define BAUD_38400 B38400 | |
| #define BAUD_57600 B57600 | |
| #define BAUD_115200 B115200 | |
| static int tty_attrib_conf(int fd, int speed, int parity) { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #include <stdint.h> | |
| #include "crc.h" | |
| /** CRC table for the CRC-16. The poly is 0x8005 (x^16 + x^15 + x^2 + 1) */ | |
| uint16_t const crc16_table[256] = { | |
| 0x0000, 0xC0C1, 0xC181, 0x0140, 0xC301, 0x03C0, 0x0280, 0xC241, | |
| 0xC601, 0x06C0, 0x0780, 0xC741, 0x0500, 0xC5C1, 0xC481, 0x0440, | |
| 0xCC01, 0x0CC0, 0x0D80, 0xCD41, 0x0F00, 0xCFC1, 0xCE81, 0x0E40, | |
| 0x0A00, 0xCAC1, 0xCB81, 0x0B40, 0xC901, 0x09C0, 0x0880, 0xC841, | |
| 0xD801, 0x18C0, 0x1980, 0xD941, 0x1B00, 0xDBC1, 0xDA81, 0x1A40, |