-
Notifications
You must be signed in to change notification settings - Fork 0
/
mcuicom.h
68 lines (53 loc) · 2.51 KB
/
mcuicom.h
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
#ifndef MCUICOM_H
#define MCUICOM_H
#ifndef CMDEND
#define CMDEND "\r"
#endif
/*****************************************************************************************************
* Serial port timing configuration: 9600 baud *
*****************************************************************************************************/
#include "clock.h"
#define BAUDRATE 9600 //Desired Baud Rate
#define BRGVAL ((FCY/BAUDRATE)/16)-1 //Formula for U1BRG register
//from dsPIC30F Family
//Reference Manual
/*****************************************************************************************************
* Variable definitions *
*****************************************************************************************************/
#include "datastruc/buffer.h"
#ifndef MCUICOM_C
/**
* Receive buffer for the communication with the other MCU (using UART1).
*/
extern buffer_t mcuicom_rcv_buf;
#endif
/*****************************************************************************************************
* Function declarations *
*****************************************************************************************************/
/**
* Set up UART1 for intercommunication with the other MCU (motorctl program).
*/
inline void mcuicom_setup(void);
int mcuicom_send(const char * const data);
/**
* Copy the first fully received GPMCU command from the receive buffer to the
* user's buffer. If no GPMCU command has been fully received yet, don't copy
* anything. If a GPMCU command has been fully received, it will be copied
* alongside with the command separator.
*
* @param buf Buffer to copy the command to.
* @param size Size of the buffer.
* @param full Output flag set to true if the command has been fully copied
* (i.e. the buffer had enough free space) and set to false if
* the command could not be fully copied to the buffer (i.e. the
* buffer didn't have enough free space).
*
* @returns Amount of bytes copied.
*/
int mcuicom_read_cmd(char buf[], int size, bool_t *full);
/**
* Return true if a full command is available (i.e. a command end mark has been
* received).
*/
bool_t mcuicom_cmd_available(void);
#endif