Advertisement
Guest User

Untitled

a guest
Jul 20th, 2019
89
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 1.56 KB | None | 0 0
  1. int main(void){
  2.   ss_init();
  3.   sei();
  4.   bool sendactive = false;
  5.   while(1){
  6.  
  7.     if(sendactive){
  8.       uart_sendl("T!");
  9.       // Comment out the below and all is well. We never see the T! unless we specifically turn on sending.
  10.       while(ss_queuebyte(count)){
  11.         count++;
  12.       }
  13.     }
  14.     ss_poll();
  15.     ss_check_errors();
  16.     uart_async_send_poll();
  17.    
  18.     bool a;
  19.     if(UCSR0A & (1<<RXC0)){
  20.       char x = UDR0;
  21.       /*if(x<97 || x > 122) {
  22.         return;
  23.       }*/
  24.       uart_send("rx: ");
  25.       uart_sendl(x);
  26.         if(x == 'r'){
  27.           uart_send("Received bytes: ");
  28.           uart_sendl(rbf_get_bytes_in_use(&ss_inbuf));
  29.           while(rbf_get_bytes_in_use(&ss_inbuf)!=0){
  30.             a = true;
  31.             uart_send(rbf_get_byte(&ss_inbuf)); // Contents are scrambled unless the while statement above is commented out (even when it doesn't run)
  32.             uart_send(",");
  33.           }
  34.           if(a) uart_send("\r\n");
  35.         }
  36.         if(x == 's'){
  37.           //ss_queuebyte(count++);
  38.           if(!sendactive){
  39.             sendactive = true;
  40.             uart_sendl("Send active");
  41.           } else {
  42.             sendactive = false;
  43.             uart_sendl("Send inactive");
  44.           }
  45.         }
  46.         if(x == 'u'){
  47.           ss_clks ++;
  48.           uart_send(ss_clks);
  49.           OCR0A = ss_clks;
  50.           uart_sendl(";");
  51.         }
  52.         if(x == 'd'){
  53.           ss_clks --;
  54.           uart_send(ss_clks);
  55.           OCR0A = ss_clks;
  56.           uart_sendl(";");
  57.         }
  58.     }
  59.     _delay_us(100);
  60.   }
  61. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement