// SPDX-License-Identifier: Apache-2.0 // Copyright (c) 2012-2024 Scott Penrose and WII5 Buoy contributors // // This file is part of WII5 Buoy firmware. // See LICENSE for full terms. /** * @file WII5_board_v2.h * @brief Pin and peripheral configuration for the WII5 v2 hardware revision. */ /* WII5 Board = WII5v2.0..v5.0 - This is current configuration used in V5.5 board in 2024 * TODO: * Update all PINS * Remove unused PINS * Test * Test V1 board is still working Define PINS and pin Modes, Serial ports etc Board Versions v1 - Hardware / Layout, just increment each time v1.1 - Second number is changes locall - e.g. v1.1 might use a Software Serial for Matrix input mega_dev - Development board using a Sparkfun 3.3V 8Mhz Arduino Mega File Structure * Names for all ports etc used on this board. NOTE: Do we need WII5 prefix?, e.g. WII5_PIN_D0_NAME Initial Build test using 595eb5a Sketch uses 115740 bytes (44%) of program storage space. Maximum is 258048 bytes. Global variables use 6667 bytes (81%) of dynamic memory, leaving 1525 bytes for local variables. Maximum is 8192 bytes. Sketch uses 115740 bytes (44%) of program storage space. Maximum is 258048 bytes. Global variables use 6667 bytes (81%) of dynamic memory, leaving 1525 bytes for local variables. Maximum is 8192 bytes. Improved strings Sketch uses 115738 bytes (44%) of program storage space. Maximum is 258048 bytes. Global variables use 6661 bytes (81%) of dynamic memory, leaving 1531 bytes for local variables. Maximum is 8192 bytes. Sketch uses 115914 bytes (44%) of program storage space. Maximum is 258048 bytes. Global variables use 6647 bytes (81%) of dynamic memory, leaving 1545 bytes for local variables. Maximum is 8192 bytes. Free Memory 213/8192 really of 213 of 1545 - so we still have 1200 bytes dynamic created ! Find and destory SUB 1 left right SUB 3 left 2 - D3 5 - D27 right 3 - D9 4 - D12 5 - D62 Shared 5 Volts: * Maths - now has its own supply, not shared * Needs 5 Volts: * Sparton * Iridium * Beeper */ // Enable extended EEPROM code #define WII5_EEPROMex #define WII5_BOARD_ID 102 #define WII5_BOARD_NAME "WII5_V5.0" #define WII5_BOARD_CPU "AVR25560" #define WII5_BOARD_MEMORY 8192 #define WII5_BOARD_EEPROM 4096 #ifdef F_CPU #define WII5_BOARD_CLOCK F_CPU #else #define WII5_BOARD_CLOCK 8000000L #endif // ---------------------------------------------------------------------- // Sh3d stuff - how to pass in. // auto_node_id = 'manual' // ---------------------------------------------------------------------- // Primary Hardware Components // ---------------------------------------------------------------------- // Small packet radio // #define WII5_RADIO // #define WII5_RADIO_LORA // #define WII5_RADIO_69 // RTC Configuration // #define WII5_RTC // TODO 2024 review // (Removed 2024, board 5.5.5) #define WDT_RESET 59 // #define WII5_WDT_INTERNAL #define WII5_WDT_EXTERNAL // WDT External #define WDT_RESET 59 #define WII5_LOWPOWERSLEEP // Test and Self Test etc (TODO 2024 - consider to save memory etc) #define WII5_ENABLE_MANUALTEST #define WII5_ENABLE_SELFTEST // GPS Configuration #define WII5_GPS // #define WII5_GPS_COMPASS // Compass specific version - some differences // COMMS - aka GSM Modem or Iridium Satellite #define WII5_COMMS #define WII5_COMMS_IRIDIUM // Iridium version of COMMS Driver // #define WII5_COMMS_GSMSMS // GSM SMS version // IMU #define WII5_IMU #define WII5_IMU_SPARTON // SPARTON aka Serial IMU // #define WII5_IMU_MPU9250 // 9250 aka I2C 9250 // Weather - Temperature, pressure, humidity and much more #define WII5_WEATHER_18B20 // Multiple Weather, incluing standard 18B20 // #define WII5_WEATHER_ANEMOMETER #define WII5_STORAGE_SDBLOCK #define WII5_BUTTON_HOLD_TIME 10000 // milliseconds // ---------------------------------------------------------------------- // BUFFER SIZES // (see Iridium instead) #define WII5_BUFFER_CONSOLE_BINARY 20 #define WII5_BUFFER_CONSOLE_PRINT 220 #define WII5_BUFFER_CONSOLE_CMD 50 #define WII5_BUFFER_RADIO 150 #define WII5_BUFFER_STRING 50 #ifdef WII5_COMMS_IRIDIUM // NOTE: Max receive = 270, Max send = 340 #define WII5_BUFFER_IRIDIUM 80 #define WII5_IRIDIUM_BIN_MAX 340 #endif #ifdef WII5_GPS #define WII5_BUFFER_GPS 80 #endif #define WII5_FIELD_MAX 15 #define WII5_TIMERLAPS 5 // ---------------------------------------------------------------------- // Convert Float to Integers etc #define GPS_POS_MULT 100000 #define GPS_ALT_MULT 100 // See BATTERY // ---------------------------------------------------------------------- // SERIAL #define SerialConsole Serial #ifdef F_CPU_11 // #define SerialConsole_Baud 115200 #define SerialConsole_Baud 230400 #else #define SerialConsole_Baud 57600 #endif #define SerialConsole_RX 0 #define SerialConsole_TX 1 #define SerialGPS Serial2 #define SerialGPS_Baud 9600 // Comms = Iridium here #define SerialComms Serial3 #define SerialComms_Baud 19200 // IMU = Sparton #define SerialIMU Serial1 #ifdef F_CPU_11 #define SerialIMU_Baud 115200 #else #define SerialIMU_Baud 57600 #endif // NOTE - Test these and all pins // Software Serial Devices // Not all pins on the Mega and Mega 2560 support change interrupts, // so only the following can be used for RX: // 10, 11, 12, 13, 14, 15, 50, 51, 52, 53, // A8 (62), A9 (63), A10 (64), A11 (65), A12 (66), A13 (67), A14 (68), A15 (69). // STATUS SERIAL - a low level interface // #define WII5_STATUS_SERIAL // #define WII5_STATUS_SERIAL_RX 11 // #define WII5_STATUS_SERIAL_TX 8 // #define WII5_STATUS_SERIAL_BAUD 9600 // DEBUG SERIAL Port - to SUB BOARD 1 // #define WII5_DEBUG_SERIAL // #define WII5_DEBUG_SERIAL_CONSOLE // Add to Console, and mark main as OUTPUT // #define WII5_DEBUG_SERIAL_RX SoftwareSerial5_RX // #define WII5_DEBUG_SERIAL_TX SoftwareSerial5_TX // #define WII5_DEBUG_SERIAL_RX 37 // #define WII5_DEBUG_SERIAL_TX 36 // #define WII5_DEBUG_SERIAL_BAUD 9600 // MOVE Maths to SoftwareSerial 6 // #define WII5_MATHS_SERIAL /* Testing 35, 34 - no 34, 35 - Yes (I could have it backwards on the begin?) D64, D65 */ // #define WII5_MATHS_SERIAL_RX 64 // #define WII5_MATHS_SERIAL_TX 65 // #define WII5_MATHS_SERIAL_BAUD 57600 // ---------------------------------------------------------------------- // Buttons and LEDjson2csv'); #define LED_1 13 #define LED_1_ON HIGH #define LED_2 41 #define LED_2_ON HIGH #define LED_3 0 #define LED_3_ON LOW #define LED_4 0 #define LED_4_ON LOW #define BUTTON_1 67 #define BUTTON_1_ON LOW #define BUTTON_2 45 #define BUTTON_2_ON LOW #define BUTTON_3 0 // Connects to GPIO 18 on the Pi #define BUTTON_3_ON LOW #define BUTTON_4 0 #define BUTTON_4_ON LOW // ---------------------------------------------------------------------- // Display / Debug - these pins can be used with LED & Buttons // - OR as a buffer / output for single wire LED grids #define LCD_1 69 #define LCD_2 68 #define LCD_3 67 #define LCD_4 66 #define LCD_5 65 #define LCD_6 64 // ---------------------------------------------------------------------- // Power Management #define POWER_MATHS_PIN 29 #define POWER_MATHS_ON HIGH #define POWER_RADIO_PIN 42 #define POWER_RADIO_ON HIGH #define POWER_COMMS_PIN 30 #define POWER_COMMS_ON HIGH #define POWER_GPS_PIN 56 #define POWER_GPS_ON HIGH #define POWER_STROBE1_PIN 33 #define POWER_STROBE1_ON HIGH #define POWER_STROBE2_PIN 32 #define POWER_STROBE2_ON HIGH #define POWER_IMU_SPARTON_PIN 25 #define POWER_IMU_SPARTON_ON HIGH #define POWER_WEATHER_18B20_PIN 6 #define POWER_WEATHER_18B20_ON HIGH #define POWER_WEATHER_PIN 39 // NC #define POWER_WEATHER_ON HIGH #define POWER_STORAGE_1_PIN 54 #define POWER_STORAGE_1_ON HIGH #define POWER_STORAGE_2_PIN 0 #define POWER_STORAGE_2_ON HIGH #define POWER_BUZZER_PIN 41 #define POWER_BUZZER_ON HIGH // Shared 5 volt piY_ #define SHARED_5VOLT_PIN 28 #define SHARED_5VOLT_ON HIGH // ---------------------------------------------------------------------- // Battery Management #define BATTERY_1_VOLTS_PIN 35 #define BATTERY_1_VOLTS_ON HIGH #define BATTERY_1_VOLTS_ANALOG A14 //#define BATTERY_2_VOLTS_PIN 36 //#define BATTERY_2_VOLTS_ON HIGH //#define BATTERY_2_VOLTS_ANALOG A15 // 3.027 / 3.3 // #define BATTERY_1_VOLTS_MULT 1320 #define BATTERY_1_VOLTS_MULT 1300 //#define BATTERY_2_VOLTS_MULT 1300 /* 1024 * 3027 / 3300 980 */ // What do we need to do to turn it into DeciVolts (100th of a volt) as integer // TODO Hard coded vs Config calibration of Voltage /* #define BATTERY_2_PIN 58 #define BATTERY_2_ON HIGH #define BATTERY_2_VOLTS_PIN 56 #define BATTERY_2_VOLTS_ON HIGH #define BATTERY_2_VOLTS_ANALOG A0 */ // TODO Hard coded vs Config calibration of Voltage // ---------------------------------------------------------------------- // Other analog sensors (e.g. Water) // ---------------------------------------------------------------------- // SPI Storage // - SPIMEMORY // - SD - Single SD Card // - SD2 - Two SD Cards - switched between boards // - FRAM #define STORAGE_PATH_TOP "data" #define STORAGE_PATH_EXT ".txt" #define STORAGE_PATH_META "meta" #define STORAGE_PATH_CONSOLE "console" #define STORAGE_PATH_DATA "data" #define STORAGE_TYPE_SD2 #define STORAGE_SPI SPI #define STORAGE_CS 53 #define STORAGE_SCK 52 #define STORAGE_MOSI 51 #define STORAGE_MISO 50 #define STORAGE_SD1_MATHS_PIN 58 #define STORAGE_SD1_MATHS_ON LOW #define STORAGE_SD2_MATHS_PIN 57 #define STORAGE_SD2_MATHS_ON LOW // ---------------------------------------------------------------------- // IMU - Serial (Sparton) // See also POWER_IMU_SERIAL* #define SPARTON_RESET 26 // #define SPARTON_INT 30 #define SPARTON_HZ 8 // 8 or 64 only ! #define SPARTON_MS (1000 / SPARTON_HZ) // Milliseconds, approx // ---------------------------------------------------------------------- // IMU - 9250 // See also POWER_IMU_9250* // + I2C // ---------------------------------------------------------------------- // Weather and Other Special Hardware #define WEATHER_18B20_DATA 5 // ---------------------------------------------------------------------- // Radio (aka LoRa - not used in WII5 2024) // See also POWER_RADIO_* #define RADIO_TYPE_RF95 #define RADIO_INT 2 #define RADIO_SPI SPI #define RADIO_CS 43 #define RADIO_SCK 52 #define RADIO_MOSI 51 #define RADIO_MISO 50 // ---------------------------------------------------------------------- // Communications / Iridium et al // See also POWER_COMMS* + Serial #define COMMS_NETWORK 31 // ---------------------------------------------------------------------- // Maths #define MATHS_RETURNLINE 4 // Connects to GPIO 18 on the Pi, PIN 12 #define MATHS_RETURNHOLD 3600 // Return HOLD for max 1 hour #define MATHS_MAXHOLD 43200 // aka 12 hours // ---------------------------------------------------------------------- // RTC // See also POWER_RTC #define RTC_ALARM 24 #define META_NC 20000 #define META_VOLTS_12 10012 #define META_VOLTS_5 10005 #define META_VOLTS_3 10003 #define META_VOLTS_SWITCHED 10001 #define META_GROUND 10000 #define META_I2C_SDA 20001 #define META_I2C_SCL 20002 #define META_SPI_MOSI 20003 #define META_SPI_MISO 20004 #define META_SPI_SCK 20005 // SubBoard 1 #define SUBBOARD_1_LEFT_1 META_VOLTS_12 #define SUBBOARD_1_LEFT_2 META_SPI_SCK #define SUBBOARD_1_LEFT_3 META_SPI_MOSI #define SUBBOARD_1_LEFT_4 META_SPI_MISO #define SUBBOARD_1_LEFT_5 33 #define SUBBOARD_1_LEFT_6 META_GROUND #define SUBBOARD_1_RIGHT_1 META_VOLTS_SWITCHED // controlled by 32 #define SUBBOARD_1_RIGHT_2 META_VOLTS_3 // Always on #define SUBBOARD_1_RIGHT_3 7 // TX4 #define SUBBOARD_1_RIGHT_4 10 // RX4 #define SUBBOARD_1_RIGHT_5 66 #define SUBBOARD_1_RIGHT_6 META_GROUND // SubBoard 2 #define SUBBOARD_2_LEFT_1 META_VOLTS_12 #define SUBBOARD_2_LEFT_2 META_NC #define SUBBOARD_2_LEFT_3 META_NC #define SUBBOARD_2_LEFT_4 META_NC #define SUBBOARD_2_LEFT_5 23 #define SUBBOARD_2_LEFT_6 META_GROUND #define SUBBOARD_2_RIGHT_1 META_VOLTS_SWITCHED // controlled by 32 #define SUBBOARD_2_RIGHT_2 META_VOLTS_3 // Always on #define SUBBOARD_2_RIGHT_3 8 // TX5 #define SUBBOARD_2_RIGHT_4 11 // RX5 #define SUBBOARD_2_RIGHT_5 65 #define SUBBOARD_2_RIGHT_6 META_GROUND // SubBoard 3 #define SUBBOARD_3_LEFT_1 META_VOLTS_12 #define SUBBOARD_3_LEFT_2 3 #define SUBBOARD_3_LEFT_3 META_I2C_SDA #define SUBBOARD_3_LEFT_4 META_I2C_SCL #define SUBBOARD_3_LEFT_5 27 #define SUBBOARD_3_LEFT_6 META_GROUND #define SUBBOARD_3_RIGHT_1 META_VOLTS_3 // Controlled by D61 (POWER_SUBBOARD_3_PIN) #define SUBBOARD_3_RIGHT_2 META_VOLTS_3 // Always on #define SUBBOARD_3_RIGHT_3 9 #define SUBBOARD_3_RIGHT_4 12 #define SUBBOARD_3_RIGHT_5 62 #define SUBBOARD_3_RIGHT_6 META_GROUND // Timing testing // #define TIMING_SPARTON_RUN SUBBOARD_3_LEFT_2 // #define TIMING_SPARTON_CHAR SUBBOARD_3_RIGHT_3 // #define TIMING_SPARTON_RECORD SUBBOARD_3_RIGHT_4 // #define TIMING_SD_WRITE SUBBOARD_3_LEFT_5