|
RocketLogger
1.1.5
|
#include <stdint.h>#include <sys/ipc.h>#include <sys/sem.h>#include <sys/types.h>#include "file_handling.h"#include "util.h"#include "web.h"#include "pru.h"
Include dependency graph for pru.c:Go to the source code of this file.
Functions | |
| void * | pru_wait_event (void *voidEvent) |
| int | pru_wait_event_timeout (unsigned int event, unsigned int timeout) |
| void * | pru_map_memory (void) |
| int | pru_unmap_memory (void *pru_mmap) |
| void | pru_set_state (rl_pru_state state) |
| int | pru_init (void) |
| int | pru_data_setup (struct pru_data_struct *pru, struct rl_conf *conf, uint32_t avg_factor) |
| int | pru_sample (FILE *data_file, FILE *ambient_file, struct rl_conf *conf, char *file_comment) |
| void | pru_stop (void) |
| void | pru_close (void) |
Variables | |
| pthread_mutex_t | waiting = PTHREAD_MUTEX_INITIALIZER |
| PRU access mutex. More... | |
| pthread_cond_t | done = PTHREAD_COND_INITIALIZER |
| Notification variable. More... | |
| void pru_close | ( | void | ) |
| int pru_data_setup | ( | struct pru_data_struct * | pru, |
| struct rl_conf * | conf, | ||
| uint32_t | avg_factor | ||
| ) |
PRU data struct setup
| pru | Pointer to pru_data_struct to setup |
| conf | Pointer to current rl_conf configuration |
| avg_factor | Average factor for sampling rates smaller than minimal ADC rate |
Definition at line 189 of file pru.c.
References pru_data_struct::buffer0_location, pru_data_struct::buffer1_location, pru_data_struct::buffer_size, CH1SET, CH2SET, CH3SET, CH4SET, CH5SET, CH6SET, CH7SET, pru_data_struct::commands, CONFIG1, CONFIG1DEFAULT, CONFIG3, CONFIG3DEFAULT, ERROR, FAILURE, GAIN1, GAIN2, K1, K16, K2, K32, K4, K64, K8, LIMIT, MMAP_FILE, rl_conf::mode, NUM_CHANNELS, NUMBER_ADC_COMMANDS, pru_data_struct::number_commands, pru_data_struct::precision, PRECISION_HIGH, PRECISION_LOW, PRU_BUFFER_STATUS_SIZE, PRU_CONTINUOUS, PRU_DIG_SIZE, PRU_LIMIT, RDATAC, read_file_value(), RESET, rl_log(), pru_data_struct::sample_limit, rl_conf::sample_limit, rl_conf::sample_rate, pru_data_struct::sample_size, SDATAC, SIZE_HIGH, pru_data_struct::state, SUCCESS, rl_conf::update_rate, and WREG.
Referenced by pru_sample().
Here is the call graph for this function:| int pru_init | ( | void | ) |
| void* pru_map_memory | ( | void | ) |
Map PRU memory into user space
Definition at line 106 of file pru.c.
References ERROR, MMAP_FILE, read_file_value(), and rl_log().
Referenced by pru_sample().
Here is the call graph for this function:| int pru_sample | ( | FILE * | data_file, |
| FILE * | ambient_file, | ||
| struct rl_conf * | conf, | ||
| char * | file_comment | ||
| ) |
Main PRU sampling function
| data_file | File pointer to data file |
| ambient_file | File pointer to ambient file |
| conf | Pointer to current rl_conf configuration |
| file_comment | Comment to store in the file header |
Definition at line 296 of file pru.c.
References AMBIENT_DATA_BLOCK_SIZE, AMBIENT_ENABLED, ambient_setup_header(), ambient_setup_lead_in(), ambient_store_data(), BIN, web_shm::buffer, BUFFER100_SIZE, BUFFER10_SIZE, BUFFER1_SIZE, rl_status::buffer_number, pru_data_struct::buffer_size, buffer_sizes, ceil_div(), rl_file_header::channel, rl_file_lead_in::channel_bin_count, rl_file_lead_in::channel_count, CHANNEL_ENABLED, rl_conf::channels, count_channels(), create_sem(), create_time_stamp(), CSV, rl_file_lead_in::data_block_count, DATA_SEM, rl_conf::digital_inputs, DIGITAL_INPUTS_ENABLED, rl_conf::enable_web_server, ERROR, FAILURE, rl_conf::file_format, file_handle_data(), file_setup_header(), file_setup_lead_in(), file_store_header_bin(), file_store_header_csv(), file_update_header_bin(), file_update_header_csv(), I1H_INDEX, I1L_INDEX, I2H_INDEX, I2L_INDEX, INFO, rl_file_header::lead_in, LIMIT, MAX_PATH_LENGTH, METER, meter_init(), meter_print_buffer(), meter_stop(), MIN_ADC_RATE, MMAP_FILE, rl_conf::mode, NO_FILE, time_stamp::nsec, web_shm::num_channels, NUM_CHANNELS, NUM_DIGITAL_INPUTS, NUM_SEMS, NUM_WEB_POINTS, PRU_BUFFER_STATUS_SIZE, PRU_CODE, pru_data_setup(), PRU_DIG_SIZE, pru_map_memory(), PRU_OFF, PRU_TIMEOUT, pru_unmap_memory(), pru_wait_event_timeout(), read_file_value(), remove_sem(), RL_ERROR, rl_log(), RL_RUNNING, rl_file_lead_in::sample_count, pru_data_struct::sample_limit, rl_conf::sample_limit, rl_conf::sample_rate, pru_data_struct::sample_size, rl_status::samples_taken, rl_status::sampling, SAMPLING_ON, time_stamp::sec, sem_id, SEM_KEY, set_sem(), pru_data_struct::state, rl_status::state, status, SUCCESS, WAIT_SEM, WARNING, web_buffer_reset(), web_create_shm(), web_data, web_handle_data(), WEB_RING_BUFFER_COUNT, and write_status().
Referenced by hw_sample().
Here is the call graph for this function:| void pru_set_state | ( | rl_pru_state | state | ) |
Write state to PRU
| state | PRU state to write |
Definition at line 157 of file pru.c.
Referenced by pru_stop().
| void pru_stop | ( | void | ) |
Stop and shut down PRU operation.
Definition at line 708 of file pru.c.
References PRU_OFF, pru_set_state(), PRU_TIMEOUT, pru_wait_event_timeout(), RL_ERROR, rl_status::state, and status.
Referenced by hw_close().
Here is the call graph for this function:| int pru_unmap_memory | ( | void * | pru_mmap | ) |
Unmap PRU memory from user space
| pru_mmap | Pointer to mapped memory |
Definition at line 138 of file pru.c.
References ERROR, FAILURE, MMAP_FILE, read_file_value(), rl_log(), and SUCCESS.
Referenced by pru_sample().
Here is the call graph for this function:| void* pru_wait_event | ( | void * | voidEvent | ) |
Wait on PRU event
| voidEvent | PRU event to wait on |
Definition at line 56 of file pru.c.
References done.
Referenced by pru_wait_event_timeout().
| int pru_wait_event_timeout | ( | unsigned int | event, |
| unsigned int | timeout | ||
| ) |
Wrapper for PRU event waiting with time out
| event | PRU event to wait on |
| timeout | Time out in seconds |
Definition at line 79 of file pru.c.
References done, pru_wait_event(), and waiting.
Referenced by pru_sample(), and pru_stop().
Here is the call graph for this function:| pthread_cond_t done = PTHREAD_COND_INITIALIZER |
Notification variable.
Definition at line 50 of file pru.c.
Referenced by pru_wait_event(), and pru_wait_event_timeout().
| pthread_mutex_t waiting = PTHREAD_MUTEX_INITIALIZER |
PRU access mutex.
Copyright (c) 2016-2019, Swiss Federal Institute of Technology (ETH Zurich) All rights reserved.
Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:
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 HOLDER 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 OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
Definition at line 47 of file pru.c.
Referenced by pru_wait_event_timeout().