return ;
}
+ // Spawn the interrupt channel
CONTIN( uart_bus_dev_bind, udi_channel_spawn, (gcb->channel, 0, UART_OPS_IRQ, rdata),
(udi_channel_t new_channel))
- // new function
rdata->interrupt_channel = new_channel;
-
+
+ // Allocate an RX buffer
+ CONTIN( uart_bus_dev_bind, udi_buf_write, (NULL, RX_BUFFER_SIZE, NULL, 0, 0, UDI_NULL_BUF_PATH),
+ (udi_buf_t *new_buf));
+ if( !new_buf )
+ {
+ // Oh...
+ udi_channel_event_complete( UDI_MCB(rdata->active_cb, udi_channel_event_cb_t),
+ UDI_STAT_RESOURCE_UNAVAIL );
+ return ;
+ }
+ rdata->rx_buffer = new_buf;
+
+ // Create interrupt CB
CONTIN( uart_bus_dev_bind, udi_cb_alloc, (UART_CB_INTR, gcb->channel),
(udi_cb_t *new_cb))
- // new function
if( !new_cb )
{
// Oh...
}
udi_intr_attach_cb_t *intr_cb = UDI_MCB(new_cb, udi_intr_attach_cb_t);
intr_cb->interrupt_idx = 0;
- intr_cb->min_event_pend = 2;
- intr_cb->preprocessing_handle = rdata->pio_handles[PIO_RX];
+ intr_cb->min_event_pend = 1;
+ intr_cb->preprocessing_handle = rdata->pio_handles[PIO_INTR];
+
+ // Attach interrupt
udi_intr_attach_req(intr_cb);
// continued in uart_bus_dev_intr_attach_ack
}
}
void uart_bus_dev_intr_attach_ack(udi_intr_attach_cb_t *intr_attach_cb, udi_status_t status)
{
+ udi_cb_t *gcb = UDI_GCB(intr_attach_cb);
+ rdata_t *rdata = gcb->context;
+
+ // TODO: Allocate interrupt cbs
+ CONTIN(uart_bus_dev_intr_attach_ack, udi_cb_alloc, (UART_CB_INTR_EVENT, rdata->interrupt_channel),
+ (udi_cb_t *new_cb))
+
+ udi_intr_event_cb_t *cb = UDI_MCB(new_cb, udi_intr_event_cb_t);
+ udi_intr_event_rdy(cb);
+
+ udi_channel_event_cb_t *channel_cb = UDI_MCB(rdata->active_cb, udi_channel_event_cb_t);
+
+ udi_channel_event_complete(channel_cb, UDI_OK);
+ // = = = = =
}
void uart_bus_dev_intr_detach_ack(udi_intr_detach_cb_t *intr_detach_cb)
{
{
case UDI_GIO_OP_READ:
// Read from local FIFO
- if( rdata->rx_buffer->buf_size < cb->data_buf->buf_size ) {
+ if( rdata->rx_bytes < cb->data_buf->buf_size ) {
// Local FIFO was empty
udi_gio_xfer_nak(cb, UDI_STAT_DATA_UNDERRUN);
}
case UDI_GIO_OP_WRITE:
// Send to device
udi_pio_trans(uart_gio_write_complete, gcb,
- rdata->pio_handles[PIO_TX], 0, cb->data_buf, NULL);
+ rdata->pio_handles[PIO_TX], 0, cb->data_buf, &cb->data_buf->buf_size);
break;
default:
udi_gio_xfer_nak(cb, UDI_STAT_NOT_SUPPORTED);