Do not reply with NAK on last byte
At least the bcm2835 (Raspberry Pi 3) I2C/SMBus master has problems when replying with a NAK to the last byte written to a slave device. Fix this by replying with NAK one byte later.
This commit is contained in:
parent
baf5a895b5
commit
559a403836
10
README.md
10
README.md
@ -10,11 +10,11 @@ Currently the following AVR MCUs are supported:
|
||||
|
||||
AVR MCU | Flash bytes used (.text + .data) | Bootloader region size
|
||||
--- | --- | ---
|
||||
attiny85 | 956 (0x3BC) | 512 words
|
||||
atmega8 | 802 (0x322) | 512 words
|
||||
atmega88 | 826 (0x33A) | 512 words
|
||||
atmega168 | 826 (0x33A) | 512 words
|
||||
atmega328p | 826 (0x33A) | 512 words
|
||||
attiny85 | 954 (0x3BA) | 512 words
|
||||
atmega8 | 786 (0x312) | 512 words
|
||||
atmega88 | 810 (0x32A) | 512 words
|
||||
atmega168 | 810 (0x32A) | 512 words
|
||||
atmega328p | 810 (0x32A) | 512 words
|
||||
|
||||
(Compiled on Ubuntu 18.04 LTS (gcc 5.4.0 / avr-libc 2.0.0) with EEPROM and LED support)
|
||||
|
||||
|
20
main.c
20
main.c
@ -21,7 +21,7 @@
|
||||
#include <avr/boot.h>
|
||||
#include <avr/pgmspace.h>
|
||||
|
||||
#define VERSION_STRING "TWIBOOT v3.1"
|
||||
#define VERSION_STRING "TWIBOOT v3.2"
|
||||
#define EEPROM_SUPPORT 1
|
||||
#define LED_SUPPORT 1
|
||||
|
||||
@ -400,20 +400,18 @@ static uint8_t TWI_data_write(uint8_t bcnt, uint8_t data)
|
||||
uint8_t pos = bcnt -4;
|
||||
|
||||
buf[pos] = data;
|
||||
if (pos >= (sizeof(buf) -2))
|
||||
{
|
||||
ack = 0x00;
|
||||
}
|
||||
|
||||
if ((cmd == CMD_ACCESS_FLASH) &&
|
||||
(pos >= (sizeof(buf) -1))
|
||||
)
|
||||
if (pos >= (SPM_PAGESIZE -1))
|
||||
{
|
||||
if (cmd == CMD_ACCESS_FLASH)
|
||||
{
|
||||
#if (USE_CLOCKSTRETCH)
|
||||
write_flash_page();
|
||||
write_flash_page();
|
||||
#else
|
||||
cmd = CMD_WRITE_FLASH_PAGE;
|
||||
cmd = CMD_WRITE_FLASH_PAGE;
|
||||
#endif
|
||||
}
|
||||
|
||||
ack = 0x00;
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user