我尝试通过I2C 读取和写入带有Raspberry Pi B + 的Atmel 24C256 EEPROM,但是我无法正常工作.
这是我到目前为止的代码:
#include <stdio.h>
#include <stdlib.h>
#include <linux/i2c-dev.h>
#include <fcntl.h>
#include <string.h>
#include <sys/ioctl.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <unistd.h>
#include <errno.h>
#include <linux/i2c.h>
#define DEVICE_PATH "/dev/i2c-1"
#define PAGE_SIZE 64
#define DEVICE_ADDR 0x50 // 0b1010xxxx
int file_desc;
char buffer[PAGE_SIZE + 2]; // 64 bytes + 2 for the address
void teardownI2C()
{
int result = close(file_desc);
}
void setupI2C()
{
file_desc = open(DEVICE_PATH, O_RDWR);
if(file_desc < 0)
{
printf("%s\n", strerror(errno));
exit(1); …Run Code Online (Sandbox Code Playgroud) 我正在阅读一些操作系统开发教程,并且经常看到以下代码段:
.intel_syntax noprefix
do_e820:
xor ebx, ebx # ebx must be 0 to start
xor bp, bp # keep an entry count in bp
mov edx, 0x0534D4150 # Place "SMAP" into edx
mov eax, 0xe820
mov [es:di + 20], dword 1 # <<<this is the line I don't get
mov ecx, 24 # ask for 24 bytes
int 0x15
jc short .failed # carry set on first call means "unsupported function"
mov edx, 0x0534D4150 # Some BIOSes apparently trash this …Run Code Online (Sandbox Code Playgroud)