亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频

? 歡迎來到蟲蟲下載站! | ?? 資源下載 ?? 資源專輯 ?? 關于我們
? 蟲蟲下載站

?? main.c

?? 實現(xiàn)了C8051F340單片機依據(jù)SMTP協(xié)議傳輸數(shù)據(jù)
?? C
字號:
//------------------------------------------------------------------------------
// main.c
//------------------------------------------------------------------------------
// Copyright (C) 2005 Silicon Laboratories, Inc.
//
// Date: 05/22/06 16:39:45
// Target: C8051F34x 
// Version: 1.31
//
// Description:
//
//    This file is an example SMTP client.
//    It runs on a C8051F340 connected to a CP2200 via AB4 board.
// 
//    This file contains the main routine, MCU initialization code, and 
//    callback functions used by the TCP/IP Library.
//
// Steps for running this example code:
//
//
//    1. DNS can be used to resolve the name of a mail server to an IP address.
//       To use DNS, set USE_DNS to 1.
//
//    2. DHCP can be used to obtain an IP address and the IP address of a DNS
//       server. To use DHCP, set USE_DHCP to 1.
//
//    3. If DHCP is not used, replace IP_SRC_ADDR in mn_userconst.h with the
//       desired IP address.
//
//    4. If DNS is not used, replace IP_SMTP_ADDR in mn_userconst.h with the
//       address of the SMTP server.
//
//    5. If DNS is used, write the name of the DNS server to mail_server[] in
//       main.c.
//
//    6. Replace the value in to[] with the email address to which the email will
//       be sent.
//
//    7. Connect to the C8051F340.
//
//    8. Compile and build the project code.
//
//    9. Download the code to the C8051F340 and press "Go".
//
//    10. The Ethernet controller will initialize and enter the network with
//       either the IP address specified in IP_SRC_ADDR or the IP address
//       obtained via DHCP.
//
//    11. If USE_DNS is set, the C8051F340 will resolve mail_server[] to an
//       IP address.
//
//    12. The C8051F340 will send two emails to email address to[].
//       One email includes an attachment.
//
//    13. After the emails are sent, mn_server() is called so the user may ping
//       the C8051F340.
//

#include "mn_userconst.h"                      // TCP/IP Library Constants
#include "mn_stackconst.h"                     // TCP/IP Library Constants
#include "mn_errs.h"                           // Library Error Codes
#include "mn_defs.h"                           // Library Type definitions
#include "mn_funcs.h"                          // Library Function Prototypes
#include <c8051F340.h>                         // Device-specific SFR Definitions


//------------------------------------------------------------------------------
// Define Statements
//------------------------------------------------------------------------------
#define  USE_DHCP    1     // If set to 1, the program will use DHCP to acquire
                           // its IP address and the IP address of the
                           // DNS server.

#define  USE_DNS     1       // If set to 1, the program will use DNS to resolve
                           // a named SMTP server to an IP address.


//------------------------------------------------------------------------------
// Function Prototypes
//------------------------------------------------------------------------------

// Initialization Routines
void PORT_Init (void);
void SYSCLK_Init (void);
void EMIF_Init(void);
int establish_network_connection();

// Application Functions
void SMTP(void);

//-----------------------------------------------------------------------------
// Variable Declarations
//-----------------------------------------------------------------------------
byte from[]      = "ETHERNET-DK@domain.com";
byte to[]        = "username@domain.com";
byte subject[]   = "SMTP test";
byte message[]   = "Email sent from C8051F340 using ETHERNET-DK.\r\n";
byte attach[]    = "This is the attachment.\r\n";
byte fname[]     = "ETHERNET-DK.txt";

#if USE_DNS
// This is the name of the mail server. It must be null-terminated.
byte mail_server[] = { 0x03, 'w', 'w', 'w', 0x06, 's', 'i', 'l', 'a', 'b', 's',
                       0x03, 'c', 'o', 'm', 0x00 };

