Skip to content

Commit

Permalink
Added Varmint board implementation files
Browse files Browse the repository at this point in the history
  • Loading branch information
bsutherland333 committed Nov 28, 2023
1 parent fdd8e5c commit 7ef6ae4
Show file tree
Hide file tree
Showing 202 changed files with 274,927 additions and 0 deletions.
198 changes: 198 additions & 0 deletions boards/varmint/STM32H753VIHX_FLASH.ld
Original file line number Diff line number Diff line change
@@ -0,0 +1,198 @@
/*
******************************************************************************
**
** File : LinkerScript.ld
**
** Author : STM32CubeIDE
**
** Abstract : Linker script for STM32H7 series
** 2048Kbytes FLASH and 1056Kbytes RAM
**
** Set heap size, stack size and stack location according
** to application requirements.
**
** Set memory bank area and size if external memory is used.
**
** Target : STMicroelectronics STM32
**
** Distribution: The file is distributed as is, without any warranty
** of any kind.
**
*****************************************************************************
** @attention
**
** Copyright (c) 2023 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.
**
****************************************************************************
*/

/* Entry Point */
ENTRY(Reset_Handler)

/* Highest address of the user mode stack */
_estack = ORIGIN(RAM_D1) + LENGTH(RAM_D1); /* end of RAM */
/* Generate a link error if heap and stack don't fit into RAM */
_Min_Heap_Size = 0x2000; /* required amount of heap */
_Min_Stack_Size = 0x2000; /* required amount of stack */

/* Specify the memory areas */
MEMORY
{
FLASH (rx) : ORIGIN = 0x08000000, LENGTH = 1024K /* Program Flash */
FLASH2 (rw) : ORIGIN = 0x08100000, LENGTH = 1024K /* Parameter Flash */
DTCMRAM (xrw) : ORIGIN = 0x20000000, LENGTH = 128K
RAM_D1 (xrw) : ORIGIN = 0x24000000, LENGTH = 512K /* Domain 1 AXI SRAM */
SRAM1 (xrw) : ORIGIN = 0x30000000, LENGTH = 128K /* Domain 2 SRAM1 - Not used */
SRAM2 (xrw) : ORIGIN = 0x30020000, LENGTH = 128K /* Domain 2 SRAM2 - Not used */
SRAM3 (rw) : ORIGIN = 0x30040000, LENGTH = 32K /* Domain 2 SRAM3 - Use for "my_dma_buffers" */
SRAM4 (rw) : ORIGIN = 0x38000000, LENGTH = 64K /* Domain 3 SRAM4 - Use for "my_bdma_buffers" */
ITCMRAM (xrw) : ORIGIN = 0x00000000, LENGTH = 64K /* Allocated for "my_buffers" */
}

/* Define output sections */
SECTIONS
{
/* The startup code goes first into FLASH */
.isr_vector :
{
. = ALIGN(4);
KEEP(*(.isr_vector)) /* Startup code */
. = ALIGN(4);
} >FLASH

/* The program code and other data goes into FLASH */
.text :
{
. = ALIGN(4);
*(.text) /* .text sections (code) */
*(.text*) /* .text* sections (code) */
*(.glue_7) /* glue arm to thumb code */
*(.glue_7t) /* glue thumb to arm code */
*(.eh_frame)

KEEP (*(.init))
KEEP (*(.fini))

. = ALIGN(4);
_etext = .; /* define a global symbols at end of code */
} >FLASH

/* Constant data goes into FLASH */
.rodata :
{
. = ALIGN(4);
*(.rodata) /* .rodata sections (constants, strings, etc.) */
*(.rodata*) /* .rodata* sections (constants, strings, etc.) */
. = ALIGN(4);
} >FLASH

.ARM.extab : { *(.ARM.extab* .gnu.linkonce.armextab.*) } >FLASH
.ARM : {
__exidx_start = .;
*(.ARM.exidx*)
__exidx_end = .;
} >FLASH

.preinit_array :
{
PROVIDE_HIDDEN (__preinit_array_start = .);
KEEP (*(.preinit_array*))
PROVIDE_HIDDEN (__preinit_array_end = .);
} >FLASH

.init_array :
{
PROVIDE_HIDDEN (__init_array_start = .);
KEEP (*(SORT(.init_array.*)))
KEEP (*(.init_array*))
PROVIDE_HIDDEN (__init_array_end = .);
} >FLASH

.fini_array :
{
PROVIDE_HIDDEN (__fini_array_start = .);
KEEP (*(SORT(.fini_array.*)))
KEEP (*(.fini_array*))
PROVIDE_HIDDEN (__fini_array_end = .);
} >FLASH

/* used by the startup to initialize data */
_sidata = LOADADDR(.data);

/* Initialized data sections goes into RAM, load LMA copy after code */
.data :
{
. = ALIGN(4);
_sdata = .; /* create a global symbol at data start */
*(.data) /* .data sections */
*(.data*) /* .data* sections */
*(.RamFunc) /* .RamFunc sections */
*(.RamFunc*) /* .RamFunc* sections */

. = ALIGN(4);
_edata = .; /* define a global symbol at data end */
} >RAM_D1 AT> FLASH

/* Uninitialized data section */
. = ALIGN(4);
.bss :
{
/* This is used by the startup in order to initialize the .bss section */
_sbss = .; /* define a global symbol at bss start */
__bss_start__ = _sbss;
*(.bss)
*(.bss*)
*(COMMON)

. = ALIGN(4);
_ebss = .; /* define a global symbol at bss end */
__bss_end__ = _ebss;
} >RAM_D1

/* User_heap_stack section, used to check that there is enough RAM left */
._user_heap_stack :
{
. = ALIGN(8);
PROVIDE ( end = . );
PROVIDE ( _end = . );
. = . + _Min_Heap_Size;
. = . + _Min_Stack_Size;
. = ALIGN(8);
} >RAM_D1

/* Remove information from the standard libraries */
/DISCARD/ :
{
libc.a ( * )
libm.a ( * )
libgcc.a ( * )
}

my_dma_buffers :
{
. = ALIGN(32);

} >SRAM3

my_bdma_buffers :
{
. = ALIGN(32);

} >SRAM4

my_buffers :
{
. = ALIGN(32);

} >DTCMRAM


.ARM.attributes 0 : { *(.ARM.attributes) }
}


187 changes: 187 additions & 0 deletions boards/varmint/include/Varmint.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,187 @@
/**
******************************************************************************
* File : varmint.h
* Date : Sep 27, 2023
******************************************************************************
*
* Copyright (c) 2023, AeroVironment, Inc.
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
*
* 1.Redistributions of source code must retain the above copyright notice, this
* list of conditions and the following disclaimer.
*
* 2.Redistributions in binary form must reproduce the above copyright notice,
* this list of conditions and the following disclaimer in the documentation
* and/or other materials provided with the distribution.
*
* 3.Neither the name of the copyright holder nor the names of its
* contributors may be used to endorse or promote products derived from
* this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
* CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
******************************************************************************
**/

#ifndef VARMINT_H_
#define VARMINT_H_

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

#include <board.h>

#ifdef __cplusplus
extern "C" {
#endif

int varmint_main(void);


#ifdef __cplusplus
}
#endif


/*
*
*/
class Varmint : public rosflight_firmware::Board
{
/**
* \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;

};


#endif /* VARMINT_H_ */
Loading

0 comments on commit 7ef6ae4

Please sign in to comment.