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

📄 lcd.lst

📁 STM32利用正交编码器实现电机的控制
💻 LST
字号:
##############################################################################
#                                                                            #
# IAR ARM ANSI C/C++ Compiler V4.42A/W32               15/May/2008  12:06:29 #
# Copyright 1999-2005 IAR Systems. All rights reserved.                      #
#                                                                            #
#    Cpu mode        =  thumb                                                #
#    Endian          =  little                                               #
#    Stack alignment =  4                                                    #
#    Source file     =  C:\David JIANG\ST MCU\Docs\STM32\AN_JIANG\TIM        #
#                       Encoder\example\project\source\lcd.c                 #
#    Command line    =  "C:\David JIANG\ST MCU\Docs\STM32\AN_JIANG\TIM       #
#                       Encoder\example\project\source\lcd.c" -D             #
#                       VECT_TAB_FLASH -lcN "C:\David JIANG\ST               #
#                       MCU\Docs\STM32\AN_JIANG\TIM                          #
#                       Encoder\example\project\EWARM\BOOT_FLASH\List\" -lb  #
#                       "C:\David JIANG\ST MCU\Docs\STM32\AN_JIANG\TIM       #
#                       Encoder\example\project\EWARM\BOOT_FLASH\List\" -o   #
#                       "C:\David JIANG\ST MCU\Docs\STM32\AN_JIANG\TIM       #
#                       Encoder\example\project\EWARM\BOOT_FLASH\Obj\" -z3   #
#                       --no_cse --no_unroll --no_inline --no_code_motion    #
#                       --no_tbaa --no_clustering --no_scheduling --debug    #
#                       --cpu_mode thumb --endian little --cpu cortex-M3     #
#                       --stack_align 4 --require_prototypes --fpu None      #
#                       --dlib_config "C:\Program Files\IAR                  #
#                       Systems\Embedded Workbench                           #
#                       4.0\arm\LIB\dl7mptnnl8f.h" -I "C:\David JIANG\ST     #
#                       MCU\Docs\STM32\AN_JIANG\TIM                          #
#                       Encoder\example\project\EWARM\" -I "C:\David         #
#                       JIANG\ST MCU\Docs\STM32\AN_JIANG\TIM                 #
#                       Encoder\example\project\EWARM\..\include\" -I        #
#                       "C:\David JIANG\ST MCU\Docs\STM32\AN_JIANG\TIM       #
#                       Encoder\example\project\EWARM\..\..\FWLib\inc\" -I   #
#                       "C:\Program Files\IAR Systems\Embedded Workbench     #
#                       4.0\arm\INC\"                                        #
#    List file       =  C:\David JIANG\ST MCU\Docs\STM32\AN_JIANG\TIM        #
#                       Encoder\example\project\EWARM\BOOT_FLASH\List\lcd.ls #
#                       t                                                    #
#    Object file     =  C:\David JIANG\ST MCU\Docs\STM32\AN_JIANG\TIM        #
#                       Encoder\example\project\EWARM\BOOT_FLASH\Obj\lcd.r79 #
#                                                                            #
#                                                                            #
##############################################################################

