PER Firmware
Loading...
Searching...
No Matches
main.c File Reference

"Torque Vector" node source code More...

#include "main.h"
#include <stdint.h>
#include "can_library/generated/TORQUE_VECTOR.h"
#include "common/freertos/freertos.h"
#include "common/heartbeat/heartbeat.h"
#include "common/phal/can.h"
#include "common/phal/gpio.h"
#include "common/phal/rcc.h"
#include "common/phal/usart.h"
#include "common/ublox/nav_pvt.h"
#include "common/ublox/nav_relposned.h"
#include "common/utils/countof.h"
#include "common/watchdog/watchdog.h"
#include "control_loop.h"
#include "sensors.h"
#include "telemetry.h"

Functions

void HardFault_Handler (void)
 
 DEFINE_CAN_TASKS ()
 
 DEFINE_TASK (control_loop, CONTROL_LOOP_PERIOD_MS, osPriorityNormal, STACK_4096)
 
 DEFINE_TASK (gps_periodic, GPS_THREAD_PERIOD_MS, osPriorityLow, STACK_1024)
 
 DEFINE_TASK (report_telemetry_100hz, TELEMETRY_100HZ_PERIOD_MS, osPriorityLow, STACK_512)
 
 DEFINE_TASK (report_telemetry_1hz, TELEMETRY_1HZ_PERIOD_MS, osPriorityLow, STACK_512)
 
 DEFINE_WATCHDOG_TASK ()
 
 DEFINE_HEARTBEAT_TASK (nullptr)
 
int main (void)
 

Variables

GPIOInitConfig_t gpio_config []
 
ClockRateConfig_t clock_config
 
uint32_t APB1ClockRateHz
 
uint32_t APB2ClockRateHz
 
uint32_t AHBClockRateHz
 
uint32_t PLLClockRateHz
 
dma_init_t rover_tx_dma_config = USART3_TXDMA_CONT_CONFIG(NULL, 2)
 
dma_init_t rover_rx_dma_config = USART3_RXDMA_CONT_CONFIG(NULL, 1)
 
usart_init_t usart3
 

Detailed Description

"Torque Vector" node source code

Author
Irving Wang (irvin.nosp@m.gw@p.nosp@m.urdue.nosp@m..edu)

Variable Documentation

◆ clock_config

ClockRateConfig_t clock_config
Initial value:
= {
.clock_source = CLOCK_SOURCE_HSE,
.use_pll = false,
.system_clock_target_hz = TargetCoreClockrateHz,
.ahb_clock_target_hz = (TargetCoreClockrateHz / 1),
.apb1_clock_target_hz = (TargetCoreClockrateHz / (1)),
.apb2_clock_target_hz = (TargetCoreClockrateHz / (1)),
}

◆ gpio_config

GPIOInitConfig_t gpio_config[]
Initial value:
= {
GPIO_INIT_OUTPUT(HEARTBEAT_LED_PORT, HEARTBEAT_LED_PIN, GPIO_OUTPUT_LOW_SPEED),
GPIO_INIT_OUTPUT(ERROR_LED_PORT, ERROR_LED_PIN, GPIO_OUTPUT_LOW_SPEED),
GPIO_INIT_OUTPUT(CONNECTION_LED_PORT, CONNECTION_LED_PIN, GPIO_OUTPUT_LOW_SPEED),
GPIO_INIT_FDCAN2TX_PB13,
GPIO_INIT_FDCAN2RX_PB12,
GPIO_INIT_USART3RX_PB11,
GPIO_INIT_USART3TX_PB10,
GPIO_INIT_OUTPUT(ROVER_RESET_PORT, ROVER_RESET_PIN, GPIO_OUTPUT_LOW_SPEED),
GPIO_INIT_USART1TX_PA9,
GPIO_INIT_USART1RX_PA10,
GPIO_INIT_OUTPUT(BASE_RESET_PORT, BASE_RESET_PIN, GPIO_OUTPUT_LOW_SPEED),
}
#define GPIO_INIT_OUTPUT(gpio_bank, pin_num, ospeed_sel)
Create GPIO Init struct to intilize a GPIO pin for output.
Definition gpio.h:131

◆ usart3

usart_init_t usart3
Initial value:
= {
.baud_rate = GPS_BAUD_RATE,
.word_length = WORD_8,
.stop_bits = SB_ONE,
.parity = PT_NONE,
.hw_flow_ctl = HW_DISABLE,
.ovsample = OV_16,
.obsample = OB_DISABLE,
.periph = USART3,
.wake_addr = false,
.usart_active_num = USART3_ACTIVE_IDX,
.tx_dma_cfg = &rover_tx_dma_config,
.rx_dma_cfg = &rover_rx_dma_config,
}
@ WORD_8
8-Bit word length
Definition usart.h:65
@ HW_DISABLE
Hardware flow control disable.
Definition usart.h:77
@ OB_DISABLE
Disable one bit sampling.
Definition usart.h:89
@ PT_NONE
Disable Parity bits.
Definition usart.h:61
@ SB_ONE
One Stop bit.
Definition usart.h:70
@ OV_16
Oversample by 16.
Definition usart.h:84