ibwrite.c 1.9 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859
  1. /***************************************************************************
  2. ibwrite.c
  3. -------------------
  4. copyright : (C) 2001, 2002 by Frank Mori Hess
  5. email : fmhess@users.sourceforge.net
  6. ***************************************************************************/
  7. /***************************************************************************
  8. * *
  9. * This program is free software; you can redistribute it and/or modify *
  10. * it under the terms of the GNU General Public License as published by *
  11. * the Free Software Foundation; either version 2 of the License, or *
  12. * (at your option) any later version. *
  13. * *
  14. ***************************************************************************/
  15. #include "gpibP.h"
  16. /*
  17. * IBWRT
  18. * Write cnt bytes of data from buf to the GPIB. The write
  19. * operation terminates only on I/O complete.
  20. *
  21. * NOTE:
  22. * 1. Prior to beginning the write, the interface is
  23. * placed in the controller standby state.
  24. * 2. Prior to calling ibwrt, the intended devices as
  25. * well as the interface board itself must be
  26. * addressed by calling ibcmd.
  27. */
  28. int ibwrt(gpib_board_t *board, uint8_t *buf, size_t cnt, int send_eoi, size_t *bytes_written)
  29. {
  30. int ret = 0;
  31. int retval;
  32. if( cnt == 0 )
  33. {
  34. printk( "gpib: ibwrt() called with zero length?\n" );
  35. return 0;
  36. }
  37. if( board->master )
  38. {
  39. retval = ibgts( board );
  40. if( retval < 0 ) return retval;
  41. }
  42. osStartTimer( board, board->usec_timeout );
  43. ret = board->interface->write(board, buf, cnt, send_eoi, bytes_written);
  44. if( io_timed_out( board ) )
  45. ret = -ETIMEDOUT;
  46. osRemoveTimer(board);
  47. return ret;
  48. }