Siphon Regulator 1.0
Nanosattelite attitude determination and control system.
Loading...
Searching...
No Matches
main.h File Reference

: Header for main.c file. This file contains the common defines of the application. More...

#include "stm32f1xx_hal.h"

Go to the source code of this file.

Data Structures

struct  sensor_data_t
 
struct  settings_t
 

Macros

#define _read_BV(reg, bit)
 
#define _set_BV(reg, bit)
 
#define _clr_BV(reg, bit)
 
#define _tog_BV(reg, bit)
 
#define _clr_time(reg)
 
#define _set_time(reg, time_l, time_r)
 
#define _read_time_r(reg)
 
#define _read_time_l(reg)
 
#define _float2int(data_fl)
 
#define BOARD_LED_Pin   GPIO_PIN_13
 
#define BOARD_LED_GPIO_Port   GPIOC
 
#define VALVE_R_Pin   GPIO_PIN_2
 
#define VALVE_R_GPIO_Port   GPIOA
 
#define VALVE_L_Pin   GPIO_PIN_3
 
#define VALVE_L_GPIO_Port   GPIOA
 
#define LED_R_Pin   GPIO_PIN_5
 
#define LED_R_GPIO_Port   GPIOA
 
#define LED_Y_Pin   GPIO_PIN_6
 
#define LED_Y_GPIO_Port   GPIOA
 
#define LED_G_Pin   GPIO_PIN_7
 
#define LED_G_GPIO_Port   GPIOA
 
#define SPI2_CS_Pin   GPIO_PIN_9
 
#define SPI2_CS_GPIO_Port   GPIOB
 
#define RUN_BIT   0
 
#define DIR_BIT   1
 
#define PULSE_BIT   2
 
#define TURN_BIT   3
 
#define REG_BIT   4
 
#define RETURN_BIT   5
 
#define HOME_BIT   7
 
#define AUTOREAD_BIT   24
 
#define AUTOREAD_ACC_BIT   25
 
#define AUTOREAD_GYR_BIT   26
 
#define AUTOREAD_POS_BIT   27
 
#define PULSE_REPRE   10
 
#define _read_valve(reg)
 
#define CAL_MUL   ((360.0f/328.0f)*(360.0f/349.0f))
 
#define CMD0_BIT   28
 
#define CMD1_BIT   29
 
#define CMD2_BIT   30
 
#define CMD3_BIT   31
 

Functions

void Error_Handler (void)
 This function is executed in case of error occurrence.
 

Detailed Description

: Header for main.c file. This file contains the common defines of the application.

Attention

Copyright (c) 2026 STMicroelectronics. All rights reserved.

This software is licensed under terms that can be found in the LICENSE file in the root directory of this software component. If no LICENSE file comes with this software, it is provided AS-IS.

Definition in file main.h.

Macro Definition Documentation

◆ _clr_BV

#define _clr_BV ( reg,
bit )
Value:
reg = reg & ~(1 << bit)

Clear single bit in register.

Definition at line 109 of file main.h.

◆ _clr_time

#define _clr_time ( reg)
Value:
reg = reg & ~0x00FFFF00

Time data are included in bites 15 to 8 (right valve) and in 23 to 16 (left valve). Set time to null.

Definition at line 118 of file main.h.

◆ _float2int

#define _float2int ( data_fl)
Value:
((int16_t)(data_fl*1000))

Float value is converted to integer. For better resolution is multiplied by 100.

Definition at line 133 of file main.h.

◆ _read_BV

#define _read_BV ( reg,
bit )
Value:
reg & (1 << bit)

Check value of single bit in register.

Definition at line 103 of file main.h.

◆ _read_time_l

#define _read_time_l ( reg)
Value:
((reg & 0x00FF0000) >> 16)

Read time settings for left valve.

Definition at line 128 of file main.h.

◆ _read_time_r

#define _read_time_r ( reg)
Value:
((reg & 0x0000FF00) >> 8)

Read time settings for right valve.

Definition at line 125 of file main.h.

◆ _read_valve

#define _read_valve ( reg)
Value:
reg & ((1 << RUN_BIT) | (1 << TURN_BIT) | (1 << PULSE_BIT) | (1 << HOME_BIT) | (1 << REG_BIT) | (1 << RETURN_BIT))
#define RETURN_BIT
Definition main.h:177
#define RUN_BIT
Definition main.h:162
#define TURN_BIT
Definition main.h:171
#define HOME_BIT
Definition main.h:180
#define PULSE_BIT
Definition main.h:168
#define REG_BIT
Definition main.h:174

Check if any command or method is performed.

Definition at line 200 of file main.h.

◆ _set_BV

#define _set_BV ( reg,
bit )
Value:
reg = reg | (1 << bit)

Set single bit in register.

Definition at line 106 of file main.h.

◆ _set_time

