Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #define START_B 1
- #define HIGH_B 2
- #define LOW_B 3
- #define STOP_B 4
- //FSK
- void SendByteFSK(unsigned char B){
- unsigned char SCnt, Skip;
- char CBit;
- unsigned int Cnt;
- for(CBit = -1; CBit<9; CBit++){
- if(CBit == -1) Skip = START_B;
- else if(CBit == 8) Skip = STOP_B;
- else{
- //Data sent LSB first
- if(B & (1<<CBit)) Skip = HIGH_B;
- else Skip = LOW_B;
- }
- //Changing skip changed frequency, if skip is larger, sine wave is faster
- for(Cnt = 0; Cnt<128; Cnt += Skip){
- setDutyCycle(sinevals[C]);
- //Delay1KTCYx(1);
- }
- }
- }
- //ASK
- void SendByteASK(unsigned char B){
- unsigned char SCnt, Ampl;
- char CBit;
- unsigned int Cnt;
- for(CBit = -1; CBit<9; CBit++){
- if(CBit == -1) Ampl = START_B;
- else if(CBit == 8) Ampl = STOP_B;
- else{
- //Data sent LSB first
- if(B & (1<<CBit)) Ampl = HIGH_B;
- else Ampl = LOW_B;
- }
- //Constant frequency
- for(Cnt = 0; Cnt<128; Cnt++){
- //If Ampl is 4, amplitude will be 1, if Ampl is 3, amplitude will be 3/4 etc.
- setDutyCycle((sinevals[C]*Ampl)>>2);
- //Delay1KTCYx(1);
- }
- }
- }
- //Style == 0 is ASK, Style == 1 is FSK
- void SendArray(unsigned char *Ar, unsigned int Len, unsigned char Style){
- unsigned int Cnt;
- if(Style == 0) for(Cnt = 0; Cnt<Len; Cnt++) SendByteASK(Ar[Cnt]);
- else for(Cnt = 0; Cnt<Len; Cnt++) SendByteFSK(Ar[Cnt]);
- }
Advertisement
Add Comment
Please, Sign In to add comment