Начало

This commit is contained in:
2024-05-08 18:09:27 +03:00
parent 37d9a3d979
commit 2c4f7289bc
301 changed files with 78330 additions and 0 deletions

View File

@@ -0,0 +1,6 @@
extern int MAY;
extern Uint16 ADC_table[];
void setup_adc(void);

View File

@@ -0,0 +1,194 @@
#define COMM_gpio00_dir 0UL
#define COMM_gpio01_dir 0UL
#define COMM_gpio02_dir 0UL
#define COMM_gpio03_dir 0UL
#define COMM_gpio04_dir 0UL
#define COMM_gpio05_dir 0UL
#define COMM_gpio06_dir 0UL
#define COMM_gpio07_dir 0UL
#define COMM_gpio08_dir 0UL
#define COMM_gpio09_dir 0UL
#define COMM_gpio10_dir 0UL
#define COMM_gpio11_dir 0UL
#define COMM_gpio19_dir 1UL // 63 — SPI
#define COMM_gpio20_dir 0UL // 64 2:9B mode 2
#define COMM_gpio21_dir 0UL // 65 2:9A mode 4
#define COMM_gpio22_dir 0UL // 66 2:12C mode 1
#define COMM_gpio23_dir 0UL // 67 2:12B control -24V
#define COMM_gpio24_dir 0UL
#define COMM_gpio25_dir 0UL
#define COMM_gpio26_dir 0UL // 72 2:11B control +24V
#define COMM_gpio27_dir 0UL
#define COMM_gpio32_dir 1UL // 74 2:10B SDA
#define COMM_gpio33_dir 1UL // 75 2:10C SCL
#define COMM_gpio34_dir 1UL // 142 — SCI
#define COMM_gpio48_dir 1UL // 88 2:14C DIOD red
#define COMM_gpio49_dir 1UL // 89 2:14B ts2 red
#define COMM_gpio50_dir 0UL
#define COMM_gpio51_dir 0UL // 91 2:13C mode !8
#define COMM_gpio52_dir 1UL // 94 2:13B ts1 green
#define COMM_gpio53_dir 0UL
#define COMM_gpio58_dir 1UL // 100 1:13C led term
#define COMM_gpio59_dir 1UL // 110 1:13B gotov
#define COMM_gpio60_dir 1UL // 111 1:13A led job
#define COMM_gpio61_dir 0UL
#define COMM_gpio62_dir 1UL // 113 1:14B alarm
#define COMM_gpio63_dir 1UL // 114 1:14A rez out
//===========================================================================
#define VEPP_gpio00_dir 0UL // 5 2:7A input
#define VEPP_gpio01_dir 0UL // 6 2:4A input
#define VEPP_gpio02_dir 0UL // 7 2:7B input
#define VEPP_gpio03_dir 0UL // 10 2:4B input
#define VEPP_gpio04_dir 0UL // 11 2:7C input
#define VEPP_gpio05_dir 0UL // 12 2:4C input
#define VEPP_gpio06_dir 0UL // 13 2:6A input
#define VEPP_gpio07_dir 0UL // 16 2:3A input
#define VEPP_gpio08_dir 0UL // 17 2:6B input
#define VEPP_gpio09_dir 0UL // 18 2:3B input
#define VEPP_gpio10_dir 0UL // 19 2:6C input
#define VEPP_gpio11_dir 0UL // 20 2:3C input
#define VEPP_gpio19_dir 1UL // 63 — SPI
#define VEPP_gpio20_dir 0UL // 64 2:9B mode 2
#define VEPP_gpio21_dir 0UL // 65 2:9A mode 4
#define VEPP_gpio22_dir 0UL // 66 2:12C mode 1
#define VEPP_gpio23_dir 0UL // 67 2:12B input
#define VEPP_gpio24_dir 0UL // 68 2:12A input
#define VEPP_gpio25_dir 0UL // 69 2:11C input
#define VEPP_gpio26_dir 0UL // 72 2:11B input
#define VEPP_gpio27_dir 0UL // 73 2:11A input
#define VEPP_gpio32_dir 0UL // 74 2:10B input
#define VEPP_gpio33_dir 0UL // 75 2:10C input
#define VEPP_gpio34_dir 1UL // 142 — SCI
#define VEPP_gpio48_dir 1UL // 88 2:14C DIOD red
#define VEPP_gpio49_dir 0UL // 89 2:14B input
#define VEPP_gpio50_dir 0UL // 90 2:14A input
#define VEPP_gpio51_dir 0UL // 91 2:13C mode !8
#define VEPP_gpio52_dir 0UL // 94 2:13B input
#define VEPP_gpio53_dir 0UL // 95 2:13A input
#define VEPP_gpio58_dir 0UL // 100 1:13C input
#define VEPP_gpio59_dir 0UL
#define VEPP_gpio60_dir 1UL // 111 1:13A gotov
#define VEPP_gpio61_dir 0UL // 112 1:14C input
#define VEPP_gpio62_dir 1UL // 113 1:14C rezout
#define VEPP_gpio63_dir 1UL // 114 1:14A ledjob
//===========================================================================
#define ISOL_gpio00_dir 0UL // 5 2:7A
#define ISOL_gpio01_dir 0UL // 6 2:4A
#define ISOL_gpio02_dir 0UL // 7 2:7B
#define ISOL_gpio03_dir 0UL // 10 2:4B
#define ISOL_gpio04_dir 0UL // 11 2:7C
#define ISOL_gpio05_dir 0UL // 12 2:4C
#define ISOL_gpio06_dir 0UL // 13 2:6A
#define ISOL_gpio07_dir 0UL // 16 2:3A
#define ISOL_gpio08_dir 0UL // 17 2:6B
#define ISOL_gpio09_dir 0UL // 18 2:3B
#define ISOL_gpio10_dir 0UL // 19 2:6C
#define ISOL_gpio11_dir 0UL // 20 2:3C
#define ISOL_gpio19_dir 1UL // 63 — SPI
#define ISOL_gpio20_dir 0UL // 64 2:9B mode 2
#define ISOL_gpio21_dir 0UL // 65 2:9A mode 4
#define ISOL_gpio22_dir 0UL // 66 2:12C mode 1
#define ISOL_gpio23_dir 0UL // 67 2:12B opt input 1
#define ISOL_gpio24_dir 1UL // 68 2:12A led 2
#define ISOL_gpio25_dir 0UL // 69 2:11C
#define ISOL_gpio26_dir 1UL // 72 2:11B opt out 2
#define ISOL_gpio27_dir 1UL // 73 2:11A led 1
#define ISOL_gpio32_dir 1UL // 74 2:10B opt out 1
#define ISOL_gpio33_dir 0UL // 75 2:10C
#define ISOL_gpio34_dir 1UL // 142 — SCI
#define ISOL_gpio48_dir 1UL // 88 2:14C DIOD red
#define ISOL_gpio49_dir 0UL // 89 2:14B
#define ISOL_gpio50_dir 0UL // 90 2:14A
#define ISOL_gpio51_dir 0UL // 91 2:13C mode !8
#define ISOL_gpio52_dir 0UL // 94 2:13B opt input 2
#define ISOL_gpio53_dir 1UL // 95 2:13A led 3
#define ISOL_gpio58_dir 0UL // 100 1:13C
#define ISOL_gpio59_dir 1UL // 110 1:13B gotov
#define ISOL_gpio60_dir 0UL // 111 1:13A
#define ISOL_gpio61_dir 0UL // 112 1:14C
#define ISOL_gpio62_dir 0UL // 113 1:14C input
#define ISOL_gpio63_dir 0UL // 114 1:14A
//===========================================================================
//===========================================================================
#define COMM_GPADIR (COMM_gpio00_dir ) + (COMM_gpio01_dir<<1) + (COMM_gpio02_dir<<2) + (COMM_gpio03_dir<<3) + \
(COMM_gpio04_dir<<4) + (COMM_gpio05_dir<<5) + (COMM_gpio06_dir<<6) + (COMM_gpio07_dir<<7) + \
(COMM_gpio08_dir<<8) + (COMM_gpio09_dir<<9) + (COMM_gpio10_dir<<10)+ (COMM_gpio11_dir<<11)+ \
(COMM_gpio19_dir<<19)+ \
(COMM_gpio20_dir<<20)+ (COMM_gpio21_dir<<21)+ (COMM_gpio22_dir<<22)+ (COMM_gpio23_dir<<23)+ \
(COMM_gpio24_dir<<24)+ (COMM_gpio25_dir<<25)+ (COMM_gpio26_dir<<26)+ (COMM_gpio27_dir<<27);
#define COMM_GPBDIR (COMM_gpio32_dir )+ (COMM_gpio33_dir<<1) + (COMM_gpio34_dir<<2 )+ \
(COMM_gpio48_dir<<16)+ (COMM_gpio49_dir<<17)+ (COMM_gpio50_dir<<18)+ (COMM_gpio51_dir<<19)+ \
(COMM_gpio52_dir<<20)+ (COMM_gpio53_dir<<21)+ \
(COMM_gpio58_dir<<26)+ (COMM_gpio59_dir<<27)+ \
(COMM_gpio60_dir<<28)+ (COMM_gpio61_dir<<29)+ (COMM_gpio62_dir<<30)+ (COMM_gpio63_dir<<31);
#define BKSD_GPADIR (BKSD_gpio00_dir ) + (BKSD_gpio01_dir<<1) + (BKSD_gpio02_dir<<2) + (BKSD_gpio03_dir<<3) + \
(BKSD_gpio04_dir<<4) + (BKSD_gpio05_dir<<5) + (BKSD_gpio06_dir<<6) + (BKSD_gpio07_dir<<7) + \
(BKSD_gpio08_dir<<8) + (BKSD_gpio09_dir<<9) + (BKSD_gpio10_dir<<10)+ (BKSD_gpio11_dir<<11)+ \
(BKSD_gpio19_dir<<19)+ \
(BKSD_gpio20_dir<<20)+ (BKSD_gpio21_dir<<21)+ (BKSD_gpio22_dir<<22)+ (BKSD_gpio23_dir<<23)+ \
(BKSD_gpio24_dir<<24)+ (BKSD_gpio25_dir<<25)+ (BKSD_gpio26_dir<<26)+ (BKSD_gpio27_dir<<27);
#define BKSD_GPBDIR (BKSD_gpio32_dir )+ (BKSD_gpio33_dir<<1) + (BKSD_gpio34_dir<<2 )+ \
(BKSD_gpio48_dir<<16)+ (BKSD_gpio49_dir<<17)+ (BKSD_gpio50_dir<<18)+ (BKSD_gpio51_dir<<19)+ \
(BKSD_gpio52_dir<<20)+ (BKSD_gpio53_dir<<21)+ \
(BKSD_gpio58_dir<<26)+ (BKSD_gpio59_dir<<27)+ \
(BKSD_gpio60_dir<<28)+ (BKSD_gpio61_dir<<29)+ (BKSD_gpio62_dir<<30)+ (BKSD_gpio63_dir<<31);
#define PULT_GPADIR (PULT_gpio00_dir ) + (PULT_gpio01_dir<<1) + (PULT_gpio02_dir<<2) + (PULT_gpio03_dir<<3) + \
(PULT_gpio04_dir<<4) + (PULT_gpio05_dir<<5) + (PULT_gpio06_dir<<6) + (PULT_gpio07_dir<<7) + \
(PULT_gpio08_dir<<8) + (PULT_gpio09_dir<<9) + (PULT_gpio10_dir<<10)+ (PULT_gpio11_dir<<11)+ \
(PULT_gpio19_dir<<19)+ \
(PULT_gpio20_dir<<20)+ (PULT_gpio21_dir<<21)+ (PULT_gpio22_dir<<22)+ (PULT_gpio23_dir<<23)+ \
(PULT_gpio24_dir<<24)+ (PULT_gpio25_dir<<25)+ (PULT_gpio26_dir<<26)+ (PULT_gpio27_dir<<27);
#define PULT_GPBDIR (PULT_gpio32_dir )+ (PULT_gpio33_dir<<1) + (PULT_gpio34_dir<<2 )+ \
(PULT_gpio48_dir<<16)+ (PULT_gpio49_dir<<17)+ (PULT_gpio50_dir<<18)+ (PULT_gpio51_dir<<19)+ \
(PULT_gpio52_dir<<20)+ (PULT_gpio53_dir<<21)+ \
(PULT_gpio58_dir<<26)+ (PULT_gpio59_dir<<27)+ \
(PULT_gpio60_dir<<28)+ (PULT_gpio61_dir<<29)+ (PULT_gpio62_dir<<30)+ (PULT_gpio63_dir<<31);
#define VEPP_GPADIR (VEPP_gpio00_dir ) + (VEPP_gpio01_dir<<1) + (VEPP_gpio02_dir<<2) + (VEPP_gpio03_dir<<3) + \
(VEPP_gpio04_dir<<4) + (VEPP_gpio05_dir<<5) + (VEPP_gpio06_dir<<6) + (VEPP_gpio07_dir<<7) + \
(VEPP_gpio08_dir<<8) + (VEPP_gpio09_dir<<9) + (VEPP_gpio10_dir<<10)+ (VEPP_gpio11_dir<<11)+ \
(VEPP_gpio19_dir<<19)+ \
(VEPP_gpio20_dir<<20)+ (VEPP_gpio21_dir<<21)+ (VEPP_gpio22_dir<<22)+ (VEPP_gpio23_dir<<23)+ \
(VEPP_gpio24_dir<<24)+ (VEPP_gpio25_dir<<25)+ (VEPP_gpio26_dir<<26)+ (VEPP_gpio27_dir<<27);
#define VEPP_GPBDIR (VEPP_gpio32_dir )+ (VEPP_gpio33_dir<<1) + (VEPP_gpio34_dir<<2 )+ \
(VEPP_gpio48_dir<<16)+ (VEPP_gpio49_dir<<17)+ (VEPP_gpio50_dir<<18)+ (VEPP_gpio51_dir<<19)+ \
(VEPP_gpio52_dir<<20)+ (VEPP_gpio53_dir<<21)+ \
(VEPP_gpio58_dir<<26)+ (VEPP_gpio59_dir<<27)+ \
(VEPP_gpio60_dir<<28)+ (VEPP_gpio61_dir<<29)+ (VEPP_gpio62_dir<<30)+ (VEPP_gpio63_dir<<31);
#define ISOL_GPADIR (ISOL_gpio00_dir ) + (ISOL_gpio01_dir<<1) + (ISOL_gpio02_dir<<2) + (ISOL_gpio03_dir<<3) + \
(ISOL_gpio04_dir<<4) + (ISOL_gpio05_dir<<5) + (ISOL_gpio06_dir<<6) + (ISOL_gpio07_dir<<7) + \
(ISOL_gpio08_dir<<8) + (ISOL_gpio09_dir<<9) + (ISOL_gpio10_dir<<10)+ (ISOL_gpio11_dir<<11)+ \
(ISOL_gpio19_dir<<19)+ \
(ISOL_gpio20_dir<<20)+ (ISOL_gpio21_dir<<21)+ (ISOL_gpio22_dir<<22)+ (ISOL_gpio23_dir<<23)+ \
(ISOL_gpio24_dir<<24)+ (ISOL_gpio25_dir<<25)+ (ISOL_gpio26_dir<<26)+ (ISOL_gpio27_dir<<27);
#define ISOL_GPBDIR (ISOL_gpio32_dir )+ (ISOL_gpio33_dir<<1) + (ISOL_gpio34_dir<<2 )+ \
(ISOL_gpio48_dir<<16)+ (ISOL_gpio49_dir<<17)+ (ISOL_gpio50_dir<<18)+ (ISOL_gpio51_dir<<19)+ \
(ISOL_gpio52_dir<<20)+ (ISOL_gpio53_dir<<21)+ \
(ISOL_gpio58_dir<<26)+ (ISOL_gpio59_dir<<27)+ \
(ISOL_gpio60_dir<<28)+ (ISOL_gpio61_dir<<29)+ (ISOL_gpio62_dir<<30)+ (ISOL_gpio63_dir<<31);
//===========================================================================
// No more.
//===========================================================================

View File

@@ -0,0 +1,138 @@
/****************************************************************/
/* TMS320C32 */
/* ====== BIOS, ÊËÀÈÍ, ÊËÂÑÏ ====== */
/* ÖÍÈÈ ÑÝÒ (ñ) 1998-2000 ã. */
/****************************************************************
RS485.h
****************************************************************
* Ïðîöåäóðû ðàáîòû ñ UART *
****************************************************************/
#ifndef _RS485
#define _RS485
#ifdef __cplusplus
extern "C" {
#endif
//#include "DSP2833x_Device.h" // DSP281x Headerfile Include File
//#include "DSP2833x_Sci.h"
//#include "cntrl_adr.h"
//#include "params.h"
#define COM_1 1
#define COM_2 2
#define MAX_RECEIVE_LENGTH 400 // 80 //150
#define MAX_SEND_LENGTH 400 //150
#define TIME_WAIT_RS_BYTE_OUT 1000
#define TIME_WAIT_RS_LOST_BYTE 100
#define RS_TIME_OUT (SECOND*10)
#define Rec_Bloc_Begin 0x200000
#define Rec_Bloc_End 0x2F0000
#define Rec_Bloc_Length (Rec_Bloc_End-Rec_Bloc_Begin)
/* Message RS declaration */
typedef struct
{
volatile struct SCI_REGS *SciRegs;
unsigned int commnumber; // Íîìåð ïîðòà
unsigned long RS_Length; // Äëèíà ïàêåòà
unsigned int *pRS_RecvPtr; // Áóôåð ïðèåìà
unsigned int *pRS_SendPtr; // Áóôåð ïîñûëêè
unsigned int *pRecvPtr;
unsigned int RS_PrevCmd; // Ïðåäûäóùàà êîììàíäà
unsigned int RS_Cmd; // Òåêóùàà êîììàíäà
unsigned int RS_Header[MAX_RECEIVE_LENGTH]; // Çàãîëîâîê
unsigned int flag_TIMEOUT_to_Send; // Ôëàã îæèäàíèà òàéìàóòà íà îòñûëêó
unsigned int flag_TIMEOUT_to_Receive; // Ôëàã îæèäàíèà òàéìàóòà íà ïðèåì
unsigned int RS_DataReady; // Ôëàã ãîòîâíîñòè RS äàííûõ
unsigned int buffer[MAX_SEND_LENGTH]; // Áóôåð äëà îòñûëêè ïî RS
unsigned int addr_answer; // àäðåñ êóäà îòâå÷àòü â ðåæèìå âåäóùåãî
unsigned int addr_recive; // àäðåñ ïî êîòîðîìó íàñ çàïðîñèëè
unsigned int flag_LEADING; // Ôëàã ðåæèìà êîíòðîëëåðà (ïî óìîë÷àíèþ âåäîìûé)
unsigned long RS_RecvLen;
unsigned long RS_SLength; // Äëèíà ïàêåòà äëà ïîñûëêè
unsigned long RS_SendLen; // Êîëè÷åñòâî áàéò óæå ïåðåäàëè
char RS_SendBlockMode; // Ðåæèì ïåðåäà÷è
char RS_Flag9bit; // äëà RS485????????
int BS_LoadOK; // Ôëàã óñïåøíîñòè ïðèåìà áëîêà
int RS_FlagBegin;
int RS_HeaderCnt;
int RS_FlagSkiping;
unsigned long curr_baud;
unsigned long time_wait_rs_out;
} RS_DATA;
extern RS_DATA rs_a,rs_b;
extern unsigned int
RS_Len[70]; /* Äåéñòâèòåëüíàà äëèíà êîìàíäû (îòëàäî÷íîé) + 1 */
interrupt void RSA_RX_Handler(void);
interrupt void RSA_TX_Handler(void);
interrupt void RSB_RX_Handler(void);
interrupt void RSB_TX_Handler(void);
/* èíèöèëèçàöèà ïåðåìåííûõ rs_a,rs_b*/
void create_uart_vars(char size_cmd15);
/** Ïîâòîðíàà èíèöèàëèçàöèà ïîñëåäîâàòåëüíîãî ïîðòà, èñïîëüçóåòñà ïîñëå ïîäâèñà */
/** Íàñòðîéêà ðåæèìà ïðèåìà/ïåðåäà÷è */
void RS_SetBitMode(RS_DATA *rs_arr, int n);
/** Ïîñûëêà áëîêà áàéòîâ.
Ïîñûëàåò ìàññèâà 32-áèòíûõ öåëûõ ÷èñåë ñòàðøèå áèòû äîëæíû áûòü 0.
@precondition Ðàáîòà ô-öèè çàâèñèò îò ìàêðî RS_TRANSMIT_INTR
@param buf àäðåñ ìàññèâà
@param len êîëè÷åñòâî áàéò
@see RS_BSend, RS_TRANSMIT_INTR
*/
int RS_Send(RS_DATA *rs_arr,unsigned int *pBuf, unsigned long len);
/** Ïîñûëêà áëîêà óïàêîâàííûõ áàéòîâ.
@precondition Ðàáîòà ô-öèè çàâèñèò îò ìàêðî RS_TRANSMIT_INTR
@param buf àäðåñ ìàññèâà
@param len êîëè÷åñòâî 8-áèòíûõ áàéò
@see RS_Send, RS_TRANSMIT_INTR
*/
int RS_BSend(RS_DATA *rs_arr,unsigned int *pBuf, unsigned long len);
/** Èíèöèàëèçàöèà ïîñëåäîâàòåëüíîãî ïîðòà */
void setup_uart(char commnumber,unsigned long speed_baud); /* speed_baud - ñêîðîñòü ëèíèè â áîäàõ */
void RS_SetLineMode(RS_DATA *rs_arr, int bit, char parity, int stop);
void RS_SetLineSpeed(RS_DATA *rs_arr, unsigned long speed);
// Transmit a character from the SCI'
#define SCI_send(x,y) x->SciRegs->SCITXBUF=(unsigned char)(y)
// Îæèäàíèå çàâåðøåíèà ïåðåäà÷è UART
// wait for TRDY =1 for empty state
#define RS_Wait4OK(x) while(!(x->SciRegs->SCICTL2.bit.TXEMPTY))
/** Ïåðåêëþ÷åíèå ëèíèè íà ïðèåì */
#define RS_Line_to_receive(x) if(x->commnumber==COM_2) GpioDataRegs.GPBDAT.bit.GPIO34 = 1;
/** Ïåðåêëþ÷åíèå ëèíèè íà ïåðåäà÷ó */
#define RS_Line_to_send(x) if(x->commnumber==COM_2) GpioDataRegs.GPBDAT.bit.GPIO34 = 0;
/** Ðàçðåøåíèå ïðåðûâàíèé ïî ïîëó÷åíèþ ñèìâîëà è îøèáêàì îò UART */
#define enableUARTInt(x) x->SciRegs->SCICTL2.all=2
#define enableUARTIntW(x) x->SciRegs->SCICTL2.all=1
void clear_timer_rs_live(RS_DATA *rs_arr);
void test_rs_live(RS_DATA *rs_arr);
#ifdef __cplusplus
}
#endif
#endif /* _RS485 */

View File

@@ -0,0 +1,85 @@
/****************************************************************/
/* TMS320C32 */
/* ====== BIOS, ÊËÀÈÍ, ÊËÂÑÏ ====== */
/* ÖÍÈÈ ÑÝÒ (ñ) 1998-2000 ã. */
/****************************************************************/
/* Bios_dsp.h */
/****************************************************************/
/* Îñíîâíûå êîììàíäû BIOS */
/****************************************************************/
#ifndef _BIOS_DSP
#define _BIOS_DSP
#ifdef __cplusplus
extern "C" {
#endif
#define BM_PACKED 1
#define BM_CHAR32 0
#define CHIEF 1
#define SLAVE 0
#define ADR_FOR_SPECIAL 0x100
#define CMD_MODBUS_3 3
#define ANS_MODBUS_3 4
#define CMD_MODBUS_15 5
#define CMD_MODBUS_6 6
#define ANS_MODBUS_6 7
#define CMD_MODBUS_16 16
/*
CMD_MODBUS_3 = 3,
ANS_MODBUS_3 = 4,
CMD_MODBUS_15 = 5,
CMD_MODBUS_6 = 6,
ANS_MODBUS_6 = 7,
CMD_MODBUS_16 = 16,
*/
enum {
CMD_LOAD=51, CMD_UPLOAD, CMD_RUN, CMD_XFLASH, CMD_TFLASH,
CMD_PEEK, CMD_POKE, CMD_INITLOAD, CMD_INIT,CMD_EXTEND,
CMD_VECTOR=61,
CMD_IMPULSE,
/* ñòàíäàðòíûå êîìàíäû */
CMD_STD=65, CMD_STD_ANS
};
enum {false=0, true};
/** Âîçâðàùàåò íîìåð êîììàíäû, åñëè åñòü èëè -1 åñëè òðàíçàêöèé íå áûëî */
int get_command(RS_DATA *rs_arr);
/** Ñòàíäàðòíûé îòâåò, áåç ïàðàìåòðîâ */
void Answer(RS_DATA *rs_arr,int n);
/** Èíèöèèðîâàòü çàãðóçêó áëîêà.
Íàñòðàèâàåò ïðèåì áëîêà äàííûõ */
void initload(RS_DATA *rs_arr);
/** Çàãðóçêà áëîêà.
Âûçûâàåòñà ïîñëå çàãðóçêè áëîêà ÷åðåç RS */
void load(RS_DATA *rs_arr);
/** Ïðî÷èòàòü à÷åéêó ïàìàòè */
void peek(RS_DATA *rs_arr);
/** Çàïèñàòü â à÷åéêó ïàìàòè */
void poke(RS_DATA *rs_arr);
/** Ïåðåäàòü áëîê ïàìàòè */
void upload(RS_DATA *rs_arr);
/* ðàñøèðåííûå êîìàíäû äëà áèîñà */
void extendbios(RS_DATA *rs_arr);
void write_memory(unsigned long addr, unsigned int data);
unsigned int read_memory(unsigned long addr);
#ifdef __cplusplus
}
#endif
#endif/* _BIOS_DSP */

View File

@@ -0,0 +1,44 @@
/****************************************************************/
/* TMS320C32 */
/* ====== BIOS, ÊËÀÈÍ, ÊËÂÑÏ ====== */
/* ÖÍÈÈ ÑÝÒ (ñ) 1998-2000 ã. */
/****************************************************************
cntrl_adr.h
****************************************************************
* Àäðåñ êîíòðîëëåðà *
****************************************************************/
#ifndef _CNTRL_ADR
#define _CNTRL_ADR
#ifdef __cplusplus
extern "C" {
#endif
/** àäðåñ êîíòðîëëåðà äëà ïîñûëêè âñåì ÀÈÍàì */
extern int ADDR_FOR_ALL;
/** àäðåñ êîíòðîëëåðà äëà ïîñûëêè îòâåòà */
extern const int ADDR_ANSWER;
/** àäðåñà òåðìèíàëà äëà ïîñûëêè îòâåòà */
extern const int ADDR_TERMINAL;
/* Àäðåñ êîíòðîëëåðà */
extern int CNTRL_ADDR;
/* Óíèâåðñàëüíûé àäðåñ êîíòðîëëåðà */
extern const int CNTRL_ADDR_UNIVERSAL;
/** Óñòàíîâêà àäðåñà êîíòðîëëåðà äëà ïðîøèâêè */
void set_cntrl_addr (int cntrl_addr,int cntrl_addr_for_all);
extern int cntr_addr_c;
extern int cntr_addr_c_all;
#ifdef __cplusplus
}
#endif
#endif /* _CNTRL_ADR */

View File

@@ -0,0 +1,10 @@
typedef unsigned short WORD;
typedef unsigned char byte;
unsigned int get_crc_ccitt(unsigned int crc, unsigned int *buf, unsigned long size );
unsigned int get_crc_16(unsigned int crc,unsigned int *buf,unsigned long size );
unsigned int get_crc_16b(unsigned int crc,unsigned int *buf,unsigned long size );
int get_crc16(unsigned int *buf, int size );
unsigned int get_crc32(unsigned long num);

View File

@@ -0,0 +1,3 @@
void Init_Can(int Port, int DevNum);
void CAN_send(int Port, int data[], int Addr);
extern int CAN_input_data[];

View File

@@ -0,0 +1,49 @@
#ifndef _FILTER_BAT2
#define _FILTER_BAT2
#ifdef __cplusplus
extern "C" {
#endif
#define K1_FILTER_BATTER2_1HZ 0.0000096
#define K2_FILTER_BATTER2_1HZ 1.94468056
#define K3_FILTER_BATTER2_1HZ -0.94471895
#define K1_FILTER_BATTER2_3HZ 0.00008766
#define K2_FILTER_BATTER2_3HZ 1.97347532
#define K3_FILTER_BATTER2_3HZ -0.97382594
#define K1_FILTER_BATTER2_5HZ 0.00024135
#define K2_FILTER_BATTER2_5HZ 1.95581276
#define K3_FILTER_BATTER2_5HZ -0.95677816
#define K1_FILTER_BATTER2_10HZ 0.00094411
#define K2_FILTER_BATTER2_10HZ 1.91126422
#define K3_FILTER_BATTER2_10HZ -0.91504065
typedef struct { float k_0;
float k_1;
float k_2;
float i_0;
float i_1;
float i_2;
float u_0;
float u_1;
float u_2;
} FILTERBAT;
#define DEF_FILTERBAT { K1_FILTER_BATTER2_5HZ, \
K2_FILTER_BATTER2_5HZ, \
K3_FILTER_BATTER2_5HZ, \
0,0,0,0,0,0}
float filterbat(FILTERBAT *b, float InpVarCurr);
#ifdef __cplusplus
}
#endif
#endif /* _FILTER_BAT2 */

View File

@@ -0,0 +1,4 @@
void I2CA_Init(void);
Uint16 I2CA_WriteData(unsigned int Addr, int Data);
int I2CA_ReadData(unsigned int Addr);
void I2CA_ReadBlock(unsigned int Addr, unsigned int * Destino, int Cuant);

View File

@@ -0,0 +1,49 @@
/****************************************************************/
/* TMS320C32 */
/* ====== BIOS, ÊËÀÈÍ, ÊËÂÑÏ ====== */
/* ÖÍÈÈ ÑÝÒ (ñ) 1998-2001ã. */
/****************************************************************/
/* log_to_mem.h
****************************************************************
* Çàïèñü ëîãîâ â ïàìyòü *
****************************************************************/
#ifndef _LOG_TO_MEM
#define _LOG_TO_MEM
#ifdef __cplusplus
extern "C" {
#endif
/* Îïðåäåëåíèa äëa ðàáîòû ëîããåðà */
#define LOG_PAGE_START 0x0200000
#define LOG_PAGE_LEN 0xFA00
extern int no_write, never_write; // Ôëàãè, ÷òîáû íå ïèñàòü (åñëè ÷òî)
extern int Read_Log; // ôëàã, ÷òî ìû ÷èòàåì
typedef struct
{
unsigned long Start;
unsigned long Finis;
unsigned long Adres;
unsigned int Circl;
} LOG;
extern LOG Log;
/* Çàïèñü ñëîâa â ïàìàòü, ãäå ëîãè ëåæàò */
#define Log_to_mem(x) *(int *)(Log.Adres++) = x
/* Ïðîâåðêà ãðàíèöû ïàìàòè äëà ëîãîâ */
#define Test_mem_limit(x) if(Log.Adres > (Log.Finis - (x))) Log.Adres = Log.Start
/* Î÷èñòêà ïàìàòè (îáíóëåíèå) */
void clear_mem();
#ifdef __cplusplus
}
#endif
#endif /* _LOG_TO_MEM */

View File

@@ -0,0 +1,105 @@
// âãâ
#ifndef _MEASURE
#define _MEASURE
interrupt void cpu_timer1_isr_SENS(void);
void Init_sensors(void);
void Init_optic(void);
void Init_packMask(void);
void Temper_count(int chan);
void Current_count(int chan);
void Power_count(int chan);
typedef union
{
struct
{
unsigned int Tear :1;
unsigned int Stick :1;
unsigned int Wry :1;
unsigned int Out :1;
unsigned int Over :1;
unsigned int Hyper :1;
unsigned int Contr1 :1;
unsigned int Contr2 :1;
unsigned int Stop :1;
unsigned int Ready :1;
unsigned int res :3;
unsigned int Latch :1;
unsigned int Ignor :1;
unsigned int Bypas :1;
} bit;
unsigned int all;
} ERROR;
typedef union
{
struct
{
unsigned int Error :1;
unsigned int Alarm :1;
unsigned int OverHeat :1;
unsigned int SubHeat :1;
unsigned int OutHeat :1;
unsigned int Test_lamp :1;
} bit;
unsigned int all;
} FLAG;
#define NOER 0xE000
#define EROR 0x01FF
#define READY_FREQ 1000 // Ãö
#define BLINK_FREQ 2 // Ãö
#define ADC_FREQ 3000//3125 //3750//5000//3885//777//2000//20000 //777 //3885 // Ãö (777*5)
#define DAC_FREQ 50 // Ãö
#define LOAD_TIME 10 // sec
#define CANPOWSE ((READY_FREQ * 2) / 100) // 10 ms
#define SENS_ERR_WAIT 10
#define maximum_bright 10
//#define ZERO 27
#define Cooling 5 // (°Ñ) Ãèñòåðåçèñ ïî ñíàòèþ ïåðåãðåâà
#define COSPi6 0.86602540378443864676372317075294
#define RADIX2 1.4142135623730950488016887242097
#define CURRENT 1 // òîê
#define VOLTAGE 2 // íàïðàæåíèå
#define TERMO_AD 3 // òåðìîäàò÷èê ìåëêîñõåìà
#define TERMO_RS 4 // òåðìîäàò÷èê ðåçèñòîð
extern int MAX_TPL_CANAL;
extern FILTERBAT filter[];
extern ERROR * sens_error;
extern int * sens_data;
extern int * sens_hi_edge;
extern int * sens_lo_edge;
extern int adc0[],tmp0[];
extern float tmpK[];
extern FLAG chk,sig;
extern int sens_type[];
extern float zer_count[];
extern int period_ready;
extern unsigned int CanPowse,CanGO;
extern unsigned int Maska[][8];
#endif //_MEASURE

View File

@@ -0,0 +1,46 @@
#ifndef MESSAGE_H
#define MESSAGE_H
typedef unsigned char CHAR;
#define ANSWER_LEN 0x80 //70 // 16+16+16+16+6
#define REPLY_LEN 0x19
#define byte_hi byte_1
#define byte_lo byte_0
typedef struct
{
unsigned char Address; // Àäðåñ êîíòðîëëåðà
unsigned char Number; // Íîìåð êîìàíäû
BAITE byte0;
BAITE byte1;
BAITE byte2;
BAITE byte3;
BAITE byte4;
BAITE byte5;
BAITE byte6;
BAITE byte7;
unsigned char crc_lo;
unsigned char crc_hi;
unsigned char add_byte;
} CMD_TO_TMS;
extern WORDE* Modbus;
extern int modbus[];
extern LONGE* outputs;
extern int DataAnalog1,DataAnalog2;
void ReceiveCommandModbus3(RS_DATA *rs_arr);
void ReceiveCommandModbus6(RS_DATA *rs_arr);
void Save_params(void);
void Load_params(void);
void Load_caliber(void);
void Default_params(void);
#endif //MESSAGE_H

View File

@@ -0,0 +1,51 @@
#ifndef PACKAGE
#define PACKAGE
//#define MODUL
//-----------------------------------------------
#define adr_REC1 1
#define adr_REC2 2
#define adr_INV1 3
#define adr_INV2 4
//-----------------------------------------------
//-----------------------------------------------
#define dsk_COMM 1
//-----------------------------------------------
#define m_FAST 0
#define m_SLOW 1
#define start_sens_error 0
#define start_data 24
#define start_sens_hi_edge 48
#define start_sens_lo_edge 72
#define KeyPressed Modbus[0x17]
#define Brightness modbus[0x64] // àðêîñòü ñèãíàëüíûõ ëàìïî÷åê
#define Cancount (modbus+0x65) // ïàóçà ìåæäó I ïîñûëêàìè CAN
#define Zeroes (modbus+0x70) // íóëåâûå óðîâíè äàò÷èêîâ íàïðàæåíèà
#define LastMode modbus[126]
#define Commands Modbus[127].all
#define cTestLamp Modbus[127].bit.bit0
#define cDefParam Modbus[127].bit.bit1
#define cSaveParam Modbus[127].bit.bit2
#define cLoadParam Modbus[127].bit.bit3
#define cTermoCal Modbus[127].bit.bit4
#define cReadCal Modbus[127].bit.bit5
#define cExtLamp Modbus[127].bit.bit6
#define cExtLite Modbus[127].bit.bit7
#define cNoLog Modbus[127].bit.bit8
#define cReset Modbus[127].bit.bitF
#endif //PACKAGE

View File

@@ -0,0 +1,33 @@
#include "DSP2833x_Device.h" // DSP281x Headerfile Include File
extern int Mode,Desk,Addrr,TermoAD,TermoRS,TermoSW,Currentoz;
extern int ExtraCanal[];
void setup_leds_line(void);
#define led1_toggle() GpioDataRegs.GPBTOGGLE.bit.GPIO32=1
#define led2_toggle() GpioDataRegs.GPBTOGGLE.bit.GPIO48=1
#define led1_off() GpioDataRegs.GPBSET.bit.GPIO32=1
#define led2_off() GpioDataRegs.GPBSET.bit.GPIO48=1
#define led1_on() GpioDataRegs.GPBCLEAR.bit.GPIO32=1
#define led2_on() GpioDataRegs.GPBCLEAR.bit.GPIO48=1
// READY ---------------------------------------------------------
static inline void dat_READY(int x)
{ GpioDataRegs.GPBDAT.bit.GPIO59=!x; }
static inline void set_READY(void)
{ GpioDataRegs.GPBCLEAR.bit.GPIO59=1; }
static inline void clear_READY(void)
{ GpioDataRegs.GPBSET.bit.GPIO59=1; }
static inline void toggle_READY(void)
{ GpioDataRegs.GPBTOGGLE.bit.GPIO59=1;}
extern WORDE Inputs;
void select_tpl_canal(int n_tpl);
void get_Mode(void);
void get_Inputs(void);
#define MAX_BUTTHURT 250000

View File

@@ -0,0 +1,134 @@
/*=====================================================================
File name : SPISE2P.H
Originator : Settu Duraisamy
C2000 Applications Team
Texas Instruments
Description :
Header file containing object definitions, proto type
declaration and default object initializers for
SPI Serial EEPROM driver using VSPI
Date : 30/6/2003 (DD/MM/YYYY)
=======================================================================*/
#ifndef __SPISE2P_H__
#define __SPISE2P_H__
// ¨ìêîñòü ïàìàòè â áàéòàõ
#define SEEPROM_LEN 0x10000
#define NULL 0
#define SIXTEEN_BIT 15
#define EIGHT_BIT 07
/***************************************************************/
/* Configurable Parameter for SPI bus Serial EEPROM */
/***************************************************************/
#define SPISE2P_DATA_WIDTH SIXTEEN_BIT//EIGHT_BIT
#define SPISE2P_ADDR_WIDTH SIXTEEN_BIT
#define SPIBAUD_REG_VAL 1//12
#define SPICLK_PHASE 1
#define SPICLK_POLARITY 0
#define SPIBAUD_RATE 100000
//10000000
/**************************************************************/
/**************************************************************/
/* Serial EEPROM Command words, left justified */
#define SPISE2P_READ_CMD 0x0300
#define SPISE2P_WRITE_CMD 0x0200
#define SPISE2P_WRDI_CMD 0x0400
#define SPISE2P_WREN_CMD 0x0600
#define SPISE2P_RDSR_CMD 0x0500
#define SPISE2P_WRSR_CMD 0x0100
#define SPISE2P_RDID_CMD 0x0A00
#define SPISE2P_DUMMY_DATA 0x0000
#define SPISE2P_BUSY_MASK 0x01
/* Symbolic constant for SPICCR to transfer 8bit or 16 bit value*/
#define SPISE2P_TFR16BIT 0x80|(SPICLK_POLARITY<<6)|SIXTEEN_BIT
#define SPISE2P_TFR8BIT 0x80|(SPICLK_POLARITY<<6)|EIGHT_BIT
/* Status valus */
#define SPISE2P_WRRQ 1 /* Write Requset */
#define SPISE2P_RDRQ 2 /* Read request */
#define SPISE2P_WRIP 4 /* Write in progress */
#define SPISE2P_RDIP 8 /* Read in progress */
/* Message declaration */
typedef struct {
unsigned int *dataPtr; /* Data pointer */
unsigned long nrData; /* number of data */
unsigned long se2pAddr; /* se2pAddr */
}SE2P_DATA;
/* Object declaration */
typedef struct {
SE2P_DATA *msgPtr;
unsigned int csr; /* control/status register */
void (*init)(void *);
void (*tick)(void *);
void (*csset)(void);
void (*csclr)(void);
}SPISE2P_DRV;
#define SPISE2P_DRV_DEFAULTS { NULL,\
0,\
(void (*)(void *))SPISE2P_DRV_init,\
(void (*)(void *))SPISE2P_DRV_tick,\
(void (*)(void))SPISE2P_DRV_csset,\
(void (*)(void))SPISE2P_DRV_csclr}
typedef SPISE2P_DRV *SPISE2P_DRV_handle;
void SPISE2P_DRV_init(SPISE2P_DRV * );
void SPISE2P_DRV_tick(SPISE2P_DRV *);
void SPISE2P_DRV_csset(void);
void SPISE2P_DRV_csclr(void);
unsigned int spiSe2pFree(SPISE2P_DRV *se2p);
void spiSe2pWrite(SPISE2P_DRV *se2p, SE2P_DATA *data);
void spiSe2pRead(SPISE2P_DRV *se2p, SE2P_DATA *data);
#if(SPISE2P_DATA_WIDTH==SIXTEEN_BIT)
#define PROM_LEN 0x8000
#define PAGE_LEN 0x20
#define WORD_LEN 2
#else
#define PROM_LEN 0x4000
#define PAGE_LEN 0x40
#define WORD_LEN 1
#endif
/* Óñòàíîâêà äðàéâåðà ñåðèàëüíîé EEPROM. **
** Èíèöèàëèçàöèà SPI è ïðî÷. Òàêæå íàñòðîéêà òàéìåðà. **
** Äðàéâåð ðàáîòàåò íà ïðåðûâàíèàõ îò òàéìåðà 2! */
void InitSeeprom(void);
/* Çàïèñü áëîêà â SEEPROM. Ïàðàìåòðû òàêîâû: **
** adres - àäðåñ â åïðîìêå, êóäà ïèñàòü. **
** adres = 0..0x8000, åñëè äëèíà ñëîâà 8 áèò **
** adres = 0..0x4000, åñëè äëèíà ñëîâà 16 áèò **
** buf - óêàçàòåëü íà ïàìàòü, îòêóäà ïèñàòü. **
** size - äëèíà áëîêà â áàéòàõ. Ïî-ëþáîìó â áàéòàõ! */
void Seeprom_write(unsigned int adres, unsigned int buf[], unsigned int size);
/* ×òåíèå áëîêà èç SEEPROM. Ïàðàìåòðû òàêîâû: **
** adres - àäðåñ â åïðîìêå, îòêóäà ÷èòàòü. **
** adres = 0..0x8000, åñëè äëèíà ñëîâà 8 áèò **
** adres = 0..0x4000, åñëè äëèíà ñëîâà 16 áèò **
** buf - óêàçàòåëü íà ïàìàòü, êóäà ÷èòàòü. **
** size - äëèíà áëîêà â áàéòàõ. Ïî-ëþáîìó â áàéòàõ! */
void Seeprom_read(unsigned int adres, unsigned int buf[], unsigned int size);
#endif

View File

@@ -0,0 +1,26 @@
#ifndef TOOLS_H
#define TOOLS_H
void init_zone7(void);
void setup_leds_line(void);
void pause_us(unsigned long t);
#ifndef TUBER
#define led1_toggle() GpioDataRegs.GPBTOGGLE.bit.GPIO32=1
#define led2_toggle() GpioDataRegs.GPBTOGGLE.bit.GPIO48=1
#define led1_off() GpioDataRegs.GPBSET.bit.GPIO32=1
#define led2_off() GpioDataRegs.GPBSET.bit.GPIO48=1
#define led1_on() GpioDataRegs.GPBCLEAR.bit.GPIO32=1
#define led2_on() GpioDataRegs.GPBCLEAR.bit.GPIO48=1
#else
#define led1_toggle() GpioDataRegs.GPBTOGGLE.bit.GPIO32=1
#define led2_toggle() GpioDataRegs.GPBTOGGLE.bit.GPIO32=1
#define led1_off() GpioDataRegs.GPBSET.bit.GPIO32=1
#define led2_off() GpioDataRegs.GPBSET.bit.GPIO32=1
#define led1_on() GpioDataRegs.GPBCLEAR.bit.GPIO32=1
#define led2_on() GpioDataRegs.GPBCLEAR.bit.GPIO32=1
#endif
#endif //TOOLS_H