Skip to content

Instantly share code, notes, and snippets.

@master-q
Created June 5, 2014 13:40
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save master-q/390631698b6bd63f867b to your computer and use it in GitHub Desktop.
Save master-q/390631698b6bd63f867b to your computer and use it in GitHub Desktop.
avr-gcc -E -mmcu=atmega2560 -DF_CPU=16000000UL -std=c99 -D_XOPEN_SOURCE -I/usr/share/arduino/hardware/arduino/cores/arduino -I/usr/share/arduino/hardware/arduino/variants/mega /usr/share/arduino/hardware/arduino/cores/arduino/HardwareSerial.cpp
# 1 "/usr/share/arduino/hardware/arduino/cores/arduino/HardwareSerial.cpp"
# 1 "<command-line>"
# 1 "/usr/share/arduino/hardware/arduino/cores/arduino/HardwareSerial.cpp"
# 26 "/usr/share/arduino/hardware/arduino/cores/arduino/HardwareSerial.cpp"
# 1 "/usr/lib/avr/include/stdlib.h" 1 3
# 47 "/usr/lib/avr/include/stdlib.h" 3
# 1 "/usr/lib/gcc/avr/4.8.1/include/stddef.h" 1 3 4
# 212 "/usr/lib/gcc/avr/4.8.1/include/stddef.h" 3 4
typedef unsigned int size_t;
# 48 "/usr/lib/avr/include/stdlib.h" 2 3
extern "C" {
# 68 "/usr/lib/avr/include/stdlib.h" 3
typedef struct {
int quot;
int rem;
} div_t;
typedef struct {
long quot;
long rem;
} ldiv_t;
typedef int (*__compar_fn_t)(const void *, const void *);
# 106 "/usr/lib/avr/include/stdlib.h" 3
extern void abort(void) __attribute__((__noreturn__));
extern int abs(int __i) __attribute__((__const__));
# 120 "/usr/lib/avr/include/stdlib.h" 3
extern long labs(long __i) __attribute__((__const__));
# 143 "/usr/lib/avr/include/stdlib.h" 3
extern void *bsearch(const void *__key, const void *__base, size_t __nmemb,
size_t __size, int (*__compar)(const void *, const void *));
extern div_t div(int __num, int __denom) __asm__("__divmodhi4") __attribute__((__const__));
extern ldiv_t ldiv(long __num, long __denom) __asm__("__divmodsi4") __attribute__((__const__));
# 175 "/usr/lib/avr/include/stdlib.h" 3
extern void qsort(void *__base, size_t __nmemb, size_t __size,
__compar_fn_t __compar);
# 208 "/usr/lib/avr/include/stdlib.h" 3
extern long strtol(const char *__nptr, char **__endptr, int __base);
# 242 "/usr/lib/avr/include/stdlib.h" 3
extern unsigned long strtoul(const char *__nptr, char **__endptr, int __base);
# 254 "/usr/lib/avr/include/stdlib.h" 3
extern long atol(const char *__s) __attribute__((__pure__));
# 266 "/usr/lib/avr/include/stdlib.h" 3
extern int atoi(const char *__s) __attribute__((__pure__));
# 278 "/usr/lib/avr/include/stdlib.h" 3
extern void exit(int __status) __attribute__((__noreturn__));
# 290 "/usr/lib/avr/include/stdlib.h" 3
extern void *malloc(size_t __size) __attribute__((__malloc__));
extern void free(void *__ptr);
extern size_t __malloc_margin;
extern char *__malloc_heap_start;
extern char *__malloc_heap_end;
extern void *calloc(size_t __nele, size_t __size) __attribute__((__malloc__));
# 338 "/usr/lib/avr/include/stdlib.h" 3
extern void *realloc(void *__ptr, size_t __size) __attribute__((__malloc__));
extern double strtod(const char *__nptr, char **__endptr);
extern double atof(const char *__nptr);
# 364 "/usr/lib/avr/include/stdlib.h" 3
extern int rand(void);
extern void srand(unsigned int __seed);
extern int rand_r(unsigned long *__ctx);
# 406 "/usr/lib/avr/include/stdlib.h" 3
extern char *itoa(int __val, char *__s, int __radix);
# 434 "/usr/lib/avr/include/stdlib.h" 3
extern char *ltoa(long int __val, char *__s, int __radix);
# 460 "/usr/lib/avr/include/stdlib.h" 3
extern char *utoa(unsigned int __val, char *__s, int __radix);
# 486 "/usr/lib/avr/include/stdlib.h" 3
extern char *ultoa(unsigned long int __val, char *__s, int __radix);
# 504 "/usr/lib/avr/include/stdlib.h" 3
extern long random(void);
extern void srandom(unsigned long __seed);
extern long random_r(unsigned long *__ctx);
# 563 "/usr/lib/avr/include/stdlib.h" 3
extern char *dtostre(double __val, char *__s, unsigned char __prec,
unsigned char __flags);
# 580 "/usr/lib/avr/include/stdlib.h" 3
extern char *dtostrf(double __val, signed char __width,
unsigned char __prec, char *__s);
# 590 "/usr/lib/avr/include/stdlib.h" 3
}
# 27 "/usr/share/arduino/hardware/arduino/cores/arduino/HardwareSerial.cpp" 2
# 1 "/usr/lib/avr/include/stdio.h" 1 3
# 44 "/usr/lib/avr/include/stdio.h" 3
# 1 "/usr/lib/avr/include/inttypes.h" 1 3
# 37 "/usr/lib/avr/include/inttypes.h" 3
# 1 "/usr/lib/gcc/avr/4.8.1/include/stdint.h" 1 3 4
# 9 "/usr/lib/gcc/avr/4.8.1/include/stdint.h" 3 4
# 1 "/usr/lib/avr/include/stdint.h" 1 3 4
# 121 "/usr/lib/avr/include/stdint.h" 3 4
typedef signed int int8_t __attribute__((__mode__(__QI__)));
typedef unsigned int uint8_t __attribute__((__mode__(__QI__)));
typedef signed int int16_t __attribute__ ((__mode__ (__HI__)));
typedef unsigned int uint16_t __attribute__ ((__mode__ (__HI__)));
typedef signed int int32_t __attribute__ ((__mode__ (__SI__)));
typedef unsigned int uint32_t __attribute__ ((__mode__ (__SI__)));
typedef signed int int64_t __attribute__((__mode__(__DI__)));
typedef unsigned int uint64_t __attribute__((__mode__(__DI__)));
# 142 "/usr/lib/avr/include/stdint.h" 3 4
typedef int16_t intptr_t;
typedef uint16_t uintptr_t;
# 159 "/usr/lib/avr/include/stdint.h" 3 4
typedef int8_t int_least8_t;
typedef uint8_t uint_least8_t;
typedef int16_t int_least16_t;
typedef uint16_t uint_least16_t;
typedef int32_t int_least32_t;
typedef uint32_t uint_least32_t;
typedef int64_t int_least64_t;
typedef uint64_t uint_least64_t;
# 213 "/usr/lib/avr/include/stdint.h" 3 4
typedef int8_t int_fast8_t;
typedef uint8_t uint_fast8_t;
typedef int16_t int_fast16_t;
typedef uint16_t uint_fast16_t;
typedef int32_t int_fast32_t;
typedef uint32_t uint_fast32_t;
typedef int64_t int_fast64_t;
typedef uint64_t uint_fast64_t;
# 273 "/usr/lib/avr/include/stdint.h" 3 4
typedef int64_t intmax_t;
typedef uint64_t uintmax_t;
# 10 "/usr/lib/gcc/avr/4.8.1/include/stdint.h" 2 3 4
# 38 "/usr/lib/avr/include/inttypes.h" 2 3
# 77 "/usr/lib/avr/include/inttypes.h" 3
typedef int32_t int_farptr_t;
typedef uint32_t uint_farptr_t;
# 45 "/usr/lib/avr/include/stdio.h" 2 3
# 1 "/usr/lib/gcc/avr/4.8.1/include/stdarg.h" 1 3 4
# 40 "/usr/lib/gcc/avr/4.8.1/include/stdarg.h" 3 4
typedef __builtin_va_list __gnuc_va_list;
# 98 "/usr/lib/gcc/avr/4.8.1/include/stdarg.h" 3 4
typedef __gnuc_va_list va_list;
# 46 "/usr/lib/avr/include/stdio.h" 2 3
# 1 "/usr/lib/gcc/avr/4.8.1/include/stddef.h" 1 3 4
# 50 "/usr/lib/avr/include/stdio.h" 2 3
# 242 "/usr/lib/avr/include/stdio.h" 3
struct __file {
char *buf;
unsigned char unget;
uint8_t flags;
# 261 "/usr/lib/avr/include/stdio.h" 3
int size;
int len;
int (*put)(char, struct __file *);
int (*get)(struct __file *);
void *udata;
};
# 397 "/usr/lib/avr/include/stdio.h" 3
extern "C" {
extern struct __file *__iob[];
# 417 "/usr/lib/avr/include/stdio.h" 3
extern struct __file *fdevopen(int (*__put)(char, struct __file*), int (*__get)(struct __file*));
# 434 "/usr/lib/avr/include/stdio.h" 3
extern int fclose(struct __file *__stream);
# 608 "/usr/lib/avr/include/stdio.h" 3
extern int vfprintf(struct __file *__stream, const char *__fmt, va_list __ap);
extern int vfprintf_P(struct __file *__stream, const char *__fmt, va_list __ap);
extern int fputc(int __c, struct __file *__stream);
extern int putc(int __c, struct __file *__stream);
extern int putchar(int __c);
# 649 "/usr/lib/avr/include/stdio.h" 3
extern int printf(const char *__fmt, ...);
extern int printf_P(const char *__fmt, ...);
extern int vprintf(const char *__fmt, va_list __ap);
extern int sprintf(char *__s, const char *__fmt, ...);
extern int sprintf_P(char *__s, const char *__fmt, ...);
# 685 "/usr/lib/avr/include/stdio.h" 3
extern int snprintf(char *__s, size_t __n, const char *__fmt, ...);
extern int snprintf_P(char *__s, size_t __n, const char *__fmt, ...);
extern int vsprintf(char *__s, const char *__fmt, va_list ap);
extern int vsprintf_P(char *__s, const char *__fmt, va_list ap);
# 713 "/usr/lib/avr/include/stdio.h" 3
extern int vsnprintf(char *__s, size_t __n, const char *__fmt, va_list ap);
extern int vsnprintf_P(char *__s, size_t __n, const char *__fmt, va_list ap);
extern int fprintf(struct __file *__stream, const char *__fmt, ...);
extern int fprintf_P(struct __file *__stream, const char *__fmt, ...);
extern int fputs(const char *__str, struct __file *__stream);
extern int fputs_P(const char *__str, struct __file *__stream);
extern int puts(const char *__str);
extern int puts_P(const char *__str);
# 762 "/usr/lib/avr/include/stdio.h" 3
extern size_t fwrite(const void *__ptr, size_t __size, size_t __nmemb,
struct __file *__stream);
extern int fgetc(struct __file *__stream);
extern int getc(struct __file *__stream);
extern int getchar(void);
# 810 "/usr/lib/avr/include/stdio.h" 3
extern int ungetc(int __c, struct __file *__stream);
# 822 "/usr/lib/avr/include/stdio.h" 3
extern char *fgets(char *__str, int __size, struct __file *__stream);
extern char *gets(char *__str);
# 840 "/usr/lib/avr/include/stdio.h" 3
extern size_t fread(void *__ptr, size_t __size, size_t __nmemb,
struct __file *__stream);
extern void clearerr(struct __file *__stream);
# 857 "/usr/lib/avr/include/stdio.h" 3
extern int feof(struct __file *__stream);
# 868 "/usr/lib/avr/include/stdio.h" 3
extern int ferror(struct __file *__stream);
extern int vfscanf(struct __file *__stream, const char *__fmt, va_list __ap);
extern int vfscanf_P(struct __file *__stream, const char *__fmt, va_list __ap);
extern int fscanf(struct __file *__stream, const char *__fmt, ...);
extern int fscanf_P(struct __file *__stream, const char *__fmt, ...);
extern int scanf(const char *__fmt, ...);
extern int scanf_P(const char *__fmt, ...);
extern int vscanf(const char *__fmt, va_list __ap);
extern int sscanf(const char *__buf, const char *__fmt, ...);
extern int sscanf_P(const char *__buf, const char *__fmt, ...);
# 938 "/usr/lib/avr/include/stdio.h" 3
static __inline__ int fflush(struct __file *stream __attribute__((unused)))
{
return 0;
}
}
# 28 "/usr/share/arduino/hardware/arduino/cores/arduino/HardwareSerial.cpp" 2
# 1 "/usr/lib/avr/include/string.h" 1 3
# 45 "/usr/lib/avr/include/string.h" 3
# 1 "/usr/lib/gcc/avr/4.8.1/include/stddef.h" 1 3 4
# 46 "/usr/lib/avr/include/string.h" 2 3
# 56 "/usr/lib/avr/include/string.h" 3
extern "C" {
# 111 "/usr/lib/avr/include/string.h" 3
extern int ffs (int __val) __attribute__((__const__));
extern int ffsl (long __val) __attribute__((__const__));
extern int ffsll (long long __val) __attribute__((__const__));
extern void *memccpy(void *, const void *, int, size_t);
extern void *memchr(const void *, int, size_t) __attribute__((__pure__));
extern int memcmp(const void *, const void *, size_t) __attribute__((__pure__));
extern void *memcpy(void *, const void *, size_t);
extern void *memmem(const void *, size_t, const void *, size_t) __attribute__((__pure__));
extern void *memmove(void *, const void *, size_t);
extern void *memrchr(const void *, int, size_t) __attribute__((__pure__));
extern void *memset(void *, int, size_t);
extern char *strcat(char *, const char *);
extern char *strchr(const char *, int) __attribute__((__pure__));
extern char *strchrnul(const char *, int) __attribute__((__pure__));
extern int strcmp(const char *, const char *) __attribute__((__pure__));
extern char *strcpy(char *, const char *);
extern int strcasecmp(const char *, const char *) __attribute__((__pure__));
extern char *strcasestr(const char *, const char *) __attribute__((__pure__));
extern size_t strcspn(const char *__s, const char *__reject) __attribute__((__pure__));
extern char *strdup(const char *s1);
extern size_t strlcat(char *, const char *, size_t);
extern size_t strlcpy(char *, const char *, size_t);
extern size_t strlen(const char *) __attribute__((__pure__));
extern char *strlwr(char *);
extern char *strncat(char *, const char *, size_t);
extern int strncmp(const char *, const char *, size_t) __attribute__((__pure__));
extern char *strncpy(char *, const char *, size_t);
extern int strncasecmp(const char *, const char *, size_t) __attribute__((__pure__));
extern size_t strnlen(const char *, size_t) __attribute__((__pure__));
extern char *strpbrk(const char *__s, const char *__accept) __attribute__((__pure__));
extern char *strrchr(const char *, int) __attribute__((__pure__));
extern char *strrev(char *);
extern char *strsep(char **, const char *);
extern size_t strspn(const char *__s, const char *__accept) __attribute__((__pure__));
extern char *strstr(const char *, const char *) __attribute__((__pure__));
extern char *strtok(char *, const char *);
extern char *strtok_r(char *, const char *, char **);
extern char *strupr(char *);
}
# 29 "/usr/share/arduino/hardware/arduino/cores/arduino/HardwareSerial.cpp" 2
# 1 "/usr/share/arduino/hardware/arduino/cores/arduino/Arduino.h" 1
# 1 "/usr/lib/avr/include/math.h" 1 3
# 121 "/usr/lib/avr/include/math.h" 3
extern "C" {
extern double cos(double __x) __attribute__((__const__));
extern double sin(double __x) __attribute__((__const__));
extern double tan(double __x) __attribute__((__const__));
extern double fabs(double __x) __attribute__((__const__));
extern double fmod(double __x, double __y) __attribute__((__const__));
# 168 "/usr/lib/avr/include/math.h" 3
extern double modf(double __x, double *__iptr);
extern float modff (float __x, float *__iptr);
extern double sqrt(double __x) __attribute__((__const__));
extern double cbrt(double __x) __attribute__((__const__));
# 194 "/usr/lib/avr/include/math.h" 3
extern double hypot (double __x, double __y) __attribute__((__const__));
extern double square(double __x) __attribute__((__const__));
extern double floor(double __x) __attribute__((__const__));
extern double ceil(double __x) __attribute__((__const__));
# 234 "/usr/lib/avr/include/math.h" 3
extern double frexp(double __x, int *__pexp);
extern double ldexp(double __x, int __exp) __attribute__((__const__));
extern double exp(double __x) __attribute__((__const__));
extern double cosh(double __x) __attribute__((__const__));
extern double sinh(double __x) __attribute__((__const__));
extern double tanh(double __x) __attribute__((__const__));
extern double acos(double __x) __attribute__((__const__));
extern double asin(double __x) __attribute__((__const__));
extern double atan(double __x) __attribute__((__const__));
# 298 "/usr/lib/avr/include/math.h" 3
extern double atan2(double __y, double __x) __attribute__((__const__));
extern double log(double __x) __attribute__((__const__));
extern double log10(double __x) __attribute__((__const__));
extern double pow(double __x, double __y) __attribute__((__const__));
extern int isnan(double __x) __attribute__((__const__));
# 333 "/usr/lib/avr/include/math.h" 3
extern int isinf(double __x) __attribute__((__const__));
__attribute__((__const__)) static inline int isfinite (double __x)
{
unsigned char __exp;
__asm__ (
"mov %0, %C1 \n\t"
"lsl %0 \n\t"
"mov %0, %D1 \n\t"
"rol %0 "
: "=r" (__exp)
: "r" (__x) );
return __exp != 0xff;
}
__attribute__((__const__)) static inline double copysign (double __x, double __y)
{
__asm__ (
"bst %D2, 7 \n\t"
"bld %D0, 7 "
: "=r" (__x)
: "0" (__x), "r" (__y) );
return __x;
}
# 376 "/usr/lib/avr/include/math.h" 3
extern int signbit (double __x) __attribute__((__const__));
extern double fdim (double __x, double __y) __attribute__((__const__));
# 392 "/usr/lib/avr/include/math.h" 3
extern double fma (double __x, double __y, double __z) __attribute__((__const__));
extern double fmax (double __x, double __y) __attribute__((__const__));
extern double fmin (double __x, double __y) __attribute__((__const__));
extern double trunc (double __x) __attribute__((__const__));
# 426 "/usr/lib/avr/include/math.h" 3
extern double round (double __x) __attribute__((__const__));
# 439 "/usr/lib/avr/include/math.h" 3
extern long lround (double __x) __attribute__((__const__));
# 453 "/usr/lib/avr/include/math.h" 3
extern long lrint (double __x) __attribute__((__const__));
}
# 7 "/usr/share/arduino/hardware/arduino/cores/arduino/Arduino.h" 2
# 1 "/usr/lib/avr/include/avr/pgmspace.h" 1 3
# 87 "/usr/lib/avr/include/avr/pgmspace.h" 3
# 1 "/usr/lib/gcc/avr/4.8.1/include/stddef.h" 1 3 4
# 88 "/usr/lib/avr/include/avr/pgmspace.h" 2 3
# 1 "/usr/lib/avr/include/avr/io.h" 1 3
# 99 "/usr/lib/avr/include/avr/io.h" 3
# 1 "/usr/lib/avr/include/avr/sfr_defs.h" 1 3
# 100 "/usr/lib/avr/include/avr/io.h" 2 3
# 160 "/usr/lib/avr/include/avr/io.h" 3
# 1 "/usr/lib/avr/include/avr/iom2560.h" 1 3
# 38 "/usr/lib/avr/include/avr/iom2560.h" 3
# 1 "/usr/lib/avr/include/avr/iomxx0_1.h" 1 3
# 39 "/usr/lib/avr/include/avr/iom2560.h" 2 3
# 161 "/usr/lib/avr/include/avr/io.h" 2 3
# 432 "/usr/lib/avr/include/avr/io.h" 3
# 1 "/usr/lib/avr/include/avr/portpins.h" 1 3
# 433 "/usr/lib/avr/include/avr/io.h" 2 3
# 1 "/usr/lib/avr/include/avr/common.h" 1 3
# 435 "/usr/lib/avr/include/avr/io.h" 2 3
# 1 "/usr/lib/avr/include/avr/version.h" 1 3
# 437 "/usr/lib/avr/include/avr/io.h" 2 3
# 1 "/usr/lib/avr/include/avr/fuse.h" 1 3
# 239 "/usr/lib/avr/include/avr/fuse.h" 3
typedef struct
{
unsigned char low;
unsigned char high;
unsigned char extended;
} __fuse_t;
# 440 "/usr/lib/avr/include/avr/io.h" 2 3
# 1 "/usr/lib/avr/include/avr/lock.h" 1 3
# 443 "/usr/lib/avr/include/avr/io.h" 2 3
# 89 "/usr/lib/avr/include/avr/pgmspace.h" 2 3
# 112 "/usr/lib/avr/include/avr/pgmspace.h" 3
extern "C" {
# 1037 "/usr/lib/avr/include/avr/pgmspace.h" 3
extern const void * memchr_P(const void *, int __val, size_t __len) __attribute__((__const__));
extern int memcmp_P(const void *, const void *, size_t) __attribute__((__pure__));
extern void *memccpy_P(void *, const void *, int __val, size_t);
extern void *memcpy_P(void *, const void *, size_t);
extern void *memmem_P(const void *, size_t, const void *, size_t) __attribute__((__pure__));
extern const void * memrchr_P(const void *, int __val, size_t __len) __attribute__((__const__));
extern char *strcat_P(char *, const char *);
extern const char * strchr_P(const char *, int __val) __attribute__((__const__));
extern const char * strchrnul_P(const char *, int __val) __attribute__((__const__));
extern int strcmp_P(const char *, const char *) __attribute__((__pure__));
extern char *strcpy_P(char *, const char *);
extern int strcasecmp_P(const char *, const char *) __attribute__((__pure__));
extern char *strcasestr_P(const char *, const char *) __attribute__((__pure__));
extern size_t strcspn_P(const char *__s, const char * __reject) __attribute__((__pure__));
extern size_t strlcat_P (char *, const char *, size_t );
extern size_t strlcpy_P (char *, const char *, size_t );
extern size_t __strlen_P(const char *) __attribute__((__const__));
extern size_t strnlen_P(const char *, size_t) __attribute__((__const__));
extern int strncmp_P(const char *, const char *, size_t) __attribute__((__pure__));
extern int strncasecmp_P(const char *, const char *, size_t) __attribute__((__pure__));
extern char *strncat_P(char *, const char *, size_t);
extern char *strncpy_P(char *, const char *, size_t);
extern char *strpbrk_P(const char *__s, const char * __accept) __attribute__((__pure__));
extern const char * strrchr_P(const char *, int __val) __attribute__((__const__));
extern char *strsep_P(char **__sp, const char * __delim);
extern size_t strspn_P(const char *__s, const char * __accept) __attribute__((__pure__));
extern char *strstr_P(const char *, const char *) __attribute__((__pure__));
extern char *strtok_P(char *__s, const char * __delim);
extern char *strtok_rP(char *__s, const char * __delim, char **__last);
extern size_t strlen_PF (uint_farptr_t src) __attribute__((__const__));
extern size_t strnlen_PF (uint_farptr_t src, size_t len) __attribute__((__const__));
extern void *memcpy_PF (void *dest, uint_farptr_t src, size_t len);
extern char *strcpy_PF (char *dest, uint_farptr_t src);
extern char *strncpy_PF (char *dest, uint_farptr_t src, size_t len);
extern char *strcat_PF (char *dest, uint_farptr_t src);
extern size_t strlcat_PF (char *dst, uint_farptr_t src, size_t siz);
extern char *strncat_PF (char *dest, uint_farptr_t src, size_t len);
extern int strcmp_PF (const char *s1, uint_farptr_t s2) __attribute__((__pure__));
extern int strncmp_PF (const char *s1, uint_farptr_t s2, size_t n) __attribute__((__pure__));
extern int strcasecmp_PF (const char *s1, uint_farptr_t s2) __attribute__((__pure__));
extern int strncasecmp_PF (const char *s1, uint_farptr_t s2, size_t n) __attribute__((__pure__));
extern char *strstr_PF (const char *s1, uint_farptr_t s2);
extern size_t strlcpy_PF (char *dst, uint_farptr_t src, size_t siz);
extern int memcmp_PF(const void *, uint_farptr_t, size_t) __attribute__((__pure__));
__attribute__((__always_inline__)) static inline size_t strlen_P(const char * s);
static inline size_t strlen_P(const char *s) {
return __builtin_constant_p(__builtin_strlen(s))
? __builtin_strlen(s) : __strlen_P(s);
}
}
# 9 "/usr/share/arduino/hardware/arduino/cores/arduino/Arduino.h" 2
# 1 "/usr/lib/avr/include/avr/interrupt.h" 1 3
# 11 "/usr/share/arduino/hardware/arduino/cores/arduino/Arduino.h" 2
# 1 "/usr/share/arduino/hardware/arduino/cores/arduino/binary.h" 1
# 13 "/usr/share/arduino/hardware/arduino/cores/arduino/Arduino.h" 2
extern "C"{
# 89 "/usr/share/arduino/hardware/arduino/cores/arduino/Arduino.h"
typedef unsigned int word;
typedef uint8_t boolean;
typedef uint8_t byte;
void init(void);
void pinMode(uint8_t, uint8_t);
void digitalWrite(uint8_t, uint8_t);
int digitalRead(uint8_t);
int analogRead(uint8_t);
void analogReference(uint8_t mode);
void analogWrite(uint8_t, int);
unsigned long millis(void);
unsigned long micros(void);
void delay(unsigned long);
void delayMicroseconds(unsigned int us);
unsigned long pulseIn(uint8_t pin, uint8_t state, unsigned long timeout);
void shiftOut(uint8_t dataPin, uint8_t clockPin, uint8_t bitOrder, uint8_t val);
uint8_t shiftIn(uint8_t dataPin, uint8_t clockPin, uint8_t bitOrder);
void attachInterrupt(uint8_t, void (*)(void), int mode);
void detachInterrupt(uint8_t);
void setup(void);
void loop(void);
# 127 "/usr/share/arduino/hardware/arduino/cores/arduino/Arduino.h"
extern const uint16_t __attribute__((__progmem__)) port_to_mode_PGM[];
extern const uint16_t __attribute__((__progmem__)) port_to_input_PGM[];
extern const uint16_t __attribute__((__progmem__)) port_to_output_PGM[];
extern const uint8_t __attribute__((__progmem__)) digital_pin_to_port_PGM[];
extern const uint8_t __attribute__((__progmem__)) digital_pin_to_bit_mask_PGM[];
extern const uint8_t __attribute__((__progmem__)) digital_pin_to_timer_PGM[];
# 187 "/usr/share/arduino/hardware/arduino/cores/arduino/Arduino.h"
}
# 1 "/usr/share/arduino/hardware/arduino/cores/arduino/WCharacter.h" 1
# 23 "/usr/share/arduino/hardware/arduino/cores/arduino/WCharacter.h"
# 1 "/usr/lib/avr/include/ctype.h" 1 3
# 48 "/usr/lib/avr/include/ctype.h" 3
extern "C" {
# 74 "/usr/lib/avr/include/ctype.h" 3
extern int isalnum(int __c) __attribute__((__const__));
extern int isalpha(int __c) __attribute__((__const__));
extern int isascii(int __c) __attribute__((__const__));
extern int isblank(int __c) __attribute__((__const__));
extern int iscntrl(int __c) __attribute__((__const__));
extern int isdigit(int __c) __attribute__((__const__));
extern int isgraph(int __c) __attribute__((__const__));
extern int islower(int __c) __attribute__((__const__));
extern int isprint(int __c) __attribute__((__const__));
extern int ispunct(int __c) __attribute__((__const__));
extern int isspace(int __c) __attribute__((__const__));
extern int isupper(int __c) __attribute__((__const__));
extern int isxdigit(int __c) __attribute__((__const__));
# 173 "/usr/lib/avr/include/ctype.h" 3
extern int toascii(int __c) __attribute__((__const__));
extern int tolower(int __c) __attribute__((__const__));
extern int toupper(int __c) __attribute__((__const__));
}
# 24 "/usr/share/arduino/hardware/arduino/cores/arduino/WCharacter.h" 2
inline boolean isAlphaNumeric(int c) __attribute__((always_inline));
inline boolean isAlpha(int c) __attribute__((always_inline));
inline boolean isAscii(int c) __attribute__((always_inline));
inline boolean isWhitespace(int c) __attribute__((always_inline));
inline boolean isControl(int c) __attribute__((always_inline));
inline boolean isDigit(int c) __attribute__((always_inline));
inline boolean isGraph(int c) __attribute__((always_inline));
inline boolean isLowerCase(int c) __attribute__((always_inline));
inline boolean isPrintable(int c) __attribute__((always_inline));
inline boolean isPunct(int c) __attribute__((always_inline));
inline boolean isSpace(int c) __attribute__((always_inline));
inline boolean isUpperCase(int c) __attribute__((always_inline));
inline boolean isHexadecimalDigit(int c) __attribute__((always_inline));
inline int toAscii(int c) __attribute__((always_inline));
inline int toLowerCase(int c) __attribute__((always_inline));
inline int toUpperCase(int c)__attribute__((always_inline));
inline boolean isAlphaNumeric(int c)
{
return ( isalnum(c) == 0 ? 0x0 : 0x1);
}
inline boolean isAlpha(int c)
{
return ( isalpha(c) == 0 ? 0x0 : 0x1);
}
inline boolean isAscii(int c)
{
return ( isascii (c) == 0 ? 0x0 : 0x1);
}
inline boolean isWhitespace(int c)
{
return ( isblank (c) == 0 ? 0x0 : 0x1);
}
inline boolean isControl(int c)
{
return ( iscntrl (c) == 0 ? 0x0 : 0x1);
}
inline boolean isDigit(int c)
{
return ( isdigit (c) == 0 ? 0x0 : 0x1);
}
inline boolean isGraph(int c)
{
return ( isgraph (c) == 0 ? 0x0 : 0x1);
}
inline boolean isLowerCase(int c)
{
return (islower (c) == 0 ? 0x0 : 0x1);
}
inline boolean isPrintable(int c)
{
return ( isprint (c) == 0 ? 0x0 : 0x1);
}
inline boolean isPunct(int c)
{
return ( ispunct (c) == 0 ? 0x0 : 0x1);
}
inline boolean isSpace(int c)
{
return ( isspace (c) == 0 ? 0x0 : 0x1);
}
inline boolean isUpperCase(int c)
{
return ( isupper (c) == 0 ? 0x0 : 0x1);
}
inline boolean isHexadecimalDigit(int c)
{
return ( isxdigit (c) == 0 ? 0x0 : 0x1);
}
inline int toAscii(int c)
{
return toascii (c);
}
# 156 "/usr/share/arduino/hardware/arduino/cores/arduino/WCharacter.h"
inline int toLowerCase(int c)
{
return tolower (c);
}
inline int toUpperCase(int c)
{
return toupper (c);
}
# 192 "/usr/share/arduino/hardware/arduino/cores/arduino/Arduino.h" 2
# 1 "/usr/share/arduino/hardware/arduino/cores/arduino/WString.h" 1
# 37 "/usr/share/arduino/hardware/arduino/cores/arduino/WString.h"
class __FlashStringHelper;
class StringSumHelper;
class String
{
typedef void (String::*StringIfHelperType)() const;
void StringIfHelper() const {}
public:
String(const char *cstr = "");
String(const String &str);
explicit String(char c);
explicit String(unsigned char, unsigned char base=10);
explicit String(int, unsigned char base=10);
explicit String(unsigned int, unsigned char base=10);
explicit String(long, unsigned char base=10);
explicit String(unsigned long, unsigned char base=10);
~String(void);
unsigned char reserve(unsigned int size);
inline unsigned int length(void) const {return len;}
String & operator = (const String &rhs);
String & operator = (const char *cstr);
# 95 "/usr/share/arduino/hardware/arduino/cores/arduino/WString.h"
unsigned char concat(const String &str);
unsigned char concat(const char *cstr);
unsigned char concat(char c);
unsigned char concat(unsigned char c);
unsigned char concat(int num);
unsigned char concat(unsigned int num);
unsigned char concat(long num);
unsigned char concat(unsigned long num);
String & operator += (const String &rhs) {concat(rhs); return (*this);}
String & operator += (const char *cstr) {concat(cstr); return (*this);}
String & operator += (char c) {concat(c); return (*this);}
String & operator += (unsigned char num) {concat(num); return (*this);}
String & operator += (int num) {concat(num); return (*this);}
String & operator += (unsigned int num) {concat(num); return (*this);}
String & operator += (long num) {concat(num); return (*this);}
String & operator += (unsigned long num) {concat(num); return (*this);}
friend StringSumHelper & operator + (const StringSumHelper &lhs, const String &rhs);
friend StringSumHelper & operator + (const StringSumHelper &lhs, const char *cstr);
friend StringSumHelper & operator + (const StringSumHelper &lhs, char c);
friend StringSumHelper & operator + (const StringSumHelper &lhs, unsigned char num);
friend StringSumHelper & operator + (const StringSumHelper &lhs, int num);
friend StringSumHelper & operator + (const StringSumHelper &lhs, unsigned int num);
friend StringSumHelper & operator + (const StringSumHelper &lhs, long num);
friend StringSumHelper & operator + (const StringSumHelper &lhs, unsigned long num);
operator StringIfHelperType() const { return buffer ? &String::StringIfHelper : 0; }
int compareTo(const String &s) const;
unsigned char equals(const String &s) const;
unsigned char equals(const char *cstr) const;
unsigned char operator == (const String &rhs) const {return equals(rhs);}
unsigned char operator == (const char *cstr) const {return equals(cstr);}
unsigned char operator != (const String &rhs) const {return !equals(rhs);}
unsigned char operator != (const char *cstr) const {return !equals(cstr);}
unsigned char operator < (const String &rhs) const;
unsigned char operator > (const String &rhs) const;
unsigned char operator <= (const String &rhs) const;
unsigned char operator >= (const String &rhs) const;
unsigned char equalsIgnoreCase(const String &s) const;
unsigned char startsWith( const String &prefix) const;
unsigned char startsWith(const String &prefix, unsigned int offset) const;
unsigned char endsWith(const String &suffix) const;
char charAt(unsigned int index) const;
void setCharAt(unsigned int index, char c);
char operator [] (unsigned int index) const;
char& operator [] (unsigned int index);
void getBytes(unsigned char *buf, unsigned int bufsize, unsigned int index=0) const;
void toCharArray(char *buf, unsigned int bufsize, unsigned int index=0) const
{getBytes((unsigned char *)buf, bufsize, index);}
const char * c_str() const { return buffer; }
int indexOf( char ch ) const;
int indexOf( char ch, unsigned int fromIndex ) const;
int indexOf( const String &str ) const;
int indexOf( const String &str, unsigned int fromIndex ) const;
int lastIndexOf( char ch ) const;
int lastIndexOf( char ch, unsigned int fromIndex ) const;
int lastIndexOf( const String &str ) const;
int lastIndexOf( const String &str, unsigned int fromIndex ) const;
String substring( unsigned int beginIndex ) const;
String substring( unsigned int beginIndex, unsigned int endIndex ) const;
void replace(char find, char replace);
void replace(const String& find, const String& replace);
void toLowerCase(void);
void toUpperCase(void);
void trim(void);
long toInt(void) const;
protected:
char *buffer;
unsigned int capacity;
unsigned int len;
unsigned char flags;
protected:
void init(void);
void invalidate(void);
unsigned char changeBuffer(unsigned int maxStrLen);
unsigned char concat(const char *cstr, unsigned int length);
String & copy(const char *cstr, unsigned int length);
};
class StringSumHelper : public String
{
public:
StringSumHelper(const String &s) : String(s) {}
StringSumHelper(const char *p) : String(p) {}
StringSumHelper(char c) : String(c) {}
StringSumHelper(unsigned char num) : String(num) {}
StringSumHelper(int num) : String(num) {}
StringSumHelper(unsigned int num) : String(num) {}
StringSumHelper(long num) : String(num) {}
StringSumHelper(unsigned long num) : String(num) {}
};
# 193 "/usr/share/arduino/hardware/arduino/cores/arduino/Arduino.h" 2
# 1 "/usr/share/arduino/hardware/arduino/cores/arduino/HardwareSerial.h" 1
# 28 "/usr/share/arduino/hardware/arduino/cores/arduino/HardwareSerial.h"
# 1 "/usr/share/arduino/hardware/arduino/cores/arduino/Stream.h" 1
# 26 "/usr/share/arduino/hardware/arduino/cores/arduino/Stream.h"
# 1 "/usr/share/arduino/hardware/arduino/cores/arduino/Print.h" 1
# 27 "/usr/share/arduino/hardware/arduino/cores/arduino/Print.h"
# 1 "/usr/share/arduino/hardware/arduino/cores/arduino/Printable.h" 1
# 23 "/usr/share/arduino/hardware/arduino/cores/arduino/Printable.h"
# 1 "/usr/share/arduino/hardware/arduino/cores/arduino/new.h" 1
# 10 "/usr/share/arduino/hardware/arduino/cores/arduino/new.h"
void * operator new(size_t size);
void * operator new[](size_t size);
void operator delete(void * ptr);
void operator delete[](void * ptr);
__extension__ typedef int __guard __attribute__((mode (__DI__)));
extern "C" int __cxa_guard_acquire(__guard *);
extern "C" void __cxa_guard_release (__guard *);
extern "C" void __cxa_guard_abort (__guard *);
extern "C" void __cxa_pure_virtual(void);
# 24 "/usr/share/arduino/hardware/arduino/cores/arduino/Printable.h" 2
class Print;
class Printable
{
public:
virtual size_t printTo(Print& p) const = 0;
};
# 28 "/usr/share/arduino/hardware/arduino/cores/arduino/Print.h" 2
class Print
{
private:
int write_error;
size_t printNumber(unsigned long, uint8_t);
size_t printFloat(double, uint8_t);
protected:
void setWriteError(int err = 1) { write_error = err; }
public:
Print() : write_error(0) {}
int getWriteError() { return write_error; }
void clearWriteError() { setWriteError(0); }
virtual size_t write(uint8_t) = 0;
size_t write(const char *str) {
if (str == __null) return 0;
return write((const uint8_t *)str, strlen(str));
}
virtual size_t write(const uint8_t *buffer, size_t size);
size_t print(const __FlashStringHelper *);
size_t print(const String &);
size_t print(const char[]);
size_t print(char);
size_t print(unsigned char, int = 10);
size_t print(int, int = 10);
size_t print(unsigned int, int = 10);
size_t print(long, int = 10);
size_t print(unsigned long, int = 10);
size_t print(double, int = 2);
size_t print(const Printable&);
size_t println(const __FlashStringHelper *);
size_t println(const String &s);
size_t println(const char[]);
size_t println(char);
size_t println(unsigned char, int = 10);
size_t println(int, int = 10);
size_t println(unsigned int, int = 10);
size_t println(long, int = 10);
size_t println(unsigned long, int = 10);
size_t println(double, int = 2);
size_t println(const Printable&);
size_t println(void);
};
# 27 "/usr/share/arduino/hardware/arduino/cores/arduino/Stream.h" 2
# 38 "/usr/share/arduino/hardware/arduino/cores/arduino/Stream.h"
class Stream : public Print
{
protected:
unsigned long _timeout;
unsigned long _startMillis;
int timedRead();
int timedPeek();
int peekNextDigit();
public:
virtual int available() = 0;
virtual int read() = 0;
virtual int peek() = 0;
virtual void flush() = 0;
Stream() {_timeout=1000;}
void setTimeout(unsigned long timeout);
bool find(char *target);
bool find(char *target, size_t length);
bool findUntil(char *target, char *terminator);
bool findUntil(char *target, size_t targetLen, char *terminate, size_t termLen);
long parseInt();
float parseFloat();
size_t readBytes( char *buffer, size_t length);
size_t readBytesUntil( char terminator, char *buffer, size_t length);
String readString();
String readStringUntil(char terminator);
protected:
long parseInt(char skipChar);
float parseFloat(char skipChar);
};
# 29 "/usr/share/arduino/hardware/arduino/cores/arduino/HardwareSerial.h" 2
struct ring_buffer;
class HardwareSerial : public Stream
{
private:
ring_buffer *_rx_buffer;
ring_buffer *_tx_buffer;
volatile uint8_t *_ubrrh;
volatile uint8_t *_ubrrl;
volatile uint8_t *_ucsra;
volatile uint8_t *_ucsrb;
volatile uint8_t *_ucsrc;
volatile uint8_t *_udr;
uint8_t _rxen;
uint8_t _txen;
uint8_t _rxcie;
uint8_t _udrie;
uint8_t _u2x;
bool transmitting;
public:
HardwareSerial(ring_buffer *rx_buffer, ring_buffer *tx_buffer,
volatile uint8_t *ubrrh, volatile uint8_t *ubrrl,
volatile uint8_t *ucsra, volatile uint8_t *ucsrb,
volatile uint8_t *ucsrc, volatile uint8_t *udr,
uint8_t rxen, uint8_t txen, uint8_t rxcie, uint8_t udrie, uint8_t u2x);
void begin(unsigned long);
void begin(unsigned long, uint8_t);
void end();
virtual int available(void);
virtual int peek(void);
virtual int read(void);
virtual void flush(void);
virtual size_t write(uint8_t);
inline size_t write(unsigned long n) { return write((uint8_t)n); }
inline size_t write(long n) { return write((uint8_t)n); }
inline size_t write(unsigned int n) { return write((uint8_t)n); }
inline size_t write(int n) { return write((uint8_t)n); }
using Print::write;
operator bool();
};
# 98 "/usr/share/arduino/hardware/arduino/cores/arduino/HardwareSerial.h"
extern HardwareSerial Serial;
extern HardwareSerial Serial1;
extern HardwareSerial Serial2;
extern HardwareSerial Serial3;
extern void serialEventRun(void) __attribute__((weak));
# 194 "/usr/share/arduino/hardware/arduino/cores/arduino/Arduino.h" 2
uint16_t makeWord(uint16_t w);
uint16_t makeWord(byte h, byte l);
unsigned long pulseIn(uint8_t pin, uint8_t state, unsigned long timeout = 1000000L);
void tone(uint8_t _pin, unsigned int frequency, unsigned long duration = 0);
void noTone(uint8_t _pin);
long random(long);
long random(long, long);
void randomSeed(unsigned int);
long map(long, long, long, long, long);
# 1 "/usr/share/arduino/hardware/arduino/variants/mega/pins_arduino.h" 1
# 35 "/usr/share/arduino/hardware/arduino/variants/mega/pins_arduino.h"
static const uint8_t SS = 53;
static const uint8_t MOSI = 51;
static const uint8_t MISO = 50;
static const uint8_t SCK = 52;
static const uint8_t SDA = 20;
static const uint8_t SCL = 21;
static const uint8_t LED_BUILTIN = 13;
static const uint8_t A0 = 54;
static const uint8_t A1 = 55;
static const uint8_t A2 = 56;
static const uint8_t A3 = 57;
static const uint8_t A4 = 58;
static const uint8_t A5 = 59;
static const uint8_t A6 = 60;
static const uint8_t A7 = 61;
static const uint8_t A8 = 62;
static const uint8_t A9 = 63;
static const uint8_t A10 = 64;
static const uint8_t A11 = 65;
static const uint8_t A12 = 66;
static const uint8_t A13 = 67;
static const uint8_t A14 = 68;
static const uint8_t A15 = 69;
# 214 "/usr/share/arduino/hardware/arduino/cores/arduino/Arduino.h" 2
# 31 "/usr/share/arduino/hardware/arduino/cores/arduino/HardwareSerial.cpp" 2
# 1 "/usr/share/arduino/hardware/arduino/cores/arduino/wiring_private.h" 1
# 36 "/usr/share/arduino/hardware/arduino/cores/arduino/wiring_private.h"
extern "C"{
# 65 "/usr/share/arduino/hardware/arduino/cores/arduino/wiring_private.h"
typedef void (*voidFuncPtr)(void);
}
# 32 "/usr/share/arduino/hardware/arduino/cores/arduino/HardwareSerial.cpp" 2
# 64 "/usr/share/arduino/hardware/arduino/cores/arduino/HardwareSerial.cpp"
struct ring_buffer
{
unsigned char buffer[64];
volatile unsigned int head;
volatile unsigned int tail;
};
ring_buffer rx_buffer = { { 0 }, 0, 0 };
ring_buffer tx_buffer = { { 0 }, 0, 0 };
ring_buffer rx_buffer1 = { { 0 }, 0, 0 };
ring_buffer tx_buffer1 = { { 0 }, 0, 0 };
ring_buffer rx_buffer2 = { { 0 }, 0, 0 };
ring_buffer tx_buffer2 = { { 0 }, 0, 0 };
ring_buffer rx_buffer3 = { { 0 }, 0, 0 };
ring_buffer tx_buffer3 = { { 0 }, 0, 0 };
inline void store_char(unsigned char c, ring_buffer *buffer)
{
int i = (unsigned int)(buffer->head + 1) % 64;
if (i != buffer->tail) {
buffer->buffer[buffer->head] = c;
buffer->head = i;
}
}
# 113 "/usr/share/arduino/hardware/arduino/cores/arduino/HardwareSerial.cpp"
void serialEvent() __attribute__((weak));
void serialEvent() {}
extern "C" void __vector_25 (void) __attribute__ ((signal,used, externally_visible)) ; void __vector_25 (void)
{
if ((!((*(volatile uint8_t *)(((uint16_t) &((*(volatile uint8_t *)(0xC0)))))) & (1 << (2))))) {
unsigned char c = (*(volatile uint8_t *)(0XC6));
store_char(c, &rx_buffer);
} else {
unsigned char c = (*(volatile uint8_t *)(0XC6));
};
# 141 "/usr/share/arduino/hardware/arduino/cores/arduino/HardwareSerial.cpp"
}
void serialEvent1() __attribute__((weak));
void serialEvent1() {}
extern "C" void __vector_36 (void) __attribute__ ((signal,used, externally_visible)) ; void __vector_36 (void)
{
if ((!((*(volatile uint8_t *)(((uint16_t) &((*(volatile uint8_t *)(0xC8)))))) & (1 << (2))))) {
unsigned char c = (*(volatile uint8_t *)(0XCE));
store_char(c, &rx_buffer1);
} else {
unsigned char c = (*(volatile uint8_t *)(0XCE));
};
}
void serialEvent2() __attribute__((weak));
void serialEvent2() {}
extern "C" void __vector_51 (void) __attribute__ ((signal,used, externally_visible)) ; void __vector_51 (void)
{
if ((!((*(volatile uint8_t *)(((uint16_t) &((*(volatile uint8_t *)(0xD0)))))) & (1 << (2))))) {
unsigned char c = (*(volatile uint8_t *)(0XD6));
store_char(c, &rx_buffer2);
} else {
unsigned char c = (*(volatile uint8_t *)(0XD6));
};
}
void serialEvent3() __attribute__((weak));
void serialEvent3() {}
extern "C" void __vector_54 (void) __attribute__ ((signal,used, externally_visible)) ; void __vector_54 (void)
{
if ((!((*(volatile uint8_t *)(((uint16_t) &((*(volatile uint8_t *)(0x130)))))) & (1 << (2))))) {
unsigned char c = (*(volatile uint8_t *)(0X136));
store_char(c, &rx_buffer3);
} else {
unsigned char c = (*(volatile uint8_t *)(0X136));
};
}
void serialEventRun(void)
{
if (Serial.available()) serialEvent();
if (Serial1.available()) serialEvent1();
if (Serial2.available()) serialEvent2();
if (Serial3.available()) serialEvent3();
}
# 218 "/usr/share/arduino/hardware/arduino/cores/arduino/HardwareSerial.cpp"
extern "C" void __vector_26 (void) __attribute__ ((signal,used, externally_visible)) ; void __vector_26 (void)
{
if (tx_buffer.head == tx_buffer.tail) {
((*(volatile uint8_t *)(((uint16_t) &((*(volatile uint8_t *)(0XC1)))))) &= ~(1 << (5)));
}
else {
unsigned char c = tx_buffer.buffer[tx_buffer.tail];
tx_buffer.tail = (tx_buffer.tail + 1) % 64;
(*(volatile uint8_t *)(0XC6)) = c;
}
}
extern "C" void __vector_37 (void) __attribute__ ((signal,used, externally_visible)) ; void __vector_37 (void)
{
if (tx_buffer1.head == tx_buffer1.tail) {
((*(volatile uint8_t *)(((uint16_t) &((*(volatile uint8_t *)(0XC9)))))) &= ~(1 << (5)));
}
else {
unsigned char c = tx_buffer1.buffer[tx_buffer1.tail];
tx_buffer1.tail = (tx_buffer1.tail + 1) % 64;
(*(volatile uint8_t *)(0XCE)) = c;
}
}
extern "C" void __vector_52 (void) __attribute__ ((signal,used, externally_visible)) ; void __vector_52 (void)
{
if (tx_buffer2.head == tx_buffer2.tail) {
((*(volatile uint8_t *)(((uint16_t) &((*(volatile uint8_t *)(0XD1)))))) &= ~(1 << (5)));
}
else {
unsigned char c = tx_buffer2.buffer[tx_buffer2.tail];
tx_buffer2.tail = (tx_buffer2.tail + 1) % 64;
(*(volatile uint8_t *)(0XD6)) = c;
}
}
extern "C" void __vector_55 (void) __attribute__ ((signal,used, externally_visible)) ; void __vector_55 (void)
{
if (tx_buffer3.head == tx_buffer3.tail) {
((*(volatile uint8_t *)(((uint16_t) &((*(volatile uint8_t *)(0X131)))))) &= ~(1 << (5)));
}
else {
unsigned char c = tx_buffer3.buffer[tx_buffer3.tail];
tx_buffer3.tail = (tx_buffer3.tail + 1) % 64;
(*(volatile uint8_t *)(0X136)) = c;
}
}
HardwareSerial::HardwareSerial(ring_buffer *rx_buffer, ring_buffer *tx_buffer,
volatile uint8_t *ubrrh, volatile uint8_t *ubrrl,
volatile uint8_t *ucsra, volatile uint8_t *ucsrb,
volatile uint8_t *ucsrc, volatile uint8_t *udr,
uint8_t rxen, uint8_t txen, uint8_t rxcie, uint8_t udrie, uint8_t u2x)
{
_rx_buffer = rx_buffer;
_tx_buffer = tx_buffer;
_ubrrh = ubrrh;
_ubrrl = ubrrl;
_ucsra = ucsra;
_ucsrb = ucsrb;
_ucsrc = ucsrc;
_udr = udr;
_rxen = rxen;
_txen = txen;
_rxcie = rxcie;
_udrie = udrie;
_u2x = u2x;
}
void HardwareSerial::begin(unsigned long baud)
{
uint16_t baud_setting;
bool use_u2x = 0x1;
if (baud == 57600) {
use_u2x = 0x0;
}
try_again:
if (use_u2x) {
*_ucsra = 1 << _u2x;
baud_setting = (16000000UL / 4 / baud - 1) / 2;
} else {
*_ucsra = 0;
baud_setting = (16000000UL / 8 / baud - 1) / 2;
}
if ((baud_setting > 4095) && use_u2x)
{
use_u2x = 0x0;
goto try_again;
}
*_ubrrh = baud_setting >> 8;
*_ubrrl = baud_setting;
transmitting = 0x0;
((*(volatile uint8_t *)(((uint16_t) &(*_ucsrb)))) |= (1 << (_rxen)));
((*(volatile uint8_t *)(((uint16_t) &(*_ucsrb)))) |= (1 << (_txen)));
((*(volatile uint8_t *)(((uint16_t) &(*_ucsrb)))) |= (1 << (_rxcie)));
((*(volatile uint8_t *)(((uint16_t) &(*_ucsrb)))) &= ~(1 << (_udrie)));
}
void HardwareSerial::begin(unsigned long baud, byte config)
{
uint16_t baud_setting;
uint8_t current_config;
bool use_u2x = 0x1;
if (baud == 57600) {
use_u2x = 0x0;
}
try_again:
if (use_u2x) {
*_ucsra = 1 << _u2x;
baud_setting = (16000000UL / 4 / baud - 1) / 2;
} else {
*_ucsra = 0;
baud_setting = (16000000UL / 8 / baud - 1) / 2;
}
if ((baud_setting > 4095) && use_u2x)
{
use_u2x = 0x0;
goto try_again;
}
*_ubrrh = baud_setting >> 8;
*_ubrrl = baud_setting;
*_ucsrc = config;
((*(volatile uint8_t *)(((uint16_t) &(*_ucsrb)))) |= (1 << (_rxen)));
((*(volatile uint8_t *)(((uint16_t) &(*_ucsrb)))) |= (1 << (_txen)));
((*(volatile uint8_t *)(((uint16_t) &(*_ucsrb)))) |= (1 << (_rxcie)));
((*(volatile uint8_t *)(((uint16_t) &(*_ucsrb)))) &= ~(1 << (_udrie)));
}
void HardwareSerial::end()
{
while (_tx_buffer->head != _tx_buffer->tail)
;
((*(volatile uint8_t *)(((uint16_t) &(*_ucsrb)))) &= ~(1 << (_rxen)));
((*(volatile uint8_t *)(((uint16_t) &(*_ucsrb)))) &= ~(1 << (_txen)));
((*(volatile uint8_t *)(((uint16_t) &(*_ucsrb)))) &= ~(1 << (_rxcie)));
((*(volatile uint8_t *)(((uint16_t) &(*_ucsrb)))) &= ~(1 << (_udrie)));
_rx_buffer->head = _rx_buffer->tail;
}
int HardwareSerial::available(void)
{
return (unsigned int)(64 + _rx_buffer->head - _rx_buffer->tail) % 64;
}
int HardwareSerial::peek(void)
{
if (_rx_buffer->head == _rx_buffer->tail) {
return -1;
} else {
return _rx_buffer->buffer[_rx_buffer->tail];
}
}
int HardwareSerial::read(void)
{
if (_rx_buffer->head == _rx_buffer->tail) {
return -1;
} else {
unsigned char c = _rx_buffer->buffer[_rx_buffer->tail];
_rx_buffer->tail = (unsigned int)(_rx_buffer->tail + 1) % 64;
return c;
}
}
void HardwareSerial::flush()
{
while (transmitting && ! (*_ucsra & (1 << (6))));
transmitting = 0x0;
}
size_t HardwareSerial::write(uint8_t c)
{
int i = (_tx_buffer->head + 1) % 64;
while (i == _tx_buffer->tail)
;
_tx_buffer->buffer[_tx_buffer->head] = c;
_tx_buffer->head = i;
((*(volatile uint8_t *)(((uint16_t) &(*_ucsrb)))) |= (1 << (_udrie)));
transmitting = 0x1;
((*(volatile uint8_t *)(((uint16_t) &(*_ucsra)))) |= (1 << (6)));
return 1;
}
HardwareSerial::operator bool() {
return 0x1;
}
HardwareSerial Serial(&rx_buffer, &tx_buffer, &(*(volatile uint8_t *)(0xC5)), &(*(volatile uint8_t *)(0xC4)), &(*(volatile uint8_t *)(0xC0)), &(*(volatile uint8_t *)(0XC1)), &(*(volatile uint8_t *)(0xC2)), &(*(volatile uint8_t *)(0XC6)), 4, 3, 7, 5, 1);
HardwareSerial Serial1(&rx_buffer1, &tx_buffer1, &(*(volatile uint8_t *)(0xCD)), &(*(volatile uint8_t *)(0xCC)), &(*(volatile uint8_t *)(0xC8)), &(*(volatile uint8_t *)(0XC9)), &(*(volatile uint8_t *)(0xCA)), &(*(volatile uint8_t *)(0XCE)), 4, 3, 7, 5, 1);
HardwareSerial Serial2(&rx_buffer2, &tx_buffer2, &(*(volatile uint8_t *)(0xD5)), &(*(volatile uint8_t *)(0xD4)), &(*(volatile uint8_t *)(0xD0)), &(*(volatile uint8_t *)(0XD1)), &(*(volatile uint8_t *)(0xD2)), &(*(volatile uint8_t *)(0XD6)), 4, 3, 7, 5, 1);
HardwareSerial Serial3(&rx_buffer3, &tx_buffer3, &(*(volatile uint8_t *)(0x135)), &(*(volatile uint8_t *)(0x134)), &(*(volatile uint8_t *)(0x130)), &(*(volatile uint8_t *)(0X131)), &(*(volatile uint8_t *)(0x132)), &(*(volatile uint8_t *)(0X136)), 4, 3, 7, 5, 1);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment