【Open Source】 Multi-functional IoT Development Kit Based on T5L chip

In this issue, we introduce the award-winning open-source case of DWIN Developer Forum - Multi-functional IoT development kit based on T5L chip. Engineers fully utilize the rich peripheral functions of the T5L1 chip, integrated USB, audio speakers, PWM signal interface, RGB color lights, Wi-Fi modules, DC motors and other interfaces, for the field of Internet of Things learners, testers and developers to provide a flexible and efficient Internet of Things development platform, which greatly meets the user's diversified needs in terms of hardware resources, and helps the majority of developers to Easily start the Internet of Things exploration journey. 【PCB Peripheral Interface】 【UI Design】 【GUI Design】 【C51Design】 (1)The core code for JPG images to be displayed on the screen is as follows: 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)The program related to RGB strip display is as follows: 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); } } //data processing 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)The iic protocol driver code is as follows. #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; }