OpenCores
URL https://opencores.org/ocsvn/openrisc/openrisc/trunk

Subversion Repositories openrisc

[/] [openrisc/] [trunk/] [rtos/] [freertos-6.1.1/] [Demo/] [HCS12_CodeWarrior_banked/] [CODE/] [_COM0.C] - Blame information for rev 797

Go to most recent revision | Details | Compare with Previous | View Log

Line No. Rev Author Line
1 588 jeremybenn
/** ###################################################################
2
**     THIS BEAN MODULE IS GENERATED BY THE TOOL. DO NOT MODIFY IT.
3
**     Filename  : COM0.C
4
**     Project   : RTOSDemo
5
**     Processor : MC9S12DP256BCPV
6
**     Beantype  : AsynchroSerial
7
**     Version   : Bean 02.231, Driver 01.08, CPU db: 2.87.283
8
**     Compiler  : Metrowerks HC12 C Compiler
9
**     Date/Time : 19/06/2005, 15:07
10
**     Abstract  :
11
**         This bean "AsynchroSerial" implements an asynchronous serial
12
**         communication. The bean supports different settings of
13
**         parity, word width, stop-bit and communication speed,
14
**         user can select interrupt or polling handler.
15
**         Communication speed can be changed also in runtime.
16
**         The bean requires one on-chip asynchronous serial channel.
17
**     Settings  :
18
**         Serial channel              : SCI0
19
**
20
**         Protocol
21
**             Init baud rate          : 38400baud
22
**             Width                   : 8 bits
23
**             Stop bits               : 1
24
**             Parity                  : none
25
**             Breaks                  : Disabled
26
**
27
**         Registers
28
**             Input buffer            : SCI0DRL   [207]
29
**             Output buffer           : SCI0DRL   [207]
30
**             Control register        : SCI0CR1   [202]
31
**             Mode register           : SCI0CR2   [203]
32
**             Baud setting reg.       : SCI0BD    [200]
33
**             Special register        : SCI0SR1   [204]
34
**
35
**         Input interrupt
36
**             Vector name             : INT_SCI0
37
**             Priority                : 1
38
**
39
**         Output interrupt
40
**             Vector name             : INT_SCI0
41
**             Priority                : 1
42
**
43
**         Used pins                   :
44
**             ----------------------------------------------------
45
**               Function | On package |    Name
46
**             ----------------------------------------------------
47
**                Input   |     89     |  PS0_RxD0
48
**                Output  |     90     |  PS1_TxD0
49
**             ----------------------------------------------------
50
**
51
**
52
**         Used baud modes             :
53
**             ----------------------------------------------------
54
**               No. |    Mode ID      |  Baud rate
55
**             ----------------------------------------------------
56
**                0  |  Bm_38400baud   |  38400baud
57
**                1  |  Bm_19200baud   |  19200baud
58
**                2  |  Bm_9600baud    |  9600baud
59
**                3  |  Bm_4800baud    |  4800baud
60
**             ----------------------------------------------------
61
**     Contents  :
62
**         SetBaudRateMode - byte COM0_SetBaudRateMode(byte Mod);
63
**
64
**     (c) Copyright UNIS, spol. s r.o. 1997-2002
65
**     UNIS, spol. s r.o.
66
**     Jundrovska 33
67
**     624 00 Brno
68
**     Czech Republic
69
**     http      : www.processorexpert.com
70
**     mail      : info@processorexpert.com
71
** ###################################################################*/
72
 
73
/* MODULE COM0. */
74
 
75
#pragma MESSAGE DISABLE C4002 /* WARNING C4002: Result not used is ignored */
76
#pragma MESSAGE DISABLE C4301 /* INFORMATION C4301: Inline expansion done for function call */
77
 
78
#include "COM0.h"
79
#include "TickTimer.h"
80
#include "Byte1.h"
81
 
82
/* Definition of DATA and CODE segments for this bean. User can specify where
83
   these segments will be located on "Build options" tab of the selected CPU bean. */
84
#pragma DATA_SEG COM0_DATA             /* Data section for this module. */
85
#pragma CODE_SEG COM0_CODE             /* Code section for this module. */
86
 
87
 
88
#define OVERRUN_ERR      1             /* Overrun error flag bit   */
89
#define FRAMING_ERR      2             /* Framing error flag bit   */
90
#define PARITY_ERR       4             /* Parity error flag bit    */
91
#define CHAR_IN_RX       8             /* Char is in RX buffer     */
92
#define FULL_TX          16            /* Full transmit buffer     */
93
#define RUNINT_FROM_TX   32            /* Interrupt is in progress */
94
#define FULL_RX          64            /* Full receive buffer      */
95
#define NOISE_ERR        128           /* Noise erorr flag bit     */
96
#define IDLE_ERR         256           /* Idle character flag bit  */
97
#define BREAK_ERR        512           /* Break detect             */
98
 
