1: 2: 3: 4: 5: 6: 7: 8: 9: 10: 11: 12:
13:
14: 15: 16: 17:
18:
19: #include <tk/tkernel.h>
20: #include <sys/sysdef.h>
21:
22: #if USE_TMONITOR
23: #include "../../libtm.h"
24:
25: #ifdef IOTE_RX231
26: #if TM_COM_SERIAL_DEV
27:
28: #define INTNO_TXI6 226
29: #define INTNO_RXI6 227
30:
31: #define PCLK (27000000UL)
32: #define ICLK (54000000UL)
33: #define RS_BAUD_RATE (115200)
34:
35: #define SCI6_SMR (0x008A0C0UL)
36: #define SCI6_BRR (0x008A0C1UL)
37: #define SCI6_SCR (0x008A0C2UL)
38: #define SCI6_TDR (0x008A0C3UL)
39: #define SCI6_SSR (0x008A0C4UL)
40: #define SCI6_RDR (0x008A0C5UL)
41: #define SCI6_SCMR (0x008A0C6UL)
42:
43: #define SCR_TIE (0x80)
44: #define SCR_RIE (0x40)
45: #define SCR_TE (0x20)
46: #define SCR_RE (0x10)
47:
48: #define SSR_TDRE (0x80)
49: #define SSR_RDRF (0x40)
50: #define SSR_ERR (0x38)
51:
52: EXPORT void tm_snd_dat( const UB* buf, INT size )
53: {
54: UB *b;
55:
56: for( b = (UB *)buf; size > 0; size--, b++ ){
57: while( (in_b(SCI6_SSR) & SSR_TDRE) == 0);
58: out_b( SCI6_TDR, *b );
59: }
60: }
61:
62: EXPORT void tm_rcv_dat( UB* buf, INT size )
63: {
64: UB ssr;
65:
66: for( ; size > 0; size--, buf++ ){
67: while(1) {
68: ssr = in_b(SCI6_SSR);
69: if( (ssr & SSR_RDRF) != 0) {
70: *buf = in_b( SCI6_RDR );
71: break;
72: } else if( ssr & SSR_ERR ) {
73: out_b( SCI6_SSR, ssr & ~SSR_ERR);
74: }
75: }
76: }
77: }
78:
79: EXPORT void tm_com_init(void)
80: {
81: _UW dly;
82:
83:
84: out_b(SCI6_SCR, 0x00);
85: out_b(SCI6_SCMR, 0xF2);
86: out_b(SCI6_SMR, 0x00);
87: out_b(SCI6_BRR, (PCLK / (64 / 2 * RS_BAUD_RATE)) - 1);
88:
89: dly = ICLK/5/RS_BAUD_RATE;
90: while ((dly--) != 0) ;
91:
92: out_b(SCI6_SCR, 0x30);
93: }
94:
95: #endif
96: #endif
97: #endif