#if !USE_DHCP
// If DNS is not used, the IP address of the DNS server should be placed here.
// It must be null-terminated.
const byte ip_dns_addr_init[] = { 255, 255, 255, 255 };

#endif

#endif

//-----------------------------------------------------------------------------
// Main Routine
//-----------------------------------------------------------------------------
void main(void)
{
   int retval;

   // Disable watchdog timer
   PCA0MD = 0x00;

   // Initialize the MCU
   PORT_Init();
   SYSCLK_Init();
   EMIF_Init();

   while(1)
   {
      // Initialize the TCP/IP stack.
      if (mn_init() < 0)
      {
         // If code execution enters this while(1) loop, the stack failed to initialize.
         // Verify that all boards are connected and powered properly.
         while(1);
      }

      // Connect to the network
      establish_network_connection();

#if USE_DHCP

      // Use DHCP to obtain an IP address.
      if (mn_dhcp_start(PTR_NULL, dhcp_default_lease_time) <= 0)
      {
         // DHCP Error
         // The DHCP server did not assign a valid IP address.
         while(1);

      }

#else

      // If DHCP is not used, override the DHCP settings to use a static address
      dhcp_lease.dhcp_state = DHCP_OK;    // Set DHCP state to OK
      dhcp_lease.infinite_lease = 1;      // Use infinite lease time -
                                          //   will not attempt to re-lease

#endif

      // Send the email via SMTP
      SMTP();

      // Start the Application Layer Services
      // If this routine exits, check the return value for an error code.
      retval = mn_server();

   }
}

//-----------------------------------------------------------------------------
// establish_network_connection
//-----------------------------------------------------------------------------
//
// This function calls mn_ether_init() to initialize the CP2200 and attach to
// the network.
//
// If there is a network connection, the function returns 1.
//
// In the call to mn_ether_init(), NUM_AUTONEG_ATTEMPTS is set to 0, so the
// function will not return until it successfully auto-negotiates.
//
// mn_ether_init() will not be a blocking call if NUM_AUTONEG_ATTEMPTS is set
// to a value greater than 0.
//
int establish_network_connection()
{
   int retval;

   do
   {
      // mn_ether_init() initializes the Ethernet controller.
      // AUTO_NEG indicates that the controller will auto-negotiate.
      retval = mn_ether_init(AUTO_NEG, 0, 0);

      // If there is no link, poll link_status until it sets or the
      // CP2200 resets and then call mn_ether_init() again.
      if (retval == LINK_FAIL)
      {
         while(!link_status && !ether_reset);
      }

      // If retval is less than zero and is not LINK_FAIL, there is a 
      // hardware error.
      else if (retval < 0)
      {
         // Verify that the Ethernet controller is connected and powered properly.
         // Verity that the EMIF has been configured at a speed compatible with the
         //    Ethernet controller.
         while(1);
      }

   }while(retval < 0);

   return (1);

}

//-----------------------------------------------------------------------------
// Application Functions
//-----------------------------------------------------------------------------


