📄 tftp_demo.c
字号:
/*----------------------------------------------------------------------------
* R T L T C P N E T E x a m p l e
*----------------------------------------------------------------------------
* Name: TFTP_DEMO.C
* Purpose: TFTP Server deni example
* Rev.: V3.12
*----------------------------------------------------------------------------
* This code is part of the RealView Run-Time Library.
* Copyright (c) 2004-2007 KEIL - An ARM Company. All rights reserved.
*---------------------------------------------------------------------------*/
#include <stdio.h>
#include <RTL.h>
#include <LPC23xx.H> /* LPC23xx definitions */
//#include "LCD.h"
#define MCLK 48000000 /* Master Clock 48 MHz */
#define TCLK 10 /* Timer Clock rate 10/s */
#define TCNT (MCLK/TCLK/4) /* Timer Counts */
BOOL tick;
/*--------------------------- init ------------------------------------------*/
static void init () {
/* Add System initialisation code here */
/* I/O Ports configured as Output (Push-pull) */
FIO2DIR = 0x000000FF;
FIO2MASK = 0x00000000;
FIO2PIN = 0x00000000;
PINSEL10 = 0;
/* Timer 1 as interval timer, reload to 100ms. */
T1TCR = 1;
T1MCR = 3;
T1MR0 = TCNT - 1;
/* Configure UART1 for 115200 baud. */
PINSEL0 = 0x40000000; /* Enable TxD1 pin */
PINSEL1 = 0x00000001; /* Enable RxD1 pin */
U1LCR = 0x83; /* 8 bits, no Parity, 1 Stop bit*/
U1DLL = 3; /* for 12MHz PCLK Clock */
U1FDR = 0x67; /* Fractional Divider */
U1LCR = 0x03; /* DLAB = 0 */
}
/*--------------------------- LED_out ---------------------------------------*/
void LED_out (U32 val) {
FIO2SET = val;
FIO2CLR = ~val;
}
/*--------------------------- init_display ----------------------------------*/
static void init_display () {
/* LCD Module.2x16 init*/
//LCD_init ();
//LCD_cur_off ();
//LCD_puts (" RL-ARM "
// " TFTP example ");
}
/*--------------------------- timer_poll ------------------------------------*/
static void timer_poll () {
/* System tick timer running in poll mode */
if (T1IR & 1) {
T1IR = 1;
/* Timer tick every 100 ms */
timer_tick ();
tick = __TRUE;
}
}
/*--------------------------- sendchar --------------------------------------*/
int sendchar (int ch) {
/* Debug output to serial port. */
if (ch == '\n') {
while (!(U1LSR & 0x20));
U1THR = '\r'; /* output CR */
}
while (!(U1LSR & 0x20));
return (U1THR = ch);
}
/*--------------------------- blink_led -------------------------------------*/
static void blink_led () {
/* Blink the LEDs on MCB-STR9 board */
const U8 led_val[16] = { 0x48,0x88,0x84,0x44,0x42,0x22,0x21,0x11,
0x12,0x0A,0x0C,0x14,0x18,0x28,0x30,0x50 };
static U32 cnt;
if (tick == __TRUE) {
/* Every 100 ms */
tick = __FALSE;
LED_out (led_val[cnt]);
if (++cnt >= sizeof(led_val)) {
cnt = 0;
}
}
}
/*---------------------------------------------------------------------------*/
int main (void) {
/* Main Thread of the TcpNet */
init ();
init_display ();
init_TcpNet ();
fformat ("");
while (1) {
timer_poll ();
main_TcpNet ();
blink_led ();
}
}
/*----------------------------------------------------------------------------
* end of file
*---------------------------------------------------------------------------*/
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -