source: PlatformSupport/WARP_Libraries/warplib.c

Last change on this file was 342, checked in by snovich, 18 years ago

Added License Info

File size: 1.5 KB
Line 
1/* Copyright (c) 2006 Rice University */ 
2/* All Rights Reserved */ 
3/* This code is covered by the Rice-WARP license */ 
4/* See http://warp.rice.edu/license/ for details */ 
5
6
7#include "warplib.h"
8#include <stdlib.h>
9#include "xparameters.h"
10
11#include <string.h>
12
13
14// a test function to make sure the library is being called correctly.
15
16void WarpLib_test(void)
17{
18    print("This is a test function for the new TAP Library that we are developing. 1337.");
19}
20
21// a basic int to character converter
22
23char WarpLib_itoc(int x)
24{
25    char c = (char)(x+48);
26    return c;
27}
28
29// a basic character to int converter
30
31int WarpLib_ctoi(char c)
32{
33    int x = (int)(c-48);
34    return x;
35}
36
37// 7 segment display mapper. Takes in desired char-type of a char or number
38// and gives out its corresponding 7-segment display code
39
40
41int WarpLib_segmap(char x) 
42{
43
44    switch(x){
45
46    case('0') : return 0x007E;
47    case('1') : return 0x0030;
48    case('2') : return 0x006D;
49    case('3') : return 0x0079;
50    case('4') : return 0x0033;
51    case('5') : return 0x005B;
52    case('6') : return 0x005F;
53    case('7') : return 0x0070;
54    case('8') : return 0x007F;
55    case('9') : return 0x007B;
56
57    case('A') : return 0x0077;
58    case('a') : return 0x0077;
59    case('B') : return 0x007F;
60    case('b') : return 0x007F;
61    case('C') : return 0x004E;
62    case('c') : return 0x004E;
63    case('D') : return 0x007E;
64    case('d') : return 0x007E;
65    case('E') : return 0x004F;
66    case('e') : return 0x004F;
67    case('F') : return 0x0047;
68    case('f') : return 0x0047;
69    default : return 0x0001;
70    }
71
72}
73
74
Note: See TracBrowser for help on using the repository browser.