read.c

来自「Source code for driving RFM01 fm radio r」· C语言 代码 · 共 22 行

C
22
字号
#include "../twi.h"

int TWI_read(unsigned char address, unsigned char *data, unsigned char bytes)
{
  while(TWI_stat & (1<<TWI_BUSY));  // Bus is busy wait (or exit with error code)

  TWI_address = address;
  TWI_data = data;
  TWI_bytes = bytes;
  TWI_ddr = TW_READ;

  TWI_retry_cnt = 0;
  
  /* Generate start condition, the remainder of the transfer is interrupt driven and
     will be performed in the background */
  TWCR = (1<<TWINT)|(1<<TWSTA)|(1<<TWEN)|(1<<TWIE);
  
  TWI_stat |= (1<<TWI_BUSY);
  return 0;
}

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?