Files
kunlun/dtest/i2c_test/i2c_test.c

594 lines
29 KiB
C
Raw Permalink Normal View History

2024-09-28 14:24:04 +08:00
/****************************************************************************
*
* Copyright(c) 2019 by Aerospace C.Power (Chongqing) Microelectronics. ALL RIGHTS RESERVED.
*
* This Information is proprietary to Aerospace C.Power (Chongqing) Microelectronics and MAY NOT
* be copied by any method or incorporated into another program without
* the express written consent of Aerospace C.Power. This Information or any portion
* thereof remains the property of Aerospace C.Power. The Information contained herein
* is believed to be accurate and Aerospace C.Power assumes no responsibility or
* liability for its use in any way and conveys no license or title under
* any patent or copyright and makes no representation or warranty that this
* Information is free from patent or copyright infringement.
*
* ****************************************************************************/
/* os shim includes */
#include "os_types.h"
#include "os_task.h"
#include "os_utils.h"
/* common includes */
#include "iot_io.h"
#include "iot_bitops.h"
#include "iot_pkt_api.h"
#include "iot_ipc.h"
#include "iot_plc_lib.h"
#include "iot_dbglog_api.h"
#include "iot_config.h"
/* driver includes */
#include "iot_clock.h"
#include "iot_uart.h"
#include "iot_led.h"
/* cli includes */
#include "iot_cli.h"
#include "iot_uart_h.h"
/* debug includes*/
#include "dbg_io.h"
#include "apb_glb_reg.h"
#include "hw_reg_api.h"
#include "gpio_mtx_reg.h"
#include "pin_rf.h"
#include "gpio_mtx.h"
#include "gpio_reg.h"
#include "i2c_reg.h"
#include "i2c_hw.h"
#include "iot_i2c_api.h"
#define OLED_X_WIDTH 132
#define OLED_Y_WIDTH 64
#define I2C_OLED_ADD 0x3C
int g_port = IOT_I2C_PORT_0;
iot_i2c_module_cfg_t g_cfg = {0};
const unsigned char pic1[]={
0xFF,0x01,0x01,0xF9,0xF9,0x09,0x89,0xC9,0xC9,0xC9,0xC9,0xC9,0xC9,0xC9,0xC9,0x49,
0x49,0x49,0x49,0x49,0x49,0x49,0x09,0x09,0x89,0x89,0xC9,0xC1,0x61,0x31,0x31,0x49,
0xC9,0xC9,0xC9,0xC9,0xC9,0xC9,0xC9,0xC9,0xC9,0xC9,0xC9,0xC9,0xC9,0xC9,0xC9,0xC9,
0xD9,0xD9,0xD9,0xD9,0xD9,0xD9,0xD9,0xD9,0xD9,0x99,0x19,0xF9,0xF1,0x01,0xFF,0xFF,
0xFF,0x00,0x00,0xFF,0x01,0x00,0xFF,0xFF,0x00,0xC0,0xFE,0x06,0x06,0xE6,0x46,0x66,
0x32,0x10,0x98,0xCC,0xCC,0x66,0x66,0x33,0x31,0x99,0x8C,0xCC,0xC6,0x66,0x33,0x32,
0x36,0x36,0x36,0x36,0x36,0x36,0x36,0x36,0x36,0x36,0x36,0x36,0x36,0x36,0x36,0x36,
0x36,0x76,0xD6,0x06,0x06,0xFE,0xC0,0x00,0xFF,0xFF,0x00,0xFF,0xFF,0x00,0x01,0xFF,
0xFF,0x00,0x00,0xFF,0x00,0x00,0xFF,0xFF,0x00,0xFF,0xFF,0x00,0x00,0xFF,0x00,0x00,
0xFF,0xF3,0x01,0xF8,0xFC,0x06,0x26,0xB3,0x33,0x99,0x99,0xCC,0xCC,0x66,0x66,0x23,
0xD9,0xD9,0xD9,0xD9,0xD9,0xC9,0xC9,0xC9,0xC9,0x09,0xE9,0xC9,0x09,0x39,0xF1,0xC7,
0x0E,0x38,0xE1,0xC7,0x0C,0x38,0xE1,0xC0,0x0F,0x3F,0x00,0x01,0xFF,0x00,0x00,0xFF,
0xFF,0x00,0x00,0xFF,0x00,0x00,0xFF,0x07,0x00,0xFF,0xFF,0x00,0x00,0xFF,0x00,0x00,
0xFF,0xFF,0x00,0x3F,0xFF,0x00,0x00,0xFF,0x80,0x01,0xFD,0xE4,0x0C,0x64,0xE6,0x26,
0x64,0x24,0xE6,0x06,0x06,0xFE,0xF0,0x00,0x0F,0xFC,0xE0,0x03,0x0F,0x7C,0xF0,0xC3,
0x0F,0x3C,0xF0,0xC3,0x0F,0x3C,0x70,0xC3,0x07,0x1C,0x78,0xE0,0x87,0x00,0x00,0xFF,
0xFF,0x00,0x00,0xE1,0x06,0x0E,0x38,0xF0,0xC3,0x0E,0x1C,0x70,0xC3,0x8F,0x1C,0x70,
0xE1,0x87,0x1E,0x38,0xE1,0x87,0x0E,0x38,0x70,0x03,0x0F,0x3C,0xB0,0xB3,0xB7,0xB2,
0x66,0x67,0x67,0x20,0x21,0x3F,0x80,0x80,0xFF,0xFF,0x00,0x1F,0xFF,0x00,0x00,0xFF,
0x00,0x00,0xFF,0xFF,0x00,0xFF,0xFF,0x00,0x00,0xFF,0x00,0x00,0xFF,0x00,0x00,0xFF,
0xFF,0x00,0x00,0xFF,0x00,0x00,0xFC,0xF8,0x01,0x87,0x1E,0x38,0xE1,0xC7,0x0E,0x38,
0xF1,0xC3,0x8E,0x9C,0xD0,0xDB,0xD9,0xD8,0xD9,0xD9,0xD9,0xD9,0xD9,0xD9,0xD9,0xD9,
0xCC,0x66,0x66,0x63,0x33,0x33,0x99,0x99,0xCC,0xCD,0x64,0x20,0x3F,0x00,0x80,0xFF,
0x00,0x00,0xFF,0xFF,0x00,0x7F,0xFF,0x00,0x00,0xFF,0x00,0x00,0xFF,0x00,0x00,0xFF,
0xFF,0x00,0x00,0xFF,0x00,0x00,0xFF,0xFF,0x00,0x01,0x7F,0x60,0x60,0x61,0x67,0x64,
0x64,0x64,0x64,0x64,0x64,0x64,0x64,0x64,0x64,0x64,0x64,0x64,0x64,0x64,0x64,0x64,
0x0C,0xCC,0xC6,0x66,0x33,0x33,0x99,0x99,0xCC,0xCC,0x66,0x62,0x33,0x19,0x19,0x4C,
0x6C,0x66,0x63,0x67,0x60,0x60,0x3F,0x00,0x00,0xFF,0x00,0x00,0xFF,0x00,0x00,0xFF,
0xFF,0x80,0x80,0x9F,0x90,0x90,0x93,0x93,0x93,0x93,0x93,0x93,0x93,0x93,0x93,0x93,
0x93,0x93,0x93,0x93,0x93,0x93,0x93,0x93,0x93,0x93,0x93,0x93,0x93,0x93,0x93,0x93,
0x93,0x9C,0x8C,0x86,0x86,0x93,0x93,0x91,0x90,0x90,0x92,0x93,0x93,0x93,0x93,0x93,
0x93,0x93,0x93,0x93,0x93,0x93,0x93,0x9B,0x9B,0x9B,0x98,0x98,0x9F,0x80,0x80,0xFF//"C:\Users\fortest\Desktop\blackwhite.bmp",0
};
const unsigned char pic2[]=
{
0xFF,0xF1,0x01,0x01,0x03,0x03,0x03,0x03,0x07,0x87,0x87,0xC7,0xC7,0xEF,0xEF,0xEF,
0xEF,0xEF,0xEF,0xEF,0xC7,0xC7,0x87,0x87,0x03,0x03,0x03,0x03,0x01,0x01,0x81,0xF1,
0xFD,0x81,0x01,0x01,0x03,0x03,0x03,0x03,0x87,0x87,0xC7,0xC7,0xE7,0xEF,0xEF,0xEF,
0xEF,0xEF,0xEF,0xC7,0xC7,0xC7,0x87,0x03,0x03,0x03,0x03,0x01,0x01,0x01,0xE1,0xFF,
0xFF,0xFF,0xFF,0xF0,0x00,0xE0,0xFC,0xFE,0x7F,0x0F,0x07,0x03,0x03,0xC1,0xE1,0xE0,
0xE0,0xE0,0xE1,0xC1,0x03,0x03,0x07,0x1F,0xFF,0xFE,0xF8,0xE0,0x00,0x78,0x3F,0x1F,
0x1F,0x3F,0x78,0x00,0xE0,0xF8,0xFE,0xFF,0x1F,0x07,0x03,0x03,0xC1,0xE1,0xE0,0xE0,
0xE0,0xE1,0xC1,0x01,0x03,0x07,0x0F,0x7F,0xFE,0xFC,0xF0,0x00,0xE0,0xFE,0xFF,0xFF,
0xFF,0xFF,0xFF,0x0F,0x00,0x0F,0x3F,0xFF,0xFC,0xE0,0xC0,0x80,0x80,0x07,0x0F,0x0F,
0x0F,0x0F,0x0F,0x07,0x80,0xC0,0xE0,0xF0,0xFF,0x7F,0x3F,0x07,0x00,0x1C,0xF8,0xF0,
0xF0,0xF8,0x1C,0x00,0x0F,0x3F,0x7F,0xFF,0xF0,0xE0,0xC0,0x80,0x03,0x07,0x0F,0x0F,
0x0F,0x0F,0x07,0x80,0x80,0xC0,0xF0,0xFC,0xFF,0x3F,0x0F,0x00,0x1F,0xFF,0xFF,0xFF,
0xFF,0x0F,0x00,0x00,0x80,0x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FF,0xFF,0xFF,0xFF,0xFF,0xFF,
0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0x1F,
0x03,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x01,
0x07,0x1F,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,
0xFF,0xFF,0xFF,0xFF,0xFF,0xC0,0x00,0x00,0x00,0x00,0x80,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,
0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0x86,0x00,0x02,0xE1,
0xF0,0xF8,0xF8,0xFC,0xFC,0xFC,0xF8,0xF8,0xF0,0xE0,0x00,0x00,0x00,0x00,0x00,0x00,
0xF0,0xF8,0xFC,0xFC,0xFC,0xFC,0xFC,0xFC,0xF8,0xF0,0x40,0x02,0x00,0x66,0xFF,0xFF,
0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0x7F,0x7F,
0xFF,0xFF,0xF1,0xC0,0x80,0x81,0x83,0x87,0x87,0x87,0x83,0x03,0x01,0x01,0x00,0x00,
0x40,0xF8,0x00,0x7C,0x60,0x00,0x00,0x01,0x01,0x03,0x03,0x03,0x03,0x03,0x03,0x01,
0x00,0x80,0xF0,0xFC,0xFF,0xFF,0x7F,0x7F,0x7F,0x7F,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xFF,0xFF,0xFF,0xFF,
0xFD,0xFC,0xFC,0xFC,0xFC,0xFE,0xFE,0xDE,0xE7,0xE0,0xF0,0xF0,0xF8,0xFC,0xFC,0xBF,
0xC0,0xE0,0xF0,0xF8,0xFC,0xFE,0xFE,0xC0,0xF0,0xF8,0xFE,0xFF,0xFF,0xFF,0xFE,0xFC,
0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF//"C:\Users\fortest\Desktop\center.bmp",0
};
const unsigned char pic5[]=
{
0x00,0x00,0x00,0x80,0xC0,0x61,0x27,0x1C,0x10,0x03,0x06,0x0C,0x18,0x0C,0x04,0x06,
0xE2,0xA1,0x11,0x19,0x0F,0x82,0xF0,0x3C,0x0E,0xC2,0xE3,0x9E,0x80,0x80,0xFE,0x7F,
0x01,0x00,0x60,0x7B,0x3E,0x31,0x97,0x9C,0xC0,0x80,0x80,0x80,0x80,0x86,0x83,0x86,
0x46,0x3C,0xD8,0x60,0x10,0x09,0x09,0x06,0x86,0x4D,0x38,0x00,0x03,0xF4,0x14,0x0A,
0x09,0x08,0x18,0xF0,0x00,0x00,0x87,0xF8,0x00,0x00,0x30,0x3F,0x20,0x20,0x20,0x20,
0x20,0x20,0x60,0xC0,0xC1,0x01,0x01,0x01,0x01,0x01,0xF0,0x1F,0x03,0x00,0x80,0xF0,
0x3F,0x00,0x00,0x80,0xC0,0x60,0x30,0x18,0x08,0x07,0x07,0x80,0xC0,0xC1,0x81,0x83,
0x03,0x01,0x00,0x18,0x3C,0x24,0x66,0x43,0x41,0x40,0x78,0x7F,0x07,0x00,0x30,0x3C,
0x00,0x1E,0x33,0x61,0x60,0x20,0x30,0x18,0x0C,0x83,0xC3,0x43,0x66,0x66,0x64,0xCC,
0x88,0x18,0x59,0xF9,0x81,0x81,0x81,0xF0,0x38,0x08,0x89,0x8D,0x4C,0x64,0x24,0x34,
0x16,0x92,0x8A,0xCB,0x09,0x0D,0x04,0x04,0x24,0x64,0xE5,0xA5,0x25,0x25,0x25,0x24,
0x24,0xE7,0x01,0x00,0x00,0x00,0x44,0xEF,0x29,0x48,0xD0,0x90,0x20,0x21,0x23,0x1C,
0x90,0x80,0x40,0x43,0x42,0x99,0xBD,0x26,0x22,0x62,0x46,0x44,0x44,0x64,0x2C,0x34,
0x14,0x14,0x16,0x13,0x11,0x30,0x20,0x60,0xC0,0x00,0x01,0x03,0x02,0x03,0x01,0x00,
0x00,0x00,0x00,0x1F,0x30,0x20,0x20,0x30,0x10,0x18,0x06,0x83,0xC0,0xE0,0x61,0x61,
0x23,0x63,0x66,0xE6,0xC6,0x04,0x0C,0xFC,0xCC,0x80,0xC0,0xC0,0xFC,0x3E,0x06,0x82,
0x03,0x03,0xCE,0x7C,0x00,0x00,0x00,0xFC,0xCF,0x01,0x00,0x00,0x00,0x00,0x00,0xE0,
0xFF,0x40,0x60,0x20,0xB1,0xD9,0xC9,0x84,0x06,0x13,0x39,0x2C,0xE4,0x06,0x83,0x81,
0x81,0x80,0x80,0x87,0x9C,0x70,0xC0,0x80,0x00,0x00,0x00,0x01,0x03,0x0E,0xF8,0x00,
0x1F,0x71,0xC0,0x80,0x00,0x00,0x80,0x61,0x0C,0x70,0x0C,0x03,0x00,0x00,0xFC,0x0C,
0x18,0x33,0x26,0x4C,0x98,0x10,0x20,0x7D,0xE3,0xC0,0xC0,0x44,0x3C,0x0C,0x08,0x08,
0x18,0x18,0x10,0x10,0x98,0x98,0x88,0x8C,0x07,0x00,0x80,0xF0,0x1C,0x0E,0x06,0x03,
0x03,0x03,0x03,0x06,0xFE,0xF8,0x00,0x00,0x00,0xF8,0xFF,0x03,0x01,0x00,0x00,0x00,
0x00,0x00,0x80,0xF0,0x9F,0x80,0xC0,0x40,0x61,0x31,0x99,0x18,0x0C,0x06,0x33,0x39,
0xCE,0x6F,0x25,0x24,0x24,0xE4,0xE4,0x06,0x03,0x3A,0xE8,0x88,0x08,0x04,0x04,0x08,
0x90,0xE2,0x03,0x05,0xC4,0x88,0x88,0x11,0x11,0x21,0x21,0x3D,0x06,0x03,0x01,0x01,
0x80,0xC0,0xC0,0x60,0x39,0x0F,0x80,0x81,0xC3,0x62,0x62,0x62,0x22,0x23,0x61,0xC0,
0x80,0x00,0x00,0x01,0x01,0x01,0x00,0x00,0x07,0x18,0x30,0x30,0x30,0x18,0x07,0x00,
0x00,0x00,0x00,0x80,0x9F,0x90,0x98,0x0E,0x06,0x0C,0x19,0x33,0x22,0x46,0xC4,0x8C,
0x98,0x18,0x0C,0x03,0x30,0x38,0x2C,0x27,0x20,0x30,0xBF,0x03,0x00,0x00,0x00,0x00,
0x30,0x38,0x3C,0x37,0x33,0x10,0x10,0x90,0x18,0x19,0x0F,0xCC,0xC0,0x60,0x20,0x20,
0x30,0x30,0x61,0x41,0x81,0x09,0x1C,0x16,0x32,0x21,0x61,0x43,0x43,0xC6,0x86,0x84,
0x6E,0xC3,0x00,0x00,0x00,0x3F,0xE0,0x80,0x00,0x00,0x00,0x03,0x0E,0x78,0xC0,0x0F,
0x1F,0x20,0x20,0x30,0x1F,0x00,0x7D,0xC3,0x80,0x00,0x00,0x80,0xC0,0x7C,0x0C,0x08,
0x19,0x13,0xF2,0x26,0x06,0x03,0x01,0x01,0xE0,0xF0,0x30,0x10,0x98,0x88,0x8C,0x06,
0x03,0x00,0x00,0x1C,0x66,0xC2,0x82,0x06,0x04,0x08,0x30,0x60,0x20,0x30,0x90,0x90,
0x98,0x48,0x4F,0xC1,0x80,0x00,0x31,0x6E,0x40,0x40,0x40,0x80,0x80,0x80,0x00,0x0F,
0x3F,0x60,0xC0,0xC0,0x60,0x7F,0x03,0x01,0x01,0x01,0x01,0x07,0x1C,0x30,0x40,0xC0,
0xC0,0x7F,0x3F,0x01,0x01,0x01,0x61,0xFF,0x03,0x00,0x00,0x01,0x03,0x0E,0x78,0xE0,
0x00,0x00,0xE0,0xFC,0x0F,0x03,0x00,0x00,0xFE,0x0C,0x8C,0xF8,0x30,0x00,0x00,0x01,
0x03,0x81,0xC0,0x60,0x30,0x30,0x11,0x13,0x26,0xE6,0x8C,0x04,0x04,0x07,0xF3,0x18,
0x08,0x08,0x18,0x30,0xE0,0x80,0x00,0x80,0xC1,0x61,0x61,0x41,0xC0,0x00,0x00,0x00,
0x00,0x00,0x0F,0x18,0x30,0x20,0x60,0x30,0x3D,0x1F,0x00,0x7F,0xC1,0x01,0x01,0x01,
0x03,0x04,0x38,0xE0,0xC0,0x38,0x0F,0x03,0xE0,0x30,0x18,0x18,0x23,0x63,0x42,0x82,
0x84,0x8C,0x78,0x00,0x1F,0x30,0x20,0xE0,0xE2,0xBE,0x86,0xFC,0xE0,0x01,0x71,0xF3,
0x22,0x26,0x4C,0xC8,0x90,0x30,0x10,0x18,0x0C,0x04,0x86,0x86,0x82,0x82,0x83,0xC2,
0x62,0x7E,0x1C,0x00,0x00,0x00,0x00,0x0F,0x38,0xE0,0xC0,0x80,0x80,0x00,0x80,0x81,
0xFF,0x30,0x00,0x03,0x06,0x04,0x04,0x06,0x03,0x00,0x0F,0x1C,0x30,0x30,0x20,0x60,
0xC3,0x81,0x00,0x30,0x30,0x70,0x58,0x4C,0xC6,0x87,0x81,0x80,0x80,0x80,0x83,0x8E,
0xB8,0xE0,0x80,0x00,0x00,0x3F,0x30,0xB3,0x9F,0x90,0xC0,0x80,0x98,0x3F,0x20,0xC0,
0x00,0x00,0x80,0xC0,0xCF,0x99,0xB1,0x61,0xC3,0x82,0x04,0x08,0x30,0x61,0xC2,0xE6,
0x3C,0x0C,0x00,0x00,0xE0,0x70,0x20,0x61,0x43,0x43,0xC3,0xC3,0xC2,0xC6,0xC4,0x7C,
0x30,0x00,0x00,0x06,0x0B,0x11,0x11,0x10,0x10,0x10,0x10,0x10,0x88,0x58,0x40,0x01,
0x79,0x89,0x09,0x12,0x1C,0x01,0x02,0x04,0x08,0x31,0x63,0xC7,0x0D,0x19,0x70,0xC0,
0x80,0xE0,0x70,0x18,0x18,0x0C,0x0C,0x04,0x04,0x0C,0x99,0xF1,0x01,0x01,0x01,0x01,
0xFC,0x8E,0x02,0x03,0x03,0x06,0x0E,0x1C,0xF0,0x80,0x00,0x80,0xE0,0x30,0x30,0x30,
0x20,0x41,0x83,0x06,0x0C,0x18,0x30,0x60,0x5C,0xBC,0x2C,0x4C,0x8D,0x8D,0x0D,0x8D,
0x85,0xC4,0x44,0x4C,0x58,0x50,0xA0,0x21,0x43,0x64,0xBC,0xB0,0x80,0x01,0x01,0xC0,
0xC0,0x40,0x47,0x9D,0xB0,0x60,0x81,0x03,0x06,0x0D,0x33,0x66,0x3C,0x18,0x01,0x81,
0xC0,0x60,0x2C,0x2F,0xE8,0x08,0x08,0x08,0xE8,0xA8,0x48,0xC0,0x08,0x0C,0xE6,0x22,
0x21,0x31,0x11,0x1A,0x0E,0x00,0x00,0x00,0x38,0x46,0x83,0x81,0x00,0x00,0x80,0xE0,
0x38,0x19,0x31,0x21,0x43,0xC2,0x86,0x84,0x98,0xF0,0x00,0x00,0xE3,0x3E,0x00,0xC0,
0xC0,0x80,0x00,0x10,0x30,0x38,0x58,0x4C,0xC6,0x87,0x83,0x81,0x80,0x00,0x00,0x00,
0x01,0x07,0x3C,0xE0,0x80,0x00,0x00,0x00,0x3F,0x21,0x20,0x33,0x3F,0x90,0x80,0x00//"C:\Users\fortest\Desktop\23987259200809112241263643115724376_003_640.bmp",0
};
const unsigned char pic6[]=
{
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x80,0x80,0xC0,0xC0,
0xE0,0xE0,0xF0,0xF0,0xF8,0xF8,0xFC,0xFC,0xFE,0xFE,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,
0xFF,0x7F,0x7F,0x3F,0x3F,0x1F,0x1F,0x0F,0x0F,0x07,0x07,0x07,0x03,0x03,0x01,0x01,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x80,0x80,0xC0,0xC0,0xE0,0xE0,0xF0,0xF0,
0xF8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C,
0xFC,0xFE,0xFE,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0x7F,0x7F,0x3F,0x3F,0x1F,0x1F,
0x0F,0x0F,0x07,0x07,0x03,0x03,0x01,0x01,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x80,0x80,0xC0,0xC0,0xE0,0xE0,0xF0,0xF0,0xF8,0xF8,0xFC,0xFC,
0xFE,0xFE,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0x7F,0x7F,0x3F,0x3F,0x1F,0x1F,0x0F,
0x0F,0x07,0x07,0x03,0x03,0x01,0x01,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00//C:\Users\fortest\Desktop\t015385bc585c6df988.bmp0
};
extern int platform_init();
os_task_h test_init_handle;
int i2c_oled_write_command(char cmd)
{
uint8_t data[2] ;
int ret=0;
data[0] = 0x00;
data[1] = cmd;
ret = iot_i2c_write(g_port, I2C_OLED_ADD, (char *)data, 2 );
return ret;
}
int i2c_oled_write_data(char data)
{
uint8_t dat[2] ;
int ret=0;
dat[0] = 0x40;
dat[1] = data;
ret = iot_i2c_write(g_port, I2C_OLED_ADD, (char *)dat, 2 );
return ret;
}
void OLED_Set_Pos(unsigned int x, unsigned char y)
{
i2c_oled_write_command(0xb0+y);
i2c_oled_write_command(((x&0xf0)>>4)|0x10);
i2c_oled_write_command((x&0x0f)|0x01);
}
void i2c_oled_draw(unsigned int x_st, char y_st, unsigned int x_end, char y_end, const unsigned char pic[])
{
unsigned char x, y=0;
unsigned int j=0;
if(y_end%8==0)
{
y=y_end/8;
}
else
{
y=y_end/8+1;
}
for(y=y_st; y<=y_end; y++)
{
OLED_Set_Pos(x_st,y);
for(x=x_st; x<x_end; x++)
{
i2c_oled_write_data(pic[j++]);
}
}
}
void OLED_clear_screen(void)
{
unsigned char y=0;
unsigned int x=0;
for(y=0;y<8;y++)
{
i2c_oled_write_command(0xb0+y);
i2c_oled_write_command(0x01);
i2c_oled_write_command(0x10);
for(x=0;x<OLED_X_WIDTH;x++)
{
i2c_oled_write_data(0);
}
}
}
unsigned char i2c_oled_read(void)
{
char buf[2];
// iot_i2c_read(port,1,I2C_OLED_ADD);
if (iot_i2c_read(g_cfg.port, I2C_OLED_ADD, buf, 1)) {
iot_printf("read failed.\n");
}
return buf[0];
}
void i2c_oled_init(void)
{
unsigned char rd_data=0;
os_delay(500);
i2c_oled_write_command(0xae);//--turn off oled panel
i2c_oled_write_command(0x00);//---set low column address
i2c_oled_write_command(0x10);//---set high column address
i2c_oled_write_command(0x40);//--set start line address Set Mapping RAM Display Start Line (0x00~0x3F)
i2c_oled_write_command(0x81);//--set contrast control register
i2c_oled_write_command(0xCF); // Set SEG Output Current Brightness
i2c_oled_write_command(0xa1);//--Set SEG/Column Mapping 0xa0???? 0xa1??
i2c_oled_write_command(0xc8);//Set COM/Row Scan Direction 0xc0???? 0xc8??
i2c_oled_write_command(0xa6);//--set normal display
i2c_oled_write_command(0xa8);//--set multiplex ratio(1 to 64)
i2c_oled_write_command(0x3f);//--1/64 duty
i2c_oled_write_command(0xd3);//-set display offset Shift Mapping RAM Counter (0x00~0x3F)
i2c_oled_write_command(0x00);//-not offset
i2c_oled_write_command(0xd5);//--set display clock divide ratio/oscillator frequency
i2c_oled_write_command(0x80);//--set divide ratio, Set Clock as 100 Frames/Sec
i2c_oled_write_command(0xd9);//--set pre-charge period
i2c_oled_write_command(0xf1);//Set Pre-Charge as 15 Clocks & Discharge as 1 Clock
i2c_oled_write_command(0xda);//--set com pins hardware configuration
i2c_oled_write_command(0x12);
i2c_oled_write_command(0xdb);//--set vcomh
i2c_oled_write_command(0x40);//Set VCOM Deselect Level
i2c_oled_write_command(0x20);//-Set Page Addressing Mode (0x00/0x01/0x02)
i2c_oled_write_command(0x02);//
i2c_oled_write_command(0x8d);//--set Charge Pump enable/disable
i2c_oled_write_command(0x14);//--set(0x10) disable
i2c_oled_write_command(0xa4);// Disable Entire Display On (0xa4/0xa5)
i2c_oled_write_command(0xa6);// Disable Inverse Display On (0xa6/a7)
OLED_Set_Pos(0,0);
rd_data = i2c_oled_read();
iot_printf("I2C data read 0x%x\n",rd_data);
i2c_oled_write_command(0xaf);//--turn on oled panel
rd_data = i2c_oled_read();
iot_printf("I2C data read 0x%x\n",rd_data);
OLED_clear_screen();
}
void i2c_test_task()
{
g_cfg.port = IOT_I2C_PORT_0;
g_cfg.nack_wait_num = 10;
g_cfg.baud = 400;
g_cfg.gpio.scl = 22;
g_cfg.gpio.sda = 23;
if(0 != iot_i2c_module_init(&g_cfg)) {
iot_printf("i2c init err\r\n");
}
iot_printf("i2c init ok\r\n");
i2c_oled_init();
while(1)
{
iot_printf("i2c ok\r\n");
i2c_oled_draw(32,0,96,7,pic1);
os_delay(2500);
i2c_oled_draw(32,0,96,7,pic2);
os_delay(2500);
OLED_clear_screen();
i2c_oled_draw(37,0,91,7,pic3);
os_delay(2500);
i2c_oled_draw(32,0,96,7,pic4);
os_delay(2500);
i2c_oled_draw(0,0,127,7,pic5);
os_delay(2500);
i2c_oled_draw(0,0,127,7,pic6);
os_delay(2500);
OLED_clear_screen();
os_delay(3000);
}
}
void i2c_test_task_init()
{
os_task_h handle;
handle = os_create_task(i2c_test_task, NULL, 6);
if(handle != NULL) {
iot_printf("task create successfully...\n");
}
}
void i2c_test_init()
{
/* init common modules */
iot_bitops_init();
/* init os related modules and utilities */
os_utils_init();
/* init ipc module */
iot_ipc_init();
/*init uart module*/
iot_uart_init(1);
i2c_test_task_init();
}
void i2c_init_task(void *arg)
{
iot_printf("task 1 entry....\n");
for(;;) {
i2c_test_init();
os_delete_task(test_init_handle);
}
}
int32_t i2c_task_init()
{
/* start plc lib task */
test_init_handle = os_create_task(i2c_init_task, NULL, 9);
//create the tasks;
if(test_init_handle != NULL) {
iot_printf("task 1 init successfully...\n");
}
return 0;
}
int32_t i2c_task_start()
{
os_start_kernel();
return 0;
}
int32_t iot_platform_init()
{
platform_init();
system_clock_init();
//system_uart_init();
dbg_uart_init();
//iot_led_init();
return 0;
}
int32_t iot_module_init(void)
{
//platform intialization;
iot_platform_init();
//create all the tasks;
i2c_task_init();
iot_printf("starting...\n");
return 0;
}
int main(void)
{
//module init;
iot_module_init();
//module start;
i2c_task_start();
return 0;
}