ra_reg_demo.c 1.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051
  1. /*
  2. * Copyright (C) 2021 Alibaba Group Holding Limited
  3. * Author: LuChongzhi <chongzhi.lcz@alibaba-inc.com>
  4. *
  5. * This program is free software; you can redistribute it and/or modify
  6. * it under the terms of the GNU General Public License version 2 as
  7. * published by the Free Software Foundation.
  8. */
  9. #include <stdio.h>
  10. #include <stdlib.h>
  11. #include <stdint.h>
  12. #include <unistd.h>
  13. #include <string.h>
  14. #include "ra_common.h"
  15. /* usage: reg_analyzer -m demo -o 0x10 -v 0x13572468 */
  16. /* usage: reg_analyzer -m demo -r DEMO_REG1 */
  17. static const reg_field_s reg_demo_desc[] = {
  18. /* structure field order
  19. reg_name, offset,reset_value,msb,lsb, field_name, field_desc */
  20. {"DEMO_REG0", "This is demo register-0 description",
  21. 0x10, 0x12345678, 31, 16, "reg0 field0", "This is demo reg0's field0"},
  22. {NULL, NULL, 0x10, 0x0, 15, 0, "reg0 field1", "This is demo reg0's field1"},
  23. {"DEMO_REG1", "This is demo register-0 description",
  24. 0x14, 0x13572468, 31, 24, "reg1 field0", "This is demo reg1's field0"},
  25. {NULL, NULL, 0x14, 0x0, 23, 0, "reg1 field1", "This is demo reg1's field1 desc line1" LINE_PADDING_6TAB
  26. "and reg1's field desc line 2" LINE_PADDING_6TAB
  27. "and reg1's field desc line 3"},
  28. };
  29. int reg_demo_dump(reg_analyzer_info_s *ra_info)
  30. {
  31. uint32_t count = sizeof(reg_demo_desc) / sizeof(reg_demo_desc[0]);
  32. return ra_dump_reg_fields(ra_info, reg_demo_desc, count);
  33. }
  34. int reg_demo_define(reg_analyzer_info_s *ra_info)
  35. {
  36. uint32_t count = sizeof(reg_demo_desc) / sizeof(reg_demo_desc[0]);
  37. return ra_dump_reg_define(ra_info, reg_demo_desc, count);
  38. }
  39. int reg_demo_find(reg_analyzer_info_s *ra_info)
  40. {
  41. uint32_t count = sizeof(reg_demo_desc) / sizeof(reg_demo_desc[0]);
  42. return ra_dump_reg_find(ra_info, reg_demo_desc, count);
  43. }