-
Notifications
You must be signed in to change notification settings - Fork 0
/
ORILIB_util.c
64 lines (51 loc) · 1.25 KB
/
ORILIB_util.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
/**
Atomix project, ORILIB_util_i.c, TODO: insert summary here
Copyright (c) 2015 Stanford University
Released under the Apache License v2.0. See the LICENSE file for details.
Author(s): Manu Bansal
*/
#include <osl/inc/swpform.h>
#include <ti/csl/csl_gpioAux.h>
#include <ti/platform/platform.h>
void printIPAddr(void * addr) {
unsigned char * p = (unsigned char *)addr;
printf("%u.%u.%u.%u", *p, *(p+1), *(p+2), *(p+3));
}
void printMacAddr(void * addr) {
int i = 0;
unsigned char * p = (unsigned char *)addr;
for (i = 0; i < 5; i++) {
printf("%02x:", p[i]);
}
printf("%02x", p[i]);
}
void ORILIB_gpio_output_control(
Uint8 bank,
Uint8 pin,
Uint8 offOnToggle
){
CSL_GpioHandle gpio;
Uint8 gpioData;
gpio = CSL_GPIO_open(bank);
CSL_GPIO_setPinDirOutput(gpio, pin);
switch (offOnToggle) {
case 0:
CSL_GPIO_clearOutputData(gpio, pin);
break;
case 1:
CSL_GPIO_setOutputData(gpio, pin);
break;
default:
CSL_GPIO_getOutputData(gpio, pin, &gpioData);
gpioData ^= 1;
if (gpioData)
CSL_GPIO_setOutputData(gpio, pin);
else
CSL_GPIO_clearOutputData(gpio, pin);
break;
}
}
//void ORILIB_init_platform_info(platform_info * p_I) {
// //fill in the platform info into the given buffer
// platform_get_info(p_I);
//}