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.

148 lines
5.1 KiB

7 years ago
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
  1. /*
  2. * prussdrv.h
  3. *
  4. * Describes PRUSS userspace driver for Industrial Communications
  5. *
  6. * Copyright (C) 2010 Texas Instruments Incorporated - http://www.ti.com/
  7. *
  8. *
  9. * Redistribution and use in source and binary forms, with or without
  10. * modification, are permitted provided that the following conditions
  11. * are met:
  12. *
  13. * Redistributions of source code must retain the above copyright
  14. * notice, this list of conditions and the following disclaimer.
  15. *
  16. * Redistributions in binary form must reproduce the above copyright
  17. * notice, this list of conditions and the following disclaimer in the
  18. * documentation and/or other materials provided with the
  19. * distribution.
  20. *
  21. * Neither the name of Texas Instruments Incorporated nor the names of
  22. * its contributors may be used to endorse or promote products derived
  23. * from this software without specific prior written permission.
  24. *
  25. * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
  26. * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
  27. * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
  28. * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
  29. * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
  30. * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
  31. * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
  32. * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
  33. * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
  34. * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
  35. * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  36. *
  37. */
  38. /*
  39. * ============================================================================
  40. * Copyright (c) Texas Instruments Inc 2010-11
  41. *
  42. * Use of this software is controlled by the terms and conditions found in the
  43. * license agreement under which this software has been supplied or provided.
  44. * ============================================================================
  45. */
  46. #ifndef _PRUSSDRV_H
  47. #define _PRUSSDRV_H
  48. #include <sys/types.h>
  49. #include <pthread.h>
  50. #if defined (__cplusplus)
  51. extern "C" {
  52. #endif
  53. #define NUM_PRU_HOSTIRQS 8
  54. #define NUM_PRU_HOSTS 10
  55. #define NUM_PRU_CHANNELS 10
  56. #define NUM_PRU_SYS_EVTS 64
  57. #define PRUSS0_PRU0_DATARAM 0
  58. #define PRUSS0_PRU1_DATARAM 1
  59. #define PRUSS0_PRU0_IRAM 2
  60. #define PRUSS0_PRU1_IRAM 3
  61. #define PRU_EVTOUT_0 0
  62. #define PRU_EVTOUT_1 1
  63. #define PRU_EVTOUT_2 2
  64. #define PRU_EVTOUT_3 3
  65. #define PRU_EVTOUT_4 4
  66. #define PRU_EVTOUT_5 5
  67. #define PRU_EVTOUT_6 6
  68. #define PRU_EVTOUT_7 7
  69. typedef void *(*prussdrv_function_handler) (void *);
  70. typedef struct __sysevt_to_channel_map {
  71. short sysevt;
  72. short channel;
  73. } tsysevt_to_channel_map;
  74. typedef struct __channel_to_host_map {
  75. short channel;
  76. short host;
  77. } tchannel_to_host_map;
  78. typedef struct __pruss_intc_initdata {
  79. //Enabled SYSEVTs - Range:0..63
  80. //{-1} indicates end of list
  81. char sysevts_enabled[NUM_PRU_SYS_EVTS];
  82. //SysEvt to Channel map. SYSEVTs - Range:0..63 Channels -Range: 0..9
  83. //{-1, -1} indicates end of list
  84. tsysevt_to_channel_map sysevt_to_channel_map[NUM_PRU_SYS_EVTS];
  85. //Channel to Host map.Channels -Range: 0..9 HOSTs - Range:0..9
  86. //{-1, -1} indicates end of list
  87. tchannel_to_host_map channel_to_host_map[NUM_PRU_CHANNELS];
  88. //10-bit mask - Enable Host0-Host9 {Host0/1:PRU0/1, Host2..9 : PRUEVT_OUT0..7)
  89. unsigned int host_enable_bitmask;
  90. } tpruss_intc_initdata;
  91. int prussdrv_init(void);
  92. int prussdrv_open(unsigned int pru_evtout_num);
  93. int prussdrv_pru_reset(unsigned int prunum);
  94. int prussdrv_pru_disable(unsigned int prunum);
  95. int prussdrv_pru_enable(unsigned int prunum);
  96. int prussdrv_pru_write_memory(unsigned int pru_ram_id,
  97. unsigned int wordoffset,
  98. unsigned int *memarea,
  99. unsigned int bytelength);
  100. int prussdrv_pruintc_init(tpruss_intc_initdata * prussintc_init_data);
  101. int prussdrv_map_l3mem(void **address);
  102. int prussdrv_map_extmem(void **address);
  103. int prussdrv_map_prumem(unsigned int pru_ram_id, void **address);
  104. unsigned int prussdrv_get_phys_addr(void *address);
  105. void *prussdrv_get_virt_addr(unsigned int phyaddr);
  106. int prussdrv_pru_wait_event(unsigned int pru_evtout_num);
  107. int prussdrv_pru_send_event(unsigned int eventnum);
  108. int prussdrv_pru_clear_event(unsigned int eventnum);
  109. int prussdrv_pru_send_wait_clear_event(unsigned int send_eventnum,
  110. unsigned int pru_evtout_num,
  111. unsigned int ack_eventnum);
  112. int prussdrv_exit(void);
  113. int prussdrv_exec_program(int prunum, char *filename);
  114. int prussdrv_start_irqthread(unsigned int pru_evtout_num, int priority,
  115. prussdrv_function_handler irqhandler);
  116. #if defined (__cplusplus)
  117. }
  118. #endif
  119. #endif