ibsic.c 2.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364
  1. /***************************************************************************
  2. ibsic.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. #include <linux/delay.h>
  17. /*
  18. * IBSIC
  19. * Send IFC for at least 100 microseconds.
  20. *
  21. * NOTE:
  22. * 1. Ibsic must be called prior to the first call to
  23. * ibcmd in order to initialize the bus and enable the
  24. * interface to leave the controller idle state.
  25. */
  26. int ibsic( gpib_board_t *board, unsigned int usec_duration )
  27. {
  28. if( board->master == 0 )
  29. {
  30. printk( "gpib: tried to assert IFC when not system controller\n" );
  31. return -1;
  32. }
  33. if( usec_duration < 100 ) usec_duration = 100;
  34. if( usec_duration > 1000 )
  35. {
  36. usec_duration = 1000;
  37. printk( "gpib: warning, shortening long udelay\n");
  38. }
  39. GPIB_DPRINTK( "sending interface clear\n" );
  40. board->interface->interface_clear(board, 1);
  41. udelay( usec_duration );
  42. board->interface->interface_clear(board, 0);
  43. return 0;
  44. }
  45. void ibrsc( gpib_board_t *board, int request_control )
  46. {
  47. board->master = request_control != 0;
  48. if( board->interface->request_system_control == NULL )
  49. {
  50. printk( "gpib: bug! driver does not implement request_system_control()\n" );
  51. return;
  52. }
  53. board->interface->request_system_control( board, request_control );
  54. }