99
static word SerFlag;                   /* Flags for serial communication */
100
                                       /* Bits: 0 - OverRun error */
101
                                       /*       1 - Framing error */
102
                                       /*       2 - Parity error */
103
                                       /*       3 - Char in RX buffer */
104
                                       /*       4 - Full TX buffer */
105
                                       /*       5 - Running int from TX */
106
                                       /*       6 - Full RX buffer */
107
                                       /*       7 - Noise error */
108
                                       /*       8 - Idle character  */
109
                                       /*       9 - Break detected  */
110
                                       /*      10 - Unused */
111
static word PrescHigh;
112
static byte NumMode;                   /* Number of selected baud mode */
113
 
114
 
115
/*
116
** ===================================================================
117
**     Method      :  HWEnDi (bean AsynchroSerial)
118
**
119
**     Description :
120
**         This method is internal. It is used by Processor Expert
121
**         only.
122
** ===================================================================
123
*/
124
static void HWEnDi(void)
125
{
126
    SCI0CR2_TE = 1;                    /* Enable transmitter */
127
    SCI0CR2_RE = 1;                    /* Enable receiver */
128
    SCI0CR2_RIE = 1;                   /* Enable recieve interrupt */
129
}
130
 
131
/*
132
** ===================================================================
133
**     Method      :  COM0_SetBaudRateMode (bean AsynchroSerial)
134
**
135
**     Description :
136
**         This method changes the channel communication speed (baud
137
**         rate). This method can be used only if you specify a list
138
**         of possible period settings at design time (see 
139
**         dialog box> - Runtime setting - from a list of values).
140
**         Each of these settings constitutes a mode and Processor
141
**         Expert^[TM] assigns them a mode identifier. The prescaler
142
**         and compare values corresponding to each mode are
143
**         calculated at design time. You may switch modes at
144
**         runtime by referring only to a mode identifier. No
145
**         run-time calculations are performed, all the calculations
146
**         are performed at design time.
147
**     Parameters  :
148
**         NAME            - DESCRIPTION
149
**         Mod             - Timing mode to set
150
**     Returns     :
151
**         ---             - Error code, possible codes:
152
**                           ERR_OK - OK
153
**                           ERR_SPEED - This device does not work in
154
**                           the active speed mode
155
** ===================================================================
156
*/
157
byte COM0_SetBaudRateMode(byte Mod)
158
{
159
  static const word COM0_PrescHigh[4] = {41,81,163,326};
160
 
161
  if(Mod >= 4)                         /* Is mode in baud mode list */
162
    return ERR_VALUE;                  /* If no then error */
163
  NumMode = Mod;                       /* New baud mode */
164
  PrescHigh = COM0_PrescHigh[Mod];     /* Prescaler in high speed mode */
165
  SCI0BD = PrescHigh;                  /* Set prescaler bits */
166
  return ERR_OK;                       /* OK */
167
}
168
 
169
/*
170
** ===================================================================
171
**     Method      :  COM0_Init (bean AsynchroSerial)
172
**
173
**     Description :
174
**         This method is internal. It is used by Processor Expert
175
**         only.
176
** ===================================================================
177
*/
178
void COM0_Init(void)
179
{
180
  PrescHigh = 41;                      /* Precaler in high speed mode */
181
  SerFlag = 0;                         /* Reset flags */
182
  NumMode = 0;                         /* Number of selected baud mode */
183
  /* SCI0CR1: LOOPS=0,SCISWAI=1,RSRC=0,M=0,WAKE=0,ILT=0,PE=0,PT=0 */
184
  SCI0CR1 = 64;                        /* Set the SCI configuration */
185
  /* SCI0SR2: ??=0,??=0,??=0,??=0,??=0,BRK13=0,TXDIR=0,RAF=0 */
186
  SCI0SR2 = 0;                         /* Set the Break Character Length and Transmitter pin data direction in Single-wire mode */
187
  SCI0SR1;                             /* Reset interrupt request flags */
188
  /* SCI0CR2: SCTIE=0,TCIE=0,RIE=0,ILIE=0,TE=0,RE=0,RWU=0,SBK=0 */
189
  SCI0CR2 = 0;                         /* Disable error interrupts */
190
  SCI0BD = PrescHigh;                  /* Set prescaler bits */
191
  HWEnDi();                            /* Enable/disable device according to status flags */
192
}
193
 
194
 
195
/* END COM0. */
196
 
197
 
198
/*
199
** ###################################################################
200
**
201
**     This file was created by UNIS Processor Expert 03.33 for
202
**     the Motorola HCS12 series of microcontrollers.
203
**
204
** ###################################################################
205
*/

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.