|
我用LM3S6432芯片,解决以下问题:
1.串口收数并处理,然后通过网口传输出去。
2.网口收数处理,然后从串口发出。
遇到的问题: 程序代码不知如何发到帖子上,以下代码为主函数代码,不知在哪里添加处理接收到的数据,并将其发送出去,请高人指点?我的联系方式:qq:22369427,多谢,有要代码的可以找我。
int main(void)
{
unsigned long ulUser0, ulUser1;
unsigned char pucMACAddr[8];
unsigned long ulLoop;
//
// If running on Rev A2 silicon, turn the LDO voltage up to 2.75V. This is
// a workaround to allow the PLL to operate reliably.
//
if(REVISION_IS_A2)
{
SysCtlLDOSet(SYSCTL_LDO_2_75V);
}
//
// Set the processor to run at 50 MHz, allowing UART operation at up to
// 3.125 MHz.
//
SysCtlClockSet(SYSCTL_SYSDIV_4 | SYSCTL_USE_PLL | SYSCTL_OSC_MAIN |
SYSCTL_XTAL_8MHZ);
//
// Enable the peripherals used by the application.
//
SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOA);
SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOB);
SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOD);
SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOF);
SysCtlPeripheralEnable(SYSCTL_PERIPH_UART0);
SysCtlPeripheralEnable(SYSCTL_PERIPH_UART1);
SysCtlPeripheralEnable(SYSCTL_PERIPH_ETH);
//
// Enable the peripherals that should continue to run when the processor
// is sleeping.
//
SysCtlPeripheralSleepEnable(SYSCTL_PERIPH_GPIOA);
SysCtlPeripheralSleepEnable(SYSCTL_PERIPH_GPIOB);
SysCtlPeripheralSleepEnable(SYSCTL_PERIPH_GPIOD);
SysCtlPeripheralSleepEnable(SYSCTL_PERIPH_GPIOF);
SysCtlPeripheralSleepEnable(SYSCTL_PERIPH_UART0);
SysCtlPeripheralSleepEnable(SYSCTL_PERIPH_UART1);
SysCtlPeripheralSleepEnable(SYSCTL_PERIPH_ETH);
//
// Enable peripheral clock gating. Note that this is required in order to
// measure the the processor usage.
//
SysCtlPeripheralClockGating(true);
//
// Set the priorities of the interrupts used by the application.
//
IntPrioritySet(INT_UART0, 0x00);
IntPrioritySet(INT_UART1, 0x00);
IntPrioritySet(INT_ETH, 0x20);
IntPrioritySet(FAULT_SYSTICK, 0x40);
//
// Configure SysTick for a periodic interrupt.
//
SysTickPeriodSet(SysCtlClockGet() / SYSTICKHZ);
SysTickEnable();
SysTickIntEnable();
//
// Enable Port F for Ethernet LEDs.
// LED0 Bit 3 Output
// LED1 Bit 2 Output
//
GPIODirModeSet(GPIO_PORTF_BASE, GPIO_PIN_2 | GPIO_PIN_3, GPIO_DIR_MODE_HW);
GPIOPadConfigSet(GPIO_PORTF_BASE, GPIO_PIN_2 | GPIO_PIN_3,
GPIO_STRENGTH_2MA, GPIO_PIN_TYPE_STD);
//
// Set the link status based on the LED0 signal (which defaults to link
// status in the PHY).
//
g_bLinkStatusUp = GPIOPinRead(GPIO_PORTF_BASE, GPIO_PIN_3) ? false : true;
//
// Initialize the configuration parameter module.
//
ConfigInit();
//
// Get the MAC address from the UART0 and UART1 registers in NV ram.
//
FlashUserGet(&ulUser0, &ulUser1);
//
// Convert the 24/24 split MAC address from NV ram into a MAC address
// array.
//
pucMACAddr[0] = ulUser0 & 0xff;
pucMACAddr[1] = (ulUser0 >> 8) & 0xff;
pucMACAddr[2] = (ulUser0 >> 16) & 0xff;
pucMACAddr[3] = ulUser1 & 0xff;
pucMACAddr[4] = (ulUser1 >> 8) & 0xff;
pucMACAddr[5] = (ulUser1 >> 16) & 0xff;
//
// Initialize the lwIP TCP/IP stack.
//
lwIPInit(pucMACAddr, g_sParameters.ulStaticIP, g_sParameters.ulSubnetMask,
g_sParameters.ulGatewayIP, ((g_sParameters.ucFlags &
CONFIG_FLAG_STATICIP) ? IPADDR_USE_STATIC : IPADDR_USE_DHCP));
//
// Setup the device locator service.
//
LocatorInit();
LocatorMACAddrSet(pucMACAddr);
LocatorAppTitleSet((char *)g_sParameters.ucModName);
//
// Initialize the serial port module.
//
SerialInit();
//
// Initialize the telnet module.
//
TelnetInit();
//
// Initialize the UPnP session.
//
UPnPInit();
//
// Initialize the HTTPD web server.
//
httpd_init();
//
// Configure SSI and CGI processing for our configuration web forms.
//
ConfigWebInit();
//
// Start the remote software update module.
//
SoftwareUpdateInit(SoftwareUpdateRequestCallback);
//
// Wait for an IP address to be assigned to the board before we try to
// initiate any connections.
//
while(!lwIPLocalIPAddrGet())
{
//
// Do nothing until we get our IP address assigned.
//
SysCtlSleep();
}
//
// Initialize the telnet session(s).
//
for(ulLoop = 0; ulLoop < MAX_S2E_PORTS; ulLoop++)
{
//
// Are we to operate as a telnet server?
//
if((g_sParameters.sPort[ulLoop].ucFlags & PORT_FLAG_TELNET_MODE) ==
PORT_TELNET_SERVER)
{
//
// Yes - start listening on the required port.
//
TelnetListen(g_sParameters.sPort[ulLoop].usTelnetLocalPort,
ulLoop);
}
else
{
//
// No - we are a client so initiate a connection to the desired
// IP address using the configured ports.
//
TelnetOpen(g_sParameters.sPort[ulLoop].ulTelnetIPAddr,
g_sParameters.sPort[ulLoop].usTelnetRemotePort,
g_sParameters.sPort[ulLoop].usTelnetLocalPort, ulLoop);
}
}
//
// Main Application Loop (for systems with no RTOS). Run every SYSTICK.
//
while(true)
{
//
// Wait for an event to occur.
//
SysCtlSleep();
//
// Check for an IP update request.
//
if(g_bChangeIPAddress == true)
{
//
// Delay 2 seconds or so to allow the response page to get back
// to the browser before we initiate the IP address change.
//
SysCtlDelay((SysCtlClockGet() / 3) * 2);
//
// Actually update the IP address.
//
g_bChangeIPAddress = false;
ConfigUpdateIPAddress();
}
//
// Check for bootloader request.
//
if((g_bStartBootloader == true) || (g_bFirmwareUpdate == true))
{
//
// Delay a couple of seconds to let any pending web server
// transmission to complete. Each loop within SysCtlDelay is
// 3 instructions long so this delays approximately 2 seconds.
//
SysCtlDelay((SysCtlClockGet() / 3) * 2);
//
// Initiate the Software Update Process in the Ethernet
// Bootloader.
//
SoftwareUpdateBegin();
//
// Should never get here, but stall just in case.
//
while(1)
{
}
}
}
} |
阿莫论坛20周年了!感谢大家的支持与爱护!!
曾经有一段真挚的爱情摆在我的面前,我没有珍惜,现在想起来,还好我没有珍惜……
|