Рефакторинг, разнесение некоторых ф-й в разные файлы для упорядочивания, создание дефайна "FREEMASRER", который определяет режим работы UART (отладка или тензодатчик)

This commit is contained in:
seklyuts 2024-09-04 14:56:34 +03:00
parent c8892500d4
commit a4a29dd929
19 changed files with 108 additions and 184 deletions

View File

@ -128,7 +128,7 @@ __interrupt void epwm2_isr(void)
if(PwmFlagStartCurrentMeashure) /// Не были отработаны измерения тока в сигма-дельта и не было запущено векторное управление if(PwmFlagStartCurrentMeashure) /// Не были отработаны измерения тока в сигма-дельта и не было запущено векторное управление
{ {
PwmFlagStartCurrentMeashure = 0; PwmFlagStartCurrentMeashure = 0;
FMSTREnableSet(); SynchPWMFonRunEnableSet();
AdcStartSet(); AdcStartSet();
BissStartSet(); BissStartSet();
PWM_ABC_StopAllClose(); PWM_ABC_StopAllClose();

View File

@ -14,22 +14,22 @@
#define BAUD 19200.0 #define BAUD 19200.0
#define BRR LSPCLK_HZ/(BAUD*8) + 1 #define BRR LSPCLK_HZ/(BAUD*8) + 1
uint16_t frmEn = 0; uint16_t SynchPWMFonRunEn = 0;
uint16_t FMSTRIsEnable(void) uint16_t SynchPWMFonRunEnable(void)
{ {
return frmEn; return SynchPWMFonRunEn;
} }
void FMSTREnableClr(void) void SynchPWMFonRunEnableClr(void)
{ {
frmEn = 0; SynchPWMFonRunEn = 0;
} }
void FMSTREnableSet(void) void SynchPWMFonRunEnableSet(void)
{ {
frmEn = 1; SynchPWMFonRunEn = 1;
} }
@ -75,7 +75,7 @@ void FRMUartInit(void)
SciaRegs.SCICTL1.all = 0x0023; // Relinquish SCI from Reset SciaRegs.SCICTL1.all = 0x0023; // Relinquish SCI from Reset
EDIS; EDIS;
FMSTREnableSet(); SynchPWMFonRunEnableSet();
} }

View File

@ -25,8 +25,8 @@ FMSTR_SCISR FMSTR_SCI_RDCLRSR(void);
void FRMUartInit(void); void FRMUartInit(void);
void FRMGPIOInit(void); void FRMGPIOInit(void);
uint16_t FMSTRIsEnable(void); uint16_t SynchPWMFonRunEnable(void);
void FMSTREnableClr(void); void SynchPWMFonRunEnableClr(void);
void FMSTREnableSet(void); void SynchPWMFonRunEnableSet(void);
#endif /* SRC_FRM_UART_H_ */ #endif /* SRC_FRM_UART_H_ */

View File

@ -18,7 +18,7 @@ void frmmstr_run(void)
{ {
static uint16_t diod = 0; static uint16_t diod = 0;
if(FMSTRIsEnable()) { if(SynchPWMFonRunEnable()) {
if(counter < 100) counter++; if(counter < 100) counter++;
else else
{ {
@ -36,7 +36,7 @@ static uint16_t diod = 0;
} }
FMSTR_Poll(); FMSTR_Poll();
FMSTR_Recorder(); FMSTR_Recorder();
FMSTREnableClr(); SynchPWMFonRunEnableClr();
} }

View File

@ -134,7 +134,7 @@ void vectorControl(int16_t CurrentA, int16_t CurrentB, int16_t CurrentC, int16_t
vector_klark_park(SectorCheckOn,Ia,Ib,Ic); vector_klark_park(SectorCheckOn,Ia,Ib,Ic);
vector_inversion(); vector_inversion();
BissStartSet(); BissStartSet();
FMSTREnableSet(); SynchPWMFonRunEnableSet();
AdcStartSet(); AdcStartSet();
} }

View File

@ -62,6 +62,7 @@
</option> </option>
<option IS_BUILTIN_EMPTY="false" IS_VALUE_EMPTY="false" id="com.ti.ccstudio.buildDefinitions.C2000_22.6.compilerID.DEFINE.2084039298" name="Pre-define NAME (--define, -D)" superClass="com.ti.ccstudio.buildDefinitions.C2000_22.6.compilerID.DEFINE" valueType="definedSymbols"> <option IS_BUILTIN_EMPTY="false" IS_VALUE_EMPTY="false" id="com.ti.ccstudio.buildDefinitions.C2000_22.6.compilerID.DEFINE.2084039298" name="Pre-define NAME (--define, -D)" superClass="com.ti.ccstudio.buildDefinitions.C2000_22.6.compilerID.DEFINE" valueType="definedSymbols">
<listOptionValue builtIn="false" value="${COM_TI_C2000WARE_SOFTWARE_PACKAGE_SYMBOLS}"/> <listOptionValue builtIn="false" value="${COM_TI_C2000WARE_SOFTWARE_PACKAGE_SYMBOLS}"/>
<listOptionValue builtIn="false" value="FREEMASTER"/>
<listOptionValue builtIn="false" value="NRS485"/> <listOptionValue builtIn="false" value="NRS485"/>
<listOptionValue builtIn="false" value="REF1"/> <listOptionValue builtIn="false" value="REF1"/>
<listOptionValue builtIn="false" value="USE_25MHZ_XTAL"/> <listOptionValue builtIn="false" value="USE_25MHZ_XTAL"/>

View File

@ -16,10 +16,11 @@
// //
#include "f28x_project.h" #include "f28x_project.h"
#include "init_perif.h" #include "init_perif.h"
#include "frmmstr_run.h" #include "SyncPWMFonRun.h"
#include "adc_init.h" #include "adc_init.h"
#include "biss.h" #include "biss.h"
#include "rele.h" #include "rele.h"
#include "uart_4Mbit.h"
void main(void) void main(void)
{ {
@ -28,7 +29,9 @@ void main(void)
for(;;) for(;;)
{ {
// asm (" NOP"); // asm (" NOP");
frmmstr_run(); // frmmstr_run();
UartErrorReset();
SyncPWMFonRun();
rele_run(); rele_run();
AdcRun(); AdcRun();
BissClkgenRun(); BissClkgenRun();

View File

@ -20,6 +20,7 @@
#include "temperature.h" #include "temperature.h"
#include "rele.h" #include "rele.h"
#include "pwm_interrupts.h" #include "pwm_interrupts.h"
#include "SyncPWMFonRun.h"
volatile uint16_t AutoChange = 0; volatile uint16_t AutoChange = 0;
volatile uint16_t PWM_out = 2500; volatile uint16_t PWM_out = 2500;
@ -164,7 +165,7 @@ __interrupt void epwm2_isr(void)
if(PwmFlagStartCurrentMeashure) /// Не были отработаны измерения тока в сигма-дельта и не было запущено векторное управление if(PwmFlagStartCurrentMeashure) /// Не были отработаны измерения тока в сигма-дельта и не было запущено векторное управление
{ {
PwmFlagStartCurrentMeashure = 0; PwmFlagStartCurrentMeashure = 0;
FMSTREnableSet(); SynchPWMFonRunEnableSet();
AdcStartSet(); AdcStartSet();
BissStartSet(); BissStartSet();
PWM_ABC_StopAllClose(); PWM_ABC_StopAllClose();

View File

@ -49,7 +49,7 @@ int buttonsRead(){
} }
//Функция нстройки расширителя интерфейса //Функция нстройки расширителя интерфейса
void buttonsInit(void) { void buttonsInit(void) {
uint16_t Conf0 = 0xFE; // uint16_t Conf0 = 0xFE;
uint16_t Conf1 = 0xFF; uint16_t Conf1 = 0xFF;
I2CWrite(0x25, 6, 1, true, &Conf1); // настраиваем расширитель I2CWrite(0x25, 6, 1, true, &Conf1); // настраиваем расширитель
@ -70,7 +70,7 @@ void buttonsInit(void) {
XintRegs.XINT3CR.bit.ENABLE = 1; XintRegs.XINT3CR.bit.ENABLE = 1;
} }
int buttonsDisp(){ void buttonsDisp(){
if(buttonClik!=0){ if(buttonClik!=0){
//проверка на нажати кнопки //проверка на нажати кнопки
if(buttonsRead()){ if(buttonsRead()){
@ -101,17 +101,18 @@ int buttonsDisp(){
button=MENU_ITEMS_COUNT-1; button=MENU_ITEMS_COUNT-1;
} }
break; break;
default: // default:
} }
SSD1306_Fill(SSD1306_COLOR_BLACK);// затираем старое меню SSD1306_Fill(SSD1306_COLOR_BLACK);// затираем старое меню
Button_Sost=0;// обнуляем состояние Button_Sost=0;// обнуляем состояние
buttonClik--;//сбрасываем флаг необходимости обработать кнопку buttonClik--;//сбрасываем флаг необходимости обработать кнопку
currentMenuItem=button;//устанавливаем выбранную функцию currentMenuItem=(MenuItem)button;//устанавливаем выбранную функцию
} }
} }
//диспетчер отображения //диспетчер отображения
int ScreenDisp(){ void ScreenDisp(){
static uint16_t oldbutton=0xFFF; static uint16_t oldbutton=0xFFF;
if(oldbutton!=button){// обнавляем меню только когода нажата кнопка if(oldbutton!=button){// обнавляем меню только когода нажата кнопка
if(button<=0xFF) if(button<=0xFF)
@ -120,10 +121,13 @@ int ScreenDisp(){
oldbutton=button; oldbutton=button;
MenuDisp();//вывод функций MenuDisp();//вывод функций
} }
//Диспетчер функций меню //Диспетчер функций меню
void MenuDisp(){ void MenuDisp()
switch(button){ {
case 0+0xFF: switch(button)
{
case 0+0xFF:
SSD1306_GotoXY(10, 32); SSD1306_GotoXY(10, 32);
SSD1306_Puts("ERROR 404: PAGE ", &Font_7x10, SSD1306_COLOR_WHITE); SSD1306_Puts("ERROR 404: PAGE ", &Font_7x10, SSD1306_COLOR_WHITE);
SSD1306_GotoXY(20, 50); SSD1306_GotoXY(20, 50);
@ -133,7 +137,7 @@ void MenuDisp(){
case 1+0xFF: case 1+0xFF:
SSD1306_GotoXY(10, 32); SSD1306_GotoXY(10, 32);
SSD1306_Puts("SYS STOP", &Font_11x18, SSD1306_COLOR_WHITE); SSD1306_Puts("SYS STOP", &Font_11x18, SSD1306_COLOR_WHITE);
SSD1306_UpdateScreen(); SSD1306_UpdateScreen();
break; break;
case 2+0xFF: case 2+0xFF:
SSD1306_GotoXY(5, 32); SSD1306_GotoXY(5, 32);
@ -211,7 +215,7 @@ void MenuDisp(){
SSD1306_Puts(" accurate", &Font_7x10, SSD1306_COLOR_WHITE); SSD1306_Puts(" accurate", &Font_7x10, SSD1306_COLOR_WHITE);
SSD1306_UpdateScreen(); SSD1306_UpdateScreen();
break; break;
default: // default:
} }
} }

View File

@ -9,9 +9,9 @@ int buttonsRead();
void buttonsInit(void); void buttonsInit(void);
int buttonsDisp(); void buttonsDisp();
int ScreenDisp(); void ScreenDisp();
void MenuDisp(); void MenuDisp();

View File

@ -7,30 +7,15 @@
#include "f28x_project.h" #include "f28x_project.h"
//#include "f2838x_pinmux.h" //#include "f2838x_pinmux.h"
#include "frm_uart.h" #include "frm_uart.h"
#include "SyncPWMFonRun.h"
#define LSPCLK_HZ 50000000.0 #define LSPCLK_HZ 50000000.0
//#define BAUD 57600.0 #define BAUD 57600.0
#define BAUD 4000000.0 //#define BAUD 4000000.0
#define BRR LSPCLK_HZ/(BAUD*8) + 1 #define BRR LSPCLK_HZ/(BAUD*8) + 1
uint16_t frmEn = 0;
uint16_t FMSTRIsEnable(void)
{
return frmEn;
}
void FMSTREnableClr(void)
{
frmEn = 0;
}
void FMSTREnableSet(void)
{
frmEn = 1;
}
void FRMUartInit(void) void FRMUartInit(void)
@ -76,7 +61,7 @@ void FRMUartInit(void)
SciaRegs.SCICTL1.bit.TXENA = 1; SciaRegs.SCICTL1.bit.TXENA = 1;
EDIS; EDIS;
FMSTREnableSet(); SynchPWMFonRunEnableSet();
} }

View File

@ -1,7 +1,7 @@
/* /*
* frm_uart.h * frm_uart.h
* *
* Created on: 21 àâã. 2023 ã. * Created on: 21 <EFBFBD><EFBFBD><EFBFBD>. 2023 <EFBFBD>.
* Author: seklyuts * Author: seklyuts
*/ */
@ -24,8 +24,6 @@ FMSTR_SCISR FMSTR_SCI_RDCLRSR(void);
//void FMSTR_InitSerial(void) ; //void FMSTR_InitSerial(void) ;
void FRMUartInit(void); void FRMUartInit(void);
uint16_t FMSTRIsEnable(void);
void FMSTREnableClr(void);
void FMSTREnableSet(void);
#endif /* SRC_FRM_UART_H_ */ #endif /* SRC_FRM_UART_H_ */

View File

@ -5,95 +5,13 @@
* Author: seklyuts * Author: seklyuts
*/ */
#include "f28x_project.h" #include "f28x_project.h"
#include "init_perif.h"
#include "frm_uart.h" #include "frm_uart.h"
#include "gpio_init.h"
#include "fault.h"
#include "i2c_oled.h"
#include "buttons.h"
#include "eqep.h"
volatile uint16_t counter=0 ;
volatile uint16_t counter1=0 ;
volatile uint16_t counter2=0 ;
volatile uint16_t testMode = 0;
uint16_t BisscPwrOn = 1;
uint16_t BrakeOn = 0;
void frmmstr_run(void) void frmmstr_run(void)
{ {
static uint16_t diod = 0; FMSTR_Poll();
FMSTR_Recorder();
if(SciaRegs.SCIRXST.bit.RXERROR)
{
EALLOW;
SciaRegs.SCICTL1.bit.SWRESET = 0;
EDIS;
}
else
{
EALLOW;
SciaRegs.SCICTL1.bit.SWRESET = 1;
EDIS;
}
if(FMSTRIsEnable())
{
FMSTR_Poll();
FMSTR_Recorder();
FMSTREnableClr();
if(counter < 100) counter++;
else
{
counter = 0;
if(counter1 < 100) counter1++;
else
{
counter1=0;
counter2++;
diod++;
if(diod > 7) diod = 0;
Gpio_rainbow(diod);
//if(testMode) FMSTR_SCI_PUTCHAR(0xA5);
}
}
// EPwm3Regs.CMPA.bit.CMPA = PWM_Vent1;
}
else
{
if(BisscPwrOn)
{
GpioDataRegs.GPADAT.bit.GPIO21 = 1;
}
else
{
GpioDataRegs.GPADAT.bit.GPIO21 = 0;
}
if(BrakeOn)
{
GpioDataRegs.GPADAT.bit.GPIO14 = 1;
}
else
{
GpioDataRegs.GPADAT.bit.GPIO14 = 0;
}
//Gpio95out(Rele);
//if(vectorReleOn()) GpioTurnOnRele;
//else GpioTurnOffRele;
if(fault_read_check())
{
fault_read_clr();
fault_read_ports();
}else{
buttonsDisp();
ScreenDisp();
}
}
} }

View File

@ -1,5 +1,6 @@
#include "i2c_oled.h" #include "i2c_oled.h"
#include "init_perif.h" #include "init_perif.h"
#include "eqep.h"
extern unsigned long uptimeSeconds; extern unsigned long uptimeSeconds;
#pragma DATA_SECTION(SSD1306_Buffer,"Filter6_RegsFile"); #pragma DATA_SECTION(SSD1306_Buffer,"Filter6_RegsFile");
@ -672,45 +673,53 @@ bool displayUptime(void) {
//Функция отображения температуры //Функция отображения температуры
void displayTemp(void) { void displayTemp(void) {
static int OldeqepTemperature = 0; static int OldeqepTemperature = 0;
uint16_t temp, eqepTemperature = geteqepTemperature(); uint16_t temp, eqepTemperature = geteqepTemperature();
temp= eqepTemperature;
char temp_str[11];
temp_str[0] = 'T'; if(OldeqepTemperature != eqepTemperature)
temp_str[1] = 'E'; {
temp_str[2] = 'M';
temp_str[3] = 'P'; temp= eqepTemperature;
temp_str[4] = ':'; char temp_str[11];
temp_str[5] = ' ';
temp_str[6] = ' '; temp_str[0] = 'T';
temp_str[7] = ' '; temp_str[1] = 'E';
temp_str[8] = ' '; temp_str[2] = 'M';
temp_str[9] = ' '; temp_str[3] = 'P';
temp_str[10] = ' '; temp_str[4] = ':';
temp_str[5] = ' ';
temp_str[6] = ' ';
temp_str[7] = ' ';
temp_str[8] = ' ';
temp_str[9] = ' ';
temp_str[10] = ' ';
int i=5; int i=5;
bool startedOutput = false; bool startedOutput = false;
if (temp >= 100 || startedOutput) { if (temp >= 100 || startedOutput)
temp_str[i] = (temp / 100) + '0'; {
i++; temp_str[i] = (temp / 100) + '0';
startedOutput = true; i++;
} startedOutput = true;
temp %= 100; }
temp %= 100;
if (temp >= 10 || startedOutput) { if (temp >= 10 || startedOutput)
temp_str[i] = (temp / 10) + '0'; {
startedOutput = true; temp_str[i] = (temp / 10) + '0';
i++; startedOutput = true;
} i++;
temp_str[i] = temp%10 + '0'; }
i++; temp_str[i] = temp%10 + '0';
i++;
SSD1306_Puts(temp_str, &Font_11x18, SSD1306_COLOR_WHITE); SSD1306_Puts(temp_str, &Font_11x18, SSD1306_COLOR_WHITE);
OldeqepTemperature = eqepTemperature; OldeqepTemperature = eqepTemperature;
SSD1306_UpdateScreen();
SSD1306_UpdateScreen();
}
} }

View File

@ -3,7 +3,7 @@
// //
// Defines // Defines
// //
typedef unsigned char uint8_t; //typedef unsigned char uint8_t;
#define I2C_SLAVE_ADDRESS 0x3C #define I2C_SLAVE_ADDRESS 0x3C
#define MAX_BUFFER_SIZE 0x10 #define MAX_BUFFER_SIZE 0x10

View File

@ -27,6 +27,8 @@
#include "rele.h" #include "rele.h"
#include "i2c_oled.h" #include "i2c_oled.h"
#include "timersec.h" #include "timersec.h"
#include "uart_4Mbit.h"
#include "buttons.h"
extern uint16_t I2C_TXdata[]; extern uint16_t I2C_TXdata[];
extern uint16_t I2C_RXdata[]; extern uint16_t I2C_RXdata[];
@ -88,7 +90,11 @@ void InitPerif(void)
vectorInitCurrLoop(); vectorInitCurrLoop();
#ifdef FREEMASTER
FRMUartInit(); FRMUartInit();
#else
UartInit();
#endif
ADCConfigure(); ADCConfigure();

View File

@ -20,7 +20,7 @@
#include "biss.h" #include "biss.h"
#include "temperature.h" #include "temperature.h"
#include "rele.h" #include "rele.h"
#include "SyncPWMFonRun.h"
typedef struct { typedef struct {
@ -196,7 +196,7 @@ void vectorControl(int16_t CurrentA, int16_t CurrentB, int16_t CurrentC, int16_t
vector_inversion(); vector_inversion();
saveTimingNow(3); saveTimingNow(3);
BissStartSet(); BissStartSet();
FMSTREnableSet(); SynchPWMFonRunEnableSet();
AdcStartSet(); AdcStartSet();
sdfm_start_conversion_brake(); sdfm_start_conversion_brake();
saveTimingNow(4); saveTimingNow(4);

View File

@ -1,17 +1,16 @@
<?xml version="1.0" encoding="UTF-8" standalone="no"?> <?xml version="1.0" encoding="UTF-8" standalone="no"?>
<configurations XML_version="1.2" id="configurations_0"> <configurations XML_version="1.2" id="configurations_0">
<configuration XML_version="1.2" id="Texas Instruments XDS100v2 USB Debug Probe_0">
<configuration XML_version="1.2" id="Texas Instruments XDS2xx USB Debug Probe_0"> <instance XML_version="1.2" desc="Texas Instruments XDS100v2 USB Debug Probe_0" href="connections/TIXDS100v2_Connection.xml" id="Texas Instruments XDS100v2 USB Debug Probe_0" xml="TIXDS100v2_Connection.xml" xmlpath="connections"/>
<instance XML_version="1.2" desc="Texas Instruments XDS2xx USB Debug Probe_0" href="connections/TIXDS2XXUSB_Connection.xml" id="Texas Instruments XDS2xx USB Debug Probe_0" xml="TIXDS2XXUSB_Connection.xml" xmlpath="connections"/> <connection XML_version="1.2" id="Texas Instruments XDS100v2 USB Debug Probe_0">
<connection XML_version="1.2" id="Texas Instruments XDS2xx USB Debug Probe_0"> <instance XML_version="1.2" href="drivers/tixds100v2icepick_c.xml" id="drivers" xml="tixds100v2icepick_c.xml" xmlpath="drivers"/>
<instance XML_version="1.2" href="drivers/tixds560icepick_c.xml" id="drivers" xml="tixds560icepick_c.xml" xmlpath="drivers"/> <instance XML_version="1.2" href="drivers/tixds100v2c28x.xml" id="drivers" xml="tixds100v2c28x.xml" xmlpath="drivers"/>
<instance XML_version="1.2" href="drivers/tixds560c28x.xml" id="drivers" xml="tixds560c28x.xml" xmlpath="drivers"/> <instance XML_version="1.2" href="drivers/tixds100v2cla2.xml" id="drivers" xml="tixds100v2cla2.xml" xmlpath="drivers"/>
<instance XML_version="1.2" href="drivers/tixds560cla2.xml" id="drivers" xml="tixds560cla2.xml" xmlpath="drivers"/> <instance XML_version="1.2" href="drivers/tixds100v2cs_child.xml" id="drivers" xml="tixds100v2cs_child.xml" xmlpath="drivers"/>
<instance XML_version="1.2" href="drivers/tixds560cs_child.xml" id="drivers" xml="tixds560cs_child.xml" xmlpath="drivers"/> <instance XML_version="1.2" href="drivers/tixds100v2cs_dap.xml" id="drivers" xml="tixds100v2cs_dap.xml" xmlpath="drivers"/>
<instance XML_version="1.2" href="drivers/tixds560cs_dap.xml" id="drivers" xml="tixds560cs_dap.xml" xmlpath="drivers"/> <instance XML_version="1.2" href="drivers/tixds100v2cortexM.xml" id="drivers" xml="tixds100v2cortexM.xml" xmlpath="drivers"/>
<instance XML_version="1.2" href="drivers/tixds560cortexM.xml" id="drivers" xml="tixds560cortexM.xml" xmlpath="drivers"/> <instance XML_version="1.2" href="drivers/tixds510ajsm.xml" id="drivers" xml="tixds510ajsm.xml" xmlpath="drivers"/>
<instance XML_version="1.2" href="drivers/tixds560ajsm.xml" id="drivers" xml="tixds560ajsm.xml" xmlpath="drivers"/>
<platform XML_version="1.2" id="platform_0"> <platform XML_version="1.2" id="platform_0">
<instance XML_version="1.2" desc="TMS320F28388D_0" href="devices/f28388d.xml" id="TMS320F28388D_0" xml="f28388d.xml" xmlpath="devices"/> <instance XML_version="1.2" desc="TMS320F28388D_0" href="devices/f28388d.xml" id="TMS320F28388D_0" xml="f28388d.xml" xmlpath="devices"/>
<device HW_revision="1" XML_version="1.2" description="" id="TMS320F28388D_0" partnum="TMS320F28388D"> <device HW_revision="1" XML_version="1.2" description="" id="TMS320F28388D_0" partnum="TMS320F28388D">