/* * File: defines.h * Author: thebears * * Created on December 18, 2024, 11:41 AM */ #ifndef DEFINES_H #define DEFINES_H #ifdef __cplusplus extern "C" { #endif #include "stdint.h" #include #include #include #ifndef F_CPU #define F_CPU 8000000UL // 8 MHz clock speed; prefer -DF_CPU=8000000UL in the build flags #endif #define BAUD 38400 #define F_SCL 200000UL // Build switches: DO_UART compiles in serial logging, ITERATING is a bench // mode that reports every minute instead of every 15. #define DO_UART true #define ITERATING false // Serial log line, compiled out entirely when DO_UART is off. Takes a string // LITERAL only: PSTR keeps the text in flash instead of copying it into RAM at // boot. The caller's file must include uart.h (directly or via another driver // header). Use uart_sendString() for runtime strings. #if DO_UART #define LOG(msg) uart_sendString_P(PSTR(msg)) #else #define LOG(msg) ((void)0) #endif #define MIN(a, b) (((a) < (b)) ? (a) : (b)) #define MAX(a, b) (((a) > (b)) ? (a) : (b)) // Shared scratch buffers (RAM is tight: 2 KB total). DATA_BUFFER_65 holds one // EEPROM page plus a terminator; DATA_BUFFER_7 holds one RTC time readout. extern unsigned char DATA_BUFFER_65[65]; extern uint8_t DATA_BUFFER_7[7]; typedef struct { uint8_t payload_len; char payload[48]; uint8_t success; } ndef_message; extern ndef_message NDEF_MSG; typedef struct { char str[21]; // Pointer to the modified string size_t length; // Length of the modified string } trimmed_string_struct; extern trimmed_string_struct TRIMMED_STRING; typedef struct { uint8_t name_len; char name_str[16]; char diameter_str[16]; uint8_t diameter_len; uint8_t hashed; } identifier_results; extern identifier_results IDENTIFIER; typedef struct { uint8_t len; uint8_t to; uint8_t from; uint8_t dtype; uint8_t flags; unsigned char msg[60]; } tx_rx_data_struct; extern tx_rx_data_struct TX_DATA; extern tx_rx_data_struct RX_DATA; typedef struct { uint8_t Second; // 0-59 uint8_t Minute; // 0-59 uint8_t Hour; // 0-23 uint8_t Wday; // Day of week, 1-7 (1 = Sunday) uint8_t Day; // 1-31 uint8_t Month; // 1-12 uint8_t Year; // Full year (e.g., 2024) } time_struct; extern time_struct TIME; typedef enum { RTC_RFM69_SET_TIME_SUCCESS = 1, RTC_RFM69_SET_TIME_FAILED = 2, } RTC_RFM69_STATUS; typedef enum // Goes into ID { DATA_SEND_SUCCESS = 1, DATA_NOT_SENT = 2 } DATA_SEND_STATUS; typedef enum // Goes into ID { MSG_TYPE_STRING = 1, MSG_TYPE_BINARY = 2 } MSG_DATA_TYPE; typedef enum // Goes into flags { MSG_REQ_CTIME = 1, MSG_RESP_CTIME = 2, MSG_SEND_COUNTS = 31, MSG_RECV_COUNTS_SUCCESS = 32, MSG_RECV_COUNTS_FAIL = 33, MSG_RESENT_COUNTS = 34 } MSG_REQUEST_TYPE_FLAG; #ifdef __cplusplus } #endif #endif /* DEFINES_H */