1 /*******************************************************************
2 Components for embedded applications builded for
3 laboratory and medical instruments firmware
5 sci_rs232.h - H8S SCI interrupt driven RS-232 interface
7 Copyright (C) 2001 by Pavel Pisa pisa@cmp.felk.cvut.cz
8 (C) 2002 by PiKRON Ltd. http://www.pikron.com
10 *******************************************************************/
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
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 */
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
52 typedef struct sci_info {
53 struct sci_regs *regs;
57 short sci_rs232_flags;
58 int sci_rs232_irq_cnt;
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 */
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;
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);
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);
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);
89 /* HACK: Include machine specific definitions */
90 #include <periph/sci_channels.h>
93 #endif /* _ID_RS232_H_ */
95 /* Local variables: */
96 /* c-basic-offset:2 */