void usbll_transmit ( unsigned epNum, struct sg_t *data, usbll_tx_callback_t callback, void *opaque ) { struct endpointDetails_t *const ep = &connections[epNum]; int first = ( ep->txAdd == ep->txTake ); unsigned next = ep->txAdd + 1 ; if( next > MAXTX_ENTRIES ) next = 0 ; if( next != ep->txTake ){ struct transmitRequest_t *tx = ep->txQueue + ep->txAdd ; tx->flags = 0 ; tx->txStart = tx->txNext = data ; tx->callback = callback ; tx->opaque = opaque ; ep->txAdd = next ; sg_zero_offs(data); if( USBEP_BULKIN == epNum ){ tx->flags |= NEEDNULLTX ; unsigned const len = sg_len(tx->txStart); if( 0 == (len&63) ){ } } if( first ) startTransmit(epNum, tx); } else DEBUGMSG( "Transmit queue overflow\r\n" ); }
// Restart the transmission of a packet that had a problem void RH_RF22::restartTransmit() { _mode = RHModeIdle; _txBufSentIndex = 0; // Serial.println("Restart"); startTransmit(); }
uint8_t RF22::send(const uint8_t* data, uint8_t len) { waitPacketSent(); if (!fillTxBuf(data, len)) return false; startTransmit(); return true; }
bool RF22::send(const uint8_t* data, uint8_t len) { waitPacketSent(); //TODO check piLock(1); if (!fillTxBuf(data, len)) return false; startTransmit(); piUnlock(1); // printBuffer("send:", data, len); return true; }
bool RH_RF22::send(const uint8_t* data, uint8_t len) { bool ret = true; waitPacketSent(); ATOMIC_BLOCK_START; if (!fillTxBuf(data, len)) ret = false; else startTransmit(); ATOMIC_BLOCK_END; // printBuffer("send:", data, len); return ret; }
static void transmitComplete( unsigned char epNum ) { if( 0 )// != epNum ) NODEBUGMSG( "TXCOMP\r\n" ); struct endpointDetails_t *const ep = &connections[epNum]; struct transmitRequest_t *tx = (ep->txTake != ep->txAdd) ? ep->txQueue + ep->txTake : 0 ; struct transmitRequest_t *firstTx = tx ; int completed = 0 ; ep->txState = EPTX_IDLE ; if( tx && tx->txNext && SG_END(tx->txNext) ){ if( tx->flags & NEEDNULLTX ){ DEBUGMSG( "NULL tx\r\n" ); tx->flags &= ~NEEDNULLTX ; } else { if( tx->callback ) tx->callback( tx->opaque, epNum, tx->txStart ); memset( tx, 0, sizeof(*tx) ); // kill pointers ep->txTake++ ; if( ep->txTake > MAXTX_ENTRIES ) ep->txTake = 0 ; } } // done with previous request tx = (ep->txTake != ep->txAdd) ? ep->txQueue + ep->txTake : 0 ; if( 0 ){ // tx DEBUGMSG( "multi-tx 0x" ); DEBUGHEX( sg_len(tx->txStart) ); DEBUGMSG( " bytes\r\n" ); dump_sg( tx->txStart ); } if( tx ){ if( firstTx == tx ) continueTransmit(epNum,tx); else { UDP_CLEAREPFLAGS(UDP->UDP_CSR+epNum, AT91C_UDP_TXCOMP); DEBUGMSG( "nextTx 0x" ); DEBUGHEX( sg_len(tx->txStart) ); DEBUGMSG("\r\n"); startTransmit(epNum,tx); completed = 1 ; } } else { assert(ep->txTake == ep->txAdd); } if( !completed ) UDP_CLEAREPFLAGS(UDP->UDP_CSR+epNum, AT91C_UDP_TXCOMP); }
bool RH_RF22::send(const uint8_t* data, uint8_t len) { bool ret = true; waitPacketSent(); ATOMIC_BLOCK_START; spiWrite(RH_RF22_REG_3A_TRANSMIT_HEADER3, _txHeaderTo); spiWrite(RH_RF22_REG_3B_TRANSMIT_HEADER2, _txHeaderFrom); spiWrite(RH_RF22_REG_3C_TRANSMIT_HEADER1, _txHeaderId); spiWrite(RH_RF22_REG_3D_TRANSMIT_HEADER0, _txHeaderFlags); if (!fillTxBuf(data, len)) ret = false; else startTransmit(); ATOMIC_BLOCK_END; // printBuffer("send:", data, len); return ret; }
/* prepends an application header */ void usbll_transmit_app ( unsigned epNum, unsigned char appId, struct sg_t *data, usbll_tx_callback_t callback, void *opaque ) { struct endpointDetails_t *const ep = &connections[epNum]; int first = ( ep->txAdd == ep->txTake ); unsigned next = ep->txAdd + 1 ; assert( 0 != data ); // tx logic doesn't handle this (header doesn't get sent) // assert( 0 != data->length ); if( next > MAXTX_ENTRIES ) next = 0 ; if( next != ep->txTake ){ struct transmitRequest_t *tx = ep->txQueue + ep->txAdd ; tx->flags = NEEDAPPID | (appId&APPID_MASK); tx->txStart = tx->txNext = data ; tx->callback = callback ; tx->opaque = opaque ; ep->txAdd = next ; sg_zero_offs(data); if( USBEP_BULKIN == epNum ){ tx->flags |= NEEDNULLTX ; unsigned const len = sg_len(tx->txStart); if( 0 == (len&63) ){ } } if( first ) startTransmit(epNum, tx); else { DEBUGMSG( "second transmit 0x" ); DEBUGHEX(sg_len(tx->txStart)); DEBUGMSG( " bytes\r\n" ); } } else DEBUGMSG( "Transmit queue overflow\r\n" ); }
// Restart the transmission of a packet that had a problem void RF22::restartTransmit() { _mode = RF22_MODE_IDLE; _txBufSentIndex = 0; startTransmit(); }
// Restart the transmission of a packet that had a problem void RF22::restartTransmit() { _mode = RF22_MODE_IDLE; _txBufSentIndex = 0; // Serial.println("Restart"); startTransmit(); }