Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Port pmic driver and add scheduler for it #1

Closed
wants to merge 101 commits into from
Closed
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
101 commits
Select commit Hold shift + click to select a range
602165b
Initial commit
jsphuebner Nov 4, 2019
1628a9a
Add files via upload
jsphuebner Nov 4, 2019
f575109
Added files and merged changes
jsphuebner Nov 4, 2019
243c92f
dynamic anain array
jsphuebner Nov 4, 2019
103cbec
Added function to iterate all CAN messages
jsphuebner Nov 5, 2019
4c2590d
Improved anti-windup, preventing locked integrator
jsphuebner Nov 10, 2019
530c569
Limiting offset the maximum output
jsphuebner Jan 19, 2020
daa6887
Removed offset, allow setting proportional and integral gain separately
jsphuebner Feb 6, 2020
6cb3a84
More comments
jsphuebner Apr 14, 2020
6412816
Made CAN class instantiatable for 2 CAN interfaces
jsphuebner Apr 20, 2020
71b798a
Merge branch 'master' of https://github.com/jsphuebner/libopeninv
jsphuebner Apr 20, 2020
74c6d5b
Refactored AnaIn
jsphuebner Apr 20, 2020
09ddd8e
Merge branch 'master' of https://github.com/jsphuebner/libopeninv
jsphuebner Apr 20, 2020
ed0c723
oops, CAN NART was still enabled
jsphuebner May 6, 2020
b975120
make hwRev dependency in terminal optional
jsphuebner May 13, 2020
a9e7ff7
Added memset32 function
jsphuebner Oct 17, 2020
5372bfd
Simplified param_save
jsphuebner Oct 17, 2020
7265372
Added boot loader pin init parameter structures
jsphuebner Oct 17, 2020
06c32c3
Merge branch 'HEAD' of https://github.com/jsphuebner/libopeninv.git i…
jsphuebner Oct 17, 2020
a3240da
Kindof fixed rounding errors
jsphuebner Nov 12, 2020
1973ef6
Added integrator preloading
jsphuebner Nov 19, 2020
e0d4412
Allow specifying length in Can::Send()
jsphuebner Jan 1, 2021
7b0e78a
Merge branch 'master' of https://github.com/jsphuebner/libopeninv
jsphuebner Jan 1, 2021
9a88ce6
made fp_atoi more generic
jsphuebner Jan 7, 2021
c2e165d
Merge branch 'master' of https://github.com/jsphuebner/libopeninv.git
jsphuebner Jan 7, 2021
216da9a
Added class with standard terminal commands
jsphuebner Jan 22, 2021
1787ba7
Refactored terminal, fixed headers
jsphuebner Feb 8, 2021
a564cc7
Allow disabling TX DMA
jsphuebner Feb 8, 2021
8a79c45
Removed unneeded include
jsphuebner Feb 8, 2021
d2eeb22
Always enable Terminal 1
jsphuebner Feb 17, 2021
aba4a4e
Small optimization
jsphuebner Feb 17, 2021
59f77f7
Add microsecond blocking delay function
davefiddes Mar 17, 2021
bbb527e
Add a simple C CRC-8-CCITT implementation
davefiddes Mar 17, 2021
0c6cec1
Merge pull request #1 from davefiddes/tesla-m3-gate-driver
jsphuebner Mar 26, 2021
93e1f99
Allow enum parameters
davefiddes Apr 10, 2021
9e90671
Optimization of FOC code
jsphuebner Apr 10, 2021
410aaf0
Add a value CLAMP macro following MIN/MAX
davefiddes Apr 11, 2021
4a4f0c2
enable temperature sensor when used
jsphuebner Apr 16, 2021
de42cb7
CAN and param save module auto-detect flash and page size and always …
jsphuebner Apr 20, 2021
463cc02
Merge branch 'HEAD' of https://github.com/jsphuebner/libopeninv.git
jsphuebner Apr 20, 2021
f089afe
Small optimization in scheduler
jsphuebner Apr 21, 2021
ce4adfc
Fix exported putchar() so it matches its prototype
davefiddes Apr 27, 2021
0317452
Added LIN class
jsphuebner Apr 30, 2021
d45374f
Merge branch 'master' of https://github.com/jsphuebner/libopeninv
jsphuebner Apr 30, 2021
306cd3b
HasReceived now uses feature ID w/o parity
jsphuebner May 1, 2021
de5b53a
Only erase flash page when it is not already erased. This allows sharing
jsphuebner May 6, 2021
60a6eba
Fixed anti-windup, had forgotten an FP_FROMINT
jsphuebner May 8, 2021
d73d83a
Fix type problems with standalone printf implementation
davefiddes May 15, 2021
c307149
Add helper methods to ErrorMessage to assist with testing
davefiddes May 15, 2021
fdcbd46
Add libopeninv CMake build
davefiddes May 15, 2021
e04d026
Properly avoid division by 0
jsphuebner May 16, 2021
def2dc3
Add macro to convert fixed point values to float values
davefiddes May 17, 2021
36550a1
Add coverage support to libopeninv
davefiddes May 20, 2021
b74e3dc
Pull all build specific options from a global_options library
davefiddes Jun 14, 2021
8985342
fixed warning in stm32_can, fixed bug in linbus
jsphuebner Jun 16, 2021
5f232dc
Added crude lockout flag to inhibit sending mapped messages while map…
jsphuebner Jun 17, 2021
5644523
Boot loader pin commands changed to new semantics
jsphuebner Jun 17, 2021
f897efe
Merge branch 'master' of https://github.com/jsphuebner/libopeninv
jsphuebner Jun 17, 2021
1068263
Include all CPP files in CMake build
davefiddes Jun 18, 2021
7e4c6c6
Fix fp_ln() to use type guaranteed to be 32-bit unsigned int
davefiddes Jun 24, 2021
1eaa7f7
Corrected MTPA formula
jsphuebner Jun 30, 2021
866a946
Converted "slow" functions to float math
jsphuebner Jun 30, 2021
a0fb57e
C2000 compatibility changes
davefiddes Jul 5, 2021
41f90af
Fix printf to not use the legacy C register keyword
davefiddes Jul 5, 2021
812e14c
Use int32_t in params
davefiddes Jul 31, 2021
1568dd9
Fix integer overflow in FOC constant and sqrt calculation
davefiddes Aug 5, 2021
4e04f58
Remove duplicate SQRT3 define
davefiddes Aug 5, 2021
7d1aa5b
Fix FOC FP constants to avoid overflow
davefiddes Aug 8, 2021
1abdb84
Convert int to int32_t in PiController
davefiddes Aug 8, 2021
c52b808
Prevent FP_FROMFLT() from overflowing on C2000 FOC
davefiddes Aug 9, 2021
a1832f0
Merge from master
davefiddes Aug 17, 2021
9dbc313
Changed order of filters, prep for performance turning
jsphuebner Sep 24, 2021
952921d
Undid formula correction. Might be more to the book but caused oscill…
jsphuebner Sep 29, 2021
dd7d769
Fixed floating point IIR Filter formula
jsphuebner Oct 5, 2021
bf44edb
Removed register attribute in printf
jsphuebner Oct 8, 2021
c045706
Added remap option to CAN constructor
jsphuebner Oct 8, 2021
72ce823
Merge upstream "float" branch
davefiddes Oct 8, 2021
a00f1f0
Added FP_TOFLOAT macro
jsphuebner Oct 12, 2021
5c3cf1f
Merge branch 'master' into float
jsphuebner Oct 13, 2021
af46faa
Make CRC8 work on the C2000 architecture
davefiddes Oct 31, 2021
a3e4923
Added Send() function for byte array
jsphuebner Oct 31, 2021
7476273
Put param change callback in Param namespace
jsphuebner Nov 19, 2021
c1f0e7e
Merge branch 'float' of github.com:jsphuebner/libopeninv into float
jsphuebner Nov 19, 2021
1dcd5b6
removed volatile
jsphuebner Nov 5, 2021
fe1fa55
Output nodeid at startup if terminal is disabled
jsphuebner Dec 16, 2021
ca7ecf8
Use RX DMA for LIN reception, would loose frames otherwise
jsphuebner Dec 27, 2021
e4483ce
Corrected ABS macro
jsphuebner Dec 27, 2021
981af9a
Merge branch 'master' of git@github.com:jsphuebner/libopeninv.git int…
jsphuebner Dec 27, 2021
7b367b8
Merge upstream libopeninv/float
davefiddes Jan 11, 2022
5b943d3
Port pmic driver and add scheduler for it
ocklin Feb 8, 2022
45354d9
add SPI ports for Launchxl to device.h
ocklin Feb 9, 2022
07633cb
add pmic testing on launchxl and bug fixing
ocklin Feb 9, 2022
231a6be
Integate gate driver support into main C2000 inverter
davefiddes Feb 9, 2022
ff48e16
Move repo contents to sub-directory prior to merge
davefiddes Feb 9, 2022
93ff3b3
Remove libopeninv submodule
davefiddes Feb 9, 2022
4749428
Merge remote-tracking branch 'libopeninv-origin/portable-cpp' into po…
davefiddes Feb 9, 2022
51e7741
Merge branch 'davefiddes:portable-cpp' into portable-cpp
ocklin Feb 9, 2022
d1c28bf
Move STM32 inverter into dedicated platform directory
davefiddes Feb 10, 2022
884dcfd
Isolate STM32 components of libopeninv in platform
davefiddes Feb 11, 2022
9e619c4
Fix gate drive PSU state message in C2000 inverter
davefiddes Feb 11, 2022
937d210
Merge branch 'davefiddes:portable-cpp' into portable-cpp
ocklin Feb 15, 2022
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
3 changes: 3 additions & 0 deletions platform/c2000/CMakeLists.txt
Expand Up @@ -16,5 +16,8 @@ add_subdirectory(inverter)
# Tesla M3 Gate Driver and PSU test application
add_subdirectory(gatedrivertest)

# Tesla M3 PMIC Driver test
add_subdirectory(pmicdrivertest)

# Dump Tesla M3 EEPROM
add_subdirectory(dumpeeprom)
16 changes: 16 additions & 0 deletions platform/c2000/device_support/include/device.h
Expand Up @@ -139,6 +139,22 @@ a single CPU should be defined."

#define DEVICE_TESLAM3_GATE_SPI SPIC_BASE


// Tesla Model 3 Inverter Pmic Driver (TLF35584)
// Pins 8, 9, 10, 12
// GPIOs 16, 17, 18, 19
#define DEVICE_TESLAM3_GPIO_PIN_PMIC_MOSI 16
#define DEVICE_TESLAM3_GPIO_PIN_PMIC_MISO 17
#define DEVICE_TESLAM3_GPIO_PIN_PMIC_CLK 18
#define DEVICE_TESLAM3_GPIO_PIN_PMIC_CS 19

#define DEVICE_TESLAM3_GPIO_CFG_PMIC_MOSI GPIO_16_SPISIMOA
#define DEVICE_TESLAM3_GPIO_CFG_PMIC_MISO GPIO_17_SPISOMIA
#define DEVICE_TESLAM3_GPIO_CFG_PMIC_CLK GPIO_18_SPICLKA
#define DEVICE_TESLAM3_GPIO_CFG_PMIC_CS GPIO_19_SPISTEA

#define DEVICE_TESLAM3_PMIC_SPI SPIA_BASE

//*****************************************************************************
//
// Defines related to clock configuration
Expand Down
10 changes: 9 additions & 1 deletion platform/c2000/inverter_drivers/CMakeLists.txt
@@ -1,4 +1,12 @@
add_library(inverter_drivers eeprom.cpp current.cpp encoder.cpp pwmdriver.cpp gatedriver.cpp gatedriverinterface.cpp)
add_library(inverter_drivers
eeprom.cpp
current.cpp
encoder.cpp
pmicspidriver.cpp
pwmdriver.cpp
gatedriver.cpp
gatedriverinterface.cpp
scheduler.cpp)
target_link_libraries(inverter_drivers global_options libopeninv device_support)
target_include_directories(inverter_drivers
PUBLIC "${CMAKE_CURRENT_SOURCE_DIR}")
41 changes: 41 additions & 0 deletions platform/c2000/inverter_drivers/c2000/pmicspidriver.h
@@ -0,0 +1,41 @@
/*
* This file is part of the stm32-sine project.
*
* Copyright (C) 2022 Bernd Ocklin <bernd@ocklin.de>
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/

#ifndef C2000SPIDRIVER_H
#define C2000SPIDRIVER_H

#include "stdint.h"

class PmicSpiDriver {

private:
static uint32_t m_base;

static void InitGPIO(uint16_t, uint32_t);

public:
static void InitGPIOs();
ocklin marked this conversation as resolved.
Show resolved Hide resolved
static void InitSPIPort();

static void WriteData(uint16_t data);
static uint16_t ReadData();
};

#endif // C2000SPIDRIVER_H

48 changes: 48 additions & 0 deletions platform/c2000/inverter_drivers/c2000/scheduler.h
@@ -0,0 +1,48 @@
/*
* This file is part of the Tesla M3 OSS Inverter project.
*
* Copyright (C) 2022 Bernd Ocklin <bernd@ocklin.de>
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/

#ifndef SCHEDULER_H
#define SCHEDULER_H

#include <stdint.h>

class Scheduler {

// making these public to allow extern "C" interrupt handlers to reach them
public:

static const uint16_t maxTasks = 3;

static uint32_t periods[maxTasks];

static void (*functions[maxTasks]) (void);

public:
// init the scheduler / timer
static void Init();

// add a task with a specific period */
static void AddTask(void (*function)(void), uint32_t msPeriod);

private:
static void InitCPUTimers();
static void ConfigureCPUTimer(uint32_t cpuTimer, uint32_t msPeriod);
};

#endif // SCHEDULER_H