Last active
August 29, 2015 14:10
-
-
Save akohlsmith/cf6d99232d8f9ceb89e1 to your computer and use it in GitHub Desktop.
This file contains 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 <stdio.h> | |
#include <stdint.h> | |
#define NOTE(tone, dur) ((((((uint8_t)(dur)) & 0x07)<<5) | (((uint8_t)(tone)) & 0x1F))) | |
#define GET_TONE(note) ((note) & 0x1F) | |
#define GET_DURATION(note) (((note)>>5) & 0x07) | |
#define END_MARKER 0XFF | |
#define READ_BIT(byte, bit) ((byte & (1 << bit)) >> bit) | |
enum { | |
T_REST, | |
T_C, | |
T_CS, | |
T_D, | |
T_EB, | |
T_E, | |
T_F, | |
T_FS, | |
T_G, | |
T_AB, | |
T_A, | |
T_BB, | |
T_B, | |
T_CX, | |
T_CSX, | |
T_DX, | |
T_EBX, | |
T_EX, | |
T_FX, | |
T_FSX, | |
T_GX, | |
T_ABX, | |
T_AX, | |
T_BBX, | |
T_BX | |
}; | |
uint8_t test_tune[] = { NOTE(T_EX, 2), NOTE(T_EX, 4), NOTE(T_EX, 4), END_MARKER }; | |
uint8_t *p; | |
void send_byte(uint8_t val) | |
{ | |
int i; | |
for (i=0; i<8; i++) { | |
printf("%c", (val & (1 << i)) ? '1' : '0'); | |
} | |
printf("\n"); | |
} | |
void send_data(uint8_t index) | |
{ | |
const uint8_t *ptr = &test_tune[0]; | |
for (uint8_t data = *ptr++; data != END_MARKER; data = *ptr++) { | |
printf("data: %02hhx: ", data); | |
send_byte(data); | |
} | |
} | |
int main(void) | |
{ | |
send_data(0); | |
return 0; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment