Skip to content
Merged
Show file tree
Hide file tree
Changes from 39 commits
Commits
Show all changes
54 commits
Select commit Hold shift + click to select a range
531fe9e
rename software folder to firmware
changxu-liu Jan 16, 2026
c2729b9
set up embedded sharepoint
changxu-liu Jan 17, 2026
d847496
fix makefile showing flash successful even when not (fix in Embedded-…
changxu-liu Jan 28, 2026
0273a31
MCP23S17 GPIO expander driver
changxu-liu Jan 31, 2026
23f06cb
update makefile to give build failure message, remove madefile when r…
changxu-liu Jan 31, 2026
f1067b1
add blank line to nix_thing.sh
changxu-liu Jan 31, 2026
72e8923
fix TEST capitalization in makefile, change formatting
changxu-liu Mar 6, 2026
f50f21d
add MCP23S17 datasheet
changxu-liu Mar 6, 2026
5b82495
change pin type to uint16_t because HAL convention
changxu-liu Mar 6, 2026
9d4e8af
add register descriptions
changxu-liu Mar 7, 2026
92ac175
add enum comments
changxu-liu Mar 7, 2026
3ffdfe0
address addressing double left-shift, comments
changxu-liu Mar 7, 2026
7994c8b
move defines out of c file to header file
changxu-liu Mar 7, 2026
d17c3b5
update function documentation comments, add comments for static funct…
changxu-liu Mar 7, 2026
c0c8f16
remove unnecessary comment
changxu-liu Mar 7, 2026
74c2594
function comment update
changxu-liu Mar 7, 2026
ac404d7
change functions to return status
changxu-liu Mar 7, 2026
42ed81a
make more functions return status
changxu-liu Mar 7, 2026
454a561
update documentation returning status, other things
changxu-liu Mar 8, 2026
191f4fa
improve addressing comment
changxu-liu Mar 8, 2026
d494a91
move uint8_to_binary_str to utilities file
changxu-liu Mar 8, 2026
9e15fbf
add pin defines to file
changxu-liu Mar 8, 2026
acb3c0a
add descriptions to tests
changxu-liu Mar 13, 2026
a62ba02
add blank lines
changxu-liu Mar 13, 2026
38f02fe
add todo
changxu-liu Mar 31, 2026
fcd25b8
add _t to type names for enums and structs
changxu-liu Apr 4, 2026
f210241
RTOSify MCP23S17 driver
changxu-liu Apr 4, 2026
2b61d4e
update constant names, update comments, clean up
changxu-liu Apr 4, 2026
ac748de
update MCP23S17 init function for less arguments, change configuratio…
changxu-liu Apr 4, 2026
da3d30f
updated MCP23S17 test for RTOS - untested as don't have TestBoard_TPS…
changxu-liu Apr 5, 2026
6ec641c
add github build action
changxu-liu Apr 5, 2026
513e7b6
add github build action (attempt 2)
changxu-liu Apr 5, 2026
b470d51
add github build action (attempt 3)
changxu-liu Apr 5, 2026
014a6b4
add github build action (attempt 4)
changxu-liu Apr 5, 2026
254f5c3
add github build action (attempt 5)
changxu-liu Apr 5, 2026
a231b80
add github build action (attempt 6)
changxu-liu Apr 5, 2026
9aaf389
add units to SPI delay names
changxu-liu Apr 5, 2026
2045a89
fix tests
changxu-liu Apr 5, 2026
212da27
change Pins, SPI, and UART files structure
changxu-liu Apr 5, 2026
c2149ce
add device and data null check
changxu-liu Apr 6, 2026
fdd8b82
move encoding of data before taking SPI mutex
changxu-liu Apr 6, 2026
e24da2b
move CS stuff to static inline function
changxu-liu Apr 6, 2026
637bdbd
lakshay being picky picky picky
changxu-liu Apr 6, 2026
9ecf93c
fix spi cs and mutex not returning to original state if spi transmiss…
changxu-liu Apr 6, 2026
ed9f7fb
fix discarding status return if not 🙂 (as now there's more statuses)
changxu-liu Apr 6, 2026
ab3dcf1
fix spi cs and mutex not returning to original state if HAL spi funct…
changxu-liu Apr 6, 2026
2d54ef9
lakshay lies
changxu-liu Apr 6, 2026
6258117
put SPI message length into variable
changxu-liu Apr 6, 2026
b19b3a8
add checks for spi mutex and sempahore null
changxu-liu Apr 6, 2026
28ad4b6
move SPI interrupt functions ot SPI file
changxu-liu Apr 6, 2026
19e3f9b
move SPI mutex and done semaphore setup to function in SPI file
changxu-liu Apr 6, 2026
2a20d58
make SPI interrupt priority a define
changxu-liu Apr 6, 2026
09a9835
move private functions to c file
changxu-liu Apr 12, 2026
9edfb8f
fix dummy send failures potential to lock up SPI mutex
changxu-liu Apr 12, 2026
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
35 changes: 35 additions & 0 deletions .github/workflows/build-tests_TestBoard_TPS27SA08-Q1.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
name: Build Tests (TestBoard_TPS27SA08-Q1)

on:
push:

jobs:
build:
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v3

- name: Initialize Submodules
run: git submodule update --init ./firmware/Embedded-Sharepoint

- name: Cache Nix
uses: actions/cache@v3
with:
path: |
~/.cache/nix
key: nix-${{ runner.os }}-${{ hashFiles('flake.lock') }}
restore-keys: |
nix-${{ runner.os }}-

- name: Install Nix Action
uses: cachix/install-nix-action@v31

- name: Clean & Build tests
run: |
nix develop ./firmware/Embedded-Sharepoint/ --accept-flake-config --command bash -c "
cd firmware
cd TestBoard_TPS27SA08-Q1
make clean
python test/MakeAllTests_TestBoard_TPS27SA08-Q1.py
"
37 changes: 36 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
# -----------------------------------------------------------------------------
# HARDWARE (KICAD)
# -----------------------------------------------------------------------------
# For PCBs designed using KiCad: https://www.kicad.org/
# Format documentation: https://kicad.org/help/file-formats/

Expand Down Expand Up @@ -37,4 +40,36 @@ fp-info-cache
**/*-backups/*.zip

# Local project settings
*.kicad_prl
*.kicad_prl

# -----------------------------------------------------------------------------
# FIRMWARE
# -----------------------------------------------------------------------------

# VS Code
.vscode/
compile_commands.json

# Build files
build
.dockerfile.hash
.cache
/can/CANMetaData.*
Madefile

# Python
*venv
__pycache__/
.env

# Nix
flake.lock

# Documentation toolset
docs/doxygen/
site/*
!site/empty.a
Zone.Identifier

# Mac specific files
.DS_Store
3 changes: 3 additions & 0 deletions .gitmodules
Original file line number Diff line number Diff line change
Expand Up @@ -4,3 +4,6 @@
[submodule "hardware/lib/KiCAD-Sharepoint"]
path = hardware/lib/KiCAD-Sharepoint
url = git@github.com:lhr-solar/KiCAD-Sharepoint.git
[submodule "firmware/Embedded-Sharepoint"]
path = firmware/Embedded-Sharepoint
url = https://github.com/lhr-solar/Embedded-Sharepoint.git
Binary file added datasheets/MCP23017_MCP23S17.pdf
Binary file not shown.
1 change: 1 addition & 0 deletions firmware/Embedded-Sharepoint
Submodule Embedded-Sharepoint added at 2bdaa5
157 changes: 157 additions & 0 deletions firmware/TestBoard_TPS27SA08-Q1/Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,157 @@
# CRAZY COLORS ----------------------------------------------------------------
RED=\033[0;31m
GREEN=\033[0;32m
ORANGE=\033[0;33m
BLUE=\033[0;34m
PURPLE=\033[0;35m
CYAN=\033[0;36m
LIGHTGRAY=\033[0;37m
DARKGRAY=\033[1;30m
YELLOW=\033[0;33m
NC=\033[0m # No Color
# -----------------------------------------------------------------------------

# generate paths
MAKEFILE_DIR = $(shell dirname $(realpath $(lastword $(MAKEFILE_LIST))))

# PROJECT CONFIGURATION -------------------------------------------------------
TEST ?= main

# COMMON TARGETS
# LSOM: stm32g473xx
# PSOM: stm32l431cbt
# FAT NUCLEO: stm32g474xx
# BAD NUCLEO: stm32l432kcu
PROJECT_TARGET ?= stm32l432kcu

# SOURCE AND INCLUDE DIRECTORIES
PROJECT_C_INCLUDES = $(wildcard core/inc) $(wildcard ../driver/inc)
PROJECT_C_SOURCES = $(wildcard core/src/*.c) $(wildcard ../driver/src/*.c)
PROJECT_MAIN_DIR ?= core/src

# BUILD DIRECTORIES
PROJECT_BUILD_DIR = build
BUILD_MAKEFILE_DIR ?= ../Embedded-Sharepoint

MADEFILE ?= true
MADEFILE_DIR = ${MAKEFILE_DIR}
# -----------------------------------------------------------------------------


# remove main and add test folders if running test
ifneq ($(TEST), "main")
PROJECT_C_SOURCES := $(filter-out $(PROJECT_MAIN_DIR)/main.c, $(PROJECT_C_SOURCES))
PROJECT_C_SOURCES += $(wildcard test/src/${TEST}.c)

PROJECT_C_INCLUDES += $(wildcard test/inc)
endif
Comment thread
changxu-liu marked this conversation as resolved.

# Convert relative paths to absolute paths for passing to Embedded-Sharepoint build
PROJECT_C_SOURCES := $(addprefix $(MAKEFILE_DIR)/, $(PROJECT_C_SOURCES))
PROJECT_C_INCLUDES := $(addprefix $(MAKEFILE_DIR)/, $(PROJECT_C_INCLUDES))

# Debug
PRINT_DEBUG ?= true

ifeq ($(PRINT_DEBUG), true)
$(info SOURCES: $(PROJECT_C_SOURCES))
$(info INCLUDES: $(PROJECT_C_INCLUDES))
endif

# generate paths (cont.d)
PROJECT_BUILD_DIR := $(addprefix $(MAKEFILE_DIR)/, $(PROJECT_BUILD_DIR))

# export variables
export PROJECT_TARGET
export PROJECT_C_SOURCES
export PROJECT_C_INCLUDES
export PROJECT_BUILD_DIR


# -----------------------------------------------------------------------------
# Clang
BEAR_PREFIX :=
# check if bear is installed
BEAR_INSTALLED := $(shell command -v bear >/dev/null 2>&1 && echo yes || echo no)

# define path of .vscode (create if missing)
VS_CODE_DIR := $(MAKEFILE_DIR)/.vscode
$(shell mkdir -p $(VS_CODE_DIR))

ifeq ($(BEAR_INSTALLED),yes)
BEAR_PREFIX := bear --output $(VS_CODE_DIR)/compile_commands.json --append --
endif
# -----------------------------------------------------------------------------


# BUILD -----------------------------------------------------------------------
ifeq ($(MAKECMDGOALS),)
default: build_code
else ifeq ($(MAKECMDGOALS), all)
all: build_code
else
%:
$(BEAR_PREFIX) $(MAKE) -C $(BUILD_MAKEFILE_DIR) $(MAKECMDGOALS)
endif


build_code:
ifeq ($(MADEFILE), true)
@echo -e "Make initiated at $(shell date)\n" > ${MADEFILE_DIR}/Madefile
endif

ifneq ($(TEST), main)
@echo -e "Making ${PURPLE}$(PROJECT_TARGET)${NC}build for ${BLUE}TEST=${PURPLE}${TEST}${NC}"
ifeq ($(MADEFILE), true)
@echo -e "Making $(PROJECT_TARGET) build for TEST=${TEST}\n" >> ${MADEFILE_DIR}/Madefile
endif
Comment thread
changxu-liu marked this conversation as resolved.
else
@echo -e "Making ${PURPLE}$(PROJECT_TARGET)${NC}build with ${ORANGE}main.${NC}"
ifeq ($(MADEFILE), true)
@echo -e "Making $(PROJECT_TARGET) build with main.\n" >> ${MADEFILE_DIR}/Madefile
endif
endif

ifeq ($(MADEFILE), true)
@set -o pipefail; if $(BEAR_PREFIX) $(MAKE) -C $(BUILD_MAKEFILE_DIR) all -j | tee -a ${MADEFILE_DIR}/Madefile; then \
echo -e "${GREEN}Compiled! Splendid! Jolly Good!!!\n${NC}"; \
echo -e "\nCompiled! Splendid! Jolly Good!!\n" >> ${MADEFILE_DIR}/Madefile; \
else \
echo -e "${RED}Build failure.\n${NC}"; \
echo -e "\nBuild failure.\n" >> ${MADEFILE_DIR}/Madefile; \
exit 1; \
fi
else
@set -o pipefail; if $(BEAR_PREFIX) $(MAKE) -C $(BUILD_MAKEFILE_DIR) all -j; then \
echo -e "${GREEN}Compiled! Splendid! Jolly Good!!!\n${NC}"; \
else \
echo -e "${RED}Build failure.\n${NC}"; \
exit 1; \
fi
endif
# -----------------------------------------------------------------------------


# FLASH -----------------------------------------------------------------------
flash:
@set -o pipefail; if $(MAKE) -C $(BUILD_MAKEFILE_DIR) flash; then \
echo -e "${GREEN}Flash successful.\n${NC}"; \
else \
echo -e "${RED}Flash failure.\n${NC}"; \
exit 1; \
fi
# -----------------------------------------------------------------------------


# CLEAN -----------------------------------------------------------------------
clean:
$(MAKE) -C $(BUILD_MAKEFILE_DIR) clean
-rm -fR $(MADEFILE_DIR)/Madefile
# -----------------------------------------------------------------------------


# DOCUMENTATION ---------------------------------------------------------------
# .PHONY: docs
# docs:
# cd $(BUILD_MAKEFILE_DIR) && mkdocs serve
# -----------------------------------------------------------------------------
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
#define LED_PIN GPIO_PIN_3
#define LED_PORT GPIOB
#define LED_CLOCK_INIT() __HAL_RCC_GPIOB_CLK_ENABLE();
Comment thread
changxu-liu marked this conversation as resolved.

#define VCP_TX_PIN GPIO_PIN_2
#define VCP_TX_PORT GPIOA
#define VCP_RX_PIN GPIO_PIN_15
#define VCP_RX_PORT GPIOA

#define GPIOEXP_CS_PIN GPIO_PIN_3
#define GPIOEXP_CS_PORT GPIOA

#define GPIOEXP_INTA_PIN GPIO_PIN_5
#define GPIOEXP_INTA_PORT GPIOA
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
#include "stm32xx_hal.h"

extern SPI_HandleTypeDef hspi1;

/**
* @brief SPI1 Initialization Function
* @param None
* @retval None
*/
void MX_SPI1_Init(void);

/**
* @brief SPI MSP Initialization
* This function configures the hardware resources used in this example
* @param hspi: SPI handle pointer
* @retval None
*/
void HAL_SPI_MspInit(SPI_HandleTypeDef* hspi);

/**
* @brief SPI MSP De-Initialization
* This function freeze the hardware resources used in this example
* @param hspi: SPI handle pointer
* @retval None
*/
void HAL_SPI_MspDeInit(SPI_HandleTypeDef* hspi);

bool SPI_Init_Dummy_Send(SPI_HandleTypeDef* spi, SemaphoreHandle_t spi2_mutex, SemaphoreHandle_t spi2_done_sem);
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
#include "stm32xx_hal.h"
#include "TestBoard_TPS27SA08-Q1_Pins.h"

extern UART_HandleTypeDef huart2;

/**
* @brief USART2 Initialization Function
* @param None
* @retval None
*/
void MX_USART2_UART_Init(void);

/**
* @brief UART MSP Initialization
* This function configures the hardware resources used in this example
* @param huart: UART handle pointer
* @retval None
*/
void HAL_UART_MspGPIOInit(UART_HandleTypeDef* huart);

/**
* @brief UART MSP De-Initialization
* This function freeze the hardware resources used in this example
* @param huart: UART handle pointer
* @retval None
*/
void HAL_UART_MspGPIODeInit(UART_HandleTypeDef* huart);
Loading
Loading