RocketLogger  2.0.0
pru.h
Go to the documentation of this file.
1 
32 #ifndef PRU_H_
33 #define PRU_H_
34 
35 #include <stdint.h>
36 #include <stdio.h>
37 
38 #include "rl.h"
39 
41 #define PRU_BINARY_FILE "/lib/firmware/rocketlogger.bin"
42 
44 #define PRU_DIGITAL_SIZE 4
46 #define PRU_SAMPLE_SIZE 4
48 #define PRU_BUFFER_STATUS_SIZE 4
49 
53 #define PRU_DIGITAL_INPUT_MASK 0x3F
54 #define PRU_DIGITAL_INPUT1_MASK 0x01
55 #define PRU_DIGITAL_INPUT2_MASK 0x02
56 #define PRU_DIGITAL_INPUT3_MASK 0x04
57 #define PRU_DIGITAL_INPUT4_MASK 0x08
58 #define PRU_DIGITAL_INPUT5_MASK 0x10
59 #define PRU_DIGITAL_INPUT6_MASK 0x20
60 #define PRU_DIGITAL_I1L_VALID_MASK 0x40
61 #define PRU_DIGITAL_I2L_VALID_MASK 0x80
62 
64 #define PRU_TIMEOUT_US 2000000
65 
69 enum pru_state {
70  PRU_STATE_OFF = 0x00,
73 };
74 
78 typedef enum pru_state pru_state_t;
79 
83 struct pru_control {
87  uint32_t sample_rate;
89  uint32_t sample_limit;
91  uint32_t buffer_length;
93  uint32_t buffer0_addr;
95  uint32_t buffer1_addr;
96 };
97 
101 typedef struct pru_control pru_control_t;
102 
106 struct pru_data {
111  uint32_t channel_digital;
117 };
118 
122 typedef struct pru_data pru_data_t;
123 
127 struct pru_buffer {
129  uint32_t index;
131  pru_data_t const data[];
132 };
133 
137 typedef struct pru_buffer pru_buffer_t;
138 
146 int pru_init(void);
147 
153 void pru_deinit(void);
154 
165  rl_config_t const *const config, uint32_t aggregates);
166 
174 int pru_set_state(pru_state_t state);
175 
186 int pru_sample(FILE *data_file, FILE *ambient_file,
187  rl_config_t const *const config);
188 
195 void pru_stop(void);
196 
197 #endif /* PRU_H_ */
pru_state
Definition: pru.h:69
@ PRU_STATE_OFF
Definition: pru.h:70
@ PRU_STATE_SAMPLE_FINITE
PRU off.
Definition: pru.h:71
@ PRU_STATE_SAMPLE_CONTINUOUS
PRU sampling in finite mode.
Definition: pru.h:72
int pru_sample(FILE *data_file, FILE *ambient_file, rl_config_t const *const config)
Definition: pru.c:130
void pru_deinit(void)
Definition: pru.c:74
int pru_control_init(pru_control_t *const pru_control, rl_config_t const *const config, uint32_t aggregates)
Definition: pru.c:80
void pru_stop(void)
Definition: pru.c:615
int pru_init(void)
Definition: pru.c:57
int pru_set_state(pru_state_t state)
Definition: pru.c:122
enum pru_state pru_state_t
Definition: pru.h:78
#define RL_CHANNEL_COUNT
Number of RocketLogger analog channels.
Definition: rl.h:56
uint32_t index
buffer index
Definition: pru.h:129
pru_data_t const data[]
the data blocks
Definition: pru.h:131
uint32_t sample_rate
Sample rate of the ADC (in kSPS)
Definition: pru.h:87
uint32_t sample_limit
Samples to take (0 for continuous)
Definition: pru.h:89
uint32_t buffer0_addr
Memory address of the shared buffer 0.
Definition: pru.h:93
uint32_t buffer1_addr
Memory address of the shared buffer 1.
Definition: pru.h:95
pru_state_t state
Current PRU state.
Definition: pru.h:85
uint32_t buffer_length
Shared buffer length in number of data elements.
Definition: pru.h:91
Definition: pru.h:106
int32_t channel_analog[RL_CHANNEL_COUNT]
Definition: pru.h:116
uint32_t channel_digital
Definition: pru.h:111
Definition: rl.h:154