学生同城空降_全国空降同城服务_全国各地可约可空降

logo

【开源获奖案例】基于T5L芯片的多功能物联网开发套件

                                ——来自迪文开发者论坛

本期为大家推送迪文开发者论坛获奖开源案例——?基于T5L芯片的多功能物联网开发套件?。工程师充分运用了T5L1芯片的丰富外设功能,集成了USB、音频喇叭、PWM信号接口、RGB彩灯、WiFi??椤⒅绷鞯缁榷嘀纸涌冢锪煊虻难罢?、测试者和开发者提供了一个灵活、高效的物联网开发平台,极大满足了用户在硬件资源方面的多元化需求,助力广大开发者轻松开启物联网探索之旅。


【演示视频】

完整开发资料含迪文屏DGUS工程资料与C51代码,获取方式:

1. 前往迪文开发者论坛获取:http://inforum.dwin.com.cn:20080/forum.php?mod=viewthread&tid=10189&extra=&_dsign=4d738c3c

2. 微信公众号中回复“物联开发套件”获取。


PCB板外设接口

PCB板外设接口

UI素材展示

UI素材展示1UI素材展示2

UI素材展示3UI素材展示4

UI素材展示5

GUI工程设计

GUI工程设计


C51工程设计

(1)JPG图片显示在屏幕的核心代码如下:

void sys_draw_jpg(u16 vp,u8 *jpg_data,u32 data_len)

{

        u32 i;

        for(i=0;i<data_len;i++)

        {

                if((jpg_data==0xFF)&&(jpg_data[i+1]==0xD8))

                        break;

         }

                if(i==data_len)

                        return;

                data_len = (data_len-i)/2+1;

                sys_write_vp(vp+2,jpg_data+i,data_len);

                data_len |= 0x5AA50000;

                sys_write_vp(vp,(u8*)&data_len,2);

}

 

(2)RGB灯带显示相关的程序如下:

void rgbled_send_zero()

{

        u8 i;

        RGBLED_SDA = 0;

        for(i=0;i<32;i++)

        {

            RGBLED_SCL = 0;

                    sys_delay_about_us(200);

                    RGBLED_SCL = 1;

                    sys_delay_about_us(200);               

        }

}

u8 rgbled_reverse_data(u8 dat)

{

        dat = ((~dat) & 0xC0) >> 6;

        return dat;

}

void rgbled_send_data(u32 dat)

{

        u8 i;

        for(i=0;i<32;i++)

        {

                if(dat&0x80000000)

                        RGBLED_SDA = 1;

                else

                        RGBLED_SDA = 0;

                dat <<= 1;

                RGBLED_SCL = 0;

                sys_delay_about_us(200);

                RGBLED_SCL = 1;

                sys_delay_about_us(200);

        }        

}

//数据处理

void rgbled_process(u8 r,u8 g,u8 b)

{

        u32 dat = 0;

        dat |= (u32)0x03 << 30;  

        dat |= (u32)rgbled_reverse_data(b) << 28;

        dat |= (u32)rgbled_reverse_data(g) << 26;

        dat |= (u32)rgbled_reverse_data(r) << 24;

        dat |= (u32)b << 16;

        dat |= (u32)g << 8;

        dat |= r;

        rgbled_send_data(dat);

}

void rgbled_show(u8 r,u8 g,u8 b)

{

        P2MDOUT |= 0x0C;   

        rgbled_send_zero();

        rgbled_process(r, g, b);

        rgbled_process(r, g, b);

        }

void rgbled_init(void)

{

        rgbled_show(0,0,0);

}


(3)iic协议驱动代码如下:

#include "iic.h"

sbit IIC_SDA_PIN = P2^2;

sbit IIC_SCL_PIN = P2^3;

#define SDA_IN()  P2MDOUT&=0xFB

#define SDA_OUT() P2MDOUT|=0x04

#define IIC_SCL   IIC_SCL_PIN

#define IIC_SDA   IIC_SDA_PIN

#define READ_SDA  IIC_SDA_PIN

#define delay_us                sys_delay_about_us

void IIC_Init(void)

{

        P2MDOUT |= 0x0C;

        IIC_SDA = 1;

        IIC_SCL = 1;  

}

void IIC_Start(void)

{

        SDA_OUT();   

        IIC_SDA=1;                    

        IIC_SCL=1;

        delay_us(4);

        IIC_SDA=0;

        delay_us(4);

        IIC_SCL=0;

}          

void IIC_Stop(void)

{

        SDA_OUT();

        IIC_SCL=0;

        IIC_SDA=0;

        delay_us(4);

        IIC_SCL=1;

        delay_us(4);                       

        IIC_SDA=1;                          

}

u8 IIC_Wait_Ack(void)

{

        u8 ucErrTime=0;

        SDA_IN();

        IIC_SDA=1;delay_us(1);          

        IIC_SCL=1;delay_us(1);         

        while(READ_SDA)

        {

                ucErrTime++;

                if(ucErrTime>250)

                {

                        IIC_Stop();

                        return 1;

                }

        }

        IIC_SCL=0;          

        return 0;  

}

void IIC_Ack(void)

{

        IIC_SCL=0;

        SDA_OUT();

        IIC_SDA=0;

        delay_us(2);

        IIC_SCL=1;

        delay_us(2);

        IIC_SCL=0;

}

void IIC_NAck(void)

{

        IIC_SCL=0;

        SDA_OUT();

        IIC_SDA=1;

        delay_us(2);

        IIC_SCL=1;

        delay_us(2);

        IIC_SCL=0;

}               

void IIC_Send_Byte(u8 txd)

{                        

        u8 t;   

        SDA_OUT();             

        IIC_SCL=0;

        for(t=0;t<8;t++)

{              

        IIC_SDA=(txd&0x80)>>7;

        txd<<=1;           

        delay_us(2);  

        IIC_SCL=1;

        delay_us(2);

        IIC_SCL=0;       

        delay_us(2);

}         

}

u8 IIC_Read_Byte(u8 ack)

{

        u8 i,receive=0;

        SDA_IN();

        for(i=0;i<8;i++ )

        {

                IIC_SCL=0;

                delay_us(2);

                IIC_SCL=1;

                receive<<=1;

                if(READ_SDA)receive++;   

                delay_us(1);

        }                                         

        if (!ack)

                IIC_NAck();

        else

                IIC_Ack();

        return receive;

}