C:\David JIANG\ST MCU\Docs\STM32\AN_JIANG\TIM Encoder\example\project\source\lcd.c
      1          /******************** (C) COPYRIGHT 2008 STMicroelectronics ********************
      2          * File Name          : main.c
      3          * Author             : Jian-guo JIANG
      4          * Date First Issued  : 2008.5.14
      5          * Description        : lcd display
      6          *
      7          ********************************************************************************
      8          * History:
      9          * 2008.5.14 : Version 1.0
     10          ********************************************************************************
     11          * THE PRESENT SOFTWARE WHICH IS FOR GUIDANCE ONLY AIMS AT PROVIDING CUSTOMERS
     12          * WITH CODING INFORMATION REGARDING THEIR PRODUCTS IN ORDER FOR THEM TO SAVE TIME.
     13          * AS A RESULT, STMICROELECTRONICS SHALL NOT BE HELD LIABLE FOR ANY DIRECT,
     14          * INDIRECT OR CONSEQUENTIAL DAMAGES WITH RESPECT TO ANY CLAIMS ARISING FROM THE
     15          * CONTENT OF SUCH SOFTWARE AND/OR THE USE MADE BY CUSTOMERS OF THE CODING
     16          * INFORMATION CONTAINED HEREIN IN CONNECTION WITH THEIR PRODUCTS.
     17          *******************************************************************************/
     18          
     19          /* Includes ------------------------------------------------------------------*/
     20          #include "stm32f10x_lib.h"
     21          #include "lcd.h"
     22          /* Private typedef -----------------------------------------------------------*/
     23          /* Private define ------------------------------------------------------------*/
     24          /* Private macro -------------------------------------------------------------*/
     25          /* Private variables ---------------------------------------------------------*/
     26          u16  frame[4];    /* LCD frame buffer  */
     27          u16  digit[4];    /* Digit frame buffer */  
     28          char text[4];
     29          
     30          /*the varitronix LCD digit is:
     31          
     32                         A
     33                --  ----------
     34              X \/  |\   |I  /|
     35                   F| H  |  J |B
     36                    |  \ | /  |
     37                    --G-- --K--
     38                    |   /| \  |
     39                  E |  L |  N |C
     40                    | /  |M  \|   _
     41                    -----------  | |DP   
     42                        D         -
     43          
     44                  PE0  PE1  PE2  PE3  ...................................................... PE15
     45          ----------------------------------------------------------------------------------------
     46          |      | S0 | S1 | S2 | S3 | S4 | S5 | S6 | S7 | S8 | S9 | S10| S11| S12| S13| S14| S15|
     47          ----------------------------------------------------------------------------------------
     48          | COM1 | 1X | 1I | 1A | 1DP| 2X | 2I | 2A | 2DP| 3X | 3I | 3A | 3DP| 4X | 4I | 4A | 4DP|
     49          ----------------------------------------------------------------------------------------
     50          | COM2 | 1F | 1H | 1J | 1B | 2F | 2H | 2J | 2B | 3F | 3H | 3J | 3B | 4F | 4H | 4J | 4B |
     51          ----------------------------------------------------------------------------------------
     52          | COM3 | 1E | 1G | 1K | 1C | 2E | 2G | 2K | 2C | 3E | 3G | 3K | 3C | 4E | 4G | 4K | 4C |
     53          ----------------------------------------------------------------------------------------
     54          | COM4 | 1L | 1M | 1N | 1D | 2L | 2M | 2N | 2D | 3L | 3M | 3N | 3D | 4L | 4M | 4N | 4D |
     55          ----------------------------------------------------------------------------------------
     56          
     57          A LCD character coding is based on the following matrix:
     58          
     59          { X , F , E , L  }
     60          { I , H , G , M  }
     61          { A , J , K , N  }
     62          { DP, B , C , D  }
     63          
     64          The characher A for example is:
     65          
     66           { 0 , 1 , 1 , 0 }
     67           { 0 , 0 , 1 , 0 }
     68           { 1 , 0 , 1 , 0 }
     69           { 0 , 1 , 1 , 0 }
     70          -------------------
     71          =  4   9   F   0   hex
     72          
     73          => 'A' = 0x4E70  */
     74          
     75          const u16 letter[26]={0x49F0,0x01F8,0x4118,0x08F8,0x4178,0x4170,0x41D8,0x09F0,0x600A,
     76          		      0x0888,0x0534,0x0118,0x0F90,0x0B94,0x4998,0x4970,0x499C,0x4974,
     77          		      0x41E8,0x6002,0x0998,0x0511,0x299A,0x0605,0x0601,0x4409};
     78          
     79          const u16 number[10]={0x4998,0x0880,0x4878,0x48E8,0x09E0,0x41E8,0x41F8,0x4880,0x49F8,0x49E8};
     80          
     81          const u16 sign[2]={0x2062,0x0060}; // {+,-}
     82          
     83          /* Private function prototypes -----------------------------------------------*/
     84          /* Private functions ---------------------------------------------------------*/
     85          
     86          /*******************************************************************************
     87          * Function Name  : convert
     88          * Description    : converts an ascii char to the a LCD digit (previous coding)
     89          * Input1         : char
     90          * Input2         : point : flag indicating if a point has to be add in front of
     91          *                  displayed character (0: no, 1: yes)
     92          * Output         : None
     93          * Return         : None
     94          *******************************************************************************/
     95          void convert (char* c,u8 point)
     96          { 
     97            u16 car=0,tmp;
     98            u8 i;
     99            const u16 mask[4]={0xF000,0x0F00,0x00F0,0x000F};
    100            const u8 shift[3]={0xC,0x8,0x4};
    101          
    102            if ((*c<0x5B)&(*c>0x40))  // 'A' --- 'F'
    103              car = letter[*c-0x41]; 
    104            else if ((*c<0x3A)&(*c>0x2F))  // '0' --- '9'
    105              car = number[*c-0x30];
    106            else if (*c==0x20) car =0;     // 'space'
    107            else if (*c=='+')  car = sign[0];   // '+'     
    108            else if (*c=='-')  car = sign[1];   // '-'  
    109            
    110            if (point==1) car|=0x8000;
    111            
    112            for (i=0;i<3;i++)
    113            {
    114              tmp = car&mask[i];
    115              digit[i] = tmp>>shift[i];
    116            }
    117            digit[3] = (car&mask[3]); 
    118          }
    119          
    120          /*******************************************************************************
    121          * Function Name  : write char
    122          * Description    : This function writes a char in the LCD frame buffer
    123          * Input1         : char ascii value
    124          * Input2         : point 0: no point to add, 1 a point to add in front of char 
    125          * Input2         : pos: position of the caracter to write [0:3]
    126          * Output         : None
    127          * Return         : None
    128          *******************************************************************************/
    129          void write_char(char* car,u8 point,u8 pos)
    130          {
    131             int i;
    132             const u16 mask[4]={0x0F,0xF0,0xF00,0xF000};
    133          
    134             convert(car,point);
    135             
    136             if (pos == 1) for (i=0;i<4;i++) digit[i]=(digit[i]<<4);
    137             if (pos == 2) for (i=0;i<4;i++) digit[i]=(digit[i]<<8); 
    138             if (pos == 3) for (i=0;i<4;i++) digit[i]=(digit[i]<<12); 
    139             
    140             for (i=0;i<4;i++) frame[i]= (frame[i]&~mask[pos])|digit[i];   
    141          }
    142          
    143          
    144          /*******************************************************************************
    145          * Function Name  : write_string
    146          * Description    : This function writes a string in the LCD
    147          * Input          : string
    148          * Output         : None
    149          * Return         : None
    150          *******************************************************************************/
    151          void write_string(char* str)
    152          {
    153            int i;
    154            for (i=0;i<4;i++) write_char(str+i,0,i);
    155          }
    156           
    157          /*******************************************************************************
    158          * Function Name  : int2char
    159          * Description    : This function convertes a int to a string
    160          * Input          : u16 value
    161          * Output         : None
    162          * Return         : None
    163          *******************************************************************************/
    164          char* int2char(u16 value)
    165          { 
    166            u8 i;
    167            u8 bValue;
    168            u16 temp;  
    169            
    170            temp = 1000;  
    171            for (i=0;i<4;i++)
    172            {
    173              bValue = (u8)(value/temp);
    174              text[i] = (char)(bValue+0x30);
    175              
    176              value %= temp;
    177              temp /= 10;                
    178            }    
    179            return(text);
    180          }
    181          
    182          
    183          /******************* (C) COPYRIGHT 2007 STMicroelectronics *****END OF FILE****/

   Maximum stack usage in bytes:

     Function     CSTACK
     --------     ------
     convert         24
     int2char         8
     write_char      24
     write_string    12


   Segment part sizes:

     Function/Label                 Bytes
     --------------                 -----
     frame                             8
     digit                             8
     text                              4
     letter                           52
     number                           20
     sign                              4
     convert                         240
     write_char                      180
     write_string                     30
     int2char                         76
     ??DataTable7                      4
     ?<Constant {61440, 3840, 240, 15}>
                                       8
     ?<Constant {12, 8, 4}>            3
     ?<Constant {15, 240, 3840, 61440}>
                                       8
      Others                          28

 
 546 bytes in segment CODE
  95 bytes in segment DATA_C
  20 bytes in segment DATA_Z
  12 bytes in segment INITTAB
 
 530 bytes of CODE  memory (+ 28 bytes shared)
  95 bytes of CONST memory
  20 bytes of DATA  memory

Errors: none
Warnings: none

⌨️ 快捷键说明

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