-
Notifications
You must be signed in to change notification settings - Fork 0
/
MB1_Serial_t.h
62 lines (53 loc) · 1.57 KB
/
MB1_Serial_t.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
/**
* @file MB1_serial_com.h
* @author Bui Van Hieu <[email protected]>
* @version 1.0
* @date 07-07-2012
*
* @copyright
* This poject and all of its relevant documents, source codes, compiled libraries are belong
* to <b> Smart Sensing and Intelligent Controlling Group (SSAIC)</b> \n
* You are prohibited to broadcast, distribute, copy, modify, print, or reproduce this in anyway
* without written permission from SSAIC \n
* <b> Copyright (C) 2012 by SSAIC, All Right Reversed </b>
*/
#ifndef __MB1_SERIAL_T_H
#define __MB1_SERIAL_T_H
#include "MB1_Glb.h"
#include "unistd.h"
/* stdStream */
#define USART_stdStream_stdout 0x1
#define USART_stdStream_stdin 0x2
#define USART_stdStream_stderr 0x4
class serial_t {
private:
uint8_t usedUart;
public: serial_t(uint8_t usedUart);
public:
void Restart(uint32_t baudRate);
void Print(uint8_t outChar);
void Print(char outChar);
void Print(uint8_t* outStr);
void Print(char* outStr);
void Print(uint32_t outNum);
void Print(int32_t outNum);
void Out(uint8_t outNum);
void Out(uint16_t outNum);
void Out(uint32_t outNum);
void Out(uint8_t outBuf[], uint32_t bufLen);
uint16_t Get (void);
uint16_t Get_ISR (void);
//enable retarget for printf.
void Retarget (uint8_t stdStream);
};
//retarget functions to overload functions in stdio.h.
#ifdef __cplusplus
extern "C"{
#endif
int _write (int fd, char *ptr, int len);
int _read (int fd, char *ptr, int len);
void _ttywrch(int ch);
#ifdef __cplusplus
}
#endif
#endif /*__SERIAL_T_H */