Mercurial > ecos
comparison packages/io/serial/current/src/arm/aeb_serial.c @ 66:bf00f99aec69 ecos-sw-2000-02-02
Merge from eCos master repository on 2000-02-02-19:16:44-GMT
| author | jlarmour |
|---|---|
| date | Wed, 02 Feb 2000 19:57:02 +0000 |
| parents | c38311975d4f |
| children |
comparison
equal
deleted
inserted
replaced
| 65:b4822dd69c33 | 66:bf00f99aec69 |
|---|---|
| 7 //========================================================================== | 7 //========================================================================== |
| 8 //####COPYRIGHTBEGIN#### | 8 //####COPYRIGHTBEGIN#### |
| 9 // | 9 // |
| 10 // ------------------------------------------- | 10 // ------------------------------------------- |
| 11 // The contents of this file are subject to the Red Hat eCos Public License | 11 // The contents of this file are subject to the Red Hat eCos Public License |
| 12 // Version 1.0 (the "License"); you may not use this file except in | 12 // Version 1.1 (the "License"); you may not use this file except in |
| 13 // compliance with the License. You may obtain a copy of the License at | 13 // compliance with the License. You may obtain a copy of the License at |
| 14 // http://sourceware.cygnus.com/ecos | 14 // http://www.redhat.com/ |
| 15 // | 15 // |
| 16 // Software distributed under the License is distributed on an | 16 // Software distributed under the License is distributed on an "AS IS" |
| 17 // basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the | 17 // basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the |
| 18 // License for the specific language governing rights and limitations under | 18 // License for the specific language governing rights and limitations under |
| 19 // the License. | 19 // the License. |
| 20 // | 20 // |
| 21 // The Original Code is eCos - Embedded Configurable Operating System, | 21 // The Original Code is eCos - Embedded Configurable Operating System, |
| 169 aeb_serial_info *aeb_chan = (aeb_serial_info *)chan->dev_priv; | 169 aeb_serial_info *aeb_chan = (aeb_serial_info *)chan->dev_priv; |
| 170 volatile struct serial_port *port = (volatile struct serial_port *)aeb_chan->base; | 170 volatile struct serial_port *port = (volatile struct serial_port *)aeb_chan->base; |
| 171 unsigned short baud_divisor = select_baud[new_config->baud]; | 171 unsigned short baud_divisor = select_baud[new_config->baud]; |
| 172 unsigned char _lcr, _ier; | 172 unsigned char _lcr, _ier; |
| 173 if (baud_divisor == 0) return false; | 173 if (baud_divisor == 0) return false; |
| 174 _ier = port->ier; | 174 _ier = port->REG_IER; |
| 175 port->ier = 0; // Disable port interrupts while changing hardware | 175 port->REG_IER = 0; // Disable port interrupts while changing hardware |
| 176 _lcr = select_word_length[new_config->word_length - CYGNUM_SERIAL_WORD_LENGTH_5] | | 176 _lcr = select_word_length[new_config->word_length - CYGNUM_SERIAL_WORD_LENGTH_5] | |
| 177 select_stop_bits[new_config->stop] | | 177 select_stop_bits[new_config->stop] | |
| 178 select_parity[new_config->parity]; | 178 select_parity[new_config->parity]; |
| 179 port->lcr = _lcr; | 179 port->REG_LCR = _lcr; |
| 180 port->lcr |= LCR_DL; | 180 port->REG_LCR |= LCR_DL; |
| 181 port->mdl = baud_divisor >> 8; | 181 port->REG_MDL = baud_divisor >> 8; |
| 182 port->ldl = baud_divisor & 0xFF; | 182 port->REG_LDL = baud_divisor & 0xFF; |
| 183 port->lcr &= ~LCR_DL; | 183 port->REG_LCR &= ~LCR_DL; |
| 184 if (init) { | 184 if (init) { |
| 185 port->fcr = 0x07; // Enable and clear FIFO | 185 port->REG_FCR = 0x07; // Enable and clear FIFO |
| 186 if (chan->out_cbuf.len != 0) { | 186 if (chan->out_cbuf.len != 0) { |
| 187 port->ier = IER_RCV; | 187 port->REG_IER = IER_RCV; |
| 188 } else { | 188 } else { |
| 189 port->ier = 0; | 189 port->REG_IER = 0; |
| 190 } | 190 } |
| 191 port->mcr = MCR_INT|MCR_DTR|MCR_RTS; // Master interrupt enable | 191 port->REG_MCR = MCR_INT|MCR_DTR|MCR_RTS; // Master interrupt enable |
| 192 } else { | 192 } else { |
| 193 port->ier = _ier; | 193 port->REG_IER = _ier; |
| 194 } | 194 } |
| 195 if (new_config != &chan->config) { | 195 if (new_config != &chan->config) { |
| 196 chan->config = *new_config; | 196 chan->config = *new_config; |
| 197 } | 197 } |
| 198 return true; | 198 return true; |
| 239 static bool | 239 static bool |
| 240 aeb_serial_putc(serial_channel *chan, unsigned char c) | 240 aeb_serial_putc(serial_channel *chan, unsigned char c) |
| 241 { | 241 { |
| 242 aeb_serial_info *aeb_chan = (aeb_serial_info *)chan->dev_priv; | 242 aeb_serial_info *aeb_chan = (aeb_serial_info *)chan->dev_priv; |
| 243 volatile struct serial_port *port = (volatile struct serial_port *)aeb_chan->base; | 243 volatile struct serial_port *port = (volatile struct serial_port *)aeb_chan->base; |
| 244 if (port->lsr & LSR_THE) { | 244 if (port->REG_LSR & LSR_THE) { |
| 245 // Transmit buffer is empty | 245 // Transmit buffer is empty |
| 246 port->thr = c; | 246 port->REG_THR = c; |
| 247 return true; | 247 return true; |
| 248 } else { | 248 } else { |
| 249 // No space | 249 // No space |
| 250 return false; | 250 return false; |
| 251 } | 251 } |
| 256 aeb_serial_getc(serial_channel *chan) | 256 aeb_serial_getc(serial_channel *chan) |
| 257 { | 257 { |
| 258 unsigned char c; | 258 unsigned char c; |
| 259 aeb_serial_info *aeb_chan = (aeb_serial_info *)chan->dev_priv; | 259 aeb_serial_info *aeb_chan = (aeb_serial_info *)chan->dev_priv; |
| 260 volatile struct serial_port *port = (volatile struct serial_port *)aeb_chan->base; | 260 volatile struct serial_port *port = (volatile struct serial_port *)aeb_chan->base; |
| 261 while ((port->lsr & LSR_RSR) == 0) ; // Wait for char | 261 while ((port->REG_LSR & LSR_RSR) == 0) ; // Wait for char |
| 262 c = port->rhr; | 262 c = port->REG_RHR; |
| 263 return c; | 263 return c; |
| 264 } | 264 } |
| 265 | 265 |
| 266 // Set up the device characteristics; baud rate, etc. | 266 // Set up the device characteristics; baud rate, etc. |
| 267 static bool | 267 static bool |
| 274 static void | 274 static void |
| 275 aeb_serial_start_xmit(serial_channel *chan) | 275 aeb_serial_start_xmit(serial_channel *chan) |
| 276 { | 276 { |
| 277 aeb_serial_info *aeb_chan = (aeb_serial_info *)chan->dev_priv; | 277 aeb_serial_info *aeb_chan = (aeb_serial_info *)chan->dev_priv; |
| 278 volatile struct serial_port *port = (volatile struct serial_port *)aeb_chan->base; | 278 volatile struct serial_port *port = (volatile struct serial_port *)aeb_chan->base; |
| 279 port->ier |= IER_XMT; // Enable xmit interrupt | 279 port->REG_IER |= IER_XMT; // Enable xmit interrupt |
| 280 } | 280 } |
| 281 | 281 |
| 282 // Disable the transmitter on the device | 282 // Disable the transmitter on the device |
| 283 static void | 283 static void |
| 284 aeb_serial_stop_xmit(serial_channel *chan) | 284 aeb_serial_stop_xmit(serial_channel *chan) |
| 285 { | 285 { |
| 286 aeb_serial_info *aeb_chan = (aeb_serial_info *)chan->dev_priv; | 286 aeb_serial_info *aeb_chan = (aeb_serial_info *)chan->dev_priv; |
| 287 volatile struct serial_port *port = (volatile struct serial_port *)aeb_chan->base; | 287 volatile struct serial_port *port = (volatile struct serial_port *)aeb_chan->base; |
| 288 port->ier &= ~IER_XMT; // Disable xmit interrupt | 288 port->REG_IER &= ~IER_XMT; // Disable xmit interrupt |
| 289 } | 289 } |
| 290 | 290 |
| 291 // Serial I/O - low level interrupt handler (ISR) | 291 // Serial I/O - low level interrupt handler (ISR) |
| 292 static cyg_uint32 | 292 static cyg_uint32 |
| 293 aeb_serial_ISR(cyg_vector_t vector, cyg_addrword_t data) | 293 aeb_serial_ISR(cyg_vector_t vector, cyg_addrword_t data) |
| 305 { | 305 { |
| 306 serial_channel *chan = (serial_channel *)data; | 306 serial_channel *chan = (serial_channel *)data; |
| 307 aeb_serial_info *aeb_chan = (aeb_serial_info *)chan->dev_priv; | 307 aeb_serial_info *aeb_chan = (aeb_serial_info *)chan->dev_priv; |
| 308 volatile struct serial_port *port = (volatile struct serial_port *)aeb_chan->base; | 308 volatile struct serial_port *port = (volatile struct serial_port *)aeb_chan->base; |
| 309 unsigned char isr; | 309 unsigned char isr; |
| 310 isr = port->isr & 0x0E; | 310 isr = port->REG_ISR & 0x0E; |
| 311 if (isr == ISR_Tx) { | 311 if (isr == ISR_Tx) { |
| 312 (chan->callbacks->xmt_char)(chan); | 312 (chan->callbacks->xmt_char)(chan); |
| 313 } else if (isr == ISR_Rx) { | 313 } else if (isr == ISR_Rx) { |
| 314 (chan->callbacks->rcv_char)(chan, port->rhr); | 314 (chan->callbacks->rcv_char)(chan, port->REG_RHR); |
| 315 } | 315 } |
| 316 cyg_drv_interrupt_unmask(aeb_chan->int_num); | 316 cyg_drv_interrupt_unmask(aeb_chan->int_num); |
| 317 } | 317 } |
| 318 #endif | 318 #endif |
