Bugfix for HardWire/I2C + configured/compiled dfu-util to work on Linux again
- Fixed 0 byte payload bug, stopping HardWire from sending only addresses to scan for devices - Fixed I2C bug accessing wrong status register for error flags - Improved Hardwire endTransmission() return flags to correspond with the actual I2C failure status - Removed dos endings from dfu-util autogen script breaking compilation
This commit is contained in:
parent
0ec837f08c
commit
3b8b7a79f4
|
@ -235,7 +235,7 @@ int32 i2c_master_xfer(i2c_dev *dev,
|
|||
|
||||
i2c_enable_irq(dev, I2C_IRQ_EVENT);
|
||||
i2c_start_condition(dev);
|
||||
|
||||
|
||||
rc = wait_for_state_change(dev, I2C_STATE_XFER_DONE, timeout);
|
||||
if (rc < 0) {
|
||||
goto out;
|
||||
|
@ -347,9 +347,20 @@ void _i2c_irq_handler(i2c_dev *dev) {
|
|||
* register. We should get another TXE interrupt
|
||||
* immediately to fill DR again.
|
||||
*/
|
||||
if (msg->length != 1) {
|
||||
if (msg->length > 1) {
|
||||
i2c_write(dev, msg->data[msg->xferred++]);
|
||||
}
|
||||
} else if (msg->length == 0){ /* We're just sending an address */
|
||||
i2c_stop_condition(dev);
|
||||
/*
|
||||
* Turn off event interrupts to keep BTF from firing until
|
||||
* the end of the stop condition. Why on earth they didn't
|
||||
* have a start/stop condition request clear BTF is beyond
|
||||
* me.
|
||||
*/
|
||||
i2c_disable_irq(dev, I2C_IRQ_EVENT);
|
||||
I2C_CRUMB(STOP_SENT, 0, 0);
|
||||
dev->state = I2C_STATE_XFER_DONE;
|
||||
} /* else we're just sending one byte */
|
||||
}
|
||||
sr1 = sr2 = 0;
|
||||
}
|
||||
|
@ -456,7 +467,7 @@ void _i2c_irq_handler(i2c_dev *dev) {
|
|||
void _i2c_irq_error_handler(i2c_dev *dev) {
|
||||
I2C_CRUMB(ERROR_ENTRY, dev->regs->SR1, dev->regs->SR2);
|
||||
|
||||
dev->error_flags = dev->regs->SR2 & (I2C_SR1_BERR |
|
||||
dev->error_flags = dev->regs->SR1 & (I2C_SR1_BERR |
|
||||
I2C_SR1_ARLO |
|
||||
I2C_SR1_AF |
|
||||
I2C_SR1_OVR);
|
||||
|
|
|
@ -40,11 +40,16 @@
|
|||
|
||||
uint8 HardWire::process() {
|
||||
int8 res = i2c_master_xfer(sel_hard, &itc_msg, 1, 0);
|
||||
if (res != 0) {
|
||||
if (res == I2C_ERROR_PROTOCOL) {
|
||||
if (sel_hard->error_flags & I2C_SR1_AF)
|
||||
res = (sel_hard->error_flags & I2C_SR1_ADDR ? ENACKADDR :
|
||||
ENACKTRNS);
|
||||
else if (sel_hard->error_flags & I2C_SR1_OVR) res = EDATA;
|
||||
else res = EOTHER;
|
||||
i2c_disable(sel_hard);
|
||||
i2c_master_enable(sel_hard, (I2C_BUS_RESET | dev_flags));
|
||||
}
|
||||
return 0;
|
||||
return res;
|
||||
}
|
||||
|
||||
// TODO: Add in Error Handling if devsel is out of range for other Maples
|
||||
|
@ -56,7 +61,7 @@ HardWire::HardWire(uint8 dev_sel, uint8 flags) {
|
|||
} else {
|
||||
ASSERT(1);
|
||||
}
|
||||
dev_flags=flags;
|
||||
dev_flags = flags;
|
||||
}
|
||||
|
||||
HardWire::~HardWire() {
|
||||
|
|
|
@ -67,5 +67,5 @@ public:
|
|||
|
||||
void begin(uint8 = 0x00);
|
||||
};
|
||||
|
||||
extern HardWire HWire;
|
||||
#endif // _HARDWIRE_H_
|
||||
|
|
|
@ -61,11 +61,10 @@ void WireBase::beginTransmission(int slave_address) {
|
|||
|
||||
uint8 WireBase::endTransmission(void) {
|
||||
uint8 retVal;
|
||||
|
||||
if (tx_buf_overflow) {
|
||||
if (tx_buf_overflow) {
|
||||
return EDATA;
|
||||
}
|
||||
retVal=process();// Changed so that the return value from process is returned by this function see also the return line below
|
||||
retVal = process();// Changed so that the return value from process is returned by this function see also the return line below
|
||||
tx_buf_idx = 0;
|
||||
tx_buf_overflow = false;
|
||||
return retVal;//SUCCESS;
|
||||
|
|
Binary file not shown.
Binary file not shown.
Binary file not shown.
|
@ -1,2 +1,2 @@
|
|||
#! /bin/sh
|
||||
autoreconf -v -i
|
||||
#! /bin/sh
|
||||
autoreconf -v -i
|
||||
|
|
Loading…
Reference in New Issue