summaryrefslogtreecommitdiff
path: root/c/rvcontroller-libraries/rvcontroller-ecalls.h
blob: 7107d21baa9b4f4ef15dfeeabc8ed534bed65f51 (plain)
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
96
97
98
99
100
101
102
103
104
105
106
107
108
/* RVController ecall C Library - C Header Portion
 * A product of Advanced Mesecons Devices, a Cheapie Systems company
 * This is free and unencumbered software released into the public domain.
 * See http://unlicense.org/ for more information */

#ifndef _STDINT_H
#include <stdint.h>
#endif

/* printint(number)
 *
 * Prints a 32-bit signed integer to standard output.
 * number: The number to print */
void printint(int32_t number);

/* printstr(*str)
 *
 * Prints a null-terminated ASCII string to standard output.
 * *str: Pointer to the start of the string data */
void printstr(char *str);

/* printchar(c)
 *
 * Prints a single ASCII character to standard output.
 * c: The character to print */
void printchar(char c);

/* digiline_send(*channel,*msg)
 *
 * Sends an arbitrary digilines message on an arbitrary channel.
 * *channel: Pointer to the start of the null-terminated channel string
 * *msg: Pointer to the start of the null-terminated message string */
void digiline_send(char *channel, char *msg);

/* digiline_bufferlevel()
 *
 * Reads the current number of digilines messages that have been received
 * but not yet read.
 * Returns: Number of messages */
uint8_t digiline_bufferlevel(void);

/* digiline_receive(*channelbuf,channelbuflen,*msgbuf,msgbuflen)
 *
 * Reads the first (oldest) digilines message from the receive queue and removes
 * the message from the queue.
 * Null termination will be added to all received strings.
 * *channelbuf: Pointer to the location of a buffer into which the channel will be placed
 * channelbuflen: The size of the buffer pointed to by channelbuf
 * *msgbuf: Pointer to the location of a buffer into which the message will be placed
 * msgbuflen: The size of the buffer pointed to by channelbuf */
void digiline_receive(char *channelbuf, int channelbuflen, char *msgbuf, int msgbuflen);

/* rdcycle()
 *
 * Reads the number of clock cycles that have passed since the processor was started.
 * Returns: Number of clock cycles */
uint32_t rdcycle(void);

/* rdtime()
 *
 * Reads the number of seconds that have elapsed since the processor was started.
 * Returns: Number of seconds */
uint32_t rdtime(void);

/* digiline_clearbuffer()
 *
 * Discards all received digilines messages currently waiting in the queue. */
void digiline_clearbuffer(void);

/* lightweight_mode(enabled)
 *
 * Turns lightweight mode (see RVController documentation) or or off.
 * enabled: 1 to enable, 0 to disable, other values are reserved */
void lightweight_mode(char enabled);

/* readint()
 *
 * Reads a 32-bit signed integer from the console.
 * This will block until the user enters a valid number.
 * returns: The number typed by the user */
int32_t readint(void);

/* readstr()
 *
 * Reads a null-terminated string from the console.
 * This will block until the user enters something.
 * buffer: Pointer to a buffer that the string will be stored in
 * bufsize: The size of the buffer */
void readstr(char *buffer, uint32_t bufsize);

/* randomint(lowlimit,highlimit)
 *
 * Generates a random integer between lowlimit and highlimit.
 * lowlimit: The lowest number that can be generated (inclusive)
 * highlimit: The highest number that can be generated (inclusive)
 * returns: Random number */
int32_t randomint(int32_t lowlimit,int32_t highlimit);

/* console_clearbuffer()
 *
 * Discards all characters currently waiting in the console input buffer. */
void console_clearbuffer(void);

/* console_readchar()
 *
 * Reads one character from the console input buffer.
 * returns: Character, or 0 if no characters are available to read */
char console_readchar(void);