Follow along with the video below to see how to install our site as a web app on your home screen.
Note: This feature may not be available in some browsers.
Code C - [expand] 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 #define F_CPU 16000000UL #include <avr/io.h> #include <string.h> #include <inttypes.h> #define SDA PC0 #define SCL PC1 #include "Lcd.avr.h" #include "I2C.avr.h" #include "i2cmaster.h" //#include "Rfid.h" #define Write_Address 0x50 //slave addres #define Register_Address 0x09 //fifo register address #define I2c_write 0 //write bit #define I2c_read 1 //read bit char Data=0x00; //Data[7:0] void Rfid_Start() { i2c_init(); i2c_start(Write_Address+I2c_write); i2c_write(Register_Address); i2c_write(Data); i2c_stop(); } unsigned char Rfid_get_data() { i2c_start(Write_Address+I2c_write); i2c_write(Register_Address);; _delay_ms(1); i2c_start(Write_Address+I2C_READ); Data = i2c_readAck(); i2c_stop(); return Data; } int main() { DDRB = 0xFF; lcd_init(); _delay_ms(100); LCD_String_xy(0,0); lcdprint("Show your card:"); Rfid_Start(); while(1) { Rfid_get_data(); LCD_String_xy(0,1); // PORTB = 0xFF; lcd_int(Data); } }
unsigned char Rfid_get_data
i2c_start(Write_Address+I2c_write);
i2c_write(Register_Address);
_delay_ms(1);
i2c_start(Write_Address+I2C_READ); [COLOR="#FF0000"]--> here I expect I2C_repeated_start instead of I2C_start[/COLOR].
Data = i2c_readAck();[COLOR="#FF0000"]--> here I expect to send a dummy byte 0xFF, then read the I2C_input_data_register[/COLOR].