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

Subversion Repositories openrisc

[/] [openrisc/] [trunk/] [rtos/] [freertos-6.1.1/] [Demo/] [HCS12_GCC_banked/] [sci.c] - Blame information for rev 588

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 588 jeremybenn
/**
2
 * sci.c controls SCI for GCC/HCS12 version of FreeRTOS Demo
3
 * Parts taken from the CodeWarrior Demo in order to work similar.
4
 *
5
 * Author Jefferson L Smith, Robotronics Inc.
6
 */
7
 
8
#include "sci.h"
9
#include <sys/ports.h>
10
 
11
//static word SerFlag;                   /* Flags for serial communication */
12
                                       /* Bits: 0 - OverRun error */
13
                                       /*       1 - Framing error */
14
                                       /*       2 - Parity error */
15
                                       /*       3 - Char in RX buffer */
16
                                       /*       4 - Full TX buffer */
17
                                       /*       5 - Running int from TX */
18
                                       /*       6 - Full RX buffer */
19
                                       /*       7 - Noise error */
20
                                       /*       8 - Idle character  */
21
                                       /*       9 - Break detected  */
22
                                       /*      10 - Unused */
23
static word PrescaleValue;
24
//static byte NumMode;                   /* Number of selected baud mode */
25
 
26
 
27
/**
28
 * SCI_SetBaudRateMode
29
 *
30
 * Changes the speed (baud rate).
31
 */
32
byte SCI_SetBaudRateMode(byte Mod)
33
{
34
  // wired for 24 MHz bus --jeffs
35
  static const word SCI_Presc[4] = {39,78,156,313};
36
 
37
  if(Mod >= 4)                         /* Is mode in baud mode list */
38
    return ERR_VALUE;                  /* If no then error */
39
  //NumMode = Mod;                       /* New baud mode */
40
  PrescaleValue = SCI_Presc[Mod];     /* Prescaler in high speed mode */
41
 
42
  /* SCI0CR1: LOOPS=0,SCISWAI=0,RSRC=0,M=0,WAKE=0,ILT=0,PE=0,PT=0 */
43
  SCICR1 = 0x00;                       /* Set the SCI configuration */
44
  /* SCI0SR2: ??=0,??=0,??=0,??=0,??=0,BRK13=0,TXDIR=0,RAF=0 */
45
  SCISR2 = 0x00;                       /* Set the Break Character Length and Transmitter pin data direction in Single-wire mode */
46
  SCISR1;                             /* Reset interrupt request flags */
47
  SCIBD = PrescaleValue;                  /* Set prescaler bits */
48
  /* SCI0CR2: SCTIE=0,TCIE=0,RIE=1,ILIE=0,TE=1,RE=1,RWU=0,SBK=0 */
49
  SCICR2 = 0x2c;                         /* Disable error interrupts */
50
 
51
  return ERR_OK;                       /* OK */
52
}
53
 
54
#if 0  //(not used)
55
 
56
/**
57
 * SCI_Init (bean AsynchroSerial)
58
 *
59
 * This enables SCI.
60
 */
61
void SCI_Init(void)
62
{
63
  PrescaleValue = 39;                      /* Precaler in high speed mode */
64
 
65
  /* SCI0CR1: LOOPS=0,SCISWAI=0,RSRC=0,M=0,WAKE=0,ILT=0,PE=0,PT=0 */
66
  SCICR1 = 0x00;                       /* Set the SCI configuration */
67
  /* SCI0SR2: ??=0,??=0,??=0,??=0,??=0,BRK13=0,TXDIR=0,RAF=0 */
68
  SCISR2 = 0x00;                       /* Set the Break Character Length and Transmitter pin data direction in Single-wire mode */
69
  SCISR1;                             /* Reset interrupt request flags */
70
  SCIBD = PrescaleValue;                  /* Set prescaler bits */
71
  /* SCI0CR2: SCTIE=0,TCIE=0,RIE=1,ILIE=0,TE=1,RE=1,RWU=0,SBK=0 */
72
  SCICR2 = 0x2c;                         /* Disable error interrupts */
73
}
74
#endif
75
 

powered by: WebSVN 2.1.0

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