Files
thebears bbdcc1e623 Refactor firmware for clarity; no functional changes
- main.c: file-header comment describing the hardware and operation, logic
  split into named phases (sleep_until_interrupt, wake_peripheral_rails,
  take_counts_snapshot, send_wheel_counts_report, handle_minute_alarm,
  init_all_hardware); shared state renamed to say what it is and made static.
- rfm69.c: reorganized into six labeled sections; cond_1/2/3 and hash scratch
  globals replaced by a reply_acknowledges() helper with clear locals; packet
  layout and every init register write documented.
- LOG() macro (compiled out when DO_UART is off) replaces the #if DO_UART
  blocks that obscured the logic.
- Drivers: file-header comments; named RTC_REG_*/RTC_ALM_MASK_BIT constants;
  EEPROM spool scheme documented; ADC_CHANNEL_BANDGAP named; repeated pin
  if/else helpers collapsed to SET_PIN_TO().
- Removed unused globals/buffers and commented-out code; ran clang-format
  with the project style.

Register writes and radio protocol are byte-identical. Builds clean under
-Wall -Wextra on gnu17 and c23; flash 13028 -> 12830 B, static RAM
1038 -> 999 B.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01YVJKatfeMJjAmuH9KYiLuv
2026-08-31 23:04:00 -04:00

26 lines
693 B
C

#include "defines.h"
#include "i2c.h"
#include "ndef.h"
#include "rfm69.h"
#include "states.h"
#include <stdbool.h>
#include <util/delay.h>
#ifndef ST25DV_H
#define ST25DV_H
#define I2C_SYSTEM_ADDR 0x57
#define I2C_USER_ADDR 0x53
// Bytes of tag memory pulled in one go to look for the first NDEF record.
#define NDEF_READ_LEN 64
identifier_results get_nugget_data(void);
ndef_message rfid_read_first_ndef_entry(void);
void rfid_set_low_power_down(bool state);
void rfid_set_i2c_power(bool state);
uint8_t rfid_read_memory(uint8_t* data, uint8_t num_bytes, uint16_t address);
uint8_t rfid_read_system_register(void);
trimmed_string_struct remove_spaces(char* str, uint8_t len_str);
#endif