I2C slave에서 마스터로 전송할 데이터가 생길 경우에는
폴링을 기다리거나, 마스터로 연결된 interrupt 핀이 있어야 한다.
Case 1: Slave has an interrupt pin
You need to connect this interrupt pin to master microcontroller. Every time the slave has some data, it should raise an interrupt. At that point, master will read the available data.
Case 2: Slave doesn't have an interrupt pin
Polling is the only option in this case. Master keeps reading all the slaves at regular interval and keeps comparing the received data with old one. If the data has changed, master will take appropriate action. You need to decide the interval according to your application. |
[링크 : https://electronics.stackexchange.com/questions/307630/slave-wants-to-send-data-to-master-in-i2c/307641]
다만 SMBUS에서는
slave가 mater 처럼 작동하여 호스트(0x08)에게 자신의 주소와 2바이트 정보는 던질 수 있도록 되어있다.
아니면 SMBALERT# 시그널을 통해 주의를 요청인데 이게 인터럽트 라인인 듯?
Arbitration in SMBus Although conceptually a single-master bus, a slave device that supports the "host notify protocol" acts as a master to perform the notification. It seizes the bus and writes a 3-byte message to the reserved "SMBus Host" address (0x08), passing its address and two bytes of data. When two slaves try to notify the host at the same time, one of them will lose arbitration and need to retry. An alternative slave notification system uses the separate SMBALERT# signal to request attention. In this case, the host performs a 1-byte read from the reserved "SMBus Alert Response Address" (0x0c), which is a kind of broadcast address. All alerting slaves respond with a data bytes containing their own address. When the slave successfully transmits its own address (winning arbitration against others) it stops raising that interrupt. In both this and the preceding case, arbitration ensures that one slave's message will be received, and the others will know they must retry. SMBus also supports an "address resolution protocol", wherein devices return a 16-byte "universal device ID" (UDID). Multiple devices may respond; the one with the least UDID will win arbitration and be recognized. |
[링크 : http://www.microchip.com/forums/m/tm.aspx?m=795577&p=1]