V1.8
This commit is contained in:
@ -17,6 +17,8 @@
|
||||
/* The PWM period (1/FPWM) is defined by the following parameters:
|
||||
ARR value, the Prescaler value, and the internal clock itself which drives the timer module FCLK.
|
||||
F_PWM = (F_CLK)/((ARR + 1) * (PSC + 1))
|
||||
(ARR + 1) * (PSC + 1) = (F_CLK)/(F_PWM)
|
||||
(PSC + 1) = (F_CLK)/(F_PWM * (ARR + 1))
|
||||
|
||||
F_CLK = 16 MHz
|
||||
|
||||
|
||||
@ -16,9 +16,6 @@
|
||||
#include "state_machine.h"
|
||||
#include <stdint.h>
|
||||
|
||||
#define CAN_ID_IN 0x501
|
||||
#define CAN_ID_OUT 0x502
|
||||
#define CAN_STATUS_FREQ 1000
|
||||
void can_init(CAN_HandleTypeDef* hcan);
|
||||
|
||||
void can_handle_send_status();
|
||||
|
||||
@ -11,22 +11,11 @@
|
||||
#include <stdint.h>
|
||||
#include <stdbool.h>
|
||||
#include "ADBMS_LL_Driver.h"
|
||||
#include "AMS_HighLevel.h"
|
||||
#include "errors.h"
|
||||
#include "PWM_control.h"
|
||||
#include "TMP1075.h"
|
||||
|
||||
// Time to wait after reaching 95% of battery voltage before exiting precharge
|
||||
// Set this to 1000 in scruti to demonstrate the voltage on the multimeter
|
||||
#define PRECHARGE_DURATION 5000 // ms
|
||||
// Time to wait for discharge
|
||||
#define DISCHARGE_DURATION 5000 // ms
|
||||
// Time to wait for charger voltage before going to TS_ERROR
|
||||
#define MAX_CHARGING_CHECK_DURATION 2000 // ms
|
||||
// Time to wait between closing relays
|
||||
#define RELAY_CLOSE_WAIT 10 // ms
|
||||
// Max time to wait for CAN messages. If we reach it then we emergency shutdown.
|
||||
#define CAN_TIMEOUT 100000
|
||||
#include <AMS_HighLevel.h>
|
||||
#include <errors.h>
|
||||
#include <PWM_control.h>
|
||||
#include <status_LED.h>
|
||||
#include <TMP1075.h>
|
||||
|
||||
typedef enum { // states -> 3 bit. valid transitions: (all could transition to error)
|
||||
STATE_INACTIVE, // INACTIVE -> PRECHARGE, CHARGING, ERROR
|
||||
|
||||
33
Core/Inc/status_LED.h
Normal file
33
Core/Inc/status_LED.h
Normal file
@ -0,0 +1,33 @@
|
||||
/*
|
||||
* status_LED.h
|
||||
*
|
||||
* Created on: 07.07.2024
|
||||
* Author: Hamza
|
||||
*/
|
||||
|
||||
#ifndef INC_STATUS_LED_H
|
||||
#define INC_STATUS_LED_H
|
||||
|
||||
#include "stm32f3xx_hal.h"
|
||||
#include <main.h>
|
||||
#include <stdint.h>
|
||||
|
||||
typedef enum {
|
||||
OFF,
|
||||
RED,
|
||||
GREEN,
|
||||
BLUE,
|
||||
YELLOW,
|
||||
PINK,
|
||||
CYAN,
|
||||
WHITE
|
||||
} color;
|
||||
|
||||
void status_led_init(TIM_HandleTypeDef* r, TIM_HandleTypeDef* g, TIM_HandleTypeDef* b);
|
||||
void status_led_update();
|
||||
|
||||
void status_led_blink_sequence(uint8_t blinks, color color);
|
||||
void status_led_set_color(color color);
|
||||
void status_led_set(uint8_t r, uint8_t g, uint8_t b);
|
||||
|
||||
#endif /* "INC_STATUS_LED_H" */
|
||||
Reference in New Issue
Block a user