//-----------------------------------------------------------------------------
// SMTP
//-----------------------------------------------------------------------------
//
// This function transmits an email using the SMTP protocol.
//
void SMTP(void)
{
   SCHAR socket_no;
   int retval;
   SMTP_INFO_T mail_info;

#if USE_DNS

#if !USE_DHCP
   // If DHCP is used, then the IP address of the DNS server was received
   // from the DHCP server.
   // Otherwise, manually write the address of the DNS server to ip_dns_addr.
   ip_dns_addr[0] = ip_dns_addr_init[0];
   ip_dns_addr[1] = ip_dns_addr_init[1];
   ip_dns_addr[2] = ip_dns_addr_init[2];
   ip_dns_addr[3] = ip_dns_addr_init[3];

#endif

   // Use DNS to obtain the IP address of the mail server
   if(mn_dns_get_addr(&mail_server, ip_smtp_addr) < 0)
      return;

#endif

   socket_no = mn_smtp_start_session(DEFAULT_PORT);

   if (socket_no >= 0)
   {
      // send a message with an attachment
      mail_info.from = from;
      mail_info.to = to;
      mail_info.subject = subject;
      mail_info.message = message;
      mail_info.attachment = attach;
      mail_info.filename = fname;

      retval = mn_smtp_send_mail(socket_no, &mail_info);

      if (retval > 0)
      {
         // send a message without an attachment
         mail_info.from = from;
         mail_info.to = to;
         mail_info.subject = subject;
         mail_info.message = message;
         mail_info.attachment = PTR_NULL;
         mail_info.filename = PTR_NULL;

         retval = mn_smtp_send_mail(socket_no, &mail_info);
      }

      mn_smtp_end_session(socket_no);

      if (retval < 0)
      {
         // There was an error sending the message
         // If the email arrived at its destination but mn_smtp_send_mail
         // returned SMTP_ERROR (-103), it is possible that we did not wait
         // for the response from the SMTP server long enough.
         // Increase socket_wait_ticks in mn_userconst.h to wait longer.
         ;
      }

   }
}


//-----------------------------------------------------------------------------
// Initialization Routines
//-----------------------------------------------------------------------------

//-----------------------------------------------------------------------------
// PORT_Init
//-----------------------------------------------------------------------------
//
// Configure the Interrupts, Crossbar and GPIO ports
//
void PORT_Init (void)
{

   IT01CF = 0x03;                      // Enable Interrupt 0 on P0.3
   TCON &= ~0x01;                      // Make /INT0 level triggered

   XBR0    = 0x01;                     // Enable UART on P0.4(TX) and P0.5(RX)
   XBR1    = 0x40;                     // Enable crossbar and enable
                                       // weak pull-ups

   P0MDOUT |= 0x10;                    // enable UTX as push-pull output
   P1MDOUT |= 0xD8;                    // /WR and /RD are push-pull
                                       // AB4 LEDs are push-pull
   P2MDOUT |= 0xFF;
   P3MDOUT |= 0xFF;
   P4MDOUT |= 0xFF;

}

//-----------------------------------------------------------------------------
// EMIF_Init
//-----------------------------------------------------------------------------
//
// Configure the External Memory Interface for both on and off-chip access.
//
void EMIF_Init (void)
{

   EMI0CF = 0x1B;             // non-muxed mode; split mode
                              // with bank select

   EMI0TC = EMIF_TIMING;      // This constant may be modified
                              // according to SYSCLK to meet the
                              // timing requirements for the CP2200

   EMI0CN = BASE_ADDRESS;     // Page of XRAM accessed by EMIF

}

//-----------------------------------------------------------------------------
// SYSCLK_Init
//-----------------------------------------------------------------------------
//
// This routine initializes the system clock.
//
void SYSCLK_Init (void)
{
   int i;

   OSCICN |= 0x03;                     // Configure internal oscillator for
                                       // its maximum frequency
  
   CLKMUL = 0x00;                      // Reset Clock Multiplier and select
                                       // internal oscillator as input source

   CLKMUL |= 0x80;                     // Enable the Clock Multiplier

   for(i = 0; i < 256; i++);           // Delay at least 5us
   
   CLKMUL |= 0xC0;                     // Initialize the Clock Multiplier
   
   while(!(CLKMUL & 0x20));            // Wait for MULRDY => 1
   
   RSTSRC = 0x06;                      // Enable missing clock detector
                                       // and VDD monitor
   
   FLSCL |= 0x10;                      // Set Flash Scale for 48MHz
   
   CLKSEL |= 0x03;                     // Select output of clock multiplier
                                       // as the system clock.

}

