📄 readme.txt
字号:
//* Function Name : send_msg_USART1
//* Object : send the newly loaded messages stored in us1_send_dma[].
//* send_point1 is to memory the pointer of the first byte
//* to be sended. tx1_wr_pt is to memory the writing pointer
//* of the us1_send_dma[]
//* autor : wang ping
//* Input Parameters : none
//* Output Parameters : none
//*-----------------------------------------------------------------------------
//*-----------------------------------------------------------------------------
//* Function Name : crc_fun
//* Object : calculate the checksum.
//* autor : wang ping
//* Input Parameters : msg[]:the bytes used to calculate; len: the length of
//* of the message.
//* Output Parameters : crc_result:the checksum
//*-----------------------------------------------------------------------------
//*-----------------------------------------------------------------------------
//* Function Name : check_crc
//* Object : check the checksum of the received message.
//* autor : wang ping
//* Input Parameters : len: the length of the message.
//* Output Parameters : 1:the checksum is correct; 0:the checksum is error
//*-----------------------------------------------------------------------------
//*-----------------------------------------------------------------------------
//* Function Name : pack_config_infor
//* Object : pack the config informations of the odu.
//* autor : wang ping
//* Input Parameters : subject:the subject number of the content to be packed
//* Output Parameters : ack:the lenth of the message package.
//* if ack==0,means the subject number is invalid.
//*-----------------------------------------------------------------------------
//*-----------------------------------------------------------------------------
//* Function Name : report_config_infor_pro
//* Object : report the config informations of the odu.CommandID=0x03
//* autor : wang ping
//* Input Parameters : subject:the subject number of the content to be reported
//* Output Parameters : none
//*-----------------------------------------------------------------------------
//*-----------------------------------------------------------------------------
//* Function Name : report_odu_options
//* Object : report all the options of odu.
//* report when the system initiated,and then 2.5seconds once.
//* autor : wang ping
//* Input Parameters : none
//* Output Parameters : none
//*-----------------------------------------------------------------------------
//*-----------------------------------------------------------------------------
//* Function Name : report_status_pro
//* Object : report the dynamic parameters of odu.
//* report in main loop
//* autor : wang ping
//* Input Parameters : subject:the subject number of the content to be reported
//* Output Parameters : none
//*-----------------------------------------------------------------------------
//*-----------------------------------------------------------------------------
//* Function Name : report_alarm_pro
//* Object : report the alarm information of odu.
//* report immediately when alarm occurs
//* autor : wang ping
//* Input Parameters : none
//* Output Parameters : none
//*-----------------------------------------------------------------------------
//*-----------------------------------------------------------------------------
//* Function Name : debug_report_pro
//* Object : report the informations for debugging,used only by monitor.
//* report in main loop
//* autor : wang ping
//* Input Parameters : subject:the subject number of the content to be reported
//* Output Parameters : none
//*-----------------------------------------------------------------------------
//*-----------------------------------------------------------------------------
//* Function Name : set_cmd_pro
//* Object : execute the set command,and give the response
//* autor : wang ping
//* Input Parameters : subject:the subject number of the content to be reported
//* component:the component ID in commands field
//* Output Parameters : none
//*-----------------------------------------------------------------------------
//*-----------------------------------------------------------------------------
//* Function Name : get_cmd_pro
//* Object : handle the get command,and give the response
//* autor : wang ping
//* Input Parameters : subject:the subject number of the content to be reported
//* component:the component ID in commands field
//* Output Parameters : none
//*-----------------------------------------------------------------------------
//*-----------------------------------------------------------------------------
//* Function Name : read_memory_pro
//* Object : handle the read memory command,and give the response
//* autor : wang ping
//* Input Parameters : addr:the beginning address of the content to read in
//* AT91C_IFLASH.
//* bytes:the number of bytes to read.
//* component:the component ID in commands field
//* Output Parameters : none
//*-----------------------------------------------------------------------------
//*-----------------------------------------------------------------------------
//* Function Name : cmd_handle
//* Object : the entrance of the command handling process.
//* autor : wang ping
//* Input Parameters : none
//* Output Parameters : none
//*-----------------------------------------------------------------------------
//*-----------------------------------------------------------------------------
//* Function Name : recv_msg
//* Object : Get a frame from the selected receiving DMA buffer.
//* revert the escape bytes,and save the frame in tx_buf[]
//* autor : wang ping
//* Input Parameters : none
//* Output Parameters : flag=0:Did not receive a frame.flag=1:received a frame
//*-----------------------------------------------------------------------------
//*-----------------------------------------------------------------------------
//* Function Name : unpack
//* Object : take out the two dilimiters from tx_buf[] and then save
//* the information in infor_msg[].
//* autor : wang ping
//* Input Parameters : none
//* Output Parameters : i:the length of the information in infor_msg[]
//*-----------------------------------------------------------------------------
//*-----------------------------------------------------------------------------
//* Function Name : load_msg
//* Object : add the two dilimiters to the message and calculate the
//* checksum,handle the especial bytes,then load the new
//* frame to the DMA Tx buffer of both the USART ports.
//* autor : wang ping
//* Input Parameters : msg:the information to be loaded;len:the number of bytes
//* Output Parameters : snum:the length of the frame loaded in DMA tx buffer
//*-----------------------------------------------------------------------------
//*-----------------------------------------------------------------------------
//* Function Name : load_msg
//* Object : loading the receiver buffer to the other USART TX DMA
//* buffer.
//* autor : wang ping
//* Input Parameters : none
//* Output Parameters : none
//*-----------------------------------------------------------------------------
//*-----------------------------------------------------------------------------
//* Function Name : odu_to_idu_com
//* Object : the entrance of the communication process.
//* autor : wang ping
//* Input Parameters : none
//* Output Parameters : none
//*-----------------------------------------------------------------------------
//*-----------------------------------------------------------------------------
The global variables of lcodu_msg.c
unsigned char rx_buf[256]; //接收缓冲区
unsigned char tx_buf[256]; //发送缓冲区
unsigned char infor_msg[256];
unsigned int hd_flag=0;//接收数据阶段标志
unsigned int rx_index,rx_len,rx_flag,rx_index1; //接收、发送数组下标及长度
unsigned int rx_rd_pt;//receiving buffer reading pointer
unsigned int tx_wr_pt;//sending buffer writing pointer
unsigned int rx1_rd_pt;//the other receiving buffer reading pointer
unsigned int tx1_wr_pt;//the other sending buffer writing pointer
unsigned int send_point;//the pointer of the first byte to be send (US0)
unsigned int send_point1;//the pointer of the first byte to be send(US1)
unsigned char escape_flag=0;//*escape_flag=1:the previous byte received is an escape byte
AT91PS_USART u_pUSART0 = AT91C_BASE_US0;
AT91PS_USART u_pUSART1 = AT91C_BASE_US1;
//*-----------------------------------------------------------------------------
/******************************************************************************/
/******************************************************************************/
functions in lcodu_spi.c
//*-----------------------------------------------------------------------------
//* Function Name : SPI_int
//* Object : initiate the SPI device
//* autor : zhu dong po
//* Input Parameters : none
//* Output Parameters : none
//*-----------------------------------------------------------------------------
//*-----------------------------------------------------------------------------
//* Function Name : Init_TX_RF
//* Object : initialization TX_RF PLL(hittie)
//* autor : zhu dong po
//* Input Parameters : none
//* Output Parameters : none
//*-----------------------------------------------------------------------------
//*-----------------------------------------------------------------------------
//* Function Name : Init_RX_RF
//* Object : initialization RX_RF PLL(hittie)
//* autor : zhu dong po
//* Input Parameters : none
//* Output Parameters : none
//*-----------------------------------------------------------------------------
//*-----------------------------------------------------------------------------
//* Function Name : Set_TX_RX_RF0
//* Object : set TX_RF/RX_RF PLL frequency(hittie),unit:MHZ
//* autor : zhu dong po
//* Input Parameters : channel == 1 (TX_RF),channel == 3 (RX_RF),
//* Output Parameters : none
//*-----------------------------------------------------------------------------
//*-----------------------------------------------------------------------------
//* Function Name : SPI_int2531
//* Object : initiate the SPI device(vco embeded,2531)
//* autor : zhu dong po
//* Input Parameters : none
//* Output Parameters : none
//*-----------------------------------------------------------------------------
//*-----------------------------------------------------------------------------
//* Function Name : wirte_rigester2531
//* Object : write the registers of the pll(vco embeded,2531)
//* autor : zhu dong po
//* Input Parameters : msb,nsb,lsb,make up the value of the register
//* channel == 1 (TX_RF),channel == 3 (RX_RF),
//* Output Parameters : none
//*-----------------------------------------------------------------------------
//*-----------------------------------------------------------------------------
//* Function Name : Init_TX_RF2531
//* Object : initialization TX_RF PLL(vco embeded,2531)
//* autor : zhu dong po
//* Input Parameters : none
//* Output Parameters : none
//*-----------------------------------------------------------------------------
//*-----------------------------------------------------------------------------
//* Function Name : Init_RX_RF2531
//* Object : initialization RX_RF PLL(vco embeded,2531)
//* autor : zhu dong po
//* Input Parameters : none
//* Output Parameters : none
//*-----------------------------------------------------------------------------
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -