]> rtime.felk.cvut.cz Git - sysless.git/blob - arch/h8300/generic/drivers/periph/sci_rs232.h
Sizes of RS232 buffers can be specified by applications.
[sysless.git] / arch / h8300 / generic / drivers / periph / sci_rs232.h
1 /*******************************************************************
2   Components for embedded applications builded for
3   laboratory and medical instruments firmware  
4  
5   sci_rs232.h - H8S SCI interrupt driven RS-232 interface
6  
7   Copyright (C) 2001 by Pavel Pisa pisa@cmp.felk.cvut.cz
8             (C) 2002 by PiKRON Ltd. http://www.pikron.com
9
10 *******************************************************************/
11
12 #ifndef _ID_RS232_H_
13 #define _ID_RS232_H_
14
15 #include <periph/sci_regs.h>
16 //*************************************************************
17 #define SCI_CHAR_XON  0x11
18 #define SCI_CHAR_XOFF 0x13
19 #define SCI_RS232_MODEA SCI_SMR_8N1
20 /* If the input buffer has only SCI_RS232_BUF_FULLTG bytes free, flow
21  * control is used to stop the sender. */
22 #define SCI_RS232_BUF_FULLTG (50) 
23 #define RS232_BAUD_RAW 0xff00
24 #define SCI_RSFLC_HW  0x1
25 #define SCI_RSFLC_XON 0x2
26
27 #define SCI_RSFL_ROR   0x1      /* Overrun error */ /*fronta znaku je plna - doslo k prepsani (RXI)*/
28 #define SCI_RSFL_RFE   0x2      /* Framing error */
29 #define SCI_RSFL_RPE   0x4      /* Parity error */
30 #define SCI_RSFL_SXOFF 0x10     /* Request to send XOFF */
31 #define SCI_RSFL_SXON  0x20     /* Request to send XON */
32 #define SCI_RSFL_TFCDI 0x40     /* Transmission disabled */
33 #define SCI_RSFL_RFCDI 0x80     /* Reception disenabled */
34 #define SCI_RSFL_TIP   0x100    /* Transmittion at Progress */
35 #define SCI_RSFL_TWCTS 0x200    /* Delaying Tx to CTS enabled */
36
37 #define m_TDR()
38 #define m_RDR()
39 #define m_SMR()
40 #define m_SCMR()
41 #define m_SCR()
42 #define m_SSR()
43 #define m_BRR()
44
45 typedef struct{
46     __u8 *buf_beg; //start of adress structur
47     __u8 *buf_end; //end of adress structur - beg+sizeof(struct)
48     __u8 *ip;      //actual position at queue
49     __u8 *op;      //position first unread char of queue
50 } sci_que_t;
51
52 typedef struct sci_info {
53   struct sci_regs *regs;
54   int sci_rs232_baud;
55   int sci_rs232_mode;
56   int sci_rs232_flowc;
57   short sci_rs232_flags;
58   int sci_rs232_irq_cnt;
59
60   /* Functions */
61   void (*sci_rs232_init)(void); /* Poweres this port on and setup interrupt handlers */
62   int  (*sci_rs232_rxd_pin)(void);  /* Reads the state of RxD pin */
63   void (*sci_rs232_rts_true)(void); /* Sets RTS */
64   void (*sci_rs232_rts_false)(void); /* Clears RTS */
65   int  (*sci_rs232_cts)(void);  /* Reads CTS */
66
67   /* Queues */
68   sci_que_t sci_rs232_que_in;
69   sci_que_t sci_rs232_que_out;
70   __u8 *sci_rs232_buf_in;
71   int sci_rs232_buf_in_size;
72   __u8 *sci_rs232_buf_out;
73   int sci_rs232_buf_out_size;
74 } sci_info_t;
75
76 int sci_rs232_sendch(int c, int chan);
77 int sci_rs232_recch(int chan);
78 int sci_rs232_sendstr(const char *s, int chan);
79
80 int sci_rs232_que_out_free(int chan);
81 int sci_rs232_que_in_ready(int chan);
82 int sci_rs232_setmode(long int baud, int mode, int flowc, int chan);
83
84 void sci_rs232_eri_isr(sci_info_t *sci);
85 void sci_rs232_rxi_isr(sci_info_t *sci);
86 void sci_rs232_txi_isr(sci_info_t *sci);
87 void sci_rs232_tei_isr(sci_info_t *sci);
88
89 /* HACK: Include machine specific definitions */
90 #include <periph/sci_channels.h>
91
92
93 #endif /* _ID_RS232_H_ */
94
95 /* Local variables: */
96 /* c-basic-offset:2 */
97 /* End: */