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

📄 psoc.lst

📁 psoc_usb的代码,用来小卡测试的.没事下下来
💻 LST
📖 第 1 页 / 共 2 页
字号:
C51 COMPILER V8.06   PSOC                                                                  01/31/2008 22:24:27 PAGE 1   


C51 COMPILER V8.06, COMPILATION OF MODULE PSOC
OBJECT MODULE PLACED IN PSoC.OBJ
COMPILER INVOKED BY: C:\Program Files\Keil\C51\BIN\C51.EXE PSoC.c OPTIMIZE(9,SPEED) MODDP2 INCDIR(C:\Cypress\USB\Target\
                    -Inc) DEFINE(__USE_USB__) DEBUG OBJECTEXTEND

line level    source

   1          /*
   2           * INVENTEC corporation (c)2007 all rights reserved. 
   3           * Description: PSoC driver for gladius
   4           *              
   5           * Update: 
   6           * Revision             Date       Author              Reason   
   7           * ========             ========== =================== ==================
   8           * 1.0.0                2007-11-22  Liu.Fang-dong(ED)  Create
   9           *
  10           * Known issues:None
  11           *
  12           * Support Chip:
  13           * CY8C27143            CY8C27243       CY8C27443       CY8C27543       CY8C27643
  14           * CY8C24123            CY8C24223       CY8C24423
  15           * CY8C22113            CY8C22213
  16           * CY8C21123            CY8C21223       CY8C21323
  17           * CY8C21234            CY8C21334       CY8C21434       CY8C21534       CY8C21634
  18           */
  19          
  20          
  21          #include <stdio.h>
  22          #include <stdlib.h>
  23          #include <math.h>
  24          #include <ctype.h>
  25          #include <string.h>
  26          
  27          #include "fx2.h"
  28          #include "fx2regs.h"
  29          #include "absacc.h"
  30          #include "serial.h"
  31          #include "scmain.h"
  32          #include "cmdlist.h"
  33          #include "PSoC.h"
  34          
  35          #ifndef __USE_USB__
              #include "serial.h"
              #endif
  38          
  39          //vectors used by PSoc
  40          xdata char* vector_init_1 = "11001010000000000000000000000000000000000000000000000000000000000000000000000
             -000000000000000000000000000000000000000000000000000000011011110111000000001111101111011000000000111100111110000011101011
             -110011111001000000111111101111010100000000111110111101000000001111110011111011100000001111101111100100110000111110111110
             -1001000000111110111100000000100111111011111000000000001111101111111100010010111";
  41          xdata char* vector_init_2 = "11011110111000000001111101111011000000000111100111110000011101011110011111001
             -000000111111101111010100000000111110111101000000001111110011111011100000001111101111100100110000111110111110100100000011
             -11001111101000000001111110111100000000011011111011111000000000001111101111111100010010111";
  42          xdata char* vector_init_3_3v = "11011110111000000001111101111010000000011111110111101010000000011111011110
             -110000010001111101111100001010001111110111110011111100011111011111010001100001111101111111100010010111000000000000000000
             -000011011110111000000001111101111010000000011111110111101010000000011111011110110000010001111101111100001100000111110111
             -110011110101011111011111010001100001111101111011100010000111110111111110001001011100000000000000000000001101111011100000
             -000111110111101000000001111111011110101000000001111101111011000001000111110111110000101000111111011111001111110011111101
             -111101000110000111110111111110001001011100000000000000000000001101111011100000000111110111101000000001111111011110101000
             -000001111101111011000001000111110111110000110000011111011111001111010001111101111101000110000111110111101110001000011111
             -011111111000100101110000000000000000000000";
