📄 emi2c_test.c
字号:
#include <stdio.h>#include <stdlib.h>#include <string.h>//#include "../include/em_types.h"//#include "../include/dmesg.h"#define ALLOW_OS_CODE 1#include "rmdef/rmdef.h"#include "llad/include/gbus.h"#include "emhwlib_hal/include/emhwlib_registers.h"#include "emhwlib_hal/i2c/include/i2c_hal.h"#include "../helper/helper.h"#include "emi2c.h"#define EM86XX_CHIP_NUMBER 0int main(){ char device[10]; RMuint16 i; struct llad *pLLAD = NULL; struct gbus *pGBus = NULL; EMI2C_CONFIG C; RMuint8 nack; /* defaults */ /* use the correct chip in the system, if provided */ snprintf(device, 10, "%d", EM86XX_CHIP_NUMBER); pLLAD = llad_open(device); if (pLLAD == NULL) { MPRINT(("llad_open failed\n")); exit(-1); } pGBus = gbus_open(pLLAD); if( pGBus == NULL ) { llad_close(pLLAD); MPRINT(("gbus_open failed\n")); exit(-1); } memset(&C, 0, sizeof(C)); C.pGBus = pGBus; C.PIO_Clock = 0; C.PIO_Data = 1; C.RegBase = REG_BASE_system_block; emi2c_start(&C); emi2c_stop(&C); MPRINT(("I2C address scan\n")); MPRINT((" 00 01 02 03 04 05 06 07 08 09 0A 0B 0C 0D 0E 0F")); for ( i = 0; i <=255; i++ ) { if( (i % 16) == 0 ) MPRINT(("\n %.2x ", i)); emi2c_start(&C); emi2c_sendbyte(&C, i, &nack); if( nack ) { MPRINT((" . ")); } else MPRINT((" 1 ")); } MPRINT(("\nend scan\n")); emi2c_stop(&C); gbus_close(pGBus); llad_close(pLLAD); exit(0);}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -