Skip to content

Commit

Permalink
Merge branch 'master' into clang-format
Browse files Browse the repository at this point in the history
  • Loading branch information
NathanielDelgado committed Sep 30, 2023
2 parents 8b07850 + a0d1c0c commit 42d6b21
Show file tree
Hide file tree
Showing 122 changed files with 5,889 additions and 2,439 deletions.
30 changes: 30 additions & 0 deletions .github/ISSUE_TEMPLATE/bug_report.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
---
name: Bug report
about: Report a bug in the Controls System
title: ''
labels: bug
assignees: ''

---

**Describe the bug**
A clear and concise description of what the bug is.

**To Reproduce**
Steps to reproduce the behavior:
1. Which feature is being tested?
2. Which requirements are being tested?
3. Which test is used?
4. What is the hardware configuration?
5. What combination of inputs cause the error?
6. What does the error look like?
7. Does this issue already exist?

**Expected behavior**
A clear and concise description of what you expected to happen.

**Screenshots**
If applicable, add screenshots to help explain your problem.

**Additional context**
Add any other context about the problem here.
20 changes: 20 additions & 0 deletions .github/ISSUE_TEMPLATE/feature_request.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
---
name: Feature request
about: Suggest a new feature for Controls
title: ''
labels: enhancement
assignees: ''

---

**Describe the problem this feature will solve**
A clear and concise description of what the problem is. Please make sure the issue for this feature does not already exist.

**Describe the proposed solution**
A clear and concise description of what you want to happen.

**Describe possible alternatives**
A clear and concise description of any alternative solutions or features you've considered.

**Additional context**
Add any other context or screenshots about the feature request here.
64 changes: 64 additions & 0 deletions .readthedocs.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
# Read the Docs configuration file for Sphinx projects

# See https://docs.readthedocs.io/en/stable/config-file/v2.html for details


# Required

version: 2


# Set the OS, Python version and other tools you might need

build:

os: ubuntu-22.04

apt_packages:
- doxygen

tools:

python: "3.11"

jobs:
post_install:
- make docs



# Build documentation in the "docs/" directory with Sphinx

sphinx:

configuration: Docs/source/conf.py

# You can configure Sphinx to use a different builder, for instance use the dirhtml builder for simpler URLs

# builder: "dirhtml"

# Fail on all warnings to avoid broken references

# fail_on_warning: true


# Optionally build your docs in additional formats such as PDF and ePub

# formats:

# - pdf

# - epub


# Optional but recommended, declare the Python requirements required

# to build your documentation

# See https://docs.readthedocs.io/en/stable/guides/reproducible-builds.html

python:

install:

- requirements: Docs/source/requirements.txt
14 changes: 11 additions & 3 deletions Apps/Inc/CAN_Queue.h
Original file line number Diff line number Diff line change
@@ -1,6 +1,11 @@
/* Copyright (c) 2021 UT Longhorn Racing Solar */
/** CAN_Queue.c
* Queue that holds all CAN messages that Task_CANBusConsumer needs to send.
/**
* @copyright Copyright (c) 2018-2023 UT Longhorn Racing Solar
* @file CAN_Queue.h
* @brief Queue that holds all CAN messages that Task_CANBusConsumer needs to send.
*
* @defgroup CAN_Queue
* @addtogroup CAN_Queue
* @{
*/

#ifndef CAN_QUEUE_H
Expand All @@ -15,3 +20,6 @@ ErrorStatus CAN_Queue_Post(CANDATA_t message);
ErrorStatus CAN_Queue_Pend(CANDATA_t *message);

#endif


/* @} */
15 changes: 14 additions & 1 deletion Apps/Inc/FaultState.h
Original file line number Diff line number Diff line change
@@ -1,6 +1,19 @@
/**
* @copyright Copyright (c) 2018-2023 UT Longhorn Racing Solar
* @file FaultState.h
* @brief
*
* @defgroup FaultState
* @addtogroup FaultState
* @{
*/
#ifndef __FAULT_STATE_H
#define __FAULT_STATE_H


void EnterFaultState(void);

#endif
#endif


/* @} */
12 changes: 11 additions & 1 deletion Apps/Inc/MedianFilter.h
Original file line number Diff line number Diff line change
@@ -1,4 +1,13 @@
// Copyright (c) 2022 Longhorn Racing Solar
/**
* @copyright Copyright (c) 2018-2023 UT Longhorn Racing Solar
* @file MedianFilter.h
* @brief
*
* @defgroup MedianFilter
* @addtogroup MedianFilter
* @{
*/

/*
* This file implements a median filter.
*
Expand Down Expand Up @@ -209,3 +218,4 @@ GETSINGLE (MF_TYPE_NAME *filter, uint32_t channel) {
#undef PUT
#undef GETSINGLE

/* @} */
15 changes: 13 additions & 2 deletions Apps/Inc/ReadCarCAN.h
Original file line number Diff line number Diff line change
@@ -1,4 +1,12 @@
/* Copyright (c) 2020 UT Longhorn Racing Solar */
/**
* @copyright Copyright (c) 2018-2023 UT Longhorn Racing Solar
* @file ReadCarCAN.h
* @brief
*
* @defgroup ReadCarCAN
* @addtogroup ReadCarCAN
* @{
*/

#ifndef __READ_CAR_CAN_H
#define __READ_CAR_CAN_H
Expand All @@ -17,4 +25,7 @@
*/
bool ChargeEnable_Get();

#endif
#endif


/* @} */
93 changes: 52 additions & 41 deletions Apps/Inc/ReadTritium.h
Original file line number Diff line number Diff line change
@@ -1,41 +1,52 @@
/* Copyright (c) 2021 UT Longhorn Racing Solar */

#ifndef __READ_TRITIUM_H
#define __READ_TRITIUM_H

#include "os.h"
#include "common.h"
#include "Tasks.h"

#define CAR_STOPPED 0

/**
* Motor Error States
* Read messages from motor in ReadTritium and trigger appropriate error messages as needed based on bits
*
*/
typedef enum{
T_HARDWARE_OVER_CURRENT_ERR = (1<<0),
T_SOFTWARE_OVER_CURRENT_ERR = (1<<1),
T_DC_BUS_OVERVOLT_ERR = (1<<2),
T_HALL_SENSOR_ERR = (1<<3),
T_WATCHDOG_LAST_RESET_ERR = (1<<4),
T_CONFIG_READ_ERR = (1<<5),
T_UNDER_VOLTAGE_LOCKOUT_ERR = (1<<6),
T_DESAT_FAULT_ERR = (1<<7),
T_MOTOR_OVER_SPEED_ERR = (1<<8),
T_INIT_FAIL = (1<<9), //motor controller fails to restart or initialize
T_NONE = 0x00,
} tritium_error_code_t;
#define NUM_TRITIUM_ERRORS 9 //9 errors, and 1 entry for no error

/**
* @brief Returns the current error status of the tritium controller
*/
tritium_error_code_t MotorController_getTritiumError(void);

float Motor_RPM_Get();
float Motor_Velocity_Get();
void MotorController_Restart();

#endif
/**
* @copyright Copyright (c) 2018-2023 UT Longhorn Racing Solar
* @file ReadTritium.h
* @brief
*
* @defgroup ReadTritium
* @addtogroup ReadTritium
* @{
*/

#ifndef __READ_TRITIUM_H
#define __READ_TRITIUM_H

#include "os.h"
#include "common.h"
#include "Tasks.h"

#define CAR_STOPPED 0

/**
* Motor Error States
* Read messages from motor in ReadTritium and trigger appropriate error messages as needed based on bits
*
*/
typedef enum{
T_HARDWARE_OVER_CURRENT_ERR = (1<<0),
T_SOFTWARE_OVER_CURRENT_ERR = (1<<1),
T_DC_BUS_OVERVOLT_ERR = (1<<2),
T_HALL_SENSOR_ERR = (1<<3),
T_WATCHDOG_LAST_RESET_ERR = (1<<4),
T_CONFIG_READ_ERR = (1<<5),
T_UNDER_VOLTAGE_LOCKOUT_ERR = (1<<6),
T_DESAT_FAULT_ERR = (1<<7),
T_MOTOR_OVER_SPEED_ERR = (1<<8),
T_INIT_FAIL = (1<<9), //motor controller fails to restart or initialize
T_NONE = 0x00,
} tritium_error_code_t;
#define NUM_TRITIUM_ERRORS 9 //9 errors, and 1 entry for no error

/**
* @brief Returns the current error status of the tritium controller
*/
tritium_error_code_t MotorController_getTritiumError(void);

float Motor_RPM_Get();
float Motor_Velocity_Get();
void MotorController_Restart();

#endif


/* @} */
74 changes: 53 additions & 21 deletions Apps/Inc/SendTritium.h
Original file line number Diff line number Diff line change
@@ -1,15 +1,32 @@
/**
* @copyright Copyright (c) 2018-2023 UT Longhorn Racing Solar
* @file SendTritium.h
* @brief
*
* @defgroup SendTritium
* @addtogroup SendTritium
* @{
*/
#ifndef __SENDTRITIUM_H
#define __SENDTRITIUM_H

#define MOTOR_MSG_PERIOD 500
#define FSM_PERIOD 250
#include "common.h"

// #define SENDTRITIUM_PRINT_MES

#define MOTOR_MSG_PERIOD 100
#define FSM_PERIOD 100
#define DEBOUNCE_PERIOD 2 // in units of FSM_PERIOD
#define MOTOR_MSG_COUNTER_THRESHOLD (MOTOR_MSG_PERIOD)/(FSM_PERIOD)

typedef enum{
FORWARD_GEAR,
NEUTRAL_GEAR,
REVERSE_GEAR
#define FOREACH_Gear(GEAR) \
GEAR(FORWARD_GEAR) \
GEAR(NEUTRAL_GEAR) \
GEAR(REVERSE_GEAR) \

typedef enum GEAR_ENUM {
FOREACH_Gear(GENERATE_ENUM)
NUM_GEARS,
} Gear_t;

// State Names
Expand All @@ -32,22 +49,37 @@ typedef struct TritiumState{
void (*stateDecider)(void);
} TritiumState_t;

#define __TEST_SENDTRITIUM
#ifdef __TEST_SENDTRITIUM
// Inputs
extern bool cruiseEnable;
extern bool cruiseSet;
extern bool onePedalEnable;
extern bool regenEnable;
// Getter functions for local variables in SendTritium.c
EXPOSE_GETTER(bool, cruiseEnable)
EXPOSE_GETTER(bool, cruiseSet)
EXPOSE_GETTER(bool, onePedalEnable)
EXPOSE_GETTER(bool, regenEnable)
EXPOSE_GETTER(uint8_t, brakePedalPercent)
EXPOSE_GETTER(uint8_t, accelPedalPercent)
EXPOSE_GETTER(Gear_t, gear)
EXPOSE_GETTER(TritiumState_t, state)
EXPOSE_GETTER(float, velocityObserved)
EXPOSE_GETTER(float, cruiseVelSetpoint)
EXPOSE_GETTER(float, currentSetpoint)
EXPOSE_GETTER(float, velocitySetpoint)

extern uint8_t brakePedalPercent;
extern uint8_t accelPedalPercent;

extern Gear_t gear;

extern TritiumState_t state;
extern float velocityObserved;
extern float cruiseVelSetpoint;
// Setter functions for local variables in SendTritium.c
#ifdef SENDTRITIUM_EXPOSE_VARS
EXPOSE_SETTER(bool, cruiseEnable)
EXPOSE_SETTER(bool, cruiseSet)
EXPOSE_SETTER(bool, onePedalEnable)
EXPOSE_SETTER(bool, regenEnable)
EXPOSE_SETTER(uint8_t, brakePedalPercent)
EXPOSE_SETTER(uint8_t, accelPedalPercent)
EXPOSE_SETTER(Gear_t, gear)
EXPOSE_SETTER(TritiumState_t, state)
EXPOSE_SETTER(float, velocityObserved)
EXPOSE_SETTER(float, cruiseVelSetpoint)
EXPOSE_SETTER(float, currentSetpoint)
EXPOSE_SETTER(float, velocitySetpoint)
#endif

#endif


/* @} */
Loading

0 comments on commit 42d6b21

Please sign in to comment.