Skip to content

Commit

Permalink
Reformatted with clang-format
Browse files Browse the repository at this point in the history
  • Loading branch information
bsutherland333 committed Dec 5, 2023
1 parent 09194e2 commit d0035c6
Show file tree
Hide file tree
Showing 46 changed files with 5,105 additions and 4,838 deletions.
235 changes: 116 additions & 119 deletions boards/varmint/include/Varmint.h
Original file line number Diff line number Diff line change
Expand Up @@ -38,150 +38,147 @@
#ifndef VARMINT_H_
#define VARMINT_H_

#include <Adc.h>
#include <Adis165xx.h>
#include <Bmi088.h>
#include <DlhrL20G.h>
#include <Dps310.h>
#include <Iis2mdc.h>
#include <Pwm.h>
#include <Sbus.h>
#include <Ubx.h>
#include <Adc.h>
#include <Sd.h>
#include <Telem.h>
#include <Ubx.h>
#include <Vcp.h>
#include <Pwm.h>
#include <Sd.h>

#include <board.h>

#ifdef __cplusplus
extern "C" {
extern "C"
{
#endif

int varmint_main(void);

int varmint_main(void);

#ifdef __cplusplus
}
#endif


/*
*
*/
class Varmint : public rosflight_firmware::Board
{
/**
* \brief
*
*
*/
/**
* \brief
*
*
*/
private:
uint32_t serial_device_;
public:
Varmint() {};

Adis165xx imu0_;
Bmi088 imu1_;
DlhrL20G pitot_;
Dps310 baro_;
Iis2mdc mag_;
Sbus rc_;
Ubx gps_;
Adc adc_;
Telem telem_;
Vcp vcp_;
Pwm pwm_[PWM_CHANNELS];
Sd sd_;

// Required ROSflight Board HAL functions:

// setup

void init_board(void) override;
void board_reset(bool bootloader) override;

// clock
uint32_t clock_millis() override;
uint64_t clock_micros() override;
void clock_delay(uint32_t milliseconds) override;

// serial
void serial_init(uint32_t baud_rate, uint32_t dev) override;
void serial_write(const uint8_t *src, size_t len) override;
uint16_t serial_bytes_available() override;
uint8_t serial_read() override;
void serial_flush() override;

// sensors
void sensors_init() override;
uint16_t num_sensor_errors() override;

uint8_t imu_has_new_data() override;
bool imu_read(float accel[3], float *temperature, float gyro[3], uint64_t *time_us) override;
void imu_not_responding_error() override;

bool mag_present() override;
uint8_t mag_has_new_data() override;
bool mag_read(float mag[3]) override;

bool baro_present() override;
uint8_t baro_has_new_data() override;
bool baro_read(float *pressure, float *temperature) override;

bool diff_pressure_present() override;
uint8_t diff_pressure_has_new_data() override;
bool diff_pressure_read(float *diff_pressure, float *temperature) override;

bool sonar_present() override;
uint8_t sonar_has_new_data() override;
bool sonar_read( float *range) override;

//Battery
uint8_t battery_has_new_data() override;
bool battery_read(float* voltage, float* current) override;
bool battery_present() override;
void battery_voltage_set_multiplier(double multiplier) override;
void battery_current_set_multiplier(double multiplier) override;

// GNSS
bool gnss_present() override;
uint8_t gnss_has_new_data() override;
bool gnss_read( rosflight_firmware::GNSSData *gnss, rosflight_firmware::GNSSFull *gnss_full) override;

// RC
void rc_init(rc_type_t rc_type) override;
uint8_t rc_has_new_data() override;
bool rc_lost() override;
// float rc_read(uint8_t channel) override;
float rc_read(uint8_t chan) override;

// PWM
void pwm_init(uint32_t refresh_rate, uint16_t idle_pwm) override;
void pwm_disable() override;
void pwm_write(uint8_t channel, float value) override;
uint32_t pwm_init_timers(uint32_t servo_pwm_period_us);

// non-volatile memory
void memory_init() override;
bool memory_read(void *dest, size_t len) override;
bool memory_write(const void *src, size_t len) override;

// LEDs
void led0_on() override;
void led0_off() override;
void led0_toggle() override;

void led1_on() override;
void led1_off() override;
void led1_toggle() override;

// Backup Data
void backup_memory_init() override;
bool backup_memory_read(void *dest, size_t len) override;
void backup_memory_write(const void *src, size_t len) override;
void backup_memory_clear(size_t len) override;
uint32_t serial_device_;

public:
Varmint(){};

Adis165xx imu0_;
Bmi088 imu1_;
DlhrL20G pitot_;
Dps310 baro_;
Iis2mdc mag_;
Sbus rc_;
Ubx gps_;
Adc adc_;
Telem telem_;
Vcp vcp_;
Pwm pwm_[PWM_CHANNELS];
Sd sd_;

// Required ROSflight Board HAL functions:

// setup

void init_board(void) override;
void board_reset(bool bootloader) override;

// clock
uint32_t clock_millis() override;
uint64_t clock_micros() override;
void clock_delay(uint32_t milliseconds) override;

// serial
void serial_init(uint32_t baud_rate, uint32_t dev) override;
void serial_write(const uint8_t *src, size_t len) override;
uint16_t serial_bytes_available() override;
uint8_t serial_read() override;
void serial_flush() override;

// sensors
void sensors_init() override;
uint16_t num_sensor_errors() override;

uint8_t imu_has_new_data() override;
bool imu_read(float accel[3], float *temperature, float gyro[3], uint64_t *time_us) override;
void imu_not_responding_error() override;

bool mag_present() override;
uint8_t mag_has_new_data() override;
bool mag_read(float mag[3]) override;

bool baro_present() override;
uint8_t baro_has_new_data() override;
bool baro_read(float *pressure, float *temperature) override;

bool diff_pressure_present() override;
uint8_t diff_pressure_has_new_data() override;
bool diff_pressure_read(float *diff_pressure, float *temperature) override;

bool sonar_present() override;
uint8_t sonar_has_new_data() override;
bool sonar_read(float *range) override;

// Battery
uint8_t battery_has_new_data() override;
bool battery_read(float *voltage, float *current) override;
bool battery_present() override;
void battery_voltage_set_multiplier(double multiplier) override;
void battery_current_set_multiplier(double multiplier) override;

// GNSS
bool gnss_present() override;
uint8_t gnss_has_new_data() override;
bool gnss_read(rosflight_firmware::GNSSData *gnss, rosflight_firmware::GNSSFull *gnss_full) override;

// RC
void rc_init(rc_type_t rc_type) override;
uint8_t rc_has_new_data() override;
bool rc_lost() override;
// float rc_read(uint8_t channel) override;
float rc_read(uint8_t chan) override;

// PWM
void pwm_init(uint32_t refresh_rate, uint16_t idle_pwm) override;
void pwm_disable() override;
void pwm_write(uint8_t channel, float value) override;
uint32_t pwm_init_timers(uint32_t servo_pwm_period_us);

// non-volatile memory
void memory_init() override;
bool memory_read(void *dest, size_t len) override;
bool memory_write(const void *src, size_t len) override;

// LEDs
void led0_on() override;
void led0_off() override;
void led0_toggle() override;

void led1_on() override;
void led1_off() override;
void led1_toggle() override;

// Backup Data
void backup_memory_init() override;
bool backup_memory_read(void *dest, size_t len) override;
void backup_memory_write(const void *src, size_t len) override;
void backup_memory_clear(size_t len) override;
};


#endif /* VARMINT_H_ */
32 changes: 16 additions & 16 deletions boards/varmint/include/board/Adc.h
Original file line number Diff line number Diff line change
Expand Up @@ -38,8 +38,8 @@
#ifndef ADC_H_
#define ADC_H_

#include <Driver.h>
#include <BoardConfig.h>
#include <Driver.h>
#include <Packets.h>

/*
Expand All @@ -48,22 +48,22 @@
class Adc : public Driver
{
public:
uint32_t init
(
uint16_t sample_rate_hz,
ADC_HandleTypeDef *hadc, ADC_TypeDef *adc_instance,
ADC_HandleTypeDef *hadc_internal, ADC_TypeDef *adc_instance_internal
);
bool poll(void){return false;};
bool poll(uint16_t poll_offset);
bool startDma(void) override;
void endDma(void) override;
bool display(void) override;
bool isMy(ADC_HandleTypeDef *hadc) { return hadcExt_==hadc; }
void setScaleFactor(uint16_t n, float scale_factor);
uint32_t init(uint16_t sample_rate_hz,
ADC_HandleTypeDef *hadc,
ADC_TypeDef *adc_instance,
ADC_HandleTypeDef *hadc_internal,
ADC_TypeDef *adc_instance_internal);
bool poll(void) { return false; };
bool poll(uint16_t poll_offset);
bool startDma(void) override;
void endDma(void) override;
bool display(void) override;
bool isMy(ADC_HandleTypeDef *hadc) { return hadcExt_ == hadc; }
void setScaleFactor(uint16_t n, float scale_factor);

private:
ADC_HandleTypeDef *hadcExt_,*hadcInt_; // The shared SPI handle
double scaleFactor_[ADC_CHANNELS_EXT] = {1.1, 2.69, 4.01, 1.68, 10.00, 11.215};
ADC_HandleTypeDef *hadcExt_, *hadcInt_; // The shared SPI handle
double scaleFactor_[ADC_CHANNELS_EXT] = {1.1, 2.69, 4.01, 1.68, 10.00, 11.215};
};

#endif /* ADC_H_ */
67 changes: 32 additions & 35 deletions boards/varmint/include/board/Adis165xx.h
Original file line number Diff line number Diff line change
Expand Up @@ -43,47 +43,44 @@
#include <Packets.h>
#include <Spi.h>


class Adis165xx : public Driver
{
public:
uint32_t init
(
// Driver initializers
uint16_t sample_rate_hz,
GPIO_TypeDef *drdy_port, // Reset GPIO Port
uint16_t drdy_pin, // Reset GPIO Pin
// SPI initializers
SPI_HandleTypeDef *hspi,
GPIO_TypeDef *cs_port, // Chip Select GPIO Port
uint16_t cs_pin, // Chip Select GPIO Pin
// ADIS165xx initializers
GPIO_TypeDef *reset_port, // Reset GPIO Port
uint16_t reset_pin, // Reset GPIO Pin
TIM_HandleTypeDef *htim,
TIM_TypeDef *htim_instance,
uint32_t htim_channel,
uint32_t htim_period_us
);
uint32_t init(
// Driver initializers
uint16_t sample_rate_hz,
GPIO_TypeDef *drdy_port, // Reset GPIO Port
uint16_t drdy_pin, // Reset GPIO Pin
// SPI initializers
SPI_HandleTypeDef *hspi,
GPIO_TypeDef *cs_port, // Chip Select GPIO Port
uint16_t cs_pin, // Chip Select GPIO Pin
// ADIS165xx initializers
GPIO_TypeDef *reset_port, // Reset GPIO Port
uint16_t reset_pin, // Reset GPIO Pin
TIM_HandleTypeDef *htim,
TIM_TypeDef *htim_instance,
uint32_t htim_channel,
uint32_t htim_period_us);

void endDma(void) override;
bool startDma(void) override;
bool display(void) override;
bool isMy(uint16_t exti_pin) { return drdyPin_== exti_pin;}
bool isMy(SPI_HandleTypeDef *hspi) { return hspi==spi_.hspi(); }
SPI_HandleTypeDef *hspi(void) {return spi_.hspi();}
void endDma(void) override;
bool startDma(void) override;
bool display(void) override;
bool isMy(uint16_t exti_pin) { return drdyPin_ == exti_pin; }
bool isMy(SPI_HandleTypeDef *hspi) { return hspi == spi_.hspi(); }
SPI_HandleTypeDef *hspi(void) { return spi_.hspi(); }

private:
// SPI Stuff
Spi spi_;
uint16_t timeoutMs_;
// ADIS165xx Stuff
GPIO_TypeDef* resetPort_;
uint16_t resetPin_;
TIM_HandleTypeDef *htim_;
uint32_t htimChannel_;
void writeRegister(uint8_t address, uint16_t value);
uint16_t readRegister(uint8_t address);
// SPI Stuff
Spi spi_;
uint16_t timeoutMs_;
// ADIS165xx Stuff
GPIO_TypeDef *resetPort_;
uint16_t resetPin_;
TIM_HandleTypeDef *htim_;
uint32_t htimChannel_;
void writeRegister(uint8_t address, uint16_t value);
uint16_t readRegister(uint8_t address);
};

#endif /* ADIS165XX_H_ */
Loading

0 comments on commit d0035c6

Please sign in to comment.