⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 main.c

📁 this is a driver for the davicom ethernet controller DM9000. this driver help in developing pc or em
💻 C
📖 第 1 页 / 共 2 页
字号:
        {
          uip_arp_out();
          DM9000_transmit();
        }
      }
      else 
      {
        if (BUF->type == htons(UIP_ETHTYPE_ARP))
        {
          B_(printf_small("ARP package received.\x0a\x0d");)
          // Received an ARP packet
          uip_arp_arpin();
          // If the above function invocation resulted in data that
          // should be sent out on the network, the global variable
          // uip_len is set to a value > 0.
          if (uip_len > 0)
          {	
            DM9000_transmit();
          }
        }
      }
    }
    if (LED_EventPending)
    {
      LED_EventPending = FALSE;
      led ^= 2;
      WriteNic(DM9000_GPR, led);
    }
  }	// end of 'while (1)'
}

//-----------------------------------------------------------------------------
// Received a datagram
//   Function template for receiving datagram
//-----------------------------------------------------------------------------
void datagram(void)
{
  printf("Received a datagram\n");
}

//-----------------------------------------------------------------------------
// Print a character on the serial port.
//    Will override dummy putchar in SDCC libraries.
//-----------------------------------------------------------------------------
void putchar(char a)
{
  while (TI0 == 0);
  SBUF = a;
  TI0 = 0;
}
    
//-----------------------------------------------------------------------------
// Routine to shut down system in an orderly fashion
//-----------------------------------------------------------------------------
void cleanup(void)
{
	EA = FALSE;
	RSTSRC |= 0x10; // Force a software reset
}

//-----------------------------------------------------------------------------
// Timer0_Init - sets up 10 mS RT interrupt
//-----------------------------------------------------------------------------
//
// Configure Timer0 to 16-bit generate an interrupt every 10 ms
// SYSCLK = 20000000Hz;
//
void Timer0_Init (void)
{
  TCON = 0x00;				                  // clear Timer0
  TF0 = FALSE;				                  // clear overflow indicator
  CKCON = 0x00;			                    // Set T0 to SYSCLK/12
  TMOD = 0x01;				                  // TMOD: Clear
  TL0 = (-((SYSCLK/12)/100) & 0x00ff);  // Load timer 0 to give  
  TH0 = (-((SYSCLK/12)/100) >> 8);      // 20MHz/12/100 = approx 10mS
  TR0 = TRUE;					                  // start Timer0
  PT0 = TRUE;					                  // T0 Interrupt Priority high
  ET0 = TRUE;					                  // enable Timer0 interrupts
}
//-----------------------------------------------------------------------------
// Timer1_Init - Timer 1 is used for UART0 baudrate generation in C8051F020
//    Currently not initialized here but in Uart_Init()
//-----------------------------------------------------------------------------
//
void Timer1_Init (int counts)
{
  TR1 = FALSE;	                        // Stop Timer1
  CKCON &= ~0x10;	                      // T1M set for SYSCLK/12
  TH1 = (-(counts) >> 8);	              // should set for 9600 BPS approx
  TL1 = 0xff;		                        // initialize Timer1
  TMOD |= 0x20;	                        // TMOD: timer 1, mode 2, 8-bit reload
  TR1 = TRUE;		                        // START Timer1
}
//-----------------------------------------------------------------------------
// Timer2_Init Not used, only contains template init code
//-----------------------------------------------------------------------------
void Timer2_Init (int counts)
{

  RCAP2H = 0x00;	                      // Timer 2 Capture Register High Byte
  RCAP2L = 0x00;	                      // Timer 2 Capture Register Low Byte	
  TL2 = (-(counts) & 0x00ff);
  TH2 = (-(counts) >> 8);
  T2CON = 0x00;	                        // Timer 2 Control Register
}

//----------------------------------------------------------------
// Timer3_Init not used, only contains template init code
//----------------------------------------------------------------
void Timer3_Init (int counts)
{
  TMR3RLL = 0x00;	                      // Timer 3 Reload Register Low Byte
  TMR3RLH = 0x00;	                      // Timer 3 Reload Register High Byte
  TMR3L = (-(counts) & 0x00ff);	
  TMR3H = (-(counts) >> 8);
  TMR3CN = 0x00;	                      // Timer 3 Control Register
}

//----------------------------------------------------------------
// Timer4_Init not used, only contains template init code
//----------------------------------------------------------------
void Timer4_Init (int counts)
{
  RCAP4H = 0x00;                        // Timer 4 Capture Register High Byte
  RCAP4L = 0x00;                        // Timer 4 Capture Register Low Byte
  TL4 = (-(counts) & 0x00ff);	
  TH4 = (-(counts) >> 8);
  T4CON = 0x00;                         // Timer 4 Control Register
}
// ---------------------------------------------------------------------------
// Timer 0 interrupt handler. Every 10ms
// ---------------------------------------------------------------------------
void Timer0_ISR (void) interrupt TF0_VECTOR using 1 critical
{

  TR0 = FALSE;					                // STOP Timer0
  TF0 = FALSE;					                // clear overflow indicator

  TL0 = (-((SYSCLK/12)/100) & 0x00ff);  // Load timer 0 to give  
  TH0 = (-((SYSCLK/12)/100) >> 8);      // 20MHz/12/100 = approx 10mS

  TR0 = TRUE;                           // start Timer0

  half_Sec--;                           // Decrement half sec counter
  if (half_Sec == 0)                    // Count 1ms intervals for half a second
  {			
    half_Sec = UIP_TX_TIMER;            // and then set the receive poll flag
    TX_EventPending = TRUE;             // the DM9000 hardware receive.
  }

  ten_Secs--;
  if (ten_Secs == 0)                    // Count 1ms intervals for ten seconds
  {              
    ten_Secs = UIP_ARP_TIMER;           // and then set the event required to
    ARP_EventPending = TRUE;            // trigger the arp timer if necessary
  }

  LedTimer--;
  if (LedTimer == 0)
  {
    LedTimer = LED_TIMER;
    LED_EventPending = TRUE;
  }

  ET0 = TRUE;                           // enable Timer0 interrupts, again
}

//-----------------------------------------------------------------------------
// 0x1b timer 1 overflow
//-----------------------------------------------------------------------------
void Timer1_ISR (void) interrupt TF1_VECTOR using 1 critical
{
// Routine code in here
}
//-----------------------------------------------------------------------------
// 0x2b Timer2_ISR overflow every 5ms
//
//-----------------------------------------------------------------------------
//
void Timer2_ISR (void) interrupt TF2_VECTOR using 1 critical
{
// Routine code in here
}
//-----------------------------------------------------------------------------
// 0x73 Timer3_ISR Interrupts every 5ms
//-----------------------------------------------------------------------------
void Timer3_ISR (void) interrupt TF3_VECTOR using 1 critical
{
// Routine code in here
}

//-----------------------------------------------------------------------------
// 0x83 Timer 4 overflow
//-----------------------------------------------------------------------------
void Timer4_ISR (void) interrupt TF4_VECTOR using 1 critical
{
// Routine code in here
}


		
	

				

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -