osmo-sdr/firmware/include/reg_field.h @ master
1 | 2a2c03a7 | Harald Welte | #ifndef _REG_FIELD_H
|
---|---|---|---|
2 | #define _REG_FIELD_H
|
||
3 | |||
4 | #include <uart_cmd.h>
|
||
5 | |||
6 | /* structure describing a field in a register */
|
||
7 | struct reg_field { |
||
8 | uint8_t reg; |
||
9 | uint8_t shift; |
||
10 | uint8_t width; |
||
11 | };
|
||
12 | |||
13 | struct reg_field_ops { |
||
14 | const struct reg_field *fields; |
||
15 | const char **field_names; |
||
16 | uint32_t num_fields; |
||
17 | void *data; |
||
18 | int (*write_cb)(void *data, uint32_t reg, uint32_t val); |
||
19 | uint32_t (*read_cb)(void *data, uint32_t reg); |
||
20 | };
|
||
21 | |||
22 | uint32_t reg_field_read(struct reg_field_ops *ops, struct reg_field *field); |
||
23 | int reg_field_write(struct reg_field_ops *ops, struct reg_field *field, uint32_t val); |
||
24 | int reg_field_cmd(struct cmd_state *cs, enum cmd_op op, |
||
25 | const char *cmd, int argc, char **argv, |
||
26 | struct reg_field_ops *ops); |
||
27 | |||
28 | |||
29 | #endif
|