//-----------------------------------------------------------------------------
// ether_reset_low
//-----------------------------------------------------------------------------
//
// This routine drives the reset pin of the ethernet controller low.
//
void ether_reset_low()
{

   P1 &= ~0x01;               // Pull reset low

}

//-----------------------------------------------------------------------------
// ether_reset_high
//-----------------------------------------------------------------------------
//
// This routine places the reset pin in High-Z allowing it to be pulled up 
// using the external pull-up resistor.
//
// Additionally, this routine waits for the reset pin to read high before
// exiting.
//
void ether_reset_high (void)
{

   P1 |= 0x01;               // Allow /RST to rise
   while(!(P1 & 0x01));      // Wait for /RST to go high


}

?? 快捷鍵說明

復制代碼 Ctrl + C
搜索代碼 Ctrl + F
全屏模式 F11
切換主題 Ctrl + Shift + D
顯示快捷鍵 ?
增大字號 Ctrl + =
減小字號 Ctrl + -
亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频
国产成人在线色| 欧美大片国产精品| 日韩免费电影网站| 国产精品素人视频| 亚洲成av人片在线观看无码| 国模套图日韩精品一区二区| 欧美少妇一区二区| ●精品国产综合乱码久久久久| 日韩高清不卡一区| 欧美吻胸吃奶大尺度电影| 欧美经典一区二区| 久久99久久久欧美国产| 欧美丰满美乳xxx高潮www| 最新中文字幕一区二区三区| 国产专区综合网| 日韩久久精品一区| 日本最新不卡在线| 欧美精品tushy高清| 亚洲欧美日韩在线| av不卡在线观看| 欧美国产日韩a欧美在线观看| 毛片基地黄久久久久久天堂| 欧美剧在线免费观看网站| 亚洲综合久久av| 日本高清不卡一区| 亚洲男人的天堂在线观看| 国产精品1区二区.| 久久老女人爱爱| 国产一区不卡视频| 精品久久99ma| 国产一区二区三区四区在线观看| 日韩女同互慰一区二区| 热久久久久久久| 日韩欧美电影在线| 韩国精品一区二区| 久久精品欧美一区二区三区麻豆| 精品一区二区三区免费| 欧美精品一区二区在线播放| 日韩和的一区二区| 欧美一区午夜视频在线观看| 日本vs亚洲vs韩国一区三区二区 | 国产麻豆精品theporn| 日韩精品资源二区在线| 国内偷窥港台综合视频在线播放| 精品国产sm最大网站免费看| 国产成人免费视频一区| 国产精品久久久一本精品| 色综合久久综合网97色综合 | 日韩制服丝袜av| 日韩视频在线你懂得| 精品中文字幕一区二区| 国产无一区二区| 色老综合老女人久久久| 五月天激情综合| 久久亚洲一区二区三区明星换脸 | 久久综合999| av日韩在线网站| 亚洲国产cao| 精品国一区二区三区| 国产成人免费在线视频| 樱花草国产18久久久久| 欧美日韩美女一区二区| 国产一区二区三区免费| 亚洲日本在线天堂| 欧美一区二区三区婷婷月色| 国产精品综合视频| 亚洲黄色av一区| 精品国产乱码91久久久久久网站| bt欧美亚洲午夜电影天堂| 亚洲成人动漫在线免费观看| 久久亚洲精品国产精品紫薇| 欧美三级中文字幕| 久久国产精品色| 亚洲美女一区二区三区| 精品国产乱码久久| 91福利国产成人精品照片| 国内精品国产成人国产三级粉色 | 日本不卡视频在线| 国产精品理论片在线观看| 欧美一区二区性放荡片| 不卡av免费在线观看| 免费在线观看精品| 樱桃视频在线观看一区| 国产日产欧美精品一区二区三区| 欧美三级中文字幕在线观看| 成人h版在线观看| 久久99日本精品| 午夜不卡av在线| 亚洲欧洲三级电影| 国产亚洲女人久久久久毛片| 91精品国产综合久久蜜臀| 91成人在线观看喷潮| 国产宾馆实践打屁股91| 久久精品国产久精国产爱| 夜夜爽夜夜爽精品视频| 亚洲视频在线一区| 国产肉丝袜一区二区| 精品99一区二区| 日韩一区二区三区视频| 欧美日韩一区二区三区在线| 99久久99久久免费精品蜜臀| 粉嫩av一区二区三区在线播放| 美女视频一区二区三区| 日韩av中文字幕一区二区三区| 一区二区三区国产精华| 最新国产成人在线观看| 国产精品视频一二三区| 中文一区二区完整视频在线观看| 精品国产麻豆免费人成网站| 91精品国产综合久久蜜臀| 777久久久精品| 欧美日本一区二区三区四区| 欧美性猛交xxxx黑人交| 日本道精品一区二区三区 | 激情五月婷婷综合| 蜜臀久久久99精品久久久久久| 视频一区免费在线观看| 亚洲一区在线免费观看| 亚洲成人av一区二区三区| 亚洲大片精品永久免费| 日韩精品亚洲专区| 久久精品久久精品| 国产成人一区在线| 99久久久精品| 在线观看视频一区二区| 欧美日韩精品欧美日韩精品一| 欧美三级中文字幕| 日韩亚洲电影在线| 欧美精品一区在线观看| 国产欧美va欧美不卡在线| 亚洲国产成人私人影院tom| 中文字幕亚洲精品在线观看 | jizzjizzjizz欧美| 色婷婷精品久久二区二区蜜臂av| 在线免费观看日本欧美| 欧美日韩精品高清| 精品久久久久久综合日本欧美| 国产婷婷色一区二区三区在线| 国产精品女同互慰在线看| 亚洲色图另类专区| 日本免费在线视频不卡一不卡二| 精品亚洲国内自在自线福利| 成人精品一区二区三区中文字幕 | 国产精品一区二区在线观看网站| 国产成人在线免费观看| 91极品美女在线| 日韩一级黄色大片| 国产精品久久久久久久久图文区| 亚洲精品国产第一综合99久久 | 一区二区免费在线| 日本免费新一区视频| 岛国av在线一区| 欧美高清视频不卡网| 久久综合九色综合欧美就去吻| 最新日韩在线视频| 麻豆精品国产传媒mv男同| 成人免费毛片片v| 4438x成人网最大色成网站| 国产网站一区二区| 天天综合网天天综合色| 国产成人免费高清| 在线不卡欧美精品一区二区三区| 久久蜜桃一区二区| 亚洲午夜精品网| 春色校园综合激情亚洲| 9191国产精品| 亚洲欧美日韩系列| 国产麻豆精品久久一二三| 欧美性猛交xxxx乱大交退制版| 国产午夜精品一区二区三区视频 | 亚洲男人的天堂在线观看| 精品一区二区在线看| 欧美亚洲精品一区| 国产精品国产自产拍高清av | 一区二区视频在线看| 精品无码三级在线观看视频| 欧美性色欧美a在线播放| 国产精品全国免费观看高清| 麻豆国产精品官网| 欧美日韩中文国产| 亚洲日本成人在线观看| 国产一区二区中文字幕| 欧美一区二区三区喷汁尤物| 一级特黄大欧美久久久| 92国产精品观看| 欧美韩日一区二区三区| 激情深爱一区二区| 日韩一区二区在线看片| 午夜精品在线视频一区| 91国内精品野花午夜精品| 成人免费在线视频观看| 成人激情免费电影网址| 国产精品免费看片| 粉嫩欧美一区二区三区高清影视| 久久精品夜色噜噜亚洲a∨| 久久99精品国产麻豆不卡| 日韩精品一区二区在线观看| 日韩av网站在线观看| 91麻豆精品国产91久久久使用方法| 一区二区三区**美女毛片|