Mercurial > hg > beaglert
diff include/prussdrv.h @ 15:901d205d1a3c
Updated to latest PRU library; external PRU file no longer needed. Also catch SIGTERM as well as SIGINT to clean up gracefully.
author | andrewm |
---|---|
date | Sat, 07 Feb 2015 16:41:56 +0000 |
parents | 8a575ba3ab52 |
children |
line wrap: on
line diff
--- a/include/prussdrv.h Fri Jan 23 15:35:10 2015 +0000 +++ b/include/prussdrv.h Sat Feb 07 16:41:56 2015 +0000 @@ -1,37 +1,37 @@ /* * prussdrv.h - * + * * Describes PRUSS userspace driver for Industrial Communications * - * Copyright (C) 2010 Texas Instruments Incorporated - http://www.ti.com/ - * - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions + * Copyright (C) 2010 Texas Instruments Incorporated - http://www.ti.com/ + * + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions * are met: * - * Redistributions of source code must retain the above copyright + * Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * * Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the * distribution. * * Neither the name of Texas Instruments Incorporated nor the names of * its contributors may be used to endorse or promote products derived * from this software without specific prior written permission. * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR - * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT - * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, - * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT + * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT + * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY - * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. * */ @@ -49,7 +49,6 @@ #define _PRUSSDRV_H #include <sys/types.h> -#include <pthread.h> #if defined (__cplusplus) extern "C" { @@ -65,6 +64,9 @@ #define PRUSS0_PRU0_IRAM 2 #define PRUSS0_PRU1_IRAM 3 +#define PRUSS_V1 1 // AM18XX +#define PRUSS_V2 2 // AM33XX + //Available in AM33xx series - begin #define PRUSS0_SHARED_DATARAM 4 #define PRUSS0_CFG 5 @@ -84,7 +86,6 @@ #define PRU_EVTOUT_6 6 #define PRU_EVTOUT_7 7 - typedef void *(*prussdrv_function_handler) (void *); typedef struct __sysevt_to_channel_map { short sysevt; short channel; @@ -103,56 +104,98 @@ //Channel to Host map.Channels -Range: 0..9 HOSTs - Range:0..9 //{-1, -1} indicates end of list tchannel_to_host_map channel_to_host_map[NUM_PRU_CHANNELS]; - //10-bit mask - Enable Host0-Host9 {Host0/1:PRU0/1, Host2..9 : PRUEVT_OUT0..7) + //10-bit mask - Enable Host0-Host9 {Host0/1:PRU0/1, Host2..9 : PRUEVT_OUT0..7} unsigned int host_enable_bitmask; } tpruss_intc_initdata; int prussdrv_init(void); - int prussdrv_open(unsigned int pru_evtout_num); + int prussdrv_open(unsigned int host_interrupt); + + /** Return version of PRU. This must be called after prussdrv_open. */ + int prussdrv_version(); + + /** Return string description of PRU version. */ + const char* prussdrv_strversion(int version); int prussdrv_pru_reset(unsigned int prunum); int prussdrv_pru_disable(unsigned int prunum); int prussdrv_pru_enable(unsigned int prunum); + int prussdrv_pru_enable_at(unsigned int prunum, size_t addr); int prussdrv_pru_write_memory(unsigned int pru_ram_id, unsigned int wordoffset, - unsigned int *memarea, + const unsigned int *memarea, unsigned int bytelength); - int prussdrv_pruintc_init(tpruss_intc_initdata * prussintc_init_data); + int prussdrv_pruintc_init(const tpruss_intc_initdata *prussintc_init_data); + + /** Find and return the channel a specified event is mapped to. + * Note that this only searches for the first channel mapped and will not + * detect error cases where an event is mapped erroneously to multiple + * channels. + * @return channel-number to which a system event is mapped. + * @return -1 for no mapping found + */ + short prussdrv_get_event_to_channel_map( unsigned int eventnum ); + + /** Find and return the host interrupt line a specified channel is mapped + * to. Note that this only searches for the first host interrupt line + * mapped and will not detect error cases where a channel is mapped + * erroneously to multiple host interrupt lines. + * @return host-interrupt-line to which a channel is mapped. + * @return -1 for no mapping found + */ + short prussdrv_get_channel_to_host_map( unsigned int channel ); + + /** Find and return the host interrupt line a specified event is mapped + * to. This first finds the intermediate channel and then the host. + * @return host-interrupt-line to which a system event is mapped. + * @return -1 for no mapping found + */ + short prussdrv_get_event_to_host_map( unsigned int eventnum ); int prussdrv_map_l3mem(void **address); int prussdrv_map_extmem(void **address); + unsigned int prussdrv_extmem_size(void); + int prussdrv_map_prumem(unsigned int pru_ram_id, void **address); int prussdrv_map_peripheral_io(unsigned int per_id, void **address); - unsigned int prussdrv_get_phys_addr(void *address); + unsigned int prussdrv_get_phys_addr(const void *address); void *prussdrv_get_virt_addr(unsigned int phyaddr); - int prussdrv_pru_wait_event(unsigned int pru_evtout_num); + /** Wait for the specified host interrupt. + * @return the number of times the event has happened. */ + unsigned int prussdrv_pru_wait_event(unsigned int host_interrupt); + + int prussdrv_pru_event_fd(unsigned int host_interrupt); int prussdrv_pru_send_event(unsigned int eventnum); - int prussdrv_pru_clear_event(unsigned int eventnum); + /** Clear the specified event and re-enable the host interrupt. */ + int prussdrv_pru_clear_event(unsigned int host_interrupt, + unsigned int sysevent); int prussdrv_pru_send_wait_clear_event(unsigned int send_eventnum, - unsigned int pru_evtout_num, + unsigned int host_interrupt, unsigned int ack_eventnum); int prussdrv_exit(void); - int prussdrv_exec_program(int prunum, char *filename); + int prussdrv_exec_program(int prunum, const char *filename); + int prussdrv_exec_program_at(int prunum, const char *filename, size_t addr); - int prussdrv_start_irqthread(unsigned int pru_evtout_num, int priority, - prussdrv_function_handler irqhandler); - + int prussdrv_exec_code(int prunum, const unsigned int *code, int codelen); + int prussdrv_exec_code_at(int prunum, const unsigned int *code, int codelen, size_t addr); + int prussdrv_load_data(int prunum, const unsigned int *code, int codelen); + int prussdrv_load_datafile(int prunum, const char *filename); #if defined (__cplusplus) }