-
Notifications
You must be signed in to change notification settings - Fork 0
/
Task_eFishery.c
64 lines (50 loc) · 1.38 KB
/
Task_eFishery.c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
#include <stdio.h>
#include <stdint.h>
void task_efishery (int data, int len);
uint8_t bit_shifter (int data, int length_shift, uint8_t line);
int data_test = 0x12345678;
int main()
{
task_efishery(data_test,4);
return 0;
}
void task_efishery (int data, int len)
{
uint8_t temp_data[len];
temp_data[0]=bit_shifter(data,24,0x00);
temp_data[1]=bit_shifter(data,16,0x01);
temp_data[2]=bit_shifter(data,8,0x02);
temp_data[3]=bit_shifter(data,0,0x03);
printf ("%02x \r\n",temp_data[0]);
printf ("%02x \r\n",temp_data[1]);
printf ("%02x \r\n",temp_data[2]);
printf ("%02x \r\n",temp_data[3]);
}
uint8_t bit_shifter (int data, int length_shift, uint8_t line)
{
uint8_t temp_sft;
int temp_data;
if (line==0x00)
{
temp_data = (data & 0xFF000000);
temp_data = temp_data >> length_shift;
temp_sft = temp_data;
}
else if (line==0x01)
{
temp_data = (data & 0x00FF0000);
temp_data = temp_data >> length_shift;
temp_sft = temp_data;
}
else if (line==0x02)
{
temp_data = (data & 0x0000FF00);
temp_data = temp_data >> length_shift;
temp_sft = temp_data;
}
else if (line==0x03)
{
temp_sft = (uint8_t) data;
}
return temp_sft;
}