Skip to main content

Posts

Showing posts from April, 2014

SDI12 (Aurduino-->AVRGCC)

# include <inttypes.h> # include <stdbool.h> # include <avr/io.h> # include "SDI12.h" // 0.1 header file for this library # define _BUFFER_SIZE 64 // 0.2 max RX buffer size # define DISABLED 0 // 0.3 value for DISABLED state # define ENABLED 1 // 0.4 value for ENABLED state # define HOLDING 2 // 0.5 value for DISABLED state # define TRANSMITTING 3 // 0.6 value for TRANSMITTING state # define LISTENING 4 // 0.7 value for LISTENING state # define SPACING 830 // 0.8 bit timing in microseconds # define PHIGH PORTB7; # define PLOW PORTB7; # define INMODE PORTB7; # define OUTMODE PORTB7; //SDI12 *SDI12__activeObject = NULL; // 0.9 pointer to active SDI12 object uint8_t _dataPin; // 0.10 reference to the data pin bool _buffe...

Debug

Bool data type in AVRGCC, the AVRStudio IDE detects bool as a keyword but throws a compile error. bool  exists in the current ANSI C - C99, but not in C89/90. In C99 the native type is actually called  _Bool , while  bool  is a standard library macro defined in  stdbool.h  (which expectedly resolves to  _Bool ). Objects of type  _Bool  hold either 0 or 1, while  true  and  false  are also macros from  stdbool.h . AVR GCC User Defined Data Types User types C language allows defining user types. For this  typedef  keyword is used: typedef unsigned char byte; //create byte type typedef unsigned int word; //create word type In other words defining custom types description structure is used: typedef standard_type custom_type; WinAVR compiler has predefined custom types: typedef signed char  int8_t ; //located in header file inttypes.h typedef unsigned char  uint8_t ; //located i...