• 大小: 3.25MB
    文件类型: .rar
    金币: 1
    下载: 0 次
    发布日期: 2023-10-15
  • 语言: 其他
  • 标签: stc12c5a60s2  例程  

资源简介

stc12c5a60s2 单片机的所有功能的实例,包括SPI、AD、串口、UCOS-II操作系统的应用。

资源截图

代码片段和文件信息

#include “STC12C5A.h“
#include “Lcd.h“
#include “char.h“
#include “chinese.h“
#include “picture.h“
const uint code colors[]=
 {
   0xf8000x07e00x001f0xffe00x00000x07ff0xf81f0xffff
 };
/****************延时函数*******************/
void delay_ms(uint ms)
 {
   unsigned char k;
   while (ms--)
    {
      for (k = 0; k < 228; k++);
    }
 }
/****************写命令与数据子函数****************/
void LCD_Write(uchar type uint value)  
 {
   LCD_CS = 0;
   LCD_RS = type;     // 0: command    1: data

   LCD_WR = 0;
   DATA   = (uchar)value;;
   LCD_WR = 1;
   LCD_CS = 1;
 }
/***************写8位数据子函数**********************/
void LCD_Write_Data8(uchar value)    // color data
 {
   LCD_CS = 0;
   LCD_RS = 1;
   LCD_WR = 0;
   DATA   = value;
   LCD_WR = 1;
   LCD_CS = 1;
 }
/************写16位数据子函数************************/
void LCD_Wirte_Data16(uint value)    // color data
 {
   LCD_CS = 0;
   LCD_RS  = 1;
   LCD_WR  = 0;
   DATA  = (uchar)value;
   LCD_WR  = 1;
   LCD_WR  = 0;
   DATA  = (uchar)(value>>8) ;
   LCD_WR  = 1;
   LCD_CS = 1;
 }
/***********写寄存器子函数*******************************/
void Reg_Write(uint reguint value) 
 {
   LCD_Write(TYPE_LCD_COMMANDreg);
   LCD_Write(TYPE_LCD_DATAvalue);
 }
/***********设置显示窗口子函数****************************/
void LCD_SetRamAddr(uint xStart uint xEnd uint yStart uint yEnd) 
 {
   uint VerPosHorPosStartAddr;
   HorPos    = (uint)(xStart | (xEnd<<8));
   VerPos    = (uint)(yStart | (yEnd<<8));
   StartAddr = (uint)(xStart | (yStart<<8));

   Reg_Write(0x09 xStart);
   Reg_Write(0x10yStart);
   Reg_Write(0x11xEnd);
   Reg_Write(0x12yEnd);

   Reg_Write(0x18 xStart); 
   Reg_Write(0x19 yStart); 
   LCD_Write(TYPE_LCD_COMMAND0x22); // 0x22
 }
void point(uint xuint yuint colour)
 {
   LCD_SetRamAddr(x x y y );
   LCD_Wirte_Data16(colour);
 }
/*********清屏子函数****************************/
void  LCD_clear(uchar n)
 {
   uint num;
   LCD_SetRamAddr(0127 0159);
   for(num=20480;num>0;num--)          //160*128=20480
     {
       LCD_Wirte_Data16(colors[n]);
     }
 }