C51 COMPILER V8.06   PSOC                                                                  01/31/2008 22:24:27 PAGE 2   

  43          xdata char* vector_init_3_5v = "11011110111000000001111101111010000000011111110111101010000000011111011110
             -110000010001111101111100001010001111110111110011111110011111011111010001100001111101111111100010010111000000000000000000
             -000011011110111000000001111101111010000000011111110111101010000000011111011110110000010001111101111100001100000111110111
             -110011110101011111011111010001100001111101111011100010000111110111111110001001011100000000000000000000001101111011100000
             -000111110111101000000001111111011110101000000001111101111011000001000111110111110000101000111111011111001111111011111101
             -111101000110000111110111111110001001011100000000000000000000001101111011100000000111110111101000000001111111011110101000
             -000001111101111011000001000111110111110000110000011111011111001111010001111101111101000110000111110111101110001000011111
             -011111111000100101110000000000000000000000";
  44          xdata char* vector_checksum_setup_CY8C27xxx = "11011110111000000001111101111011000000000111100111110000011
             -101011110011111001000000111111101111010100000000111110111101000000001111110011111011100000001111101111100100110000111110
             -11111010010000001111001111101000000000111110111100000000011111111011111000000000001111101111111100010010111";
  45          //xdata char* vector_checksum_setup_CY8C21x23_24xxx = "110111101110000000011111011110110000000001111001111
             -100000111010111100111110010000001111111011110101000000001111101111010000000011111100111110111000000011111011111001001100
             -0011111011111010010000001111001111101001000000111110111100000000011111111011111000000000001111101111111100010010111";
  46          //xdata char* vector_checksum_setup_CY8C21x34 = "110111101110000000011111011110110000000001111001111100000
             -111010111100111110010000001111111011110101000000001111101111010000000011111100111110110000000011111011111001001100001111
             -1011111010010000001111001111101010000000111110111100000000011111111011111000000000001111101111111100010010111";
  47          //xdata char* vector_checksum_setup_CY8C22xxx = "110111101110000000011111011110110000000001111001111100000
             -111010111100111110010000001111111011110101000000001111101111010000000011111100111110111000000011111011111001001100001111
             -1011111010010000001111001111101000100000111110111100000000011111111011111000000000001111101111111100010010111";
  48          xdata char* vector_verify_setup = "11011110111000000001111101111011000000000111100111110000011101011110011
             -111001000000111111101111010100000000111110111101000000001111110011111011100000001111101111100100110000111110111110100100
             -0000111110111100000000000111111011111000000000001111101111111100010010111";
  49          xdata char* vector_ID_setup = "110111101110001000011111011100000000000101111101111011100000000111110111101
             -100000000011110011111000001110101111001111100100000011111110111101010000000011111011110100000000111111001111101110000000
             -111110111110010011000011111011111010010000001111001111101000000000111110111100000000011011111011111000000000001111101111
             -111100010010111";
  50          xdata char* vector_40zero = "0000000000000000000000000000000000000000";
  51          
  52          //-----------------------------------------------------------------------------
  53          //list for command
  54          //-----------------------------------------------------------------------------
  55          const struct command_name xdata psoc_cmd[] = {
  56                  {"select", do_psoc_init},
  57                  {"getchecksum", GetCheckSum},
  58                  {"sgpiotest", SgpioTest},
  59                  {"psocreset", PsocReset},
  60                  {0, 0}
  61          };
  62          
  63          //-----------------------------------------------------------------------------
  64          //extern function
  65          //-----------------------------------------------------------------------------
  66          extern int   mydef_strcasecmp(char *dst, char *src);
  67          extern int (*lookup_command_func(struct command_name *pcmd,char * cmd_str))();
  68          extern char *get_current_cmd(char * buff);
  69          extern char *lookup_return_str(int ret_cmd);
  70          extern int   lookup_return_val(struct command_param *pm, char * cmd_str);
  71          extern struct command_list * add_to_retlist(char * cmd);
  72          extern void (*fp_blinking)(BYTE);
  73          
  74          
  75          int do_psoc_init()
  76          {
  77   1           return RET_OK;    
  78   1      }
  79          
  80          int PsocReset(void)
  81          {
  82   1              SETOUT_PD(0);
  83   1              PSOC_RESET(HIGH);
  84   1              EZUSB_Delay(1);
C51 COMPILER V8.06   PSOC                                                                  01/31/2008 22:24:27 PAGE 3   

  85   1              PSOC_RESET(LOW);
  86   1              EZUSB_Delay(10);
  87   1              
  88   1              return RET_OK;
  89   1      }
  90          
  91          void PsocDelay(int count)
  92          {
  93   1              int i = 0;
  94   1              for(i = 0; i < 5*count; i++)
  95   1              {       
  96   2              }
  97   1      }
  98          
  99          //*****************************************************************************
 100          //  function name:     WriteBit()/ReadBit() 
 101          //  description:       send only one bit to SDATA
 102          //  return:            none
 103          //  note :
 104          //*****************************************************************************
 105          void WriteBit(char p)
 106          {
 107   1              p &= 0x01;
 108   1              
 109   1              if(0 == p)
 110   1                      PSOC_DOUT(LOW);
 111   1              else
 112   1                      PSOC_DOUT(HIGH);
 113   1      }
 114          
 115          
 116          BYTE ReadBit(void)
 117          {
 118   1              return PSOC_DIN;
 119   1      }
 120          
 121          
 122          //*****************************************************************************
 123          //  function name:     /Readbyte() 
 124          //  description:       send/read a byte
 125          //  return:            none
 126          //  note :
 127          //*****************************************************************************
 128          BYTE ReadByte(void)
 129          {
 130   1              BYTE returnValue = 0;
 131   1              BYTE tmp = 0;
 132   1              int n = 0;
 133   1              
 134   1              SET_DIN;
 135   1              EZUSB_Delay(1);
 136   1              
 137   1              for (n = 7; n >= 0;n--)
 138   1              {
 139   2                      PSOC_CLK(HIGH);
 140   2                      //PsocDelay(1);
 141   2                      PSOC_CLK(LOW);
 142   2                      //PsocDelay(1);
 143   2                      returnValue |=( (tmp = ReadBit())<<n);
 144   2              }
 145   1              
 146   1              SET_DOUT;
C51 COMPILER V8.06   PSOC                                                                  01/31/2008 22:24:27 PAGE 4   

 147   1              EZUSB_Delay(1);
 148   1              
 149   1              return returnValue;
 150   1      }
 151          
 152          //*****************************************************************************
 153          //  function name:     WriteVector()
 154          //  description:       send/read a byte
 155          //  return:            none
 156          //  note :
 157          //*****************************************************************************
 158          void WriteVector(char* vector)
 159          {
 160   1              int n = 0;
 161   1              
 162   1              while (vector[n] != '\0')
 163   1              {
 164   2                      PSOC_CLK(HIGH);
 165   2                      WriteBit(vector[n]);
 166   2                      PSOC_CLK(LOW);
 167   2      
 168   2                      n++;            
 169   2              }
 170   1      }
 171          
 172          //*****************************************************************************
 173          //  function name:      WaitSingle()
 174          //  description:        wait the single given bye psoc that shows we can give next
 175          //                                      vector or we can read back from psoc                                                     
 176          //  return:                     none
 177          //  note :
 178          //*****************************************************************************
 179          void WaitSingle(void)
 180          {
 181   1              int delay = 100000;
 182   1      
 183   1              SET_DIN;
 184   1              EZUSB_Delay(1);
 185   1              
 186   1              //wait HIGH single
 187   1              while(delay--)
 188   1              {
 189   2                      if(HIGH == ReadBit())
 190   2                      {
 191   3                              break;
 192   3                      }
 193   2                      else
 194   2                      {
 195   3                              PSOC_CLK(HIGH);
 196   3                              PSOC_CLK(LOW);
 197   3                      }
 198   2              }
 199   1              
 200   1              //wait LOW single
 201   1              delay = 100000;
 202   1              while(delay--)
 203   1              {
 204   2                      if(LOW == ReadBit())
 205   2                      {
 206   3                              SET_DOUT;
 207   3                              EZUSB_Delay(1);
 208   3                              WriteVector(vector_40zero);
C51 COMPILER V8.06   PSOC                                                                  01/31/2008 22:24:27 PAGE 5   

 209   3                              break;
 210   3                      }
 211   2                      else
 212   2                      {
 213   3                              PSOC_CLK(HIGH);
 214   3                              PSOC_CLK(LOW);
 215   3                      }
 216   2              }
 217   1              

⌨️ 快捷键说明

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