aboutsummaryrefslogtreecommitdiffstats
path: root/libmaple/i2c.c
diff options
context:
space:
mode:
authorBarry Carter <barry.carter@robotfuzz.com>2012-09-05 00:08:10 +0100
committerBarry Carter <barry.carter@robotfuzz.com>2012-09-05 00:08:10 +0100
commit0d8f8210e5decb4870f77b5cd0e5325cb803a3af (patch)
treefdbe3f9a4886dd6d7bc452949a28f46c00efff42 /libmaple/i2c.c
parent576457f5477597c3bc88f06cbae01c01a459c32e (diff)
downloadlibrambutan-0d8f8210e5decb4870f77b5cd0e5325cb803a3af.tar.gz
librambutan-0d8f8210e5decb4870f77b5cd0e5325cb803a3af.zip
Added I2C slave echo example in examples folder. Using another maple, write a byte and then read.
Slight tidy up. Reformatted CREDITS file to be in correct order. Added a note about buffer overrun Signed-off-by:- Barry Carter <barry.carter@gmail.com>
Diffstat (limited to 'libmaple/i2c.c')
-rw-r--r--libmaple/i2c.c4
1 files changed, 4 insertions, 0 deletions
diff --git a/libmaple/i2c.c b/libmaple/i2c.c
index 6c609d9..bbbf123 100644
--- a/libmaple/i2c.c
+++ b/libmaple/i2c.c
@@ -458,6 +458,10 @@ void _i2c_irq_handler(i2c_dev *dev) {
if (sr1 & I2C_SR1_RXNE) {
if (dev->config_flags & I2C_SLAVE_USE_RX_BUFFER) {
/* Fill the buffer with the contents of the data register */
+ /* These is potential for buffer overflow here, so we should
+ * really store the size of the array. This is expensive in
+ * the ISR so left out for now. We must trust the implementor!
+ */
dev->i2c_slave_msg->data[dev->i2c_slave_msg->xferred++] = dev->regs->DR;
dev->i2c_slave_msg->length++;
}