Skip to content

Commit

Permalink
Adding new gpio expander driver changes and pdu interface
Browse files Browse the repository at this point in the history
  • Loading branch information
nwdepatie committed Dec 29, 2023
1 parent 5753e7b commit 695fe10
Show file tree
Hide file tree
Showing 4 changed files with 62 additions and 1 deletion.
36 changes: 36 additions & 0 deletions Core/Inc/pdu.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
#ifndef PDU_H
#define PDU_H

#include <stdint.h>
#include <stdbool.h>
#include "pi4ioe.h"
#include "cmsis_os.h"

typedef struct {
pi4ioe_t *gpio_exp;
osMutexId_t *mutex;
} pdu_t;

/* Creates a new PDU interface */
pdu_t *init_pdu(I2C_HandleTypeDef *hi2c);

/* Functions to Control PDU */
int8_t write_pump(pdu_t *pdu, bool status);
int8_t write_fan_radiator(pdu_t *pdu, bool status);
int8_t write_brakelight(pdu_t *pdu, bool status);
int8_t write_fan_battbox(pdu_t *pdu, bool status);

/* Functions to Read the Status of Fuses from PDU */
int8_t read_fuse_pump(pdu_t *pdu);
int8_t read_fuse_fan_radiator(pdu_t *pdu);
int8_t read_fuse_fan_battbox(pdu_t *pdu);
int8_t read_fuse_mc(pdu_t *pdu);
int8_t read_fuse_lvbox(pdu_t *pdu);
int8_t read_fuse_dashboard(pdu_t *pdu);
int8_t read_fuse_brakelight(pdu_t *pdu);
int8_t read_fuse_brb(pdu_t *pdu);

/* Function to read the status of Tractive System Main Switch */
int8_t read_tsms_sense(pdu_t *pdu);

#endif /* PDU_H */
24 changes: 24 additions & 0 deletions Core/Src/pdu.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
#include "pdu.h"

#define PUMP_CTRL 0x00
#define RADFAN_CTRL 0x01
#define BRKLIGHT_CTRL 0x02
#define BATBOXFAN_CTRL 0x03
#define TSMS_CTRL 0x04
#define SMBALERT 0x05

pdu_t *init_pdu(I2C_HandleTypeDef *hi2c);

int8_t write_pump(pdu_t *pdu, bool status);
int8_t write_fan_radiator(pdu_t *pdu_t, bool status);
int8_t write_brakelight(pdu_t *pdu, bool status);
int8_t write_fan_battbox(pdu_t *pdu, bool status);
int8_t read_fuse_pump(pdu_t *pdu);
int8_t read_fuse_fan_radiator(pdu_t *pdu);
int8_t read_fuse_fan_battbox(pdu_t *pdu);
int8_t read_fuse_mc(pdu_t *pdu);
int8_t read_fuse_lvbox(pdu_t *pdu);
int8_t read_fuse_dashboard(pdu_t *pdu);
int8_t read_fuse_brakelight(pdu_t *pdu);
int8_t read_fuse_brb(pdu_t *pdu);
int8_t read_tsms_sense(pdu_t *pdu);
1 change: 1 addition & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@ Core/Src/monitor.c \
Core/Src/fault.c \
Core/Src/can_handler.c \
Core/Src/serial_monitor.c \
Core/Src/pdu.c \
Drivers/STM32F4xx_HAL_Driver/Src/stm32f4xx_hal_can.c \
Drivers/STM32F4xx_HAL_Driver/Src/stm32f4xx_hal_rcc.c \
Drivers/STM32F4xx_HAL_Driver/Src/stm32f4xx_hal_rcc_ex.c \
Expand Down

0 comments on commit 695fe10

Please sign in to comment.