Paparazzi UAS  v5.14.0_stable-0-g3f680d1
Paparazzi is a free software Unmanned Aircraft System.
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Modules Pages
vms_ecu_demo.c File Reference

Viking Motorsports Engine Control Unit demo module see https://wiki.paparazziuav.org/wiki/VMS_ECU for more details. More...

#include "modules/fsae_electric/vms_ecu_demo.h"
#include "pprzlink/messages.h"
#include "subsystems/datalink/downlink.h"
#include "mcu_periph/gpio.h"
#include "ch.h"
#include "hal.h"
#include "generated/airframe.h"
#include <BOARD_CONFIG>
+ Include dependency graph for vms_ecu_demo.c:

Go to the source code of this file.

Data Structures

struct  can_instance
 

Macros

#define ADC_BIT_RES   12
 
#define ADC_VREF   3300.0
 
#define ADC_VREF_MULT   ADC_VREF/(1<<ADC_BIT_RES)
 
#define ADC_VGAIN   1.5
 
#define DAC_BUFFER_SIZE   1
 

Functions

static THD_WORKING_AREA (can_rx1_wa, 256)
 
static THD_WORKING_AREA (can_rx2_wa, 256)
 
static THD_FUNCTION (can_rx, p)
 
static THD_WORKING_AREA (can_tx_wa, 256)
 
static THD_FUNCTION (can_tx, p)
 
void vms_ecu_demo_init (void)
 
void vms_ecu_demo_periodic (void)
 
void vms_ecu_demo_downlink (void)
 
void vms_ecu_demo_UpdateDac1 (uint16_t val)
 Reset sweep number. More...
 
void vms_ecu_demo_UpdateDac2 (uint16_t val)
 

Variables

float ain_1
 
float ain_2
 
float ain_3
 
float ain_4
 
struct adc_buf adc_buf_1
 
struct adc_buf adc_buf_2
 
struct adc_buf adc_buf_3
 
struct adc_buf adc_buf_4
 
uint16_t dac_1
 
uint16_t dac_2
 
static const DACConfig dac1cfg1
 
static const DACConfig dac1cfg2
 
dacsample_t dac_ref1
 
dacsample_t dac_ref2
 
bool ams_status
 
bool pwr_ready
 
bool pwr_stdby
 
bool rtds
 
uint8_t stg_in
 
uint8_t stb_in
 
static const struct can_instance can1 = {&CAND1, 11}
 
static const struct can_instance can2 = {&CAND2, 12}
 
static const CANConfig cancfg_lb
 
static const CANConfig cancfg
 

Detailed Description

Viking Motorsports Engine Control Unit demo module see https://wiki.paparazziuav.org/wiki/VMS_ECU for more details.

Definition in file vms_ecu_demo.c.


Data Structure Documentation

struct can_instance

Definition at line 110 of file vms_ecu_demo.c.

Data Fields
CANDriver * canp
uint32_t led

Macro Definition Documentation

#define ADC_BIT_RES   12

Definition at line 47 of file vms_ecu_demo.c.

#define ADC_VGAIN   1.5

Definition at line 57 of file vms_ecu_demo.c.

Referenced by vms_ecu_demo_periodic().

#define ADC_VREF   3300.0

Definition at line 51 of file vms_ecu_demo.c.

#define ADC_VREF_MULT   ADC_VREF/(1<<ADC_BIT_RES)

Definition at line 54 of file vms_ecu_demo.c.

Referenced by vms_ecu_demo_periodic().

#define DAC_BUFFER_SIZE   1

Definition at line 59 of file vms_ecu_demo.c.

Function Documentation

static THD_FUNCTION ( can_rx  ,
p   
)
static

Definition at line 144 of file vms_ecu_demo.c.

References can_instance::canp, GPIOD, can_instance::led, and p.

static THD_FUNCTION ( can_tx  ,
p   
)
static

Definition at line 170 of file vms_ecu_demo.c.

References p.

static THD_WORKING_AREA ( can_rx1_wa  ,
256   
)
static
static THD_WORKING_AREA ( can_rx2_wa  ,
256   
)
static
static THD_WORKING_AREA ( can_tx_wa  ,
256   
)
static
void vms_ecu_demo_downlink ( void  )

Definition at line 315 of file vms_ecu_demo.c.

References ain_1, ain_2, ain_3, ain_4, DefaultChannel, DefaultDevice, stb_in, and stg_in.

void vms_ecu_demo_init ( void  )
void vms_ecu_demo_periodic ( void  )
void vms_ecu_demo_UpdateDac1 ( uint16_t  val)

Reset sweep number.

Definition at line 326 of file vms_ecu_demo.c.

References dac_1, dac_ref1, and val.

void vms_ecu_demo_UpdateDac2 ( uint16_t  val)

Definition at line 332 of file vms_ecu_demo.c.

References dac_2, dac_ref2, and val.

Variable Documentation

struct adc_buf adc_buf_1