/*************字符显示子函数**********************/
void LCD_ShowChar(uchar xuchar yuint For_coloruint Bk_color char ch)
 {       
   uchar temp;
   uchar post;
   uchar  CHAR_WCHAR_H;  
   CHAR_W = 8;         //8*16
   CHAR_H = 16;
   if(x>(LCD_SIZE_X-CHAR_W)||y>(LCD_SIZE_Y-CHAR_H))
     return;
   LCD_SetRamAddr(x x+CHAR_W-1 yy+CHAR_H-1);
   ch = ch-32;                       //按照ASCII编码顺序的到相应字母的编码
   for(pos=0;pos     {
       temp= Font8x16[ch][pos];
       for(t=0;t        {                 
      if(temp&0x80)
        LCD_Wirte_Data16(For_color);  //textcolor
      else 
        LCD_Wirte_Data16(Bk_color);  //backcolor
          temp<<=1; 
        }   
     }
 }  
/***********显示字符串子函数****************
            xy:起点坐标  
 *********  *p:字符串起始地址***************/
void LCD_ShowString(uchar xu

 属性            大小     日期    时间   名称
----------- ---------  ---------- -----  ----

     文件        610  2012-04-07 14:10  STC12C5A60S2\Demo_class\STC12_AT24C02_I2C\Sourse\STC12_AT24C02_I2C.C

     文件       2380  2012-04-07 14:13  STC12C5A60S2\Demo_class\STC12_AT24C02_I2C\Sourse\2402.c

     文件      14154  2012-04-07 14:13  STC12C5A60S2\Demo_class\STC12_AT24C02_I2C\List\STARTUP.lst

     文件      17960  2012-04-07 14:13  STC12C5A60S2\Demo_class\STC12_AT24C02_I2C\List\STC12_AT24C02_I2C.m51

     文件       6376  2009-05-07 14:37  STC12C5A60S2\Demo_class\STC12_AT24C02_I2C\List\STARTUP.A51

     文件       8923  2012-04-03 18:30  STC12C5A60S2\Demo_class\STC12_AT24C02_I2C\List\AT24C04.lst

     文件       2070  2012-04-07 14:13  STC12C5A60S2\Demo_class\STC12_AT24C02_I2C\List\STC12_AT24C02_I2C.lst

     文件       4311  2012-04-07 14:13  STC12C5A60S2\Demo_class\STC12_AT24C02_I2C\List\2402.lst

     文件       2023  2012-04-07 14:13  STC12C5A60S2\Demo_class\STC12_AT24C02_I2C\List\UART.lst

     文件       7590  2012-04-07 14:13  STC12C5A60S2\Demo_class\STC12_AT24C02_I2C\List\I2C.lst

     文件        839  2012-04-07 14:13  STC12C5A60S2\Demo_class\STC12_AT24C02_I2C\Output\STARTUP.obj

     文件      13166  2012-04-07 14:13  STC12C5A60S2\Demo_class\STC12_AT24C02_I2C\Output\2402.obj

     文件      10571  2012-04-07 14:13  STC12C5A60S2\Demo_class\STC12_AT24C02_I2C\Output\UART.obj

     文件        212  2012-04-07 14:13  STC12C5A60S2\Demo_class\STC12_AT24C02_I2C\Output\STC12_AT24C02_I2C.lnp

     文件      12201  2012-04-07 14:13  STC12C5A60S2\Demo_class\STC12_AT24C02_I2C\Output\STC12_AT24C02_I2C.obj

     文件      15274  2012-04-07 14:13  STC12C5A60S2\Demo_class\STC12_AT24C02_I2C\Output\I2C.obj

     文件       2116  2012-04-07 14:13  STC12C5A60S2\Demo_class\STC12_AT24C02_I2C\Output\STC12_AT24C02_I2C.hex

     文件      50029  2012-04-07 14:13  STC12C5A60S2\Demo_class\STC12_AT24C02_I2C\Output\STC12_AT24C02_I2C

     文件      22534  2012-04-07 14:18  STC12C5A60S2\Demo_class\STC12_AT24C02_I2C\Output\STC12_AT24C02_I2C.plg

     文件      16918  2012-04-03 18:30  STC12C5A60S2\Demo_class\STC12_AT24C02_I2C\Output\AT24C04.obj

    .......     13469  2012-04-03 16:45  STC12C5A60S2\Demo_class\STC12_AT24C02_I2C\STC12_AT24C02_I2C_uvproj.bak

    .......    145692  2012-04-04 20:23  STC12C5A60S2\Demo_class\STC12_AT24C02_I2C\STC12_AT24C02_I2C_uvopt.bak

    .......     14118  2012-04-03 20:56  STC12C5A60S2\Demo_class\STC12_AT24C02_I2C\STC12_AT24C02_I2C.uvproj

    .......    144104  2012-04-07 14:18  STC12C5A60S2\Demo_class\STC12_AT24C02_I2C\STC12_AT24C02_I2C.uvopt

     文件        245  2012-04-30 23:08  STC12C5A60S2\Demo_class\STC12_NRF24L01_SPI\Sourse\NRF24L01_SPI.C

     文件      10598  2012-04-30 23:08  STC12C5A60S2\Demo_class\STC12_NRF24L01_SPI\Output\UART.obj

     文件      13639  2012-04-30 23:08  STC12C5A60S2\Demo_class\STC12_NRF24L01_SPI\Output\NRF24L01_SPI.obj

     文件        805  2012-04-30 23:08  STC12C5A60S2\Demo_class\STC12_NRF24L01_SPI\Output\STARTUP.obj

     文件        201  2012-04-30 23:08  STC12C5A60S2\Demo_class\STC12_NRF24L01_SPI\Output\NRF24L01_SPI.lnp

     文件      25366  2012-04-30 23:08  STC12C5A60S2\Demo_class\STC12_NRF24L01_SPI\Output\NRF24L01.obj

............此处省略365个文件信息

评论

共有 条评论