Difference between revisions of "Arduino notes"

From Wiki at Neela Nurseries
Jump to: navigation, search
m
m
Line 29: Line 29:
  
  
 +
== Arduino Wire Library ==
 +
 +
2018-05-21 - Monday, looking at /usr/share/arduino/libraries/Wire/utility/twi.c, routine twi_writeTo() error codes:
 +
 +
<pre>
 +
177 /*
 +
178  * Function twi_writeTo
 +
179  * Desc    attempts to become twi bus master and write a
 +
180  *          series of bytes to a device on the bus
 +
181  * Input    address: 7bit i2c device address
 +
182  *          data: pointer to byte array
 +
183  *          length: number of bytes in array
 +
184  *          wait: boolean indicating to wait for write or not
 +
185  *          sendStop: boolean indicating whether or not to send a stop at the end
 +
186  * Output  0 .. success
 +
187  *          1 .. length to long for buffer
 +
188  *          2 .. address send, NACK received
 +
189  *          3 .. data send, NACK received
 +
190  *          4 .. other twi error (lost bus arbitration, bus error, ..)
 +
191  */
 +
192 uint8_t twi_writeTo(uint8_t address, uint8_t* data, uint8_t length, uint8_t wait, uint8_t sendStop)
 +
193 {
 +
194  uint8_t i;
 +
195
 +
196  // ensure data will fit into buffer
 +
197  if(TWI_BUFFER_LENGTH < length){
 +
198    return 1;
 +
199  }
 +
  .
 +
  .
 +
  .
 +
</pre>
 +
 +
 +
<!-- comment -->
 +
 +
 +
 +
 +
<!-- comment -->
 
<!-- comment -->
 
<!-- comment -->

Revision as of 15:57, 21 May 2018



Getting started:


The ATMEGA328P processor used in Arduino Uno boards:


Specific Arduino projects:


FreeRTOS port to Arduino:


Arduino Wire Library

2018-05-21 - Monday, looking at /usr/share/arduino/libraries/Wire/utility/twi.c, routine twi_writeTo() error codes:

177 /*
178  * Function twi_writeTo
179  * Desc     attempts to become twi bus master and write a
180  *          series of bytes to a device on the bus
181  * Input    address: 7bit i2c device address
182  *          data: pointer to byte array
183  *          length: number of bytes in array
184  *          wait: boolean indicating to wait for write or not
185  *          sendStop: boolean indicating whether or not to send a stop at the end
186  * Output   0 .. success
187  *          1 .. length to long for buffer
188  *          2 .. address send, NACK received
189  *          3 .. data send, NACK received
190  *          4 .. other twi error (lost bus arbitration, bus error, ..)
191  */
192 uint8_t twi_writeTo(uint8_t address, uint8_t* data, uint8_t length, uint8_t wait, uint8_t sendStop)
193 {
194   uint8_t i;
195 
196   // ensure data will fit into buffer
197   if(TWI_BUFFER_LENGTH < length){
198     return 1;
199   }
   .
   .
   .