source: firmware/FSC/src/usart.h@ 17504

Last change on this file since 17504 was 10667, checked in by neise, 14 years ago
File size: 2.8 KB
Line 
1#ifndef __USART_H
2#define __USART_H
3//-----------------------------------------------------------------------------
4
5#include "typedefs.h"
6#include "application.h"
7#include "num_conversion.h"
8
9//-----------------------------------------------------------------------------
10#define USART_RX_BUFFER_SIZE 32 // Receive buffer size
11#define USART_TX_BUFFER_SIZE 5 // Receive buffer size. MUST not be larger 255
12
13#define USART_BAUDRATE 9600 // USART baudrate original
14#define USART_USE_TX // Transmitter used?
15#define USART_USE_RX // Receiver used?
16#define USART_USE_RX_IRQ // RX interrupt used?
17//#define USART_USE_UPPERCASE // Convert received chars to uppercase?
18//-----------------------------------------------------------------------------
19
20#define USART_CHAR_BS 8
21#define USART_CHAR_LF 10
22#define USART_CHAR_CR 13
23#define USART_CHAR_ESC 27
24#define USART_CHAR_SPC 32
25//-----------------------------------------------------------------------------
26
27#define USART_SET_BAUDRATE(br) (UBRRH = (U08)((((U32)F_CPU) /\
28 ((U32)br * 16) - 1) >> 8),\
29 UBRRL = (U08)(((U32)F_CPU) /\
30 ((U32)br * 16) - 1))
31//-----------------------------------------------------------------------------
32
33// USART global variables
34 extern U08 usart_rx_buffer[USART_RX_BUFFER_SIZE];
35 extern U08 usart_tx_buffer[USART_TX_BUFFER_SIZE];
36 extern U08 usart_received_chars;
37
38 extern U08 usart_tx_buffer_index;
39 extern U08 usart_last_char; // last received char
40
41// USART FLAGS
42 extern bool usart_tx_buffer_overflow; // true if usart_tx_buffer was full.
43
44
45
46extern bool usart_tx_buffer_overflow;
47extern U08 usart_tx_buffer_index;
48extern U08 usart_tx_buffer[USART_TX_BUFFER_SIZE];
49
50#ifdef USART_USE_RX_IRQ
51 extern U08 usart_rx_buffer[];
52 //U08 *usart_rx_buffer_ptr = &usart_rx_buffer[0];
53 extern U08 usart_received_chars;
54 extern volatile BOOL usart_rx_ready;
55#endif
56
57//-----------------------------------------------------------------------------
58
59void usart_init(void);
60void usart_write_char(U08 data);
61void usart_write_crlf(void);
62void usart_write_str(pU08 str);
63void usart_writeln_str(pU08 str);
64void usart_write_flash_str(fpU08 str);
65void usart_writeln_flash_str(fpU08 str);
66void usart_write_U08(U08 value,U08 digits);
67void usart_write_S08(S08 value,U08 digits);
68void usart_write_U08_hex(U08 value);
69void usart_write_U08_bin(U08 value);
70void usart_write_U16(U16 value,U08 digits);
71void usart_write_S16(S16 value,U08 digits);
72void usart_write_U16_hex(U16 value);
73void usart_write_U32(U32 value,U08 digits);
74void usart_write_S32(S32 value,U08 digits);
75void usart_write_U32_hex(U32 value);
76void usart_write_float(float value,U08 decimals,U08 digits);
77//-----------------------------------------------------------------------------
78
79#endif
Note: See TracBrowser for help on using the repository browser.