00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00055 #include <sys/ports.h>
00056
00057 #define BIT_0 (1<<0)
00058 #define BIT_1 (1<<1)
00059 #define BIT_2 (1<<2)
00060 #define BIT_3 (1<<3)
00061 #define BIT_4 (1<<4)
00062 #define BIT_5 (1<<5)
00063 #define BIT_6 (1<<6)
00064 #define BIT_7 (1<<7)
00065
00066
00067 #define BOARD_RX (BIT_0)
00068 #define BOARD_TX (BIT_1)
00069 #define BOARD_LCD_0 (BIT_2)
00070 #define BOARD_LCD_1 (BIT_3)
00071 #define BOARD_LCD_2 (BIT_4)
00072 #define BOARD_LCD_3 (BIT_5)
00073
00074
00075 #define BOARD_KEY_0 (BIT_0)
00076 #define BOARD_KEY_1 (BIT_1)
00077 #define BOARD_KEY_2 (BIT_2)
00078 #define BOARD_ROM_DIS (BIT_3)
00079 #define BOARD_LCD_4 (BIT_4)
00080 #define BOARD_LCD_5 (BIT_5)
00081 #define BOARD_LCD_6 (BIT_6)
00082 #define BOARD_KEY_3 (BIT_7)
00083
00084
00085 #define BOARD_PEB_0 (BIT_0)
00086 #define BOARD_PEB_1 (BIT_1)
00087 #define BOARD_PEB_2 (BIT_2)
00088 #define BOARD_PEB_3 (BIT_3)
00089 #define BOARD_PEB_4 (BIT_4)
00090 #define BOARD_PEB_5 (BIT_5)
00091 #define BOARD_PEB_6 (BIT_6)
00092 #define BOARD_PEB_7 (BIT_7)
00093
00094
00095 #define EBCS_CMD_FAN (BOARD_LCD_5)
00096 #define EBCS_CMD_LIGHT (BOARD_LCD_6)
00097 #define EBCS_SENSE_LIGHT (BOARD_KEY_0)
00098 #define EBCS_SENSE_MAINS (BOARD_PE2)
00099
00100 int __attribute__((noreturn)) main (void);
00101 void _start (void);
00102 void delay_ms (unsigned ms);
00103
00104 void
00105 _start()
00106 {
00107 set_bus_expanded ();
00108
00109 main ();
00110 }
00111
00112 #define TABLE_SIZE(X) ((sizeof X) / sizeof (X[0]))
00113
00114
00115
00116
00117
00118
00119
00120 #define SPEED(T,CNT) ((((T)/100) & 0x0F) | ((CNT) & 0x0F)<<4)
00121
00122 static const unsigned char speeds[] = {
00123 SPEED(200,4),
00124 SPEED(500,2),
00125 SPEED(300,1),
00126 SPEED(500,5),
00127 SPEED(800,3),
00128 SPEED(200,4),
00129 SPEED(100,6),
00130 SPEED(500,4),
00131
00132 SPEED(200,3),
00133 SPEED(600,4),
00134 SPEED(100,2),
00135 SPEED(400,6),
00136 SPEED(800,2),
00137 SPEED(100,1),
00138 SPEED(900,1),
00139 SPEED(100,2),
00140 SPEED(900,1),
00141 SPEED(100,2),
00142 SPEED(900,1),
00143
00144 SPEED(800,4),
00145 SPEED(100,1),
00146 SPEED(800,4),
00147 SPEED(100,2),
00148 SPEED(800,3),
00149 SPEED(100,4),
00150 SPEED(800,2),
00151 SPEED(100,8),
00152 SPEED(800,1),
00153
00154 SPEED(1500,2)
00155 };
00156
00157
00158
00159 void
00160 delay_ms (unsigned ms)
00161 {
00162 unsigned short tcnt;
00163
00164 while (ms > 0)
00165 {
00166 unsigned i;
00167
00168 for (i = 100; --i != 0;)
00169 tcnt = get_timer_counter ();
00170
00171 ms--;
00172 }
00173 }
00174
00175 int
00176 main ()
00177 {
00178 unsigned short i;
00179 unsigned short dt;
00180 short j;
00181
00182 i = 0;
00183 while (1)
00184 {
00185 dt = speeds[i];
00186 j = (short) (speeds[i] >> 4);
00187 dt = (unsigned short) ((speeds[i] & (char) 0x0F) * (char) 100);
00188
00189 do {
00190
00191 _io_ports[M6811_PORTA] |= EBCS_CMD_FAN | EBCS_CMD_LIGHT;
00192
00193
00194 delay_ms (dt);
00195
00196
00197 _io_ports[M6811_PORTA] &= ~(EBCS_CMD_FAN | EBCS_CMD_LIGHT);
00198
00199
00200 delay_ms (dt);
00201 } while (--j >= 0);
00202
00203
00204 i++;
00205 if (i > TABLE_SIZE (speeds))
00206 i = 0;
00207 }
00208 }
00209