初始提交
This commit is contained in:
		
							
								
								
									
										265
									
								
								dtest/rawdata_test/rawdata/rawdata_test.h
									
									
									
									
									
										Executable file
									
								
							
							
						
						
									
										265
									
								
								dtest/rawdata_test/rawdata/rawdata_test.h
									
									
									
									
									
										Executable file
									
								
							| @@ -0,0 +1,265 @@ | ||||
| /**************************************************************************** | ||||
|  | ||||
| Copyright(c) 2019 by Aerospace C.Power (Chongqing) Microelectronics. ALL RIGHTS RESERVED. | ||||
|  | ||||
| This Information is proprietary to Aerospace C.Power (Chongqing) Microelectronics and MAY NOT | ||||
| be copied by any method or incorporated into another program without | ||||
| the express written consent of Aerospace C.Power. This Information or any portion | ||||
| thereof remains the property of Aerospace C.Power. The Information contained herein | ||||
| is believed to be accurate and Aerospace C.Power assumes no responsibility or | ||||
| liability for its use in any way and conveys no license or title under | ||||
| any patent or copyright and makes no representation or warranty that this | ||||
| Information is free from patent or copyright infringement. | ||||
|  | ||||
| ****************************************************************************/ | ||||
|  | ||||
|  | ||||
| #ifndef _H_RAWDATA_TEST | ||||
| #define _H_RAWDATA_TEST | ||||
|  | ||||
| // To save CPU efficent, less function call, use global variable | ||||
| #define RAWDATA_TIME_PROFILE_ENABLE | ||||
|  | ||||
| /*  | ||||
| *  In interrut mode, all things done in interrupt route. | ||||
| *  If mask this macro off, interrupt just mark flag, and leave main loop | ||||
| *  to handle reset. Like dsr route | ||||
| */ | ||||
| #define RUN_MODE_IN_INTERRUPT | ||||
|  | ||||
|  | ||||
| /* | ||||
| *  Define rawdata converter API interface | ||||
| */ | ||||
|  | ||||
| #define RAWDATA_HW_TICKS CFG_RAW_NTB_TIMER_ADDR /* TBD */ | ||||
|  | ||||
| #define RAW_FC_LEN_DW  4 | ||||
|  | ||||
| #define RAWDATA_PROFILE_SLOT_MAX 8  | ||||
|  | ||||
|  | ||||
| #ifdef RAWDATA_TIME_PROFILE_ENABLE | ||||
|  | ||||
| #define iot_rawdata_mark_timestamp(x) \ | ||||
|         ( (*x) = RGF_RAW_READ_REG(RAWDATA_HW_TICKS) ) | ||||
|  | ||||
| #else | ||||
|  | ||||
| #define iot_rawdata_mark_timestamp(x) | ||||
|  | ||||
|  | ||||
| #endif | ||||
|  | ||||
| /* | ||||
| *  store high accurency hw tick timer, used for profiling timing | ||||
| */ | ||||
| typedef struct _fc_profile{ | ||||
|     uint32_t rawdata_interrupt_trigger_ticks; | ||||
|     uint32_t rawdata_get_fc_ticks; | ||||
|     uint32_t rawdata_translate_fc_ticks; | ||||
|     uint32_t rawdata_set_translate_fc_ticks; | ||||
|     uint32_t rawdata_interrupt_release_ticks; | ||||
|     uint32_t irq_type; | ||||
| }fc_profile; | ||||
|  | ||||
|  | ||||
| /* | ||||
| *  translate message include src dest and timing | ||||
| */ | ||||
| typedef struct _fc_trans_msg{ | ||||
|     uint32_t  org_fc[RAW_FC_LEN_DW]; | ||||
|     uint32_t  trans_fc[RAW_FC_LEN_DW]; | ||||
|     fc_profile profile; | ||||
| }fc_trans_msg; | ||||
|  | ||||
| /* | ||||
| * rawdata context  | ||||
| */ | ||||
| typedef struct _rawdata_context{ | ||||
|     uint32_t dsr_flag; | ||||
|     uint32_t src_prot; | ||||
|     uint32_t trans_prot; | ||||
|     uint32_t irq_time; | ||||
|     uint32_t timeout_txcnt; | ||||
|     uint32_t timeout_rxcnt; | ||||
|     uint32_t exc_flag; | ||||
|     uint32_t pre_exc_flag; | ||||
|     uint32_t irq_catch; | ||||
|     uint32_t pre_irq_catch; | ||||
|     uint32_t subfunc_exe_flag; | ||||
|     uint32_t dbgchangeid; | ||||
|  | ||||
|  | ||||
|  | ||||
|     uint32_t txmsg_idx;  | ||||
|     fc_trans_msg tx_msg[RAWDATA_PROFILE_SLOT_MAX]; | ||||
|  | ||||
|     uint32_t ackmsg_idx; | ||||
|     fc_trans_msg ack_msg[RAWDATA_PROFILE_SLOT_MAX]; | ||||
|  | ||||
|     uint32_t recmsg_idx; | ||||
|     fc_trans_msg rec_msg[RAWDATA_PROFILE_SLOT_MAX]; | ||||
|  | ||||
| }rawdata_context; | ||||
|  | ||||
| /* iot_rawdata_init - function to init rawdata context/data struct  | ||||
| * | ||||
| *  @cxt-input- context pointer | ||||
| *  return: | ||||
| *  0           -   success | ||||
| *  otherwise   -   error | ||||
| */ | ||||
| uint32_t iot_rawdata_context_init(rawdata_context* cxt); | ||||
|  | ||||
|  | ||||
| /* iot_rawdata_hw_set - function to turn on/off raw mode in hw, hook interrupt | ||||
| * | ||||
| *  @on -input- 1: enable hw into raw mode state, 0 disable | ||||
| *  @src_prot -input- set hw in SG mode or SPG mode  | ||||
| *  @trans_prot -input- set hw communicate protoal. current is SG.     | ||||
| *  return: | ||||
| *  0           -   success | ||||
| *  otherwise   -   error | ||||
| */ | ||||
| uint32_t iot_rawdata_hw_set(uint32_t on, uint32_t src_prot,\ | ||||
|                             uint32_t trans_prot); | ||||
|  | ||||
|  | ||||
| /* iot_rawdata_interrupt_handler - function to service interrupt | ||||
| * | ||||
| *  @on -input- 1: enable hw into raw mode state, 0 disable | ||||
| *  @src_prot -input- set hw in SG mode or SPG mode  | ||||
| *  @trans_prot -input- set hw communicate protoal. current is SG.     | ||||
| *  return: | ||||
| *  0           -   success | ||||
| *  otherwise   -   error | ||||
| */ | ||||
| uint32_t iot_rawdata_interrupt_handler(uint32_t vector, iot_addrword_t data); | ||||
|  | ||||
|  | ||||
| /* iot_rawdata_get_tx_fc_bytes - fetch tx fc head(4 DWs) from hw register | ||||
| * | ||||
| *  @fc_ptr -input- 4DWs to store tx fc head | ||||
| * | ||||
| *  return: | ||||
| *  0           -   success | ||||
| *  otherwise   -   error | ||||
| */ | ||||
| uint32_t iot_rawdata_get_tx_fc_bytes(fc_trans_msg *rawfc); | ||||
|  | ||||
|  | ||||
| /* iot_rawdata_translate_tx_fc - translate src fc head into dest format | ||||
| * | ||||
| *  @rawfc -input- one translate message  | ||||
| *  @src_prot -input - message prot type | ||||
| *  @trans_prot -input - message dest format type | ||||
| *  return: | ||||
| *  0           -   success | ||||
| *  otherwise   -   error | ||||
| */ | ||||
| uint32_t iot_rawdata_translate_tx_fc(fc_trans_msg *rawfc, \ | ||||
|                                      uint32_t src_prot, uint32_t trans_prot); | ||||
|  | ||||
| /* iot_rawdata_set_translate_tx_fc - plumb translated fc in hw register | ||||
| * | ||||
| *  @rawfc -input- one translated message  | ||||
| * | ||||
| *  return: | ||||
| *  0           -   success | ||||
| *  otherwise   -   error | ||||
| */ | ||||
| uint32_t iot_rawdata_set_translate_tx_fc(fc_trans_msg *rawfc); | ||||
|  | ||||
| /* iot_rawdata_get_hw_sack_fc_bytes - fetch sack fc head(4 DWs) from hw register | ||||
| * | ||||
| *  @fc_ptr -input- 4DWs to store sack fc head | ||||
| * | ||||
| *  return: | ||||
| *  0           -   success | ||||
| *  otherwise   -   error | ||||
| */ | ||||
| uint32_t iot_rawdata_get_hw_sack_fc_bytes(fc_trans_msg *rawfc); | ||||
|  | ||||
|  | ||||
| /* iot_rawdata_translate_hwsack_fc - translate sack fc to dest prot | ||||
| * | ||||
| *  @rawfc -input- one translated message  | ||||
| *  @src_prot -input - hw prepared sack fc proto | ||||
| *  @trans_prot -input - hw desired translated sack fc proto | ||||
| * | ||||
| *  return: | ||||
| *  0           -   success | ||||
| *  otherwise   -   error | ||||
| */ | ||||
| uint32_t iot_rawdata_translate_hwsack_fc(fc_trans_msg *rawfc, \ | ||||
|                                          uint32_t src_prot, uint32_t trans_prot); | ||||
|  | ||||
| /* iot_rawdata_set_translate_sack_fc - plumb translated fc in hw register | ||||
| * | ||||
| *  @rawfc -input- one translated message  | ||||
| * | ||||
| *  return: | ||||
| *  0           -   success | ||||
| *  otherwise   -   error | ||||
| */ | ||||
| uint32_t iot_rawdata_set_translate_sack_fc(fc_trans_msg* rawfc); | ||||
|  | ||||
|  | ||||
| /* iot_rawdata_get_hw_receive_fc_bytes - plumb translated fc in hw register | ||||
| * | ||||
| *  @rawfc -input- one translated message  | ||||
| * | ||||
| *  return: | ||||
| *  0           -   success | ||||
| *  otherwise   -   error | ||||
| */ | ||||
| uint32_t iot_rawdata_get_hw_receive_fc_bytes(fc_trans_msg *rawfc); | ||||
|  | ||||
|  | ||||
| /* iot_rawdata_translate_hwrec_fc - translate received fc to dest prot | ||||
| * | ||||
| *  @rawfc -input- one translated message  | ||||
| *  @src_prot -input - hw prepared sack fc proto | ||||
| *  @trans_prot -input - hw desired translated sack fc proto | ||||
| * | ||||
| *  return: | ||||
| *  0           -   success | ||||
| *  otherwise   -   error | ||||
| */ | ||||
| uint32_t iot_rawdata_translate_hwrec_fc(fc_trans_msg *rawfc, \ | ||||
|                                      uint32_t src_prot, uint32_t trans_prot); | ||||
|   | ||||
|  | ||||
| /* iot_rawdata_set_translate_recv_fc - plumb translated fc in hw register | ||||
| * | ||||
| *  @rawfc -input- one translated message  | ||||
| * | ||||
| *  return: | ||||
| *  0           -   success | ||||
| *  otherwise   -   error | ||||
| */ | ||||
| uint32_t iot_rawdata_set_translate_recv_fc(fc_trans_msg *rawfc); | ||||
|  | ||||
|  | ||||
| /* iot_disable_hw_interrupt - disable interrupt | ||||
| */ | ||||
| void iot_disable_hw_interrupt(uint32_t irq_type); | ||||
|  | ||||
| /* iot_enable_hw_interrupt - enable interrupt | ||||
| */ | ||||
| void iot_enable_hw_interrupt(uint32_t irq_type); | ||||
|  | ||||
| /* iot_get_interrupt_type - get interupt type | ||||
| * | ||||
| * | ||||
| *  return: | ||||
| *  define INTR_TYPE_CPU0_TX_FC | ||||
| *  define INTR_TYPE_HW_SACK_FC | ||||
| * | ||||
| */ | ||||
| uint32_t iot_get_hw_interrupt_type(void); | ||||
|  | ||||
|  | ||||
|  | ||||
| #endif | ||||
		Reference in New Issue
	
	Block a user