You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 
 

85 lines
2.8 KiB

  1. /***************************************************************************
  2. * Copyright (C) 2009 - 2010 by Simon Qian <SimonQian@SimonQian.com> *
  3. * *
  4. * This program is free software; you can redistribute it and/or modify *
  5. * it under the terms of the GNU General Public License as published by *
  6. * the Free Software Foundation; either version 2 of the License, or *
  7. * (at your option) any later version. *
  8. * *
  9. * This program is distributed in the hope that it will be useful, *
  10. * but WITHOUT ANY WARRANTY; without even the implied warranty of *
  11. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
  12. * GNU General Public License for more details. *
  13. * *
  14. * You should have received a copy of the GNU General Public License *
  15. * along with this program; if not, write to the *
  16. * Free Software Foundation, Inc., *
  17. * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *
  18. ***************************************************************************/
  19. #ifdef HAVE_CONFIG_H
  20. #include "config.h"
  21. #endif
  22. #include <string.h>
  23. #include "../versaloon_include.h"
  24. #include "../versaloon.h"
  25. #include "../versaloon_internal.h"
  26. #include "usbtoxxx.h"
  27. #include "usbtoxxx_internal.h"
  28. RESULT usbtojtagraw_init(uint8_t interface_index)
  29. {
  30. return usbtoxxx_init_command(USB_TO_JTAG_RAW, interface_index);
  31. }
  32. RESULT usbtojtagraw_fini(uint8_t interface_index)
  33. {
  34. return usbtoxxx_fini_command(USB_TO_JTAG_RAW, interface_index);
  35. }
  36. RESULT usbtojtagraw_config(uint8_t interface_index, uint32_t kHz)
  37. {
  38. uint8_t cfg_buf[4];
  39. #if PARAM_CHECK
  40. if (interface_index > 7)
  41. {
  42. LOG_BUG(ERRMSG_INVALID_INTERFACE_NUM, interface_index);
  43. return ERROR_FAIL;
  44. }
  45. #endif
  46. SET_LE_U32(&cfg_buf[0], kHz);
  47. return usbtoxxx_conf_command(USB_TO_JTAG_RAW, interface_index, cfg_buf, 4);
  48. }
  49. RESULT usbtojtagraw_execute(uint8_t interface_index, uint8_t *tdi,
  50. uint8_t *tms, uint8_t *tdo, uint32_t bitlen)
  51. {
  52. uint16_t bytelen;
  53. #if PARAM_CHECK
  54. if (interface_index > 7)
  55. {
  56. LOG_BUG(ERRMSG_INVALID_INTERFACE_NUM, interface_index);
  57. return ERROR_FAIL;
  58. }
  59. #endif
  60. if (bitlen > 8 * 0xFFFF)
  61. {
  62. return ERROR_FAIL;
  63. }
  64. bytelen = (uint16_t)((bitlen + 7) >> 3);
  65. SET_LE_U32(&versaloon_cmd_buf[0], bitlen);
  66. memcpy(versaloon_cmd_buf + 4, tdi, bytelen);
  67. memcpy(versaloon_cmd_buf + 4 + bytelen, tms, bytelen);
  68. return usbtoxxx_inout_command(USB_TO_JTAG_RAW, interface_index,
  69. versaloon_cmd_buf, 4 + bytelen * 2, bytelen, tdo, 0, bytelen, 0);
  70. }