Advertisement
Guest User

Reciever.c

a guest
Apr 30th, 2018
551
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 0.72 KB | None | 0 0
  1. #include "project.h"
  2. #include "stdio.h"
  3.  
  4. #define TRUE 1
  5. #define FALSE 0
  6. char TransmitBufferUSB[16];
  7. int16 rx_data = 0;
  8. uint16 rx_udata = 0;
  9.  
  10.  
  11. CY_ISR(UART_ISR){
  12.     ISR_Rx_Disable(); //Make sure i can't be interrupted while i'm interrupting.
  13.     Status_pin_Write(0xFF); //Used for debugging
  14.     uint8 rx_msb = UART_GetByte();
  15.     uint8 rx_lsb = UART_GetByte();
  16.     rx_udata = ((uint16)rx_msb << 8) | rx_lsb;
  17.     sprintf(TransmitBufferUSB,"%d\n\r",rx_udata);
  18.     UART_USB_PutString(TransmitBufferUSB);
  19.     Status_pin_Write(0x00);
  20.     ISR_Rx_Enable();
  21. }
  22.    
  23.  
  24. int main(void)
  25. {
  26.     CyGlobalIntEnable; /* Enable global interrupts. */
  27.  
  28. UART_USB_Start();
  29. UART_Start();
  30. ISR_Rx_StartEx(UART_ISR);
  31.     while(1){
  32.     }
  33. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement