Skip to content

API Utils

Hrisabh Yadav edited this page Nov 14, 2025 · 1 revision

API-Utils.h

System utilities and global variables for MagisV2 flight controller.

Global Variables

System Counters

  • uint8_t resetCounter - System reset counter
  • uint8_t intLogCounter - Integer logging counter
  • uint8_t floatLogCounter - Float logging counter

Navigation Variables

  • int16_t appHeading - Application heading in degrees
  • int16_t userHeading - User-defined heading
  • int16_t AUX3_VALUE - AUX3 channel value
  • uint32_t userLoopFrequency - User-defined loop frequency

Arrays

  • int32_t user_GPS_coord[2] - User GPS coordinates [lat, lon]
  • int32_t app_GPS_coord[2] - Application GPS coordinates [lat, lon]
  • int32_t MOTOR_ARRAY[4] - Motor PWM values [M1, M2, M3, M4]
  • int32_t RC_ARRAY[4] - RC command values [Roll, Pitch, Yaw, Throttle]

System Flags

  • bool runUserCode - Enable/disable user code execution
  • bool developerMode - Developer mode flag
  • bool hasTakeOff - Takeoff completion flag
  • bool fsLowBattery - Low battery failsafe
  • bool External_RC_FLAG[4] - External RC channel flags

Functions

void userEnabledLand(void)

Initiates user-controlled landing sequence.

void resetUserRCflag(void)

Resets all user RC flags to default state.

void resetUser(void)

Resets all user-defined variables and flags to default values.

GPIO Utility Functions

  • int getGPIOport(unibus_e pin) - Gets GPIO port number
  • GPIO_Pin getGPIOpin(unibus_e pin) - Gets GPIO pin structure
  • uint32_t getGPIOclock(unibus_e pin) - Gets clock configuration

Usage Example

// Check system state
if (hasTakeOff && !fsLowBattery) {
    // Continue flight operations
}

// Reset user settings
resetUser();
resetUserRCflag();

Clone this wiki locally