Chameleon-Mini
Terminal.h
1 /*
2  * CommandLine.h
3  *
4  * Created on: 10.02.2013
5  * Author: skuser
6  */
7 
8 #ifndef TERMINAL_H_
9 #define TERMINAL_H_
10 
11 #include "../Common.h"
12 #include "../LUFA/Drivers/USB/USB.h"
13 #include "XModem.h"
14 #include "CommandLine.h"
15 
16 #define TERMINAL_VBUS_PORT PORTD
17 #define TERMINAL_VBUS_MASK PIN5_bm
18 
19 #define TERMINAL_BUFFER_SIZE 512
20 
21 typedef enum {
22  TERMINAL_UNINITIALIZED,
23  TERMINAL_INITIALIZING,
24  TERMINAL_INITIALIZED,
25  TERMINAL_UNITIALIZING
26 } TerminalStateEnum;
27 
28 extern uint8_t TerminalBuffer[TERMINAL_BUFFER_SIZE];
29 extern uint16_t TerminalBufferIdx;
30 extern USB_ClassInfo_CDC_Device_t TerminalHandle;
31 extern TerminalStateEnum TerminalState;
32 
33 void TerminalInit(void);
34 void TerminalTask(void);
35 void TerminalTick(void);
36 
37 /*void TerminalSendHex(void* Buffer, uint16_t ByteCount);*/
38 INLINE void TerminalSendByte(uint8_t Byte);
39 INLINE void TerminalFlushBuffer(void);
40 void TerminalSendBlock(const void *Buffer, uint16_t ByteCount);
41 
42 INLINE void TerminalSendChar(char c);
43 void TerminalSendString(const char *s);
44 void TerminalSendStringP(const char *s);
45 
46 void EVENT_USB_Device_Connect(void);
47 void EVENT_USB_Device_Disconnect(void);
48 void EVENT_USB_Device_ConfigurationChanged(void);
49 void EVENT_USB_Device_ControlRequest(void);
50 
51 INLINE void TerminalSendChar(char c) { CDC_Device_SendByte(&TerminalHandle, c); }
52 INLINE void TerminalSendByte(uint8_t Byte) { CDC_Device_SendByte(&TerminalHandle, Byte); }
53 
54 INLINE void TerminalFlushBuffer(void) {
55  CDC_Device_Flush(&TerminalHandle);
56  TerminalBufferIdx = 0;
57  TerminalBuffer[TerminalBufferIdx] = '\0';
58 }
59 
60 #endif /* TERMINAL_H_ */