Advertisement
Guest User

Untitled

a guest
Oct 26th, 2011
102
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 1.18 KB | None | 0 0
  1. /* Code snippet showing how I initialize the registers */
  2.  
  3.           Serial3.end();
  4.      // Setup our USART3
  5.    
  6.      USART3->regs->BRR = 0x120; // Baud Rate Register
  7.      USART3->regs->CR1 = 0b0010000000001100;  // CR 1
  8.      USART3->regs->CR2 = 0b0010000000100000; // CR 2
  9.      USART3->regs->CR3 = 0x0000; // CR 3
  10.  
  11. /* End snip */
  12.  
  13. /* Code snippet showing my IRQ handler */
  14.  
  15.  
  16.  
  17. void __irq_usart3(void) {
  18.  
  19.   if((USART3->regs->SR & 0x0002) == 0x0002)  // Detects FE
  20.     {
  21.         //digitalWrite(33,HIGH);
  22.         i = USART3->regs->DR;
  23.         current_slot = 0;
  24.         //waiting_for_break = 0;
  25.           slots_loc = 0;
  26.         //SerialUSB.print("B");
  27.     }
  28.   else if(current_slot <= DIMMERS)
  29.   {
  30.  
  31.     //SerialUSB.println(current_slot);
  32.     if((USART3->regs->SR & 0x0020) == 0x0020)
  33.     {
  34.       //SerialUSB.print("s");
  35.       if(current_slot == 0)
  36.       {
  37.  
  38.         if(USART3->regs->DR == 0x00)
  39.         {
  40.           slots[current_slot] = USART3->regs->DR;
  41.           needs_write = 1;
  42.         }
  43.         digitalWrite(33,LOW);
  44.       }
  45.       else
  46.       {
  47.         slots[current_slot] = USART3->regs->DR;
  48.       }
  49.        
  50.       current_slot++;  
  51.     }
  52.   }
  53.  
  54.  
  55. }
  56.  
  57.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement