-
Notifications
You must be signed in to change notification settings - Fork 0
/
modules.c
95 lines (76 loc) · 2.45 KB
/
modules.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
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
#include <stdlib.h>
#include <stdio.h>
#include <stdint.h>
#include <stdbool.h>
#include "../coroutines_mgr_v2/coroutines_mgr_v2.h"
#include "../thread_task_mgr/thread_task_mgr.h"
#include "modules.h"
bool SSP1CON2bits_SEN1;
bool SSP1STATbits_RW1;
static unsigned long start_millis = 0;
uint8_t i2c_write(void){
FunctionStart;
SSP1CON2bits_SEN1 = 1;
printf("SSP1CON2bits_SEN1 ### SET ### %d\n", SSP1CON2bits_SEN1);
FunctionCheck(SSP1CON2bits_SEN1, BitSet);
printf("SSP1CON2bits_SEN1 ### CLEARED ### %d\n", SSP1CON2bits_SEN1);
SSP1STATbits_RW1 = 1;
printf("SSP1STATbits_RW1 ### SET ### %d\n", SSP1STATbits_RW1);
FunctionCheck(SSP1STATbits_RW1, BitSet);
printf("SSP1STATbits_RW1 ### CLEARED ### %d\n", SSP1STATbits_RW1);
FunctionEnd;
}
void start_time(void){
start_millis = millis();
}
void i2c_bit_set_clear_routine(void){
if(millis() - start_millis > 10){
printf("time difference %lu\n", millis() - start_millis);
printf("---------------------------------------------------------------\n");
printf("---------------------------------------------------------------\n");
printf("bits cleared ==================================================\n");
SSP1CON2bits_SEN1 = 0;
SSP1STATbits_RW1 = 0;
start_millis = millis();
}
}
bool function1(void){
BeginCoroutine;
printf("\n1 part1 %d\n", __LINE__ + 1);
CoroutineDelay(200);
printf("\n1 part2 %d\n", __LINE__ + 1);
CoroutineDelay(30);
printf("\n1 part3 %d\n", __LINE__ + 1);
CoroutineDelay(50);
printf("\n1 part4 %d\n", __LINE__ + 1);
CoroutineDelay(10);
EndCoroutine;
}
bool function2(void){
BeginCoroutine;
printf("\n2 part1 %d\n", __LINE__ + 1);
CoroutineDelay(50);
printf("\n2 part2 %d\n", __LINE__ + 1);
CoroutineDelay(10);
printf("\n2 part3 %d\n", __LINE__ + 1);
CoroutineDelay(50);
printf("\n2 part4 %d\n", __LINE__ + 1);
CoroutineDelay(10);
EndCoroutine;
}
bool function3(void){
BeginCoroutine;
printf("\n3 part1 %d\n", __LINE__ + 1);
CoroutineDelay(100);
printf("\n3 part2 %d\n", __LINE__ + 1);
CoroutineDelay(200);
EndCoroutine;
}
bool function4(void){
BeginCoroutine;
printf("\n4 part1 %d\n", __LINE__ + 1);
CoroutineDelay(500);
printf("\n4 part2 %d\n", __LINE__ + 1);
CoroutineDelay(50);
EndCoroutine;
}