|
RocketLogger
1.0
|
#include <stdio.h>#include <stdlib.h>#include <stdint.h>#include <unistd.h>#include <string.h>#include <errno.h>#include <fcntl.h>#include <ctype.h>#include <termios.h>#include <math.h>#include <time.h>#include <pthread.h>#include <sys/types.h>#include <sys/mman.h>#include <sys/stat.h>#include <sys/time.h>#include <sys/select.h>#include <sys/ipc.h>#include <sys/shm.h>#include <prussdrv.h>#include <pruss_intc_mapping.h>#include "log.h"#include "util.h"#include "types.h"#include "calibration.h"#include "meter.h"#include "file_handling.h"#include "sem.h"#include "web.h"
Include dependency graph for pru.h:
This graph shows which files directly or indirectly include this file:Go to the source code of this file.
Data Structures | |
| struct | pru_data_struct |
Macros | |
| #define | WAKEUP 0x02000000 |
| #define | STANDBY 0x04000000 |
| #define | RESET 0x06000000 |
| #define | START 0x08000000 |
| #define | STOP 0x0A000000 |
| #define | OFFSETCAL 0x1A000000 |
| #define | RDATAC 0x10000000 |
| #define | SDATAC 0x11000000 |
| #define | RDATA 0x12000000 |
| #define | RREG 0x20000000 |
| #define | WREG 0x40000000 |
| #define | ID 0x00000000 |
| #define | CONFIG1 0x01000000 |
| #define | CONFIG2 0x02000000 |
| #define | CONFIG3 0x03000000 |
| #define | CH1SET 0x05000000 |
| #define | CH2SET 0x06000000 |
| #define | CH3SET 0x07000000 |
| #define | CH4SET 0x08000000 |
| #define | CH5SET 0x09000000 |
| #define | CH6SET 0x0A000000 |
| #define | CH7SET 0x0B000000 |
| #define | CH8SET 0x0C000000 |
| #define | GAIN1 0x1000 |
| #define | GAIN2 0x2000 |
| #define | GAIN12 0x6000 |
| #define | K1 0x0600 |
| #define | K2 0x0500 |
| #define | K4 0x0400 |
| #define | K8 0x0300 |
| #define | K16 0x0200 |
| #define | K32 0x0100 |
| #define | K64 0x0000 |
| #define | CONFIG1DEFAULT 0x9000 |
| #define | CONFIG2DEFAULT 0xE000 |
| #define | CONFIG3DEFAULT 0xE800 |
| #define | MMAP_FILE "/sys/class/uio/uio0/maps/map1/" |
| Memory map file. More... | |
| #define | PRU_CODE "/lib/firmware/rocketlogger_spi.bin" |
| PRU binary file location. More... | |
| #define | PRECISION_HIGH 24 |
| #define | PRECISION_LOW 16 |
| #define | SIZE_HIGH 4 |
| #define | SIZE_LOW 2 |
| #define | PRU_TIMEOUT 3 |
| PRU time out in seconds. More... | |
| #define | NUMBER_ADC_COMMANDS 12 |
| Number of ADC commands. More... | |
Typedefs | |
| typedef enum pru_state | rl_pru_state |
Enumerations | |
| enum | pru_state { PRU_OFF = 0, PRU_LIMIT = 1, PRU_CONTINUOUS = 3 } |
Functions | |
| void * | pru_wait_event (void *voidEvent) |
| int | pru_wait_event_timeout (unsigned int event, unsigned int timeout) |
| 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, struct rl_conf *conf) |
| void | pru_stop (void) |
| void | pru_close (void) |
| #define CH1SET 0x05000000 |
Definition at line 68 of file pru.h.
Referenced by pru_data_setup().
| #define CH2SET 0x06000000 |
Definition at line 69 of file pru.h.
Referenced by pru_data_setup().
| #define CH3SET 0x07000000 |
Definition at line 70 of file pru.h.
Referenced by pru_data_setup().
| #define CH4SET 0x08000000 |
Definition at line 71 of file pru.h.
Referenced by pru_data_setup().
| #define CH5SET 0x09000000 |
Definition at line 72 of file pru.h.
Referenced by pru_data_setup().
| #define CH6SET 0x0A000000 |
Definition at line 73 of file pru.h.
Referenced by pru_data_setup().
| #define CH7SET 0x0B000000 |
Definition at line 74 of file pru.h.
Referenced by pru_data_setup().
| #define CONFIG1 0x01000000 |
Definition at line 65 of file pru.h.
Referenced by pru_data_setup().
| #define CONFIG1DEFAULT 0x9000 |
ADS131E08S configuration default value defines
Definition at line 98 of file pru.h.
Referenced by pru_data_setup().
| #define CONFIG3 0x03000000 |
Definition at line 67 of file pru.h.
Referenced by pru_data_setup().
| #define CONFIG3DEFAULT 0xE800 |
Definition at line 100 of file pru.h.
Referenced by pru_data_setup().
| #define GAIN1 0x1000 |
| #define GAIN2 0x2000 |
Definition at line 81 of file pru.h.
Referenced by pru_data_setup().
| #define K1 0x0600 |
| #define K16 0x0200 |
Definition at line 91 of file pru.h.
Referenced by pru_data_setup().
| #define K2 0x0500 |
Definition at line 88 of file pru.h.
Referenced by pru_data_setup().
| #define K32 0x0100 |
Definition at line 92 of file pru.h.
Referenced by pru_data_setup().
| #define K4 0x0400 |
Definition at line 89 of file pru.h.
Referenced by pru_data_setup().
| #define K64 0x0000 |
Definition at line 93 of file pru.h.
Referenced by pru_data_setup().
| #define K8 0x0300 |
Definition at line 90 of file pru.h.
Referenced by pru_data_setup().
| #define MMAP_FILE "/sys/class/uio/uio0/maps/map1/" |
Memory map file.
Definition at line 105 of file pru.h.
Referenced by map_pru_memory(), pru_data_setup(), pru_sample(), and unmap_pru_memory().
| #define NUMBER_ADC_COMMANDS 12 |
| #define PRECISION_HIGH 24 |
ADS131E08S precision defines(PRECISION_HIGH for low sampling rates, PRECISION_LOW for high ones)
Definition at line 114 of file pru.h.
Referenced by pru_data_setup().
| #define PRECISION_LOW 16 |
Definition at line 115 of file pru.h.
Referenced by pru_data_setup().
| #define PRU_CODE "/lib/firmware/rocketlogger_spi.bin" |
| #define PRU_TIMEOUT 3 |
PRU time out in seconds.
Definition at line 124 of file pru.h.
Referenced by pru_sample(), and pru_stop().
| #define RDATAC 0x10000000 |
Definition at line 55 of file pru.h.
Referenced by pru_data_setup().
| #define RESET 0x06000000 |
Definition at line 51 of file pru.h.
Referenced by pru_data_setup().
| #define SDATAC 0x11000000 |
Definition at line 56 of file pru.h.
Referenced by pru_data_setup().
| #define SIZE_HIGH 4 |
| #define SIZE_LOW 2 |
Definition at line 121 of file pru.h.
Referenced by pru_data_setup().
| #define WAKEUP 0x02000000 |
| #define WREG 0x40000000 |
Definition at line 59 of file pru.h.
Referenced by pru_data_setup().
| typedef enum pru_state rl_pru_state |
PRU state definition
| enum pru_state |
| 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 160 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, SIZE_LOW, 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 | ) |
| int pru_sample | ( | FILE * | data, |
| struct rl_conf * | conf | ||
| ) |
Main PRU sampling function
| data | File pointer to data file |
| conf | Pointer to current rl_conf configuration |
Definition at line 266 of file pru.c.
References 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_web_shm(), 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, rl_conf::file_name, handle_data_buffer(), I1H_INDEX, I1L_INDEX, I2H_INDEX, I2L_INDEX, INFO, rl_file_header::lead_in, LIMIT, map_pru_memory(), rl_conf::max_file_size, MAX_PATH_LENGTH, METER, meter_init(), meter_print_buffer(), meter_stop(), MIN_ADC_RATE, MMAP_FILE, rl_conf::mode, NO_FILE, web_shm::num_channels, NUM_CHANNELS, NUM_DIGITAL_INPUTS, NUM_WEB_POINTS, PRU_BUFFER_STATUS_SIZE, PRU_CODE, pru_data_setup(), PRU_DIG_SIZE, PRU_OFF, PRU_TIMEOUT, pru_wait_event_timeout(), read_file_value(), remove_sem(), reset_buffer(), 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, sem_id, set_sem(), setup_header(), setup_lead_in(), pru_data_struct::state, rl_status::state, status, store_header_bin(), store_header_csv(), SUCCESS, unmap_pru_memory(), update_header_bin(), update_header_csv(), WAIT_SEM, WARNING, web_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 129 of file pru.c.
Referenced by pru_stop().
| void pru_stop | ( | void | ) |
Stop and shut down PRU operation
Definition at line 567 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:| void* pru_wait_event | ( | void * | voidEvent | ) |
Wait on PRU event
| voidEvent | PRU event to wait on |
Definition at line 21 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 44 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: