Chinaunix首页 | 论坛 | 博客
  • 博客访问: 1502877
  • 博文数量: 108
  • 博客积分: 0
  • 博客等级: 民兵
  • 技术积分: 997
  • 用 户 组: 普通用户
  • 注册时间: 2013-06-29 09:58
个人简介

兴趣是坚持一件事永不衰竭的动力

文章分类

全部博文(108)

文章存档

2021年(1)

2020年(10)

2019年(19)

2018年(9)

2016年(23)

2015年(43)

2013年(3)

我的朋友

分类: 嵌入式

2020-05-10 14:48:42

sys_config.fex
[board_para]
edp_bl_pwm_channel = 0
gpio_f_2 = port:PF02<2><1><2>
gpio_f_3 = port:PF02<2><1><2>
string_demo=string:abcd1234
===================================================


点击(此处)折叠或打开

  1. void script_parser_fetch_test(){
  2.  //获取GPIO
  3.     user_gpio_set_t gpio_info[1];
  4.     int ret;
  5.     ret = script_parser_fetch("board_para", "pwm0", gpio_info, sizeof(user_gpio_set_t)/sizeof(int));
  6.     if(ret < 0)
  7.         printk("fetch script gpio infomation fail\n");
  8.     else
  9.         printk("fetch script gpio infomation ok \n");
  10.  printk("[info] gpio_info.port=%04x,file=%s,fun=%s,line=%d\n",gpio_info[0].port,__FILE__ ,__func__,__LINE__);
  11.  printk("[info] gpio_info.port_num=%04x,file=%s,fun=%s,line=%d\n",gpio_info[0].port_num,__FILE__ ,__func__,__LINE__);
  12.  printk("[info] gpio_info.mul_sel=%04x,file=%s,fun=%s,line=%d\n",gpio_info[0].mul_sel,__FILE__ ,__func__,__LINE__);
  13.  printk("[info] gpio_info.pull=%04x,file=%s,fun=%s,line=%d\n",gpio_info[0].pull,__FILE__ ,__func__,__LINE__);
  14.  printk("[info] gpio_info.drv_level=%04x,file=%s,fun=%s,line=%d\n",gpio_info[0].drv_level,__FILE__ ,__func__,__LINE__);
  15.  printk("[info] gpio_info.data=%04x,file=%s,fun=%s,line=%d\n",gpio_info[0].data,__FILE__ ,__func__,__LINE__);
  16.  
  17.  char string_info[128];
  18.     memset(string_info, 0, 128);
  19.     ret = script_parser_fetch("board_para", "string_demo", string_info, 128/sizeof(int));
  20.     if(ret < 0)
  21.         printk("fetch script string infomation fail\n");
  22.  else
  23.      printk("fetch script string infomation ok \n");
  24.  printk("[info] string_info=%s,file=%s,fun=%s,line=%d\n",string_info,__FILE__ ,__func__,__LINE__);


  25.  //获取子键个数
  26.     int sub_key_count = script_parser_subkey_count ("board_para");
  27.     if(sub_key_count < 0)
  28.         printk("fetch script sub key count fail\n");
  29.     else
  30.      printk("[info] sub_key_count=%d,file=%s,fun=%s,line=%d\n",sub_key_count,__FILE__ ,__func__,__LINE__);
  31. //获取主键个数


  32.     int main_key_count = script_parser_mainkey_count();
  33.     if(main_key_count < 0)
  34.         printk("fetch script sub key count fail\n");
  35.     else
  36.         printk("[info] main_key_count=%d,file=%s,fun=%s,line=%d\n",main_key_count,__FILE__ ,__func__,__LINE__);


  37.  
  38. //获取主键下GPIO配置
  39.     ret = script_parser_mainkey_get_gpio_cfg("board_para",gpio_info, 1);
  40.     if(ret < 0)
  41.         printk("fetch script gpio infomation fail\n");
  42.     else{
  43.         
  44.  printk("script_parser_mainkey_get_gpio_cfg script gpio infomation ok \n");
  45.  printk("[info] gpio_info.port=%04x,file=%s,fun=%s,line=%d\n",gpio_info[0].port,__FILE__ ,__func__,__LINE__);
  46.  printk("[info] gpio_info.port_num=%04x,file=%s,fun=%s,line=%d\n",gpio_info[0].port_num,__FILE__ ,__func__,__LINE__);
  47.  printk("[info] gpio_info.mul_sel=%04x,file=%s,fun=%s,line=%d\n",gpio_info[0].mul_sel,__FILE__ ,__func__,__LINE__);
  48.  printk("[info] gpio_info.pull=%04x,file=%s,fun=%s,line=%d\n",gpio_info[0].pull,__FILE__ ,__func__,__LINE__);
  49.  printk("[info] gpio_info.drv_level=%04x,file=%s,fun=%s,line=%d\n",gpio_info[0].drv_level,__FILE__ ,__func__,__LINE__);
  50.  printk("[info] gpio_info.data=%04x,file=%s,fun=%s,line=%d\n",gpio_info[0].data,__FILE__ ,__func__,__LINE__);
  51.     }
  52. //获取主键下GPIO个数
  53.     int gpio_key_count = script_parser_mainkey_get_gpio_count ("twi_para");
  54.     if(gpio_key_count < 0)
  55.         printk("fetch script sub key count fail\n");
  56.     else
  57.         printk("fetch script gpio key count ok , gpio_key_count = %d\n", gpio_key_count);


  58. }


阅读(1772) | 评论(0) | 转发(0) |
给主人留下些什么吧!~~