/* * navikit.h * * Created on: Apr 17, 2020 * Author: oarap */ #ifndef INC_NAVIKIT_H_ #define INC_NAVIKIT_H_ #include "stdbool.h" #include "stm32f1xx_hal.h" #include "adc.h" #include "gpio.h" #define ADC_CH_COUNT 5+2 //number of adc channels (include temp sensor and vrefint adc_in17) typedef struct { struct{ enum { shutdown, //only mcu runing running, //all function runing sleep, //SOCs and FANs are stop dfu, //device firmware update for SOM isp //in system program for BIOS }sta,next_sta; //power state machine bool power_btn; //power button bool custom_btn;//custom button bool pwr_led;//power led (on switch) bool run_led;//run led (on board) }sys; struct{ bool mod_sleep; bool power_en; bool shutdown_req; bool sys_reset; bool force_recovery; bool sleep_wake; }som;//som power management struct{ struct{ uint32_t adc[ADC_CH_COUNT]; float out_24v;//_div16 float out_5v;//_div8 float out_12v;//_div8 float bkp_bat;//_div8 float main_pwr;//_div16 }rails;//power rails struct{ bool temp_sen_en; bool temp_sen_alt; bool coulomb_alcc; bool chrg_stat2; bool chrg_stat1; }sta; struct{ float voltage; float current; float cap; float temp; }coulomb; }pmb;//power management board // struct{ // bool u2_vbus_1; // bool u2_vbus_2; // bool u2_vbus_3; // bool u2_vbus_4; // bool u2_vbus_5; // bool u2_vbus_6; // bool u3_vbus_1; // bool u3_vbus_2; // bool u3_vbus_3; // bool u3_vbus_4; // bool u3_vbus_5; // bool u3_vbus_6; // }port; // struct{ // bool u2_hub_pwr; // bool u3_hub_pwr; // bool u3_host_pwr; // bool u3_gec_pwr; // bool ge_sw_pwr; // }soc; // struct{ // bool fan_valid_1; // bool fan_valid_2; // bool fan_valid_3; // }fan; // struct{ // bool fan_1; // bool fan_2; // bool fan_3; // }status; // struct { // float sensor_1; // float sensor_2; // float sensor_3; // }temp; }NaviKit_t; extern NaviKit_t NaviKit; void NaviKit_var_init(); //power state machine switch function void enter_isp_state(); void enter_runing_state(); void enter_shutdown_state(uint8_t timeout = 0); void enter_sleep_state(); void enter_dfu_state(); void Beep(uint32_t time_ms); void HAL_ADC_ConvCpltCallback(ADC_HandleTypeDef* hadc); #endif /* INC_NAVIKIT_H_ */