#define _set_time ( reg,
time_l,
time_r )
Value:
reg = reg | (time_r << 8) | (time_l << 16)

Set open-valve time to the defined values, separately for left and right valve.

Definition at line 122 of file main.h.

◆ _tog_BV

#define _tog_BV ( reg,
bit )
Value:
reg = reg ^ (1 << bit)

Toggle single bit in register.

Definition at line 112 of file main.h.

◆ AUTOREAD_ACC_BIT

#define AUTOREAD_ACC_BIT   25

If active, the automatic message includes the accelerometer reading.

Definition at line 186 of file main.h.

◆ AUTOREAD_BIT

#define AUTOREAD_BIT   24

If active, global sending of the automatic reading is enabled.

Definition at line 183 of file main.h.

◆ AUTOREAD_GYR_BIT

#define AUTOREAD_GYR_BIT   26

If active, the automatic message includes the gyroscope reading.

Definition at line 189 of file main.h.

◆ AUTOREAD_POS_BIT

#define AUTOREAD_POS_BIT   27

If active, the automatic message includes the orientation data.

Definition at line 192 of file main.h.

◆ BOARD_LED_GPIO_Port

#define BOARD_LED_GPIO_Port   GPIOC

Definition at line 146 of file main.h.

◆ BOARD_LED_Pin

#define BOARD_LED_Pin   GPIO_PIN_13

Definition at line 145 of file main.h.

◆ CAL_MUL

#define CAL_MUL   ((360.0f/328.0f)*(360.0f/349.0f))

Calibration constant, get from comparison required angle for turn and measured

Definition at line 204 of file main.h.

◆ CMD0_BIT

#define CMD0_BIT   28

0 - disable regulation, 1 - enable regulation

Definition at line 208 of file main.h.

◆ CMD1_BIT

#define CMD1_BIT   29

Reserved

Definition at line 211 of file main.h.

◆ CMD2_BIT

#define CMD2_BIT   30

Reserved

Definition at line 214 of file main.h.

◆ CMD3_BIT

#define CMD3_BIT   31

Reserved

Definition at line 217 of file main.h.

◆ DIR_BIT

#define DIR_BIT   1

0 - left, 1 - right

Definition at line 165 of file main.h.

◆ HOME_BIT

#define HOME_BIT   7

If active, the home command is being executed.

Definition at line 180 of file main.h.

◆ LED_G_GPIO_Port

#define LED_G_GPIO_Port   GPIOA

Definition at line 156 of file main.h.

◆ LED_G_Pin

#define LED_G_Pin   GPIO_PIN_7

Definition at line 155 of file main.h.

◆ LED_R_GPIO_Port

#define LED_R_GPIO_Port   GPIOA

Definition at line 152 of file main.h.

◆ LED_R_Pin

#define LED_R_Pin   GPIO_PIN_5

Definition at line 151 of file main.h.

◆ LED_Y_GPIO_Port

#define LED_Y_GPIO_Port   GPIOA

Definition at line 154 of file main.h.

◆ LED_Y_Pin

#define LED_Y_Pin   GPIO_PIN_6

Definition at line 153 of file main.h.

◆ PULSE_BIT

#define PULSE_BIT   2

If active, the pulse command is being executed.

Definition at line 168 of file main.h.

◆ PULSE_REPRE

#define PULSE_REPRE   10

Valve time is multiplied by 10.

Definition at line 195 of file main.h.

◆ REG_BIT

#define REG_BIT   4

If active, the satellite counteracts external deflection.

Definition at line 174 of file main.h.

◆ RETURN_BIT

#define RETURN_BIT   5

If active, the satellite returns to the position prior to deflection.

Definition at line 177 of file main.h.

◆ RUN_BIT

#define RUN_BIT   0

If active, a new action is requested.

Definition at line 162 of file main.h.

◆ SPI2_CS_GPIO_Port

#define SPI2_CS_GPIO_Port   GPIOB

Definition at line 158 of file main.h.

◆ SPI2_CS_Pin

#define SPI2_CS_Pin   GPIO_PIN_9

Definition at line 157 of file main.h.

◆ TURN_BIT

#define TURN_BIT   3

If active, the turn command is being executed.

Definition at line 171 of file main.h.

◆ VALVE_L_GPIO_Port

#define VALVE_L_GPIO_Port   GPIOA

Definition at line 150 of file main.h.

◆ VALVE_L_Pin

#define VALVE_L_Pin   GPIO_PIN_3

Definition at line 149 of file main.h.

◆ VALVE_R_GPIO_Port

#define VALVE_R_GPIO_Port   GPIOA

Definition at line 148 of file main.h.

◆ VALVE_R_Pin

#define VALVE_R_Pin   GPIO_PIN_2

Definition at line 147 of file main.h.

Function Documentation

◆ Error_Handler()

void Error_Handler ( void )

This function is executed in case of error occurrence.

Return values
None

Definition at line 379 of file main.c.