Definition at line 66 of file vms_ecu_demo.c.

Referenced by vms_ecu_demo_init(), and vms_ecu_demo_periodic().

struct adc_buf adc_buf_2

Definition at line 67 of file vms_ecu_demo.c.

Referenced by vms_ecu_demo_init(), and vms_ecu_demo_periodic().

struct adc_buf adc_buf_3

Definition at line 68 of file vms_ecu_demo.c.

Referenced by vms_ecu_demo_init(), and vms_ecu_demo_periodic().

struct adc_buf adc_buf_4

Definition at line 69 of file vms_ecu_demo.c.

Referenced by vms_ecu_demo_init(), and vms_ecu_demo_periodic().

float ain_1

Definition at line 61 of file vms_ecu_demo.c.

Referenced by vms_ecu_demo_downlink(), vms_ecu_demo_init(), and vms_ecu_demo_periodic().

float ain_2

Definition at line 62 of file vms_ecu_demo.c.

Referenced by vms_ecu_demo_downlink(), vms_ecu_demo_init(), and vms_ecu_demo_periodic().

float ain_3

Definition at line 63 of file vms_ecu_demo.c.

Referenced by vms_ecu_demo_downlink(), vms_ecu_demo_init(), and vms_ecu_demo_periodic().

float ain_4

Definition at line 64 of file vms_ecu_demo.c.

Referenced by vms_ecu_demo_downlink(), vms_ecu_demo_init(), and vms_ecu_demo_periodic().

bool ams_status

Definition at line 97 of file vms_ecu_demo.c.

Referenced by vms_ecu_demo_init(), and vms_ecu_demo_periodic().

const struct can_instance can1 = {&CAND1, 11}
static

Definition at line 115 of file vms_ecu_demo.c.

const struct can_instance can2 = {&CAND2, 12}
static

Definition at line 116 of file vms_ecu_demo.c.

Referenced by int32_quat_of_axis_angle().

const CANConfig cancfg
static
Initial value:
= {
CAN_MCR_ABOM | CAN_MCR_AWUM | CAN_MCR_TXFP,
CAN_BTR_SJW(0) | CAN_BTR_TS2(1) |
CAN_BTR_TS1(8) | CAN_BTR_BRP(6)
}

Definition at line 133 of file vms_ecu_demo.c.

Referenced by vms_ecu_demo_init().

const CANConfig cancfg_lb
static
Initial value:
= {
CAN_MCR_ABOM | CAN_MCR_AWUM | CAN_MCR_TXFP,
CAN_BTR_LBKM | CAN_BTR_SJW(0) | CAN_BTR_TS2(1) |
CAN_BTR_TS1(8) | CAN_BTR_BRP(6)
}

Definition at line 124 of file vms_ecu_demo.c.

const DACConfig dac1cfg1
static
Initial value:
= {
.init = 2047U,
.datamode = DAC_DHRM_12BIT_RIGHT
}

Definition at line 79 of file vms_ecu_demo.c.

Referenced by vms_ecu_demo_init().

const DACConfig dac1cfg2
static
Initial value:
= {
.init = 0U,
.datamode = DAC_DHRM_12BIT_RIGHT
}

Definition at line 84 of file vms_ecu_demo.c.

Referenced by vms_ecu_demo_init().

uint16_t dac_1

Definition at line 76 of file vms_ecu_demo.c.

Referenced by vms_ecu_demo_init(), and vms_ecu_demo_UpdateDac1().

uint16_t dac_2

Definition at line 77 of file vms_ecu_demo.c.

Referenced by vms_ecu_demo_init(), and vms_ecu_demo_UpdateDac2().

dacsample_t dac_ref1

Definition at line 90 of file vms_ecu_demo.c.

Referenced by vms_ecu_demo_init(), and vms_ecu_demo_UpdateDac1().

dacsample_t dac_ref2

Definition at line 91 of file vms_ecu_demo.c.

Referenced by vms_ecu_demo_init(), and vms_ecu_demo_UpdateDac2().

bool pwr_ready

Definition at line 98 of file vms_ecu_demo.c.

Referenced by vms_ecu_demo_init(), and vms_ecu_demo_periodic().

bool pwr_stdby

Definition at line 99 of file vms_ecu_demo.c.

Referenced by vms_ecu_demo_init(), and vms_ecu_demo_periodic().

bool rtds

Definition at line 100 of file vms_ecu_demo.c.

Referenced by vms_ecu_demo_init(), and vms_ecu_demo_periodic().

uint8_t stb_in

Definition at line 103 of file vms_ecu_demo.c.

Referenced by vms_ecu_demo_downlink(), vms_ecu_demo_init(), and vms_ecu_demo_periodic().

uint8_t stg_in

Definition at line 102 of file vms_ecu_demo.c.

Referenced by vms_ecu_demo_downlink(), vms_ecu_demo_init(), and vms_ecu_demo_periodic().