Difference between revisions of "Arduino notes"
From Wiki at Neela Nurseries
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:
- https://playground.arduino.cc/Learning/CommandLine . . . mentions PlatformIO "ecosystem" and specific Linux ready command line tools for working with Arduino
- https://www.youtube.com/watch?v=qAM2S27FWAI . . . avr-dude and related tools can program Arduino Uno boards
- https://playground.arduino.cc/OpenBSD/CLI . . . Arduino development work on OpenBSD systems
The ATMEGA328P processor used in Arduino Uno boards:
- http://www.microchip.com/wwwproducts/en/ATmega328p . . . the ATMEGA328P processor used in Arduino Uno boards
Specific Arduino projects:
- https://www.hackster.io/niesse/water-level-ultrasonic-sensor-with-lorawan-c2cf55
- https://www.arduino.cc/en/Tutorial/HelloWorld
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 } . . .