]> git.sur5r.net Git - freertos/blob - Demo/HCS12_CodeWarrior_small/CODE/Byte1.C
Prepare files for export (MicroBlaze project).
[freertos] / Demo / HCS12_CodeWarrior_small / CODE / Byte1.C
1 /** ###################################################################\r
2 **     THIS BEAN MODULE IS GENERATED BY THE TOOL. DO NOT MODIFY IT.\r
3 **     Filename  : Byte1.C\r
4 **     Project   : RTOSDemo\r
5 **     Processor : MC9S12C32CFU\r
6 **     Beantype  : ByteIO\r
7 **     Version   : Bean 02.019, Driver 01.03, CPU db: 2.87.276\r
8 **     Compiler  : Metrowerks HC12 C Compiler\r
9 **     Date/Time : 10/05/2005, 11:49\r
10 **     Abstract  :\r
11 **         This bean "ByteIO" implements an one-byte input/output.\r
12 **         It uses one 8-bit port.\r
13 **         Note: This bean is set to work in Output direction only.\r
14 **         Methods of this bean are mostly implemented as a macros \r
15 **         (if supported by target langauage and compiler).\r
16 **     Settings  :\r
17 **         Port name                   : B\r
18 **\r
19 **         Initial direction           : Output (direction cannot be changed)\r
20 **         Initial output value        : 0 = 000H\r
21 **         Initial pull option         : off\r
22 **\r
23 **         8-bit data register         : PORTB     [1]\r
24 **         8-bit control register      : DDRB      [3]\r
25 **\r
26 **             ----------------------------------------------------\r
27 **                   Bit     |   Pin   |   Name\r
28 **             ----------------------------------------------------\r
29 **                    0      |    16   |   PB0_ADDR0_DATA0\r
30 **                    1      |    17   |   PB1_ADDR1_DATA1\r
31 **                    2      |    18   |   PB2_ADDR2_DATA2\r
32 **                    3      |    19   |   PB3_ADDR3_DATA3\r
33 **                    4      |    20   |   PB4_ADDR4_DATA4\r
34 **                    5      |    21   |   PB5_ADDR5_DATA5\r
35 **                    6      |    22   |   PB6_ADDR6_DATA6\r
36 **                    7      |    23   |   PB7_ADDR7_DATA7\r
37 **             ----------------------------------------------------\r
38 **     Contents  :\r
39 **         PutBit - void Byte1_PutBit(byte Bit,bool Val);\r
40 **         NegBit - void Byte1_NegBit(byte Bit);\r
41 **\r
42 **     (c) Copyright UNIS, spol. s r.o. 1997-2002\r
43 **     UNIS, spol. s r.o.\r
44 **     Jundrovska 33\r
45 **     624 00 Brno\r
46 **     Czech Republic\r
47 **     http      : www.processorexpert.com\r
48 **     mail      : info@processorexpert.com\r
49 ** ###################################################################*/\r
50 \r
51 \r
52 /* MODULE Byte1. */\r
53 \r
54 #include "Byte1.h"\r
55 /*Including shared modules, which are used for all project*/\r
56 #include "PE_Types.h"\r
57 #include "PE_Error.h"\r
58 #include "PE_Const.h"\r
59 #include "IO_Map.h"\r
60 \r
61 #include "Cpu.h"\r
62 \r
63 /* Definition of DATA and CODE segments for this bean. User can specify where\r
64    these segments will be located on "Build options" tab of the selected CPU bean. */\r
65 #pragma DATA_SEG Byte1_DATA            /* Data section for this module. */\r
66 #pragma CODE_SEG Byte1_CODE            /* Code section for this module. */\r
67 \r
68 /*\r
69 ** ===================================================================\r
70 **     Method      :  Byte1_GetMsk (bean ByteIO)\r
71 **\r
72 **     Description :\r
73 **         This method is internal. It is used by Processor Expert\r
74 **         only.\r
75 ** ===================================================================\r
76 */\r
77 byte Byte1_Table[8]={ 1, 2, 4, 8, 16, 32, 64, 128 }; /* Table of mask constants */\r
78 \r
79 byte Byte1_GetMsk(byte Value)\r
80 {\r
81   return((Value<8)?Byte1_Table[Value]:0); /* Return appropriate bit mask */\r
82 }\r
83 \r
84 /*\r
85 ** ===================================================================\r
86 **     Method      :  Byte1_PutBit (bean ByteIO)\r
87 **\r
88 **     Description :\r
89 **         This method writes the new value to the specified bit\r
90 **         of the output value.\r
91 **     Parameters  :\r
92 **         NAME       - DESCRIPTION\r
93 **         Bitnum     - Number of the bit (0 to 7)\r
94 **         Val        - New value of the bit (FALSE or TRUE)\r
95 **                      FALSE = "0" or "Low", TRUE = "1" or "High"\r
96 **     Returns     : Nothing\r
97 ** ===================================================================\r
98 */\r
99 void Byte1_PutBit(byte BitNum, byte Value)\r
100 {\r
101   byte Mask=Byte1_GetMsk(BitNum);      /* Temporary variable - bit mask */\r
102 \r
103   if (Mask)                            /* Is bit mask correct? */\r
104     if (Value) {                       /* Is it one to be written? */\r
105       PORTB |= Mask;                   /* Set appropriate bit on port */\r
106     }\r
107     else {                             /* Is it zero to be written? */\r
108       PORTB &= ~Mask;                  /* Clear appropriate bit on port */\r
109     }\r
110 }\r
111 \r
112 /*\r
113 ** ===================================================================\r
114 **     Method      :  Byte1_NegBit (bean ByteIO)\r
115 **\r
116 **     Description :\r
117 **         This method negates (invertes) the specified bit of the\r
118 **         output value.\r
119 **     Parameters  :\r
120 **         NAME       - DESCRIPTION\r
121 **         Bit        - Number of the bit to invert (0 to 7)\r
122 **     Returns     : Nothing\r
123 ** ===================================================================\r
124 */\r
125 void Byte1_NegBit(byte BitNum)\r
126 {\r
127   byte Mask=Byte1_GetMsk(BitNum);      /* Temporary variable - bit mask */\r
128 \r
129   if (Mask) {                          /* Is bit mask correct? */\r
130     PORTB ^= Mask;                     /* Negate appropriate bit on port */\r
131   }\r
132 }\r
133 \r
134 \r
135 /* END Byte1. */\r
136 \r
137 /*\r
138 ** ###################################################################\r
139 **\r
140 **     This file was created by UNIS Processor Expert 03.33 for \r
141 **     the Motorola HCS12 series of microcontrollers.\r
142 **\r
143 ** ###################################################################\r
144 */\r