Generalized-Core-Counter 3.20
Particle-based generalized core counter firmware
Loading...
Searching...
No Matches
device_pinout.cpp
Go to the documentation of this file.
1// Particle Functions
2#include "Particle.h"
3#include "device_pinout.h"
4
5// Carrier board pin definitions
6// See device_pinout.h for the full header mapping and documentation.
7
8// ---------------------------------------------------------------------------
9// Carrier-board common pins (same logical role on all platforms)
10// ---------------------------------------------------------------------------
11// TMP36 temperature sensor:
12// - On Boron carrier, wired to A4.
13// - On Photon 2 / P2 carrier, silk is "S4"; map explicitly for that
14// platform so we don't rely on A4 aliasing.
15
16// Optional override (for example, a Muon carrier) that wires the TMP36 to a
17// different analog-capable pin.
18#if defined(MUON_TMP36_SENSE_PIN)
19const pin_t TMP36_SENSE_PIN = MUON_TMP36_SENSE_PIN;
20#elif PLATFORM_ID == PLATFORM_P2
21const pin_t TMP36_SENSE_PIN = S4;
22#else
23const pin_t TMP36_SENSE_PIN = A4;
24#endif
25
26const pin_t BUTTON_PIN = D4;
27const pin_t BLUE_LED = D7;
28const pin_t WAKEUP_PIN = WKP; // D10 on Photon2 (was D8 on Argon/Boron)
29
30// Convenience aliases for carrier functions
31// (No additional aliases; use the base names directly in application code.)
32
33// ---------------------------------------------------------------------------
34// Sensor-specific pins (PIR-on-carrier) with platform-specific mapping
35// ---------------------------------------------------------------------------
36// All device-specific identifiers (D12 vs MOSI vs S1, etc.) are handled here
37// so the rest of the firmware only ever uses intPin/disableModule/ledPower.
38
39// P2 uses S0/S1/S2 for the primary SPI header, while Boron exposes them as
40// D11/D12/D13 (MISO/MOSI/SCK). We select the correct mapping based on
41// PLATFORM_ID so this same firmware can target both.
42
43#if PLATFORM_ID == PLATFORM_P2
44const pin_t intPin = S2; // PIR interrupt on SPI SCK-equivalent
45const pin_t disableModule = S0; // Sensor enable (SPI MOSI-equivalent)
46const pin_t ledPower = S1; // Sensor LED power (SPI MISO-equivalent)
47
48#elif PLATFORM_ID == PLATFORM_BORON
49const pin_t intPin = SCK; // D13 on Boron
50const pin_t disableModule = MOSI; // D12 on Boron
51const pin_t ledPower = MISO; // D11 on Boron
52
53#else
54// Fallback: assume SPI pins follow the common SCK/MOSI/MISO aliases.
55const pin_t intPin = SCK;
56const pin_t disableModule = MOSI;
57const pin_t ledPower = MISO;
58#endif
59
61 Log.info("Initalizing the pinModes");
62 // Define as inputs or outputs
63 pinMode(BUTTON_PIN, INPUT); // User button on the carrier board - external pull-up on carrier
64 pinMode(WAKEUP_PIN, INPUT_PULLUP); // AB1805 FOUT/nIRQ (open-drain, active-LOW, needs pull-up)
65 pinMode(BLUE_LED, OUTPUT); // On-module status LED
66 return true;
67}
68
69
71 /*
72 Log.info("Initializing Power Config");
73 const int maxCurrentFromPanel = 900; // Not currently used (100,150,500,900,1200,2000 - will pick closest) (550mA for 3.5W Panel, 340 for 2W panel)
74 SystemPowerConfiguration conf;
75 System.setPowerConfiguration(SystemPowerConfiguration()); // To restore the default configuration
76
77 conf.powerSourceMaxCurrent(maxCurrentFromPanel) // Set maximum current the power source can provide 3.5W Panel (applies only when powered through VIN)
78 .powerSourceMinVoltage(5080) // Set minimum voltage the power source can provide (applies only when powered through VIN)
79 .batteryChargeCurrent(maxCurrentFromPanel) // Set battery charge current
80 .batteryChargeVoltage(4208) // Set battery termination voltage
81 .feature(SystemPowerFeature::USE_VIN_SETTINGS_WITH_USB_HOST); // For the cases where the device is powered through VIN
82 // but the USB cable is connected to a USB host, this feature flag
83 // enforces the voltage/current limits specified in the configuration
84 // (where by default the device would be thinking that it's powered by the USB Host)
85 int res = System.setPowerConfiguration(conf); // returns SYSTEM_ERROR_NONE (0) in case of success
86 return res;
87 */
88 return true;
89}
90
bool initializePinModes()
bool initializePowerCfg()
const pin_t BLUE_LED
const pin_t TMP36_SENSE_PIN
const pin_t ledPower
const pin_t disableModule
const pin_t WAKEUP_PIN
const pin_t BUTTON_PIN
const pin_t intPin
Pinout definitions for the carrier board and sensors.