OpenCores
URL https://opencores.org/ocsvn/fsl2serial/fsl2serial/trunk

Subversion Repositories fsl2serial

[/] [fsl2serial/] [trunk/] [fsl2serial_v1_00_a/] [code/] [fsl_interface.c] - Blame information for rev 2

Go to most recent revision | Details | Compare with Previous | View Log

Line No. Rev Author Line
1 2 cutullus
// This is the source file implementing the FSL interface developed for use with the FSL2Serial
2
// module.  Data can also be sent over this link, but the assumption is that text will be sent.
3
//
4
// This requires the Xilinx FSL interface code, which can generally be found in fsl.h,
5
// mb_interface.h, and xbasic_types.h
6
//
7
// Alex Marschner
8
// 2007.03.12
9
 
10
#include "fsl_interface.h"
11
 
12
// Put a string of data through the specified FSL port.
13
void fsl0print(const char* s)
14
{
15
    while(*s)
16
    {
17
        putfsl(*s, FSL0);
18
        ++s;
19
    }
20
        return;
21
}
22
 
23
// Put a string of data through the specified FSL port.
24
void fsl0nprint(const char* s)
25
{
26
    while(*s)
27
    {
28
        nputfsl(*s, FSL0);
29
        ++s;
30
    }
31
        return;
32
}
33
 
34
// Print a single character to the specified FSL port.  (BLOCKING)
35
void fsl0put(const char s)
36
{
37
        putfsl(s, FSL0);
38
        return;
39
}
40
 
41
// Print a single character to the specified FSL port.  (NONBLOCKING)
42
void fsl0nput(const char s)
43
{
44
        nputfsl(s, FSL0);
45
        return;
46
}
47
 
48
// Get a single character from the specified FSL port.  (BLOCKING)
49
char fsl0get(char * s)
50
{
51
        char inchar;
52
 
53
        getfsl(inchar, FSL0);
54
        if(s!=NULL) (*s) = inchar;
55
 
56
        return inchar;
57
}
58
 
59
// Get a single character from the specified FSL port.  (NONBLOCKING)
60
char fsl0nget(char * s)
61
{
62
        char inchar;
63
 
64
        ngetfsl(inchar, FSL0);
65
        if(s!=NULL) (*s) = inchar;
66
 
67
        return inchar;
68
}
69
 
70
// Print the hexadecimal representation of a 32-bit integer to the specified FSL port.
71
void fsl0hex(const unsigned int val)
72
{
73
        char hexstring[10];
74
        unsigned int shiftval = val;
75
        char maskval;
76
        int ctr;
77
 
78
        for(ctr=9; ctr>1; ctr--)
79
        {
80
                maskval = shiftval & 0x0000000F;
81
 
82
                if(maskval < 10)
83
                        hexstring[ctr] = maskval + 0x30;
84
                else
85
                        hexstring[ctr] = maskval + (0x41-0xA);
86
 
87
                shiftval = shiftval >> 4;
88
        }
89
 
90
        hexstring[0] = '0';
91
        hexstring[1] = 'x';
92
 
93
        fsl0print(hexstring);
94
 
95
        return;
96
}
97
 

powered by: WebSVN 2.1.0

© copyright 1999-2025 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.