Facebook
From Toxic Capybara, 7 Years ago, written in C.
Embed
Download Paste or View Raw
Hits: 340
  1. #include <board.h>
  2. #include <xb_usart.h>
  3. #include <xb_cmdinterface.h>
  4.  
  5.  
  6. uint8_t lpt_data;
  7.  
  8. DefineBuffer(512,LPTDATABUF)
  9.  
  10. void EXTI9_5_IRQHandler(void)
  11. {
  12.         if (EXTI_GetITStatus(EXTI_Line9) != RESET)
  13.         {
  14.                 LPT_BUSY_ON(); 
  15.                
  16.                 {uint32_t x = 3;while ((x--) > 0) _nop();}
  17.                 lpt_data = LPT_DATA_GET();
  18.                 PutBuffer(&LPTDATABUF, lpt_data);
  19.                 EXTI_ClearITPendingBit(EXTI_Line9);
  20.         }
  21. }
  22.  
  23.  
  24. int main()
  25. {
  26.         volatile uint16_t tmp = 0;
  27.         volatile bool indatasend = false;
  28.         xbUSARTSendText(USART1, ";;;twr;Start...");
  29.        
  30.         LPT_BUSY_OFF();
  31.         LPT_SELECTED_ON();
  32.         LPT_ERR_ON();
  33.        
  34.        
  35.         for(;;)
  36.         {
  37.                 tmp = GetBuffer(&LPTDATABUF);
  38.                 if (tmp != 0x100)
  39.                 {
  40.                         if (!indatasend)
  41.                         {
  42.                                 indatasend = true;
  43.                                 cmd_SendText(&csTERM, "nD("");
  44.                         }
  45.                         cmd_SendCharInQuote(&csTERM, tmp);
  46.                 }
  47.                 else
  48.                 {
  49.                         BEGIN_WAITMS(inds,1000)
  50.                         if (indatasend)
  51.                         {
  52.                                 indatasend = false;
  53.                                 cmd_SendText(&csTERM, "");");
  54.                         }
  55.                         RESET_WAITMS(inds)
  56.                         END_WAITMS(inds)
  57.                         CMD_DoEvent();
  58.                 }
  59.                 LPT_BUSY_OFF();
  60.         }
  61. }
  62.