http://blog.csdn.net/liang890319/article/details/52456224 2016 - typedef _BYTE uint8_t;
- typedef _WORD uint16_t;
- typedef _DWORD uint32_t;
-
- //---------------------------------------------------------
- //定时器3更新中断
- //---------------------------------------------------------
- int Timer3_int_handle(void)
- {
- //控制IO PORTB PORTA TIM9 TIM4
- return 1;
- }
-
- //---------------------------------------------------------
- //定时器4更新中断
- //---------------------------------------------------------
- int Timer4_int_handle(void)
- {
- {
- int result; // r0@1
-
- // sub_800E3EA(1073809408, 64);
- // sub_800764E(1073872896, 0x8000);
- // result = (unsigned __int8)byte_20000B11;
- // if ( !byte_20000B11 )
- // result = sub_800764E(1073873920, 256);
- return result;
-
- }
-
- //----------------------------------------
- //
- //定时器2更新中断
- //
- //---------------------------------------------------------
- unsigned long dword_20000B64=0;
- int Timer2_int_handle(void)
- {
-
- int *result; // r0@1
-
- result = &dword_20000B64;
- dword_20000B64 += 0x10000;
-
- Gen_time12(1);
- Gen_time34();
-
- return result;
-
- }
- //
- //
- //
- //
- int get_counter1_cntORb64()
- {
- int v0; // r5@1
- unsigned int v1; // r0@1
- int result; // r0@3
-
- v0 = dword_20000B64;
- __dmb();
- v1 = get_timer2reg_cnt();
- __dmb();
- if ( v0 != dword_20000B64 && v1 >> 15 )
- result = v1 | v0;
- else
- result = v1 | dword_20000B64;
- return result;
- }
-
-
- //---------------------------------------------------------
- //定时器2CCR3中断
- //产生时间戳12 INPUT:var_BCF
- //---------------------------------------------------------
- unsigned long dword_20000B90=0;
- unsigned long dword_20000B94=0;
- unsigned char unk_200009C8[32]={0};
-
- int Gen_time12(int a1){
-
- int v1; // r4@1
- char *v2; // r6@1
- unsigned int v3; // r0@1
- unsigned __int16 v4; // r7@1
- int v5; // r0@1
-
- v1 = a1;
- v2 = (char *)&unk_200009C8 + 8 * (((uint8_t)dword_20000B90 + 1) & 3);
- *((uint16_t *)v2 + 2) = dword_20000B90 + 1;
-
- v3 = get_counter1_cntORb64(); //reg cnt || var_B64
- v4 = v3;
- v5 = get_ccr3_reg() | (v3 >> 16 << 16);
- if ( v1 && v4 < (unsigned int) v5 ) v5 -= 0x10000;
- *(uint16_t *)v2 = v5;
- return dword_20000B90++ + 1;
- }
-
-
-
- //
- //
- //
- int mem_cpy(int a1, char *a2, unsigned int a3)
- {
- char v3; // t1@2
- char v5; // cf@7
- unsigned int i; // r2@7
- int v7; // r3@9
- int v8; // r12@9
- _DWORD *v9; // r0@9
-
- while ( (_DWORD)a2 << 30 )
- {
- --a3;
- v3 = *a2++;
- *(_BYTE *)a1++ = v3;
- if ( !a3 ) break;
- }
- return sub_8007324(a1, (int)a2, a3);
- }
- //
- //
- //
- //
- int if_copy_timer12(int dstarr)
- {
- int result; // r0@2
-
- if ( *(uint16_t *)(dstarr + 4) == dword_20000B90 ) //除非定时器死了 否则不会相等?
- {
- result = 0;
- }
- else
- {
- mem_cpy(dstarr, &byte_200009C8[8 * (dword_20000B90 & 3)], 8u);
- result = 1;
- }
- return result;
- }
-
- //
- //
- //
- //
- int prepare_timer12_data_8bytes(int a1)
- {
-
- int v2; // r8@1
- signed int v3; // r5@1
- int v9; // r2@17
- int v15; // [sp+Ch] [bp-24h]@11
- uint16_t v16; // [sp+10h] [bp-20h]@13
-
-
- v2 = a1;
- v3 = 0;
-
- if ( if_copy_timer12((int)&v15) )
- {
- v9 = *(_DWORD *)&v16;
- *(_DWORD *)v2 = v15;
- *(_DWORD *)(v2 + 4) = v9;
- v3 = 1;
- }
- return v3;
- }
-
- char cpy_time12to_hidbuf(char *result)
- {
- *(uint16_t *)(packet_buf+50) = *((_WORD *)result + 2);
- *(uint32_t *)(packet_buf+52) = *(_DWORD *)result;
- return 1;
- }
-
-
-
-
-
-
- //---------------------------------------------------------
- //定时器2ccr2中断
- //产生时间戳34 INPUT:var_BD0
- //---------------------------------------------------------
- unsigned long dword_200004EC=0;
- unsigned char unk_20000988[64]={0};
- int Gen_time34(int a1){
-
- int v1; // r4@1
- char *v2; // r6@1
- unsigned int v3; // r0@1
- unsigned __int16 v4; // r7@1
- int v5; // r0@1
-
- v1 = a1;
- v2 = (char *)&unk_20000988 + 8 * (((_BYTE)dword_200004EC + 1) & 3);
-
- *((_DWORD *)v2 + 1) = dword_200004EC + 1;
- v3 = get_counter1_cntORb64(); //中断发生时cnt值
- v4 = v3;
- v5 = get_reg_ccr2() | (v3 >> 16 << 16); //中断发生计时
- if ( v1 && (v4 < (uint16_t)v5 ) v5 -= 0x10000;
- *(_DWORD *)v2 = v5;
- return dword_200004EC++ + 1;
- }
-
- //
- //
- //生成时间戳34的数据
- //
- signed int __fastcall prepare_timer34_data_8bytes(int dst_arr, int a2)
- {
- int v2; // r4@1
- unsigned int v3; // r0@2
- signed int result; // r0@5
- char *v5; // r0@8
- int v6; // r11@8
- int v30; // [sp+18h] [bp-28h]@1
-
- v30 = a2;
- v2 = dst_arr;
- if ( dword_200004EC == dword_200004F0 ) //若下次定时还没到 那么不更新时间戳
- v3 = 0;
- else
- v3 = 1;
-
- if ( v3 ) dword_200004F0 = dword_200004EC;
- v5 = (char *)&unk_20000988 + 8 * (dword_200004F0 & 3);
-
- *(_WORD *)v2 = *((_DWORD *)v5 + 1);
- *(_DWORD *)(v2 + 4) = *(_DWORD *)v5;
-
- return 1;
- }
-
- char unk_20000420[64]={0}
-
-
- //
- //把时间戳34数据拷贝到buf中准备发送
- //
- //
- char cpy_time34to_hidbuf(char *time34Buf)
- {
- char *v1; // r8@1
- signed int v2; // r4@4
- char v3; // r1@4
- int v4; // r4@6
- int v5; // r10@7
- char *v6; // r1@9
- char *v7; // r0@9
- int v8; // r0@11
- char *result; // r0@13
-
- v1 = time34Buf;
- if ( system_run_counter )
- {
- if ( (uint8_t)system_run_counter == 254 )
- {
- v2 = 0;
- v3 = 2 - 1;
- system_run_counter = v3;
- *(_WORD *)&byte_20000920[4] = *(_WORD *)time34Buf -v3; //arr[2]=4 time 2 byres
- }
- }
- else
- {
- *(_WORD *)&byte_20000920[4] = *(_WORD *)time34Buf; //arr[2]=4 time stamp
- }
-
- *(_DWORD *)&byte_20000920[*(_BYTE *)(dword_20000B48 + 7)] = *((_DWORD *)v1 + 1); //arr[7] //4bytes time
- *(_WORD *)&byte_20000920[*(_BYTE *)(v8 + 4)] = *((_WORD *)v1 + 4); //arr[4]=6 temple
- ++system_run_counter; //time34 cpy counter= main loop run counter
-
- return 1;
- }
-
- //
- //
- //
- //
- signed int data_packet_generate()
- {
- int v0; // r0@1
- unsigned int v1; // r1@1
- unsigned int v2; // r0@1
- signed int v3; // r5@2
- int v4; // r6@2
- signed int v5; // r5@2
- char *v6; // r4@2
- unsigned int v7; // r4@4
- signed int v8; // r5@4
- int v9; // r7@7
- int v10; // r11@7
- int v11; // r1@7
- int v12; // r8@7
- int v13; // r1@7
- int v14; // r9@7
- int v15; // r6@8
- unsigned int v16; // r0@8
-
- v0 = dword_20000B48;
- v1 = (unsigned __int8)system_run_counter;//time34 cpy counter= main loop run counter
- byte_20000920[3] = system_run_counter;//arr[1] time34 cpy counter= main loop run counter
- v2 = *(_BYTE *)(v0 + 8); //arr[8]
-
- if ( v2 >= v1 )
- {
- if ( v1 == 1 )
- {
- LOBYTE(v7) = 1;
- v8 = 16;
- if ( v2 >= 2 )
- {
- do
- {
- sub_800D408(&byte_20000920[*(_BYTE *)(dword_20000B48 + 5)] + v8, 16, 0);//arr[5]=12
- v8 += 16;
- v7 = (unsigned __int8)(v7 + 1);
- }
- while ( v7 < *(_BYTE *)(dword_20000B48 + 8) ); //arr[8]=8
- }
- }
- v5 = 0;
- v6 = (char *)&unk_20000420;
- }
-
- while ( 1 )
- {
- v15 = dword_20000B48;
- v16 = 2;
- if ( v16 >= (unsigned __int8)system_run_counter ) v16 = (unsigned __int8)system_run_counter;
- if ( v5 >= (signed int)v16 ) break;
- v9 = (int)&v6[36 * v5];
- v10 = accumulate_cast(*(_DWORD *)(v9 + 24), (unsigned __int8)system_run_counter);
- v12 = accumulate_cast(*(_DWORD *)(v9 + 28), v11);
- v14 = accumulate_cast(*(_DWORD *)(v9 + 32), v13);
- data_packet_pack_sensor(
- &byte_20000920[16 * v5] + *(_BYTE *)(v15 + 5),
- *(_DWORD *)(v9 + 12),
- *(_DWORD *)(v9 + 16),
- *(_DWORD *)(v9 + 20));
- data_packet_pack_sensor(&byte_20000920[16 * v5 + 8] + *(_BYTE *)(dword_20000B48 + 5), v10, v12, v14);
- v5 ++;
- }
-
- USB_SIL_Write(EP1_IN, packet_buf, DATA_PACKET_SIZE); //这个函数已经查看过,没有作其他处理
- //把数据发送出去
- // Mark that the endpoint has valid data
- SetEPTxValid(ENDP1);
- byte_20000BC1 = 0;
- system_run_counter = 0;
- return 1;
- }
|