虫虫首页|资源下载|资源专辑|精品软件
登录|注册

initial

  • svn单机版使用教程

    Repository 即源码的集中存放处,所有修改后提交的源码就是保存在这里,并在其中记录所有的修改版本,分支版本,版本合并,以及并发修改处理等。SVN最主要的功能是用于团队开发时用的,用于处理源码修改的版本控制和并发修改冲突。对于个人开发来说,虽然不存在并发修改冲突的问题,但个人源码可以使用到SVN的版本控制功能,以便找到开发过程中的版本记录。一般个人没有条件也没必要搭一个独立的服务器来做Repository,在本机的开发过程中误删代码的情况有可能会发生,所以在本机创建一个SVN Repository 还是有必要的。

    标签: svn

    上传时间: 2015-06-23

    上传用户:Huang Jonathan

  • Delphi 泛型容器 TDictionary 的用法 Demo

    Collection of key-value pairs.  TDictionary represents a generic collection of key-value pairs.  This class provides a mapping from a collection of keys to a collection of values. When you create a TDictionary object, you can specify various combinations of initial capacity, equality operation, and initial content.  You can add a key that is associated with a corresponding value with the Add or AddOrSetValue methods. You can remove entries with Remove or Clear, which removes all key-value pairs. Adding or removing a key-value pair and looking up a key are efficient, close to O(1), because keys are hashed. A key must not be nil (though a value may be nil) and there must be an equality comparison operation for keys.  You can test for the presence or keys and values with the TryGetValue, ContainsKey and ContainsValue methods.  The Items property lists all Count dictionary entries. You can also set and get values by indexing the Items property. Setting the value this way overwrites any existing value.  The class TObjectDictionary inherits from TDictionary and provides an automatic mechanism for freeing objects removed from dictionary entries. 

    标签: Delphi 泛型

    上传时间: 2015-07-01

    上传用户:mirage

  • net_tcp.h

    /* ********************************************************************************************************* *                                             uC/TCP-IP V2 *                                      The Embedded TCP/IP Suite * *                          (c) Copyright 2003-2010; Micrium, Inc.; Weston, FL * *               All rights reserved.  Protected by international copyright laws. * *               uC/TCP-IP is provided in source form to registered licensees ONLY.  It is  *               illegal to distribute this source code to any third party unless you receive  *               written permission by an authorized Micrium representative.  Knowledge of  *               the source code may NOT be used to develop a similar product. * *               Please help us continue to provide the Embedded community with the finest  *               software available.  Your honesty is greatly appreciated. * *               You can contact us at www.micrium.com. ********************************************************************************************************* */ /* ********************************************************************************************************* * *                                          NETWORK TCP LAYER *                                   (TRANSMISSION CONTROL PROTOCOL) * * Filename      : net_tcp.h * Version       : V2.10 * Programmer(s) : ITJ ********************************************************************************************************* * Note(s)       : (1) Supports Transmission Control Protocol as described in RFC #793 with the following *                     restrictions/constraints : * *                     (a) TCP Security & Precedence NOT supported               RFC # 793, Section 3.6 * *                     (b) TCP Urgent Data           NOT supported               RFC # 793, Section 3.7 *                                                                                'The Communication of *                                                                                  Urgent Information' * *                     (c) The following TCP options NOT supported :              * *                         (1) Window Scale                                      RFC #1072, Section 2 *                                                                               RFC #1323, Section 2 *                         (2) Selective Acknowledgement (SACK)                  RFC #1072, Section 3 *                                                                               RFC #2018 *                                                                               RFC #2883 *                         (3) TCP Echo                                          RFC #1072, Section 4 *                         (4) Timestamp                                         RFC #1323, Section 3.2 *                         (5) Protection Against Wrapped Sequences (PAWS)       RFC #1323, Section 4 * *                     (d) #### IP-Options-to-TCP-Connection                     RFC #1122, Section 4.2.3.8 *                                Handling NOT           supported * *                     (e) #### ICMP-Error-Message-to-TCP-Connection             RFC #1122, Section 4.2.3.9 *                                Handling NOT currently supported * *                 (2) TCP Layer assumes/requires Network Socket Layer (see 'net_sock.h  MODULE  Note #1a2'). ********************************************************************************************************* */ /*$PAGE*/ /* ********************************************************************************************************* *                                               MODULE * * Note(s) : (1) TCP Layer module is NOT required for UDP-to-Application API configuration. * *               See also 'net_cfg.h  TRANSPORT LAYER CONFIGURATION' *                      & 'net_cfg.h  USER DATAGRAM PROTOCOL LAYER CONFIGURATION'. * *               See also 'net_tcp.h  Note #2'. * *           (2) The following TCP-module-present configuration value MUST be pre-#define'd in  *               'net_cfg_net.h' PRIOR to all other network modules that require TCP Layer *               configuration (see 'net_cfg_net.h  TCP LAYER CONFIGURATION  Note #2b') : * *                   NET_TCP_MODULE_PRESENT ********************************************************************************************************* */ #ifdef   NET_TCP_MODULE_PRESENT                                 /* See Note #2.                                         */ /* ********************************************************************************************************* *                                               EXTERNS ********************************************************************************************************* */ #if ((defined(NET_TCP_MODULE)) && \      (defined(NET_GLOBALS_EXT))) #define  NET_TCP_EXT #else #define  NET_TCP_EXT  extern #endif /*$PAGE*/ /* ********************************************************************************************************* *                                               DEFINES ********************************************************************************************************* */ /* ********************************************************************************************************* *                                         TCP HEADER DEFINES * * Note(s) : (1) The following TCP value MUST be pre-#define'd in 'net_def.h' PRIOR to 'net_buf.h' so that *               the Network Buffer Module can configure maximum buffer header size (see 'net_def.h  TCP *               LAYER DEFINES' & 'net_buf.h  NETWORK BUFFER INDEX & SIZE DEFINES  Note #1') : * *               (a) NET_TCP_HDR_SIZE_MAX                  60        (NET_TCP_HDR_LEN_MAX *                                                                  * NET_TCP_HDR_LEN_WORD_SIZE) * *           (2) Urgent pointer & data NOT supported (see 'net_tcp.h  Note #1b'). ********************************************************************************************************* */ #define  NET_TCP_HDR_LEN_MASK                         0xF000u #define  NET_TCP_HDR_LEN_SHIFT                            12u #define  NET_TCP_HDR_LEN_NONE                              0u #define  NET_TCP_HDR_LEN_MIN                               5u #define  NET_TCP_HDR_LEN_MAX                              15u #define  NET_TCP_HDR_LEN_WORD_SIZE                       CPU_WORD_SIZE_32 #define  NET_TCP_HDR_SIZE_MIN                           (NET_TCP_HDR_LEN_MIN * NET_TCP_HDR_LEN_WORD_SIZE) #if 0                                                           /* See Note #1a.                                        */ #define  NET_TCP_HDR_SIZE_MAX                           (NET_TCP_HDR_LEN_MAX * NET_TCP_HDR_LEN_WORD_SIZE) #endif #define  NET_TCP_HDR_SIZE_TOT_MIN                       (NET_IP_HDR_SIZE_TOT_MIN + NET_TCP_HDR_SIZE_MIN) #define  NET_TCP_HDR_SIZE_TOT_MAX                       (NET_IP_HDR_SIZE_TOT_MAX + NET_TCP_HDR_SIZE_MAX) #define  NET_TCP_PSEUDO_HDR_SIZE                          12u   /*  = sizeof(NET_TCP_PSEUDO_HDR)                        */ #define  NET_TCP_PORT_NBR_RESERVED                       NET_PORT_NBR_RESERVED #define  NET_TCP_PORT_NBR_NONE                           NET_TCP_PORT_NBR_RESERVED #define  NET_TCP_HDR_URG_PTR_NONE                     0x0000u   /* See Note #2.                                         */ /*$PAGE*/ /* ********************************************************************************************************* *                                       TCP HEADER FLAG DEFINES * * Note(s) : (1) See 'TCP HEADER  Note #2' for flag fields. * *           (2) Urgent pointer & data NOT supported (see 'net_tcp.h  Note #1b'). ********************************************************************************************************* */ #define  NET_TCP_HDR_FLAG_MASK                        0x0FFFu #define  NET_TCP_HDR_FLAG_NONE                    DEF_BIT_NONE #define  NET_TCP_HDR_FLAG_RESERVED                    0x0FE0u   /* MUST be '0'.                                         */ #define  NET_TCP_HDR_FLAG_URGENT                  DEF_BIT_05    /* See Note #2.                                         */ #define  NET_TCP_HDR_FLAG_ACK                     DEF_BIT_04 #define  NET_TCP_HDR_FLAG_PUSH                    DEF_BIT_03 #define  NET_TCP_HDR_FLAG_RESET                   DEF_BIT_02 #define  NET_TCP_HDR_FLAG_SYNC                    DEF_BIT_01 #define  NET_TCP_HDR_FLAG_FIN                     DEF_BIT_00 #define  NET_TCP_HDR_FLAG_CLOSE                   NET_TCP_HDR_FLAG_FIN /* ********************************************************************************************************* *                                          TCP FLAG DEFINES ********************************************************************************************************* */                                                                 /* ------------------ NET TCP FLAGS ------------------- */ #define  NET_TCP_FLAG_NONE                        DEF_BIT_NONE #define  NET_TCP_FLAG_USED                        DEF_BIT_00    /* TCP conn cur used; i.e. NOT in free TCP conn pool.   */                                                                 /* ------------------ TCP TX  FLAGS ------------------- */                                                                 /* TCP tx flags copied from TCP hdr flags.              */ #define  NET_TCP_FLAG_TX_FIN                      NET_TCP_HDR_FLAG_FIN #define  NET_TCP_FLAG_TX_CLOSE                    NET_TCP_FLAG_TX_FIN #define  NET_TCP_FLAG_TX_SYNC                     NET_TCP_HDR_FLAG_SYNC #define  NET_TCP_FLAG_TX_RESET                    NET_TCP_HDR_FLAG_RESET #define  NET_TCP_FLAG_TX_PUSH                     NET_TCP_HDR_FLAG_PUSH #define  NET_TCP_FLAG_TX_ACK                      NET_TCP_HDR_FLAG_ACK #define  NET_TCP_FLAG_TX_URGENT                   NET_TCP_HDR_FLAG_URGENT #define  NET_TCP_FLAG_TX_BLOCK                    DEF_BIT_07                                                                 /* ------------------ TCP RX  FLAGS ------------------- */ #define  NET_TCP_FLAG_RX_DATA_PEEK                DEF_BIT_08 #define  NET_TCP_FLAG_RX_BLOCK                    DEF_BIT_15 /*$PAGE*/ /* ********************************************************************************************************* *                                          TCP TYPE DEFINES * * Note(s) : (1) NET_TCP_TYPE_&&& #define values specifically chosen as ASCII representations of the TCP *               types.  Memory displays of TCP types will display with their chosen ASCII names. ********************************************************************************************************* */                                                                 /* ------------------ NET TCP TYPES ------------------- */ #if     (CPU_CFG_ENDIAN_TYPE == CPU_ENDIAN_TYPE_BIG) #define  NET_TCP_TYPE_NONE                        0x4E4F4E45u   /* "NONE" in ASCII.                                     */ #define  NET_TCP_TYPE_CONN                        0x54435020u   /* "TCP " in ASCII.                                     */ #else #if     (CPU_CFG_DATA_SIZE   == CPU_WORD_SIZE_32) #define  NET_TCP_TYPE_NONE                        0x454E4F4Eu   /* "NONE" in ASCII.                                     */ #define  NET_TCP_TYPE_CONN                        0x20504354u   /* "TCP " in ASCII.                                     */ #elif   (CPU_CFG_DATA_SIZE   == CPU_WORD_SIZE_16) #define  NET_TCP_TYPE_NONE                        0x4F4E454Eu   /* "NONE" in ASCII.                                     */ #define  NET_TCP_TYPE_CONN                        0x43542050u   /* "TCP " in ASCII.                                     */ #else                                                           /* Dflt CPU_WORD_SIZE_08.                               */ #define  NET_TCP_TYPE_NONE                        0x4E4F4E45u   /* "NONE" in ASCII.                                     */ #define  NET_TCP_TYPE_CONN                        0x54435020u   /* "TCP " in ASCII.                                     */ #endif #endif /* ********************************************************************************************************* *                                     TCP SEQUENCE NUMBER DEFINES * * Note(s) : (1) TCP initial transmit sequence number is incremented by a fixed value, preferably a large *               prime value or a large value with multiple unique factors. * *               (a) One reasonable TCP initial transmit sequence number increment value example : * *                       65527  =  37 * 23 * 11 * 7 * * *               #### NET_TCP_TX_SEQ_NBR_CTR_INC could be developer-configured in 'net_cfg.h'. * *               See also 'NET_TCP_TX_GET_SEQ_NBR()  Notes #1b2 & #1c2'. ********************************************************************************************************* */ #define  NET_TCP_SEQ_NBR_NONE                              0u #define  NET_TCP_ACK_NBR_NONE                            NET_TCP_SEQ_NBR_NONE #define  NET_TCP_TX_SEQ_NBR_CTR_INC                    65527u   /* See Note #1.                                         */ #define  NET_TCP_ACK_NBR_DUP_WIN_SIZE_SCALE                4 /*$PAGE*/ /* ********************************************************************************************************* *                                    TCP DATA/TOTAL LENGTH DEFINES * * Note(s) : (1) (a) TCP total length #define's (NET_TCP_TOT_LEN)  relate to the total size of a complete *                   TCP packet, including the packet's TCP header.  Note that a complete TCP packet MAY *                   be fragmented in multiple Internet Protocol packets. * *               (b) TCP data  length #define's (NET_TCP_DATA_LEN) relate to the data  size of a complete *                   TCP packet, equal to the total TCP packet length minus its TCP header size.  Note  *                   that a complete TCP packet MAY be fragmented in multiple Internet Protocol packets. ********************************************************************************************************* */                                                                                 /* See Notes #1a & #1b.                 */ #define  NET_TCP_DATA_LEN_MIN                              0u #define  NET_TCP_TOT_LEN_MIN                            (NET_TCP_HDR_SIZE_MIN + NET_TCP_DATA_LEN_MIN) #define  NET_TCP_TOT_LEN_MAX                            (NET_IP_TOT_LEN_MAX   - NET_IP_HDR_SIZE_MIN ) #define  NET_TCP_DATA_LEN_MAX                           (NET_TCP_TOT_LEN_MAX  - NET_TCP_HDR_SIZE_MIN) /*$PAGE*/ /* ********************************************************************************************************* *                                      TCP SEGMENT SIZE DEFINES * * Note(s) : (1) (a) RFC # 879, Section 3 states that the TCP Maximum Segment Size "counts only *                   data octets in the segment, ... not the TCP header or the IP header". * *               (b) RFC #1122, Section 4.2.2.6 requires that : * *                   (1) "The MSS value to be sent in an MSS option must be less than or equal to * *                        (A) MMS_R - 20 * *                        where MMS_R is the maximum size for a transport-layer message that can *                        be received." * *                   (2) "If an MSS option is not received at connection setup, TCP MUST assume a *                        default send MSS of 536 (576 - 40)." * *                   See also 'net_ip.h  IP DATA/TOTAL LENGTH DEFINES  Note #1'. ********************************************************************************************************* */                                                                                         /* See Note #1.                 */ #define  NET_TCP_MAX_SEG_SIZE_DFLT                      (NET_IP_MAX_DATAGRAM_SIZE_DFLT - NET_IP_HDR_SIZE_MIN - NET_TCP_HDR_SIZE_MIN) #define  NET_TCP_MAX_SEG_SIZE_DFLT_RX                    NET_TCP_DATA_LEN_MAX           /* See Note #1b1.               */ #define  NET_TCP_MAX_SEG_SIZE_DFLT_TX                    NET_TCP_MAX_SEG_SIZE_DFLT      /* See Note #1b2.               */ #define  NET_TCP_MAX_SEG_SIZE_NONE                         0u #define  NET_TCP_MAX_SEG_SIZE_MIN                        NET_TCP_MAX_SEG_SIZE_DFLT #define  NET_TCP_MAX_SEG_SIZE_MAX                        NET_TCP_DATA_LEN_MAX #define  NET_TCP_SEG_LEN_MIN                             NET_TCP_DATA_LEN_MIN #define  NET_TCP_SEG_LEN_MAX                             NET_TCP_DATA_LEN_MAX #define  NET_TCP_SEG_LEN_SYNC                              1u #define  NET_TCP_SEG_LEN_FIN                               1u #define  NET_TCP_SEG_LEN_CLOSE                           NET_TCP_SEG_LEN_FIN #define  NET_TCP_SEG_LEN_ACK                               0u #define  NET_TCP_SEG_LEN_RESET                             0u #define  NET_TCP_SEG_LEN_PROBE                             0u #define  NET_TCP_DATA_LEN_TX_SYNC                          0u #define  NET_TCP_DATA_LEN_TX_FIN                           0u #define  NET_TCP_DATA_LEN_TX_CLOSE                       NET_TCP_DATA_LEN_TX_FIN #define  NET_TCP_DATA_LEN_TX_ACK                           0u #define  NET_TCP_DATA_LEN_TX_PROBE_NO_DATA                 0u #define  NET_TCP_DATA_LEN_TX_PROBE_DATA                    1u #define  NET_TCP_DATA_LEN_TX_RESET                         0u #define  NET_TCP_TX_PROBE_DATA                          0x00u /* ********************************************************************************************************* *                                       TCP WINDOW SIZE DEFINES * * Note(s) : (1) Although NO RFC specifies the absolute minimum TCP connection window size value allowed, *               RFC #793, Section 3.7 'Data Communication : Managing the Window' states that for "the *               window ... there is an assumption that this is related to the currently available data *               buffer space available for this connection". ********************************************************************************************************* */ #define  NET_TCP_WIN_SIZE_NONE                             0u #define  NET_TCP_WIN_SIZE_MIN                            NET_TCP_MAX_SEG_SIZE_MIN #define  NET_TCP_WIN_SIZE_MAX                            DEF_INT_16U_MAX_VAL /*$PAGE*/ /* ********************************************************************************************************* *                                     TCP HEADER OPTIONS DEFINES * * Note(s) : (1) See the following RFC's for TCP options summary : * *               (a) RFC # 793, Section  3.1 'Header Format : Options' *               (b) RFC #1122; Sections 4.2.2.5, 4.2.2.6 * *           (2) TCP option types are encoded in the first octet for each TCP option as follows : * *                           -------- *                           | TYPE | *                           -------- * *               The TCP option type value determines the TCP option format : * *               (a) The following TCP option types are single-octet TCP options -- i.e. the option type *                   octet is the ONLY octet for the TCP option. * *                   (1) TYPE =  0   End of Options List *                   (2) TYPE =  1   No Operation * * *               (b) All other TCP options MUST be multi-octet TCP options (see RFC #1122, Section 4.2.2.5) : * *                           ------------------------------ *                           | TYPE | LEN  |   TCP OPT    | *                           ------------------------------ * *                       where  *                               TYPE        Indicates the specific TCP option type *                               LEN         Indicates the total    TCP option length, in octets, including  *                                                the option type & the option length octets *                               TCP OPT     Additional TCP option octets, if any, that contain the remaining *                                                TCP option information * *                   The following TCP option types are multi-octet TCP options where the option's second *                   octet specify the total TCP option length, in octets, including the option type & the *                   option length octets : * *                   (1) TYPE =  2   Maximum Segment Size        See RFC # 793, Section  3.1 'Header Format : *                                                                   Options : Maximum Segment Size'; *                                                                   RFC #1122, Section 4.2.2.6; *                                                                   RFC # 879, Section 3 * *                   (2) TYPE =  3   Window  Scale               See 'net_tcp.h  Note #1c1' *                   (3) TYPE =  4   SACK Allowed                See 'net_tcp.h  Note #1c2' *                   (4) TYPE =  5   SACK Option                 See 'net_tcp.h  Note #1c2' *                   (5) TYPE =  6   Echo Request                See 'net_tcp.h  Note #1c3' *                   (6) TYPE =  7   Echo Reply                  See 'net_tcp.h  Note #1c3' *                   (7) TYPE =  8   Timestamp                   See 'net_tcp.h  Note #1c4' * *           (3) TCP header allows for a maximum option list length of 40 octets : * *                   NET_TCP_HDR_OPT_SIZE_MAX = NET_TCP_HDR_SIZE_MAX - NET_TCP_HDR_SIZE_MIN * *                                            = 60 - 20 * *                                            = 40 * *           (4) 'NET_TCP_OPT_SIZE'  MUST be pre-defined PRIOR to all definitions that require TCP option  *                size data type. ********************************************************************************************************* */ /*$PAGE*/ #define  NET_TCP_HDR_OPT_END_LIST                          0u #define  NET_TCP_HDR_OPT_NOP                               1u #define  NET_TCP_HDR_OPT_MAX_SEG_SIZE                      2u #define  NET_TCP_HDR_OPT_WIN_SCALE                         3u #define  NET_TCP_HDR_OPT_SACK_PERMIT                       4u #define  NET_TCP_HDR_OPT_SACK                              5u #define  NET_TCP_HDR_OPT_ECHO_REQ                          6u #define  NET_TCP_HDR_OPT_ECHO_REPLY                        7u #define  NET_TCP_HDR_OPT_TS                                8u #define  NET_TCP_HDR_OPT_PAD                             NET_TCP_HDR_OPT_END_LIST #define  NET_TCP_HDR_OPT_LEN_END_LIST                      1u #define  NET_TCP_HDR_OPT_LEN_NOP                           1u #define  NET_TCP_HDR_OPT_LEN_MAX_SEG_SIZE                  4u #define  NET_TCP_HDR_OPT_LEN_WIN_SCALE                     3u #define  NET_TCP_HDR_OPT_LEN_SACK_PERMIT                   2u #define  NET_TCP_HDR_OPT_LEN_ECHO_REQ                      6u #define  NET_TCP_HDR_OPT_LEN_ECHO_REPLY                    6u #define  NET_TCP_HDR_OPT_LEN_TS                           10u #define  NET_TCP_HDR_OPT_LEN_SACK_MIN                      6u #define  NET_TCP_HDR_OPT_LEN_SACK_MAX                     38u #define  NET_TCP_HDR_OPT_LEN_MIN                           1u #define  NET_TCP_HDR_OPT_LEN_MIN_LEN                       2u #define  NET_TCP_HDR_OPT_LEN_MAX                          38u typedef  CPU_INT32U  NET_TCP_OPT_SIZE;                          /* TCP opt size data type (see Note #4).                */ #define  NET_TCP_HDR_OPT_SIZE_WORD               (sizeof(NET_TCP_OPT_SIZE)) #define  NET_TCP_HDR_OPT_SIZE_MAX                       (NET_TCP_HDR_SIZE_MAX - NET_TCP_HDR_SIZE_MIN) #define  NET_TCP_HDR_OPT_NBR_MIN                           0u #define  NET_TCP_HDR_OPT_NBR_MAX                        (NET_TCP_HDR_OPT_SIZE_MAX / NET_TCP_HDR_OPT_SIZE_WORD) #define  NET_TCP_HDR_OPT_IX                              NET_TCP_HDR_SIZE_MIN /*$PAGE*/ /* ********************************************************************************************************* *                                TCP OPTION CONFIGURATION TYPE DEFINES * * Note(s) : (1) NET_TCP_OPT_CFG_TYPE_&&& #define values specifically chosen as ASCII representations of  *               the TCP option configuration types.  Memory displays of TCP option configuration buffers  *               will display the TCP option configuration TYPEs with their chosen ASCII names. ********************************************************************************************************* */                                                                 /* ---------------- TCP OPT CFG TYPES ----------------- */ #if     (CPU_CFG_ENDIAN_TYPE == CPU_ENDIAN_TYPE_BIG) #define  NET_TCP_OPT_CFG_TYPE_NONE                0x4E4F4E45u   /* "NONE" in ASCII.                                     */ #define  NET_TCP_OPT_CFG_TYPE_MAX_SEG_SIZE        0x4D535320u   /* "MSS " in ASCII.                                     */ #define  NET_TCP_OPT_CFG_TYPE_WIN_SCALE           0x57494E20u   /* "WIN " in ASCII (see 'net_tcp.h  Note #1c1').        */ #define  NET_TCP_OPT_CFG_TYPE_SACK_PERMIT         0x53434B50u   /* "SCKP" in ASCII (see 'net_tcp.h  Note #1c2').        */ #define  NET_TCP_OPT_CFG_TYPE_SACK                0x5341434Bu   /* "SACK" in ASCII (see 'net_tcp.h  Note #1c2').        */ #define  NET_TCP_OPT_CFG_TYPE_ECHO_REQ            0x45524551u   /* "EREQ" in ASCII (see 'net_tcp.h  Note #1c3').        */ #define  NET_TCP_OPT_CFG_TYPE_ECHO_REPLY          0x4543484Fu   /* "ECHO" in ASCII (see 'net_tcp.h  Note #1c3').        */ #define  NET_TCP_OPT_CFG_TYPE_TS                  0x54532020u   /* "TS  " in ASCII (see 'net_tcp.h  Note #1c4').        */ #else #if     (CPU_CFG_DATA_SIZE   == CPU_WORD_SIZE_32) #define  NET_TCP_OPT_CFG_TYPE_NONE                0x454E4F4Eu   /* "NONE" in ASCII.                                     */ #define  NET_TCP_OPT_CFG_TYPE_MAX_SEG_SIZE        0x2053534Du   /* "MSS " in ASCII.                                     */ #define  NET_TCP_OPT_CFG_TYPE_WIN_SCALE           0x204E4957u   /* "WIN " in ASCII (see 'net_tcp.h  Note #1c1').        */ #define  NET_TCP_OPT_CFG_TYPE_SACK_PERMIT         0x504B4353u   /* "SCKP" in ASCII (see 'net_tcp.h  Note #1c2').        */ #define  NET_TCP_OPT_CFG_TYPE_SACK                0x4B434153u   /* "SACK" in ASCII (see 'net_tcp.h  Note #1c2').        */ #define  NET_TCP_OPT_CFG_TYPE_ECHO_REQ            0x51455245u   /* "EREQ" in ASCII (see 'net_tcp.h  Note #1c3').        */ #define  NET_TCP_OPT_CFG_TYPE_ECHO_REPLY          0x4F484345u   /* "ECHO" in ASCII (see 'net_tcp.h  Note #1c3').        */ #define  NET_TCP_OPT_CFG_TYPE_TS                  0x20205354u   /* "TS  " in ASCII (see 'net_tcp.h  Note #1c4').        */ #elif   (CPU_CFG_DATA_SIZE   == CPU_WORD_SIZE_16) #define  NET_TCP_OPT_CFG_TYPE_NONE                0x4F4E454Eu   /* "NONE" in ASCII.                                     */ #define  NET_TCP_OPT_CFG_TYPE_MAX_SEG_SIZE        0x534D2053u   /* "MSS " in ASCII.                                     */ #define  NET_TCP_OPT_CFG_TYPE_WIN_SCALE           0x4957204Eu   /* "WIN " in ASCII (see 'net_tcp.h  Note #1c1').        */ #define  NET_TCP_OPT_CFG_TYPE_SACK_PERMIT         0x4353504Bu   /* "SCKP" in ASCII (see 'net_tcp.h  Note #1c2').        */ #define  NET_TCP_OPT_CFG_TYPE_SACK                0x41534B43u   /* "SACK" in ASCII (see 'net_tcp.h  Note #1c2').        */ #define  NET_TCP_OPT_CFG_TYPE_ECHO_REQ            0x52455145u   /* "EREQ" in ASCII (see 'net_tcp.h  Note #1c3').        */ #define  NET_TCP_OPT_CFG_TYPE_ECHO_REPLY          0x43454F48u   /* "ECHO" in ASCII (see 'net_tcp.h  Note #1c3').        */ #define  NET_TCP_OPT_CFG_TYPE_TS                  0x53542020u   /* "TS  " in ASCII (see 'net_tcp.h  Note #1c4').        */ #else                                                           /* Dflt CPU_WORD_SIZE_08.                               */ #define  NET_TCP_OPT_CFG_TYPE_NONE                0x4E4F4E45u   /* "NONE" in ASCII.                                     */ #define  NET_TCP_OPT_CFG_TYPE_MAX_SEG_SIZE        0x4D535320u   /* "MSS " in ASCII.                                     */ #define  NET_TCP_OPT_CFG_TYPE_WIN_SCALE           0x57494E20u   /* "WIN " in ASCII (see 'net_tcp.h  Note #1c1').        */ #define  NET_TCP_OPT_CFG_TYPE_SACK_PERMIT         0x53434B50u   /* "SCKP" in ASCII (see 'net_tcp.h  Note #1c2').        */ #define  NET_TCP_OPT_CFG_TYPE_SACK                0x5341434Bu   /* "SACK" in ASCII (see 'net_tcp.h  Note #1c2').        */ #define  NET_TCP_OPT_CFG_TYPE_ECHO_REQ            0x45524551u   /* "EREQ" in ASCII (see 'net_tcp.h  Note #1c3').        */ #define  NET_TCP_OPT_CFG_TYPE_ECHO_REPLY          0x4543484Fu   /* "ECHO" in ASCII (see 'net_tcp.h  Note #1c3').        */ #define  NET_TCP_OPT_CFG_TYPE_TS                  0x54532020u   /* "TS  " in ASCII (see 'net_tcp.h  Note #1c4').        */ #endif #endif /*$PAGE*/ /* ********************************************************************************************************* *                                   TCP CONNECTION TIMEOUT DEFINES * * Note(s) : (1) (a) (1) RFC #1122, Section 4.2.2.13 'DISCUSSION' states that "the graceful close algorithm *                       of TCP requires that the connection state remain defined on (at least) one end of *                       the connection, for a timeout period of 2xMSL ... During this period, the (remote  *                       socket, local socket) pair that defines the connection is busy and cannot be reused". * *                   (2) The following sections reiterate that the TIME-WAIT state timeout scalar is two *                       maximum segment lifetimes (2 MSL) : * *                       (A) RFC #793, Section 3.9 'Event Processing : SEGMENT ARRIVES : *                               Check Sequence Number : TIME-WAIT STATE' *                       (B) RFC #793, Section 3.9 'Event Processing : SEGMENT ARRIVES : *                               Check FIN Bit         : TIME-WAIT STATE' * *               (b) (1) RFC #793, Section 3.3 'Sequence Numbers : Knowing When to Keep Quiet' states that *                       "the Maximum Segment Lifetime (MSL) is ... to be 2 minutes.  This is an engineering *                       choice, and may be changed if experience indicates it is desirable to do so". * *                   (2) Microsoft Corporation's Windows XP defaults MSL to 15 seconds. ********************************************************************************************************* */                                                                                     /* Max seg timeout (see Note #1b) : */ #define  NET_TCP_CONN_TIMEOUT_MAX_SEG_MIN_SEC   (  0u                           )   /* ... min  =  0 seconds            */ #define  NET_TCP_CONN_TIMEOUT_MAX_SEG_MAX_SEC   (  2u * DEF_TIME_NBR_SEC_PER_MIN)   /* ... max  =  2 minutes            */ #define  NET_TCP_CONN_TIMEOUT_MAX_SEG_DFLT_SEC  ( 15u                           )   /* ... dflt = 15 seconds            */ #define  NET_TCP_CONN_TIMEOUT_MAX_SEG_SCALAR       2u                               /* ... scalar (see Note #1a).       */ #define  NET_TCP_CONN_TIMEOUT_CONN_DFLT_SEC     (120u * DEF_TIME_NBR_SEC_PER_MIN)   /* Dflt conn timeout = 120 minutes  */ #define  NET_TCP_CONN_TIMEOUT_USER_DFLT_SEC     ( 30u * DEF_TIME_NBR_SEC_PER_MIN)   /* Dflt user timeout =  30 minutes  */ /*$PAGE*/ /* ********************************************************************************************************* *                                        TCP CONNECTION STATES * * Note(s) : (1) See the following RFC's for TCP state machine summary : * *               (a) RFC # 793; Sections 3.2, 3.4, 3.5, 3.9 *               (b) RFC #1122; Sections 4.2.2.8, 4.2.2.10, 4.2.2.11, 4.2.2.13, 4.2.2.18, 4.2.2.20 * *           (2) (a) #### Additional closing-data-available state used for closing connections to allow the *                   application layer to receive any remaining data. * *                   See also 'net_tcp.c  NetTCP_RxPktConnHandlerFinWait1()  Note #2f5A2', *                            'net_tcp.c  NetTCP_RxPktConnHandlerFinWait2()  Note #2f5B', *                            'net_tcp.c  NetTCP_RxPktConnHandlerClosing()   Note #2d2B2a1B', *                          & 'net_tcp.c  NetTCP_RxPktConnHandlerLastAck()   Note #2d2A1b'. ********************************************************************************************************* */ #define  NET_TCP_CONN_STATE_NONE                           0u #define  NET_TCP_CONN_STATE_FREE                           1u #define  NET_TCP_CONN_STATE_CLOSED                        10u #define  NET_TCP_CONN_STATE_LISTEN                        20u #define  NET_TCP_CONN_STATE_SYNC_RXD                      30u #define  NET_TCP_CONN_STATE_SYNC_RXD_PASSIVE              31u #define  NET_TCP_CONN_STATE_SYNC_RXD_ACTIVE               32u #define  NET_TCP_CONN_STATE_SYNC_TXD                      35u #define  NET_TCP_CONN_STATE_CONN                          40u #define  NET_TCP_CONN_STATE_FIN_WAIT_1                    50u #define  NET_TCP_CONN_STATE_FIN_WAIT_2                    51u #define  NET_TCP_CONN_STATE_CLOSING                       52u #define  NET_TCP_CONN_STATE_TIME_WAIT                     53u #define  NET_TCP_CONN_STATE_CLOSE_WAIT                    55u #define  NET_TCP_CONN_STATE_LAST_ACK                      56u #define  NET_TCP_CONN_STATE_CLOSING_DATA_AVAIL            59u   /* See Note #2a.                                        */ /* ********************************************************************************************************* *                                     TCP CONNECTION QUEUE STATES ********************************************************************************************************* */ #define  NET_TCP_RX_Q_STATE_NONE                           0u #define  NET_TCP_RX_Q_STATE_CLOSED                       100u #define  NET_TCP_RX_Q_STATE_CLOSING                      101u #define  NET_TCP_RX_Q_STATE_SYNC                         110u #define  NET_TCP_RX_Q_STATE_CONN                         111u #define  NET_TCP_TX_Q_STATE_NONE                           0u #define  NET_TCP_TX_Q_STATE_CLOSED                       200u #define  NET_TCP_TX_Q_STATE_CLOSING                      201u #define  NET_TCP_TX_Q_STATE_SYNC                         210u #define  NET_TCP_TX_Q_STATE_CONN                         211u #define  NET_TCP_TX_Q_STATE_SUSPEND                      215u #define  NET_TCP_TX_Q_STATE_CLOSED_SUSPEND               220u #define  NET_TCP_TX_Q_STATE_CLOSING_SUSPEND              221u /*$PAGE*/ /* ********************************************************************************************************* *                                     TCP CONNECTION CODE DEFINES **************

    标签: tcp uCOS-II

    上传时间: 2015-11-22

    上传用户:the same kong

  • 课程与教学的基本原理

    课程与教学的基本原理,泰勒,经验,活动,我们如何思维。。。。     资料搜索    代码搜索    热门搜索:fpga51单片机protel99se机器人linux 单片机 dsp armProteusmat

    标签: 泰勒

    上传时间: 2015-12-08

    上传用户:Izaya

  • PCI 总线学习笔记

    一、地址映射与数据传输 二、PCI9054的基本知识 三、PCI9054的寄存器之间的关系

    标签: PCI 总线学习笔记

    上传时间: 2016-02-15

    上传用户:4722656

  • tas3204

    The TAS3204 is a highly-integrated audio system-on-chip (SOC) consisting of a fully-programmable, 48-bit digital audio processor, a 3:1 stereo analog input MUX, four ADCs, four DACs, and other analog functionality. The TAS3204 is programmable with the graphical PurePath Studio™ suite of DSP code development software. PurePath Studio is a highly intuitive, drag-and-drop environment that minimizes software development effort while allowing the end user to utilize the power and flexibility of the TAS3204’s digital audio processing core. TAS3204 processing capability includes speaker equalization and crossover, volume/bass/treble control, signal mixing/MUXing/splitting, delay compensation, dynamic range compression, and many other basic audio functions. Audio functions such as matrix decoding, stereo widening, surround sound virtualization and psychoacoustic bass boost are also available with either third-party or TI royalty-free algorithms. The TAS3204 contains a custom-designed, fully-programmable 135-MHz, 48-bit digital audio processor. A 76-bit accumulator ensures that the high precision necessary for quality digital audio is maintained during arithmetic operations. Four differential 102 dB DNR ADCs and four differential 105 dB DNR DACs ensure that high quality audio is maintained through the whole signal chain as well as increasing robustness against noise sources such as TDMA interference. The TAS3204 is composed of eight functional blocks: Clocking System Digital Audio Interface Analog Audio Interface Power supply Clocks, digital PLL I2C control interface 8051 MCUcontroller Audio DSP – digital audio processing 特性 Digital Audio Processor Fully Programmable With the Graphical, Drag-and-Drop PurePath Studio™ Software Development Environment 135-MHz Operation 48-Bit Data Path With 76-Bit Accumulator Hardware Single-Cycle Multiplier (28 × 48)

    标签: 3204 tas

    上传时间: 2016-05-06

    上传用户:fagong

  • CNC初级教程

    频道 劲爆,看《欢乐颂》第二季 上传 书房 登录 注册 菜单 收藏到书房下载文档 上一页  /386 下一页     全屏    < 返回首页  CNC初级教程/FANUC学校讲义 顶 8 踩 0 浏览 1,196 收藏 89 评论 1 加入豆单 举报 手机观看

    标签: CNC 教程

    上传时间: 2016-05-16

    上传用户:kim123

  • 32feet.NET 3.5 Bluetooth coding

    32feet.NET is a shared-source project to make personal area networking technologies such as Bluetooth, Infrared (IrDA) and more, easily accessible from .NET code. Supports desktop, mobile or embedded systems. 32feet.NET is free for commercial or non-commercial use. If you use the binaries you can just use the library as-is, if you make modifications to the source you need to include the 32feet.NET License.txt document and ensure the file headers are not modified/removed. The project currently consists of the following libraries:- Bluetooth IrDA Object Exchange Bluetooth support requires a device with either the Microsoft, Widcomm, BlueSoleil, or Stonestreet One Bluetopia Bluetooth stack. Requires .NET Compact Framework v3.5 or above and Windows CE.NET 4.2 or above, or .NET Framework v3.5 for desktop Windows XP, Vista, 7 and 8. A subset of functionality is available for Windows Phone 8 and Windows Embedded Handheld 8 in the InTheHand.Phone.Bluetooth.dll library.

    标签: feet 3.5 NET 32

    上传时间: 2016-07-06

    上传用户:magister2016

  • 三种SMA接口pcb封装

    三种SMA接口pcb封装 捕获1.PNG (16.1 KB, 下载次数: 86) 捕获2.PNG (17.35 KB, 下载次数: 39) 捕获3.PNG (19.16 KB, 下载次数: 37)

    标签: SMA pcb 接口 封装

    上传时间: 2017-03-06

    上传用户:qjjjjwqvc

  • 12345

    /****************temic*********t5557***********************************/    #include   <at892051.h>     #include   <string.h>    #include   <intrins.h>     #include   <stdio.h>     #define    uchar    unsigned char     #define    uint     unsigned int     #define    ulong    unsigned long     //STC12C2051AD的SFR定义     sfr  WDT_CONTR = 0xe1;//stc2051的看门狗??????     /**********全局常量************/    //写卡的命令     #define    write_command0       0//写密码     #define    write_command1       1//写配置字     #define    write_command2       2//密码写数据     #define    write_command3       3//唤醒     #define    write_command4       4//停止命令     #define    TRUE       1     #define    FALSE      0     #define    OK         0     #define    ERROR      255     //读卡的时间参数us     #define ts_min          250//270*11.0592/12=249//取近似的整数     #define ts_max          304//330*11.0592/12=304     #define t1_min          73//90*11.0592/12=83:-10调整     #define t1_max          156//180*11.0592/12=166     #define t2_min          184//210*11.0592/12=194     #define t2_max          267//300*11.0592/12=276     //***********不采用中断处理:采用查询的方法读卡时关所有中断****************/     sbit p_U2270B_Standby = P3^5;//p_U2270B_Standby PIN=13     sbit p_U2270B_CFE = P3^3;//p_U2270B_CFE     PIN=6     sbit p_U2270B_OutPut = P3^7;//p_U2270B_OutPut  PIN=2     sbit wtd_sck = P1^7;//SPI总线     sbit wtd_si = P1^3;    sbit wtd_so = P1^2;    sbit iic_data = P1^2;//lcd IIC     sbit iic_clk = P1^7;    sbit led_light = P1^6;//测试绿灯     sbit led_light1 = P1^5;//测试红灯     sbit led_light_ok  = P1^1;//读卡成功标志     sbit fengmingqi = P1^5;    /***********全局变量************************************/       uchar data Nkey_a[4] = {0xA0, 0xA1, 0xA2, 0xA3};//初始密码             //uchar idata card_snr[4];   //配置字     uchar data bankdata[28] = {1,2,3,4,5,6,7,1,2,3,4,5,6,7,1,2,3,4,5,6,7,1,2,3,4,5,6,7};     //存储卡上用户数据(1-7)7*4=28     uchar data cominceptbuff[6] = {1,2,3,4,5,6};//串口接收数组ram     uchar command; //第一个命令     uchar command1;//     //uint  temp;     uchar j,i;    uchar myaddr = 8;    //uchar ywqz_count,time_count;             //ywqz jishu:     uchar bdata DATA;    sbit BIT0 = DATA^0;    sbit BIT1 = DATA^1;    sbit BIT2 = DATA^2;    sbit BIT3 = DATA^3;    sbit BIT4 = DATA^4;    sbit BIT5 = DATA^5;    sbit BIT6 = DATA^6;    sbit BIT7 = DATA^7;    uchar bdata DATA1;    sbit BIT10 = DATA1^0;    sbit BIT11 = DATA1^1;    sbit BIT12 = DATA1^2;    sbit BIT13 = DATA1^3;    sbit BIT14 = DATA1^4;    sbit BIT15 = DATA1^5;    sbit BIT16 = DATA1^6;    sbit BIT17 = DATA1^7;    bit i_CurrentLevel;//i_CurrentLevel  BIT 00H(Saves current level of OutPut pin of U2270B)     bit timer1_end;    bit read_ok = 0;    //缓存定时值,因用同一个定时器     union HLint { uint W;    struct   {    uchar H;uchar L;   }   B; };//union HLint idata a     union HLint data a;    //缓存定时值,因用同一个定时器     union HLint0 { uint W;    struct {   uchar H;   uchar L; } B; };//union HLint idata a     union HLint0 data b;    /**********************函数原型*****************/    //读写操作     void f_readcard(void);//全部读出1~7 AOR唤醒     void f_writecard(uchar x);//根据命令写不同的内容和操作     void f_clearpassword(void);//清除密码     void f_changepassword(void);//修改密码     //功能子函数     void write_password(uchar data *data p);//写初始密码或数据     void write_block(uchar x,uchar data *data p);//不能用通用指针     void write_bit(bit x);//写位     /*子函数区*****************************************************/    void delay_2(uint x)    //延时,时间x*10us@12mhz,最小20us@12mhz     {    x--; x--;    while(x)    {      _nop_();      _nop_();      x--;    }    _nop_();//WDT_CONTR=0X3C;不能频繁的复位     _nop_();    }    /////////////////////////////////////////////////////////////////////     void initial(void)    {    SCON = 0x50; //串口方式1,允许接收     //SCON  =0x50;     //01010000B:10位异步收发,波特率可变,SM2=0不用接收到有效停止位才RI=1,     //REN=1允许接收     TMOD = 0x21; //定时器1 定时方式2(8位),定时器0 定时方式1(16位)     TCON = 0x40; //设定时器1 允许开始计时(IT1=1)     TH1 = 0xfD;  //FB 18.432MHz 9600 波特率     TL1 = 0xfD;  //fd 11.0592 9600     IE = 0X90;     //EA=ES=1     TR1 = 1;     //启动定时器     WDT_CONTR = 0x3c;//使能看门狗     p_U2270B_Standby = 0;//单电源     PCON = 0x00;    IP = 0x10;//uart you xian XXXPS PT1 PX1 PT0 PX0     led_light1 = 1;    led_light = 0;    p_U2270B_OutPut = 1;    }    /************************************************/    void f_readcard()//读卡     {    EA = 0;//全关,防止影响跳变的定时器计时     WDT_CONTR = 0X3C;//喂狗     p_U2270B_CFE = 1;//      delay_2(232);  //>2.5ms            /*   //   aor    用唤醒功能来防碰撞   p_U2270B_CFE = 0; delay_2(18);//start gap>150us   write_bit(1);//10=操作码读0页   write_bit(0);       write_password(&bankdata[24]);//密码block7   p_U2270B_CFE =1 ;//    delay_2(516);//编程及确认时间5.6ms   */    WDT_CONTR = 0X3C;//喂狗     led_light = 0;    b.W = 0;    while(!(read_ok == 1))    {             //while(p_U2270B_OutPut);//等一个稳定的低电平?超时判断?              while(!p_U2270B_OutPut);//等待上升沿的到来同步信号检测1       TR0 = 1;      //deng xia jiang       while(p_U2270B_OutPut);//等待下降沿       TR0 = 0;   a.B.H = TH0;   a.B.L = TL0;   TH0 = TL0 = 0;   TR0 = 1;//定时器晚启动10个周期       //同步头       if((324 < a.W) && (a.W < 353)) ;//检测同步信号1                  else     {     TR0 = 0;     TH0 = TL0 = 0;     goto read_error;    }      //等待上升沿        while(!p_U2270B_OutPut);   TR0 = 0;   a.B.H = TH0;   a.B.L = TL0;   TH0 = TL0 = 0;   TR0 = 1;//b.N1<<=8;            if(a.B.L < 195);//0.5p       else     {     TR0 = 0;     TH0 = TL0 = 0;     goto read_error;    }      //读0~7块的数据       for(j = 0;j < 28;j++)      {       //uchar i;                  for(i = 0;i < 16;i++)//8个位        {        //等待下降沿的到来         while(p_U2270B_OutPut);                TR0 = 0;     a.B.H = TH0;     a.B.L = TL0;     TH0 = TL0 = 0;     TR0 = 1;              if(t2_max < a.W/*)&&(a.W < t2_max)*/)//1P          {         b.W >>= 2;//先左移再赋值          b.B.L += 0xc0;                             i++;        }        else if(t1_min < a.B.L/*)&&(a.B.L < t1_max)*/)//0.5p         {         b.W >>= 1;         b.B.L += 0x80;                           }        else      {      TR0 = 0;      TH0 = TL0 = 0;      goto read_error;     }        i++;        while(!p_U2270B_OutPut);//上升                   TR0 = 0;     a.B.H = TH0;     a.B.L = TL0;     TH0 = TL0 = 0;     TR0 = 1;                      if(t2_min < a.W/*)&&(a.W < t2_max)*/)//1P          {         b.W >>= 2;         i++;        }        else if(t1_min < a.B.L/*a.W)&&(a.B.L < t1_max)*/)//0.5P         //else if(!(a.W==0))         {         b.W >>= 1;         //temp+=0x00;          //led_light1=0;led_light=1;delay_2(40000);         }        else      {      TR0 = 0;      TH0 = TL0 = 0;      goto read_error;     }        i++;       }       //取出奇位        DATA = b.B.L;       BIT13 = BIT7;    BIT12 = BIT5;    BIT11 = BIT3;    BIT10 = BIT1;       DATA = b.B.H;       BIT17 = BIT7;    BIT16 = BIT5;    BIT15 = BIT3;    BIT14 = BIT1;       bankdata[j] = DATA1;      }              read_ok = 1;//读卡完成了     read_error:    _nop_();    }       }    /***************************************************/    void f_writecard(uchar x)//写卡     {    p_U2270B_CFE = 1;    delay_2(232);  //>2.5ms            //psw=0 standard write     if (x == write_command0)//写密码:初始化密码     {      uchar i;      uchar data *data p;      p = cominceptbuff;      p_U2270B_CFE = 0;   delay_2(31);//start gap>330us       write_bit(1);//写操作码1:10       write_bit(0);//写操作码0       write_bit(0);//写锁定位0       for(i = 0;i < 35;i++)      {       write_bit(1);//写数据位1       }      p_U2270B_CFE = 1;      led_light1 = 0;   led_light = 1;   delay_2(40000);//测试使用       //write_block(cominceptbuff[4],p);       p_U2270B_CFE = 1;      bankdata[20] = cominceptbuff[0];//密码存入       bankdata[21] = cominceptbuff[1];      bankdata[22] = cominceptbuff[2];      bankdata[23] = cominceptbuff[3];    }    else if (x == write_command1)//配置卡参数:初始化     {      uchar data *data p;      p = cominceptbuff;      write_bit(1);//写操作码1:10       write_bit(0);//写操作码0       write_bit(0);//写锁定位0               write_block(cominceptbuff[4],p);      p_U2270B_CFE=  1;    }    //psw=1  pssword mode     else if(x == write_command2)  //密码写数据    {      uchar data*data p;      p = &bankdata[24];      write_bit(1);//写操作码1:10       write_bit(0);//写操作码0       write_password(p);//发口令       write_bit(0);//写锁定位0       p = cominceptbuff;      write_block(cominceptbuff[4],p);//写数据            }    else if(x == write_command3)//aor    //唤醒 {      //cominceptbuff[1]操作码10 X xxxxxB       uchar data *data p;      p = cominceptbuff;      write_bit(1);//10       write_bit(0);             write_password(p);//密码       p_U2270B_CFE = 1;//此时数据不停的循环传出     }    else //停止操作码     {      write_bit(1);//11       write_bit(1);             p_U2270B_CFE = 1;         }    p_U2270B_CFE = 1;    delay_2(560);//5.6ms     }    /************************************/    void f_clearpassword()//清除密码     {    uchar data *data p;    uchar i,x;          p = &bankdata[24];//原密码     p_U2270B_CFE = 0; delay_2(18);//start gap>150us     //操作码10:10xxxxxxB     write_bit(1);    write_bit(0);              for(x = 0;x < 4;x++)//发原密码     {             DATA = *(p++);      for(i = 0;i < 8;i++)      {       write_bit(BIT0);       DATA >>= 1;      }    }    write_bit(0);//锁定位0:0     p = &cominceptbuff[0];    write_block(0x00,p);//写新配置参数:pwd=0             //密码无效:即清除密码     DATA = 0x00;//停止操作码00000000B     for(i = 0;i < 2;i++)    {    write_bit(BIT7);    DATA <<= 1;    }    p_U2270B_CFE = 1;       delay_2(560);//5.6ms     }    /*********************************/    void f_changepassword()//修改密码            {       uchar data *data p;    uchar i,x,addr;    addr = 0x07;//block7     p = &Nkey_a[0];//原密码     DATA = 0x80;//操作码10:10xxxxxxB     for(i = 0;i < 2;i++)    {      write_bit(BIT7);      DATA <<= 1;    }    for(x = 0;x < 4;x++)//发原密码     {             DATA = *(p++);      for(i = 0;i < 8;i++)      {       write_bit(BIT7);       DATA >>= 1;      }    }    write_bit(0);//锁定位0:0     p = &cominceptbuff[0];    write_block(0x07,p);//写新密码     p_U2270B_CFE = 1;    bankdata[24] = cominceptbuff[0];//密码存入     bankdata[25] = cominceptbuff[1];    bankdata[26] = cominceptbuff[2];    bankdata[27] = cominceptbuff[3];    DATA = 0x00;//停止操作码00000000B     for(i = 0;i < 2;i++)    {      write_bit(BIT7);      DATA <<= 1;    }    p_U2270B_CFE = 1;       delay_2(560);//5.6ms     }    /***************************子函数***********************************/    void write_bit(bit x)//写一位     {    if(x)    {      p_U2270B_CFE = 1;   delay_2(32);//448*11.0592/120=42延时448us       p_U2270B_CFE = 0;   delay_2(28);//280*11.0592/120=26写1     }    else    {      p_U2270B_CFE = 1;   delay_2(92);//192*11.0592/120=18       p_U2270B_CFE = 0;   delay_2(28);//280*11.0592/120=26写0     }    }    /*******************写一个block*******************/    void write_block(uchar addr,uchar data *data p)    {    uchar i,j;        for(i = 0;i < 4;i++)//block0数据     {             DATA = *(p++);      for(j = 0;j < 8;j++)      {       write_bit(BIT0);       DATA >>= 1;      }    }    DATA = addr <<= 5;//0地址     for(i = 0;i < 3;i++)    {      write_bit(BIT7);      DATA <<= 1;    }                   }    /*************************************************/    void write_password(uchar data *data p)    {    uchar i,j;        for(i = 0;i < 4;i++)//     {             DATA = *(p++);      for(j = 0;j < 8;j++)      {       write_bit(BIT0);       DATA >>= 1;      }    }        }   /*************************************************/   void main()    {    initial();    TI = RI = 0;    ES = 1;    EA = 1;  delay_2(28);   //f_readcard();     while(1) {   f_readcard();      //读卡   f_writecard(command1);  //写卡    f_clearpassword();   //清除密码     f_changepassword();    //修改密码 } }

    标签: 12345

    上传时间: 2017-10-20

    上传用户:my_lcs