5、【国产FPGA安路 高集成低功耗SF1系列FPSoC新品测评】128*32 OLED 点阵屏显示

1nnocent   2024-3-27 22:03 楼主

    由于OLED屏幕的FPC软排线断了几根导致最后的工作无法继续,一共断了四根FPC软排线。

image.png  

    看到此情此景有点懵,因为当时收到货后确认了屏幕是可以用的,后面仔细回想了一下原因可能是因为收到货时屏幕后面的双面胶粘性不够,屏幕一直搭拉着,应该是后续使用时不小心刮到了屏幕导致排线断裂。断裂的地方刚好是FPC排线座和排线的连接处。
image.png  

    后续在某宝上也没找到相同型号的OLED屏幕,后来硬着头皮尝试将断裂的四根FPC排线焊接回去,发现焊完还真能用。第一次挑战焊接这种排线也记录一下。首先是刮开FPC排线表面的图层使铜线露出来,为了不增加焊接难度将刮开的焊接点尽量远离,这里就只让第一根红色线离得近一点,蓝色和黄色线离得远保证焊接时两根线互不干扰。接近金手指的地方由于破损的地方较刁钻,只能挤在一起焊。

image.png  

    然后找来了杜邦线里面的铜线来充当引线焊接,用胶带固定好后进行焊接补救。

image.png

    焊接好后准备点屏看看焊接的效果。

    TD软件新建工程后编写代码,顶层模块就例化了两个模块,其中一个是PLL IP核用于产生PS和PL端需要使用到的时钟,里一个ps_wrapper模块用于PS和PL端引脚的接口交互。以下为top层代码:


module design_top_wrapper (
    input wire        I_clk_25m,
    input wire        I_rst_n,

    input wire        I_jtag_tck,
    output wire       O_jtag_tdo,
    input wire        I_jtag_tms,
    input wire        I_jtag_tdi,


    input wire        I_uart_rx,
    output wire       O_uart_tx,

	output wire       O_oled_scl,
    inout wire        IO_oled_sda,
	output wire       O_oled_rst_n,
	output wire       O_led,
    inout wire        IO_key
);

    wire      S_sys_clk_100m;
	wire      S_rst;

    
    assign S_rst = ~I_rst_n;


    pll u_pll(
        .refclk   ( I_clk_25m      ),
        .reset    ( S_rst          ),
        .extlock  (                ),
        .clk0_out ( S_sys_clk_100m )
    );



    ps_wrapper u_ps_wrapper(
        .I_clk            ( S_sys_clk_100m   ),
		.I_timer_clk      ( I_clk_25m        ),
        .I_rst            ( S_rst            ),

        .I_jtag_tck       ( I_jtag_tck       ),
        .O_jtag_tdo       ( O_jtag_tdo       ),
        .I_jtag_tms       ( I_jtag_tms       ),
        .I_jtag_tdi       ( I_jtag_tdi       ),

        .I_uart_rx        ( I_uart_rx        ),
        .O_uart_tx        ( O_uart_tx        ),

        .IO_gpio_0        ( O_oled_scl       ),
        .IO_gpio_1        ( IO_oled_sda      ),
        .IO_gpio_2        ( O_led            ),
        .IO_gpio_3        ( IO_key           ),
        .IO_gpio_4        ( O_oled_rst_n     ),
        .IO_gpio_5        (  ),
        .IO_gpio_6        (  ),
        .IO_gpio_7        (  )
    );




    
endmodule

    ps_wrapper模块用于PS和PL端引脚的接口交互,除了JTAG和UART接口外还有八个用户IO,其中用于点屏的iic接口就在这八个IO中。

四线JTAG接口对应的管脚为:

信号                    FPGA引脚
SF1_FPGA_TDI
C4
SF1_FPGA_TDO   
C5
SF1_FPGA_TMS
A6
SF1_FPGA_TCK
A7

image.png  

    UART对应的接口为:

信号 FPGA引脚
SF1_UART_RX
E4
SF1_UART_TX
A4

image.png  

    用户IO管脚为:

信号    FPGA引脚

O_oled_scl

G4

IO_oled_sda

J2

O_oled_rst_n

H9

O_led

J5

image.png  

    

    ps_wrapper模块代码如下:

 

module ps_wrapper (
    input wire        I_clk,
    input wire        I_rst,
	input wire        I_timer_clk,

    input wire        I_jtag_tck,
    output wire       O_jtag_tdo,
    input wire        I_jtag_tms,
    input wire        I_jtag_tdi,

    input wire        I_uart_rx,
    output wire       O_uart_tx,

    inout wire        IO_gpio_0,
    inout wire        IO_gpio_1,
    inout wire        IO_gpio_2,
    inout wire        IO_gpio_3,
    inout wire        IO_gpio_4,
    inout wire        IO_gpio_5,
    inout wire        IO_gpio_6,
    inout wire        IO_gpio_7
);
    

    wire S_gpio0_out;
    wire S_gpio0_dir;
    wire S_gpio0_in ;
    wire S_gpio1_out;
    wire S_gpio1_dir;
    wire S_gpio1_in ;
    wire S_gpio2_out;
    wire S_gpio2_dir;
    wire S_gpio2_in ;
    wire S_gpio3_out;
    wire S_gpio3_dir;
    wire S_gpio3_in ;
    wire S_gpio4_out;
    wire S_gpio4_dir;
    wire S_gpio4_in ;
    wire S_gpio5_out;
    wire S_gpio5_dir;
    wire S_gpio5_in ;
    wire S_gpio6_out;
    wire S_gpio6_dir;
    wire S_gpio6_in ;
    wire S_gpio7_out;
    wire S_gpio7_dir;
    wire S_gpio7_in ;


    gpio_controler u0_gpio_controler(
        .O_gpio_in  ( S_gpio0_in  ),
        .I_gpio_dir ( S_gpio0_dir ),
        .I_gpio_out ( S_gpio0_out ),

        .IO_gpio    ( IO_gpio_0   )
    );

    gpio_controler u1_gpio_controler(
        .O_gpio_in  ( S_gpio1_in  ),
        .I_gpio_dir ( S_gpio1_dir ),
        .I_gpio_out ( S_gpio1_out ),

        .IO_gpio    ( IO_gpio_1   )
    );

    gpio_controler u2_gpio_controler(
        .O_gpio_in  ( S_gpio2_in  ),
        .I_gpio_dir ( S_gpio2_dir ),
        .I_gpio_out ( S_gpio2_out ),

        .IO_gpio    ( IO_gpio_2   )
    );

    gpio_controler u3_gpio_controler(
        .O_gpio_in  ( S_gpio3_in  ),
        .I_gpio_dir ( S_gpio3_dir ),
        .I_gpio_out ( S_gpio3_out ),

        .IO_gpio    ( IO_gpio_3   )
    );

    gpio_controler u4_gpio_controler(
        .O_gpio_in  ( S_gpio4_in  ),
        .I_gpio_dir ( S_gpio4_dir ),
        .I_gpio_out ( S_gpio4_out ),

        .IO_gpio    ( IO_gpio_4   )
    );

    gpio_controler u5_gpio_controler(
        .O_gpio_in  ( S_gpio5_in  ),
        .I_gpio_dir ( S_gpio5_dir ),
        .I_gpio_out ( S_gpio5_out ),

        .IO_gpio    ( IO_gpio_5   )
    );

    gpio_controler u6_gpio_controler(
        .O_gpio_in  ( S_gpio6_in  ),
        .I_gpio_dir ( S_gpio6_dir ),
        .I_gpio_out ( S_gpio6_out ),

        .IO_gpio    ( IO_gpio_6   )
    );

    gpio_controler u7_gpio_controler(
        .O_gpio_in  ( S_gpio7_in  ),
        .I_gpio_dir ( S_gpio7_dir ),
        .I_gpio_out ( S_gpio7_out ),

        .IO_gpio    ( IO_gpio_7   )
    );


    MCU u_MCU(
        .core_clk         ( I_clk       ),
		.timer_clk        ( I_timer_clk ),
        .core_reset       ( I_rst       ),

        .jtag_tck         ( I_jtag_tck  ),
        .jtag_tdo         ( O_jtag_tdo  ),
        .jtag_tms         ( I_jtag_tms  ),
        .jtag_tdi         ( I_jtag_tdi  ),

        .soft_ip_apbm_en  ( 1'b0       ),
        .qspi0cfg1_mode   ( 1'b1       ),
        .qspi0cfg2_mode   ( 1'b1       ),

        .uart_tx          ( I_uart_tx  ),
        .uart_rx          ( O_uart_rx  ),

        .gpio0_out        ( S_gpio0_out  ),
        .gpio0_dir        ( S_gpio0_dir  ),
        .gpio0_in         ( S_gpio0_in   ),

        .gpio1_out        ( S_gpio1_out  ),
        .gpio1_dir        ( S_gpio1_dir  ),
        .gpio1_in         ( S_gpio1_in   ),

        .gpio2_out        ( S_gpio2_out  ),
        .gpio2_dir        ( S_gpio2_dir  ),
        .gpio2_in         ( S_gpio2_in   ),

        .gpio3_out        ( S_gpio3_out  ),
        .gpio3_dir        ( S_gpio3_dir  ),
        .gpio3_in         ( S_gpio3_in   ),

        .gpio4_out        ( S_gpio4_out  ),
        .gpio4_dir        ( S_gpio4_dir  ),
        .gpio4_in         ( S_gpio4_in   ),

        .gpio5_out        ( S_gpio5_out  ),
        .gpio5_dir        ( S_gpio5_dir  ),
        .gpio5_in         ( S_gpio5_in   ),

        .gpio6_out        ( S_gpio6_out  ),
        .gpio6_dir        ( S_gpio6_dir  ),
        .gpio6_in         ( S_gpio6_in   ),

        .gpio7_out        ( S_gpio7_out  ),
        .gpio7_dir        ( S_gpio7_dir  ),
        .gpio7_in         ( S_gpio7_in   ),

        .htrans           (  ),
        .hwrite           (  ),
        .haddr            (  ),
        .hsize            (  ),
        .hburst           (  ),
        .hprot            (  ),
        .hmastlock        (  ),
        .hwdata           (  ),
        .hclk             (  ),
        .hrdata           (  ),
        .hresp            (  ),
        .hready           (  ),
        .i2c_sda_out      (  ),
        .i2c_sda_sel      (  ),
        .i2c_scl_out      (  ),
        .i2c_scl_sel      (  ),
        .i2c_sda_in       (  ),
        .i2c_scl_in       (  ),
        .nmi              (  ),
        .clic_irq         (  ),
        .sysrstreq        (  ),
        .apb_clk_down     (  ),
        .apb_paddr_down   (  ),
        .apb_penable_down (  ),
        .apb_pprot_down   (  ),
        .apb_prdata_down  (  ),
        .apb_pready_down  (  ),
        .apb_pslverr_down (  ),
        .apb_pstrobe_down (  ),
        .apb_pwdata_down  (  ),
        .apb_pwrite_down  (  ),
        .apb_psel0_down   (  ),
        .apb_psel1_down   (  ),
        .apb_psel2_down   (  )
    );


endmodule

    管脚约束文件如下:

set_pin_assignment	{ I_clk_25m }	{ LOCATION = D7; }
set_pin_assignment  { I_rst_n   }   { LOCATION = H3; }

set_pin_assignment  { O_oled_scl }  { LOCATION = G4; }
set_pin_assignment  { IO_oled_sda } { LOCATION = J2; }
set_pin_assignment  { O_oled_rst_n} { LOCATION = H9; }
set_pin_assignment  { O_led }       { LOCATION = J5; }

set_pin_assignment  { I_jtag_tck }  { LOCATION = C7;}
set_pin_assignment  { O_jtag_tdo }  { LOCATION = C6;}
set_pin_assignment  { I_jtag_tms }  { LOCATION = D6;}
set_pin_assignment  { I_jtag_tdi }  { LOCATION = D5;}
                               

    FD软件代码,main.c实现led灯点亮期间实现图片滚动效果,led熄灭期间图片停止滚动。

#include <stdio.h>
#include "nuclei_sdk_hal.h"
#include "./inc/oled_display.h"

int main(void)
{  

	anlogic_log_display();

    while(1)
    {

       	LED_High();
       	display_horizontal_scroll_enable();
    	delay_1ms(2270);
    	LED_Low();
    	display_horizontal_scroll_disable();
    	delay_1ms(4000);
    }

    return 0;
}


    oled_display.c文件存放图片数据,以及点屏的代码:

/*
 * oled_display.c
 *
 *  Created on: 2022年1月13日
 *      Author: guoqiang.xiong
 */
#include "./inc/gpio_controler.h"
#include "./inc/oled_display.h"
#include <machine/_default_types.h>



void anlogic_log_display(void)
{
	int index=0;
	int oled_display_data[8][128];
    int anlogic_log_data[512] =    {0x04, 0x00, 0x00, 0x00, 0x07, 0x00, 0x00, 0x00, 0x07, 0xc0, 0x00, 0x00, 0x07, 0x80, 0x00, 0x00,
									0x0f, 0x80, 0x00, 0x00, 0x0f, 0x80, 0x00, 0xf0, 0x0f, 0x80, 0x00, 0xf8, 0x0f, 0x80, 0x00, 0x78,
									0x07, 0x80, 0x00, 0x78, 0x07, 0xc0, 0x00, 0x78, 0x07, 0xc0, 0x00, 0x78, 0x07, 0xc0, 0x00, 0x78,
									0x03, 0xe0, 0x00, 0x78, 0x03, 0xf0, 0x00, 0xf8, 0x01, 0xf8, 0x00, 0xf8, 0x00, 0xfc, 0x01, 0xf8,
									0x00, 0x7f, 0xc7, 0xf0, 0x00, 0x3f, 0xff, 0xf0, 0x00, 0x1f, 0xff, 0xe0, 0x00, 0x0f, 0xff, 0xc0,
									0x00, 0x03, 0xff, 0x80, 0x07, 0x00, 0x18, 0x00, 0x07, 0xf0, 0x00, 0x00, 0x07, 0xff, 0x00, 0x00,
									0x07, 0xff, 0xf8, 0x00, 0x07, 0xff, 0xff, 0xc0, 0x01, 0xff, 0xff, 0xf8, 0x00, 0x0f, 0xff, 0xf8,
									0x00, 0x00, 0x7f, 0xf8, 0x00, 0x00, 0x07, 0xf8, 0x00, 0x00, 0x00, 0x38, 0x07, 0x00, 0x00, 0x00,
									0x07, 0xc1, 0xe0, 0x00, 0x07, 0xc0, 0xff, 0x00, 0x07, 0x80, 0xff, 0xf0, 0x07, 0x80, 0xff, 0xf0,
									0x07, 0x80, 0x7f, 0xf0, 0x07, 0x80, 0x71, 0xf8, 0x07, 0x80, 0x20, 0xf8, 0x07, 0x80, 0x20, 0x78,
									0x07, 0x80, 0x00, 0x78, 0x07, 0xc0, 0x00, 0x78, 0x03, 0xc0, 0x00, 0x78, 0x03, 0xe0, 0x00, 0xf8,
									0x03, 0xf0, 0x00, 0xf8, 0x01, 0xf8, 0x00, 0xf8, 0x00, 0xfc, 0x01, 0xf8, 0x00, 0x7f, 0x87, 0xf0,
									0x00, 0x3f, 0xff, 0xf0, 0x00, 0x1f, 0xff, 0xe0, 0x00, 0x0f, 0xff, 0xc0, 0x00, 0x03, 0xff, 0x80,
									0x00, 0x00, 0x7f, 0x00, 0x00, 0x1c, 0x00, 0x00, 0x00, 0x7f, 0xe0, 0x00, 0x00, 0xff, 0xf8, 0x00,
									0x01, 0xff, 0xfe, 0x00, 0x03, 0xff, 0xff, 0x00, 0x07, 0xff, 0xff, 0xc0, 0x07, 0xf0, 0x3f, 0xe0,
									0x0f, 0xc0, 0x0f, 0xe0, 0x0f, 0x80, 0x03, 0xf0, 0x0f, 0x80, 0x01, 0xf0, 0x0f, 0x80, 0x00, 0xf8,
									0x0f, 0x80, 0x00, 0x78, 0x07, 0x80, 0x00, 0x78, 0x07, 0x80, 0x00, 0x78, 0x07, 0xc0, 0x00, 0x78,
									0x03, 0xe0, 0x00, 0x78, 0x03, 0xf8, 0x00, 0xf8, 0x01, 0xfe, 0x01, 0xf8, 0x00, 0xff, 0x07, 0xf8,
									0x00, 0x7f, 0xff, 0xf8, 0x00, 0x3f, 0xff, 0xf0, 0x00, 0x1f, 0xff, 0xe0, 0x00, 0x07, 0xff, 0xc0,
									0x00, 0x01, 0xff, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x70, 0x00, 0x00, 0x00, 0x78,
									0x00, 0x00, 0x00, 0x78, 0x00, 0x00, 0x00, 0x78, 0x00, 0x00, 0x00, 0x78, 0x07, 0x00, 0x00, 0x78,
									0x07, 0xf0, 0x00, 0x78, 0x07, 0xff, 0x80, 0x78, 0x07, 0xff, 0xf8, 0x78, 0x07, 0xff, 0xff, 0xf8,
									0x07, 0xff, 0xff, 0xf8, 0x00, 0x1f, 0xff, 0xf8, 0x00, 0x01, 0xff, 0xf8, 0x00, 0x00, 0x0f, 0xf8,
									0x08, 0x00, 0x00, 0x78, 0x08, 0x00, 0x00, 0x00, 0x09, 0x00, 0x00, 0x00, 0x09, 0x20, 0x00, 0x00,
									0x09, 0x24, 0x00, 0x00, 0x09, 0x24, 0x00, 0x00, 0x09, 0x24, 0x80, 0x00, 0x09, 0x24, 0x90, 0x00,
									0x09, 0x24, 0x90, 0x00, 0x09, 0x24, 0x94, 0x00, 0x09, 0x24, 0x94, 0x80, 0x09, 0x24, 0x94, 0x90,
									0x09, 0x24, 0x94, 0x80, 0x09, 0x24, 0x94, 0x30, 0x09, 0x24, 0x90, 0xf0, 0x09, 0x24, 0x93, 0xf0,
									0x09, 0x24, 0x8f, 0xf0, 0x09, 0x24, 0x3f, 0xf0, 0x09, 0x24, 0xff, 0xe0, 0x09, 0x23, 0xff, 0x80,
									0x09, 0x0f, 0xfe, 0x00, 0x08, 0x3f, 0xf8, 0x10, 0x08, 0xff, 0xe0, 0x70, 0x03, 0xff, 0x80, 0xf0,
									0x07, 0xff, 0x00, 0xf0, 0x03, 0xff, 0xc0, 0xf0, 0x00, 0x7f, 0xf0, 0xf0, 0x00, 0x1f, 0xfc, 0xf0,
									0x00, 0x07, 0xff, 0xf0, 0x00, 0x01, 0xff, 0xf0, 0x00, 0x00, 0x7f, 0xf0, 0x00, 0x00, 0x1f, 0xf0,
									0x00, 0x00, 0x07, 0xf0, 0x00, 0x00, 0x01, 0xf0, 0x00, 0x00, 0x00, 0x70, 0x00, 0x00, 0x00, 0x10};

    //图像数据映射为SSD1306的显示数据
	for(int j=0; j<128; j++)
	{
		for(int i=7; i>=0; i--)
		{
			if(i > 3)
			{
				oled_display_data[i][j] = anlogic_log_data[index];
				index++;
			}
			else
				oled_display_data[i][j] = 0x00;
		}
	}

	OLED_Init();      //初始化

	OLED_Clear();     //清屏

	OLED_WriteC(0x2e);//关闭滚动

	OLED_Frame(oled_display_data);  //写入图像

	OLED_WriteC(0x27);  //水平向左或者右滚动 26/27
	OLED_WriteC(0x00);  //虚拟字节
	OLED_WriteC(0x00);  //起始页 0
	OLED_WriteC(0x07);  //滚动时间间隔
	OLED_WriteC(0x07);  //终止页 7
	OLED_WriteC(0x00);  //虚拟字节
	OLED_WriteC(0xff);  //虚拟字节
	OLED_WriteC(0x2f);  //开启滚动
}

void display_horizontal_scroll_enable()
{
	OLED_WriteC(0x2f);//开启滚动
}

void display_horizontal_scroll_disable()
{
	OLED_WriteC(0x2e);//关闭滚动
}

void oled_display_reset()
{
	gpio_wr(4,0);
	delay_1us(10000);
	gpio_wr(4,1);
	delay_1us(10000);
}

void OLED_WriteD(int dat)
{
	IIC_START();		// 通信开始
	IIC_Write(0X78);	// 写从机地址'0111 100' 读写符号'0'
	IIC_WaitACK();
	IIC_Write(0X40);	// 写数据 Co='0' C/D='100 0000'
	IIC_WaitACK();
	IIC_Write(dat);		// 写入数据
	IIC_WaitACK();
}

void OLED_WriteC(int cmd)
{
	IIC_START();		// 通信开始
	IIC_Write(0X78);	// 写从机地址'0111 100' 读写符号'0'
	IIC_WaitACK();
	IIC_Write(0X00);	// 写命令 Co='0' C/D='000 0000'
	IIC_WaitACK();
	IIC_Write(cmd);		// 写入命令
	IIC_WaitACK();
}

void OLED_WriteDat(int dat)
{
	OLED_WriteD(dat);
	IIC_STOP();			// 通信结束
}

void OLED_WriteCmd(int cmd)
{
	OLED_WriteC(cmd);
	IIC_STOP();			// 通信结束
}

void OLED_Init(void)
{
	oled_display_reset();

	OLED_WriteC(0XAE);		// 关OLED显示
	// 基础设置
	OLED_WriteC(0XA4);		// 输出GDDRAM内容
	OLED_WriteC(0XA6);		// 正常显示(1亮0灭)
	OLED_WriteC(0X81);		// 设置对比度
	OLED_WriteC(0X7F);		// 第127级对比度
	// COM和SEG输出设置
	OLED_WriteC(0XD3);		// 设置垂直显示偏移(向上)
	OLED_WriteC(0X00);		// 偏移0行
	OLED_WriteC(0X40);		// 设置GDDRAM起始行 0
	OLED_WriteC(0XA8);		// 设置MUX数 (显示行数)
	OLED_WriteC(0X3F);		//  MUX=63	 (显示63行)
	OLED_WriteC(0XA1);		// 左右反置关(段重映射)
	OLED_WriteC(0XC8);		// 上下反置关(行重映射)
	OLED_WriteC(0XDA);		// 设置COM引脚配置
	OLED_WriteC(0X02);		// 序列COM配置,禁用左右反置
	// 时钟设置
	OLED_WriteC(0XD5);		// 设置DCLK分频和OSC频率
	OLED_WriteC(0X80);		// 无分频,第8级OSC频率
	// 开OLED
	OLED_WriteC(0X8D);		// 启用电荷泵
	OLED_WriteC(0X14);		// 启用电荷泵
	OLED_WriteC(0XAF);		// 开OLED显示

	IIC_STOP();
}

void OLED_Clear(void)
{
	int i,j;

	OLED_WriteC(0X00);		// 水平寻址模式
	OLED_WriteC(0X21);		// 设置列起始和结束地址
	OLED_WriteC(0X00);		// 列起始地址 0
	OLED_WriteC(0X7F);		// 列终止地址 127
	OLED_WriteC(0X22);		// 设置页起始和结束地址
	OLED_WriteC(0X00);		// 页起始地址 0
	OLED_WriteC(0X07);		// 页终止地址 7

	for(i=0; i<8; i++)		// 写入一帧'0'
		for(j=0; j<128; j++)
			OLED_WriteD(0X00);

	IIC_STOP();
}

void OLED_Frame(int P[8][128])
{
	int i,j;

	OLED_WriteC(0X20);	// 设置GDDRAM模式
	OLED_WriteC(0X00);	// 水平寻址模式
	OLED_WriteC(0X21);	// 设置列起始和结束地址
	OLED_WriteC(0X00);	// 列起始地址 0
	OLED_WriteC(0X7F);	// 列终止地址 127
	OLED_WriteC(0X22);	// 设置页起始和结束地址
	OLED_WriteC(0X00);	// 页起始地址 0
	OLED_WriteC(0X07);	// 页终止地址 7

	for(i=0; i<8; i++)		// 写入一帧数据
		for(j=0; j<128; j++)
			OLED_WriteDat(P[i][j]);

	IIC_STOP();
}

//----------------------------------内部函数内容-----------------------------------//

void IIC_START(void)
{
	SCL_Low();		// SCL拉低 防止可能出现的各种误动作
	delay1us();
	SDA_High();		// SDA拉高
	SCL_High();		// SCL拉高 准备发出起始信号
	delay1us();
	SDA_Low();		// SDA拉低 发出起始信号
	SCL_Low();		// SCL拉低 开始传输
}

void IIC_STOP(void)
{
	SCL_Low();		// SCL拉低 防止可能出现的各种误动作
	SDA_Low();		// SDA拉低
	delay1us();
	SCL_High();		// SCL拉高 准备发出结束信号
	delay1us();
	SDA_High();		// SDA拉高 发出结束信号
}

int IIC_WaitACK(void)
{
	int s;
	SCL_Low();		// 拉低SCL
	delay1us();
	SDA_High();		// 拉高SDA 主机释放总线
	delay1us();
	SCL_High();		// 拉高SCL
	delay1us();
	s = SDA_read();		// 采集SDA信号线状态
	delay1us();
	SCL_Low();		// 拉低SCL 结束询问ACK
	if(s)
		return 0;	// 无应答(ACK)
	else
		return 1;	// 有应答(ACK)
}

void IIC_Write(int dat)
{
	int i;
	int temp;

	for(i=0; i<8; i++)
	{
		temp = dat & 0x80;
		if(temp == 0x80)
			SDA_High();
		else
			SDA_Low();
		dat <<= 1;			// 数据格式:高位在前
		delay1us();
		SCL_High();			// 拉高SCL 发送数据
		delay1us();
		SCL_Low();			// 拉低SCL 结束发送
	}
}

void delay1us(void)
{
	delay_1us(1);
}


void SCL_Low(void)
{
	gpio_wr(0,0);
}

void SCL_High(void)
{
	gpio_wr(0,1);
}

void SDA_Low(void)
{
	gpio_wr(1,0);
}

void SDA_High(void)
{
//	gpio_wr(1,1);
	gpio_rd(1);
}

void LED_High(void)
{
	gpio_wr(2,1);
}

void LED_Low(void)
{
	gpio_wr(2,0);
}

int SDA_read(void)
{
	int temp;

	temp = gpio_rd(1);

	if(temp == 1)
		return 1;
	else
		return 0;
}



    实验效果:可以看到当led点亮时ANLOGIC图片滚动,led熄灭时图片停止滚动。实际OLED屏幕排线焊接效果还行,就是屏幕亮度比较暗。本来还想了解一下板子加速神经网络相关计算的历程,后面因为OLED屏幕排线断了,排查了一段时间,导致现在已经接近测评尾声了。

V20240302-150726

 

本帖最后由 1nnocent 于 2024-3-27 22:03 编辑

回复评论

暂无评论,赶紧抢沙发吧
电子工程世界版权所有 京B2-20211791 京ICP备10001474号-1 京公网安备 11010802033920号
    写回复