| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117 |
- #pragma once
- /*
- * AVR Compatibility Layer for PC compilation
- * Provides AVR types, macros, and functions for x86/x64 hosts
- */
- /* Prevent AVR-specific headers from being included */
- #define _AVR_PGMSPACE_H_ 1
- #define _AVR_IO_H_ 1
- #define _AVR_WDT_H_ 1
- #define _AVR_SLEEP_H_ 1
- #include <stdio.h>
- #include <stdint.h>
- #include <string.h>
- #include <time.h>
- #include <math.h>
- /* AVR type definitions - on PC, these are already correct */
- /* No need to redefine built-in types */
- /* PROGMEM/Flash support - on PC everything is in RAM */
- #define PROGMEM
- #define __flash
- #define PSTR(s) (s)
- #define strcpy_P strcpy
- #define strcat_P strcat
- /* xprintf functions are implemented in gpx_wrapper.c and nmea_wrapper.c */
- /* FatFS types stub */
- typedef struct {
- FILE *fp;
- char filename[256];
- } FIL;
- typedef uint32_t DWORD;
- typedef unsigned int UINT;
- /* FatFS function stubs */
- #define FA_WRITE 0x02
- #define FA_OPEN_ALWAYS 0x10
- static inline unsigned char f_open(FIL *file, const char *path, unsigned char mode) {
- (void)mode;
- file->fp = fopen(path, "w");
- if (file->fp) {
- strncpy(file->filename, path, sizeof(file->filename) - 1);
- return 0;
- }
- return 1;
- }
- static inline unsigned char f_write(FIL *file, const void *buf, unsigned int len, unsigned int *written) {
- if (!file->fp) return 1;
- *written = fwrite(buf, 1, len, file->fp);
- return (*written == len) ? 0 : 1;
- }
- static inline unsigned char f_close(FIL *file) {
- if (file->fp) {
- fclose(file->fp);
- file->fp = NULL;
- return 0;
- }
- return 1;
- }
- /* Math functions */
- #ifndef M_PI
- #define M_PI 3.14159265358979323846
- #endif
- /* AVR interrupt stubs */
- #define cli()
- #define sei()
- /* System structure - simplified for PC testing */
- struct config_s {
- unsigned char skip_points;
- unsigned char auto_pause_dist;
- };
- struct system_s {
- struct config_s conf;
- unsigned long int distance;
- unsigned long int elevation_gain;
- unsigned long int elevation_loss;
- time_t time_start;
- time_t current_pause_start;
- time_t pause_time;
- unsigned tracking_paused:1;
- unsigned tracking_auto_paused:1;
- };
- struct location_s {
- float lon;
- float lat;
- float alt;
- time_t time;
- };
- extern volatile struct system_s System;
- extern struct location_s location;
- extern time_t utc;
- /* Settings flags */
- #define CONFFLAG_DISABLE_FILTERS 0x01
- extern unsigned char config_flags;
- static inline unsigned char get_flag(unsigned char flag) {
- return (config_flags & flag) ? 1 : 0;
- }
- /* Time functions */
- char *get_iso_time(time_t time, unsigned char local);
- void iso_time_to_filename(char *time);
|