myconf.c 1.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105
  1. /******************************************************************************
  2. 版权所有:
  3. 文件名称: myconf.c
  4. 文件版本: 01.01
  5. 创建作者: xxxxxx
  6. 创建日期: 2015-5-5
  7. 功能说明: 配置实现文件
  8. 使用本框架前,应配置必要参数.
  9. 1.配置PROTOCOL_CHNS
  10. -------------------
  11. - APP层 -
  12. -------------------
  13. - 协议层 -
  14. -------------------
  15. - 通道层 -
  16. -------------------
  17. - 驱动层 -
  18. -------------------
  19. 其它说明:
  20. 修改记录:
  21. */
  22. #include "head.h"
  23. #include "myconf.h"
  24. #include "protocol.h"
  25. T_channel g_h_boj[PROTOCOL_CHNS];
  26. //static int g_uart_fd = 0;
  27. int myuart_init(void)
  28. {
  29. //uart_open(0, 57600, PARITY_NONE_1, STOPBIT_ONE);
  30. return 0;
  31. }
  32. static int myuart_write(struct channel_obj *h_obj, const char *data, int count)
  33. {
  34. int ret = 0;
  35. (void)h_obj;
  36. ret = uart_write(h_obj->fd, data, count);
  37. return ret;
  38. }
  39. static int myuart_read(struct channel_obj *h_obj, char *data, int count)
  40. {
  41. int ret = 0;
  42. (void)h_obj;
  43. ret = uart_read(h_obj->fd, data, count);
  44. return ret;
  45. }
  46. /******************************************************************************
  47. 函数名称: user_conf_init
  48. 函数版本: 01.01
  49. 创建作者: xxxxxx
  50. 创建日期: 2015-05-05
  51. 函数说明: 用户配置初始化
  52. 参数说明:
  53. 无
  54. 返回值: 无
  55. 修改记录:
  56. */
  57. void user_conf_init(void)
  58. {
  59. myuart_init();
  60. g_h_boj[0].read = myuart_read;
  61. g_h_boj[0].write = myuart_write;
  62. if((g_h_boj[0].fd==CFG_UART_485_0) ||(g_h_boj[0].fd==CFG_UART_485_1) || (g_h_boj[0].fd==CFG_UART_485_2) )
  63. {
  64. g_h_boj[0].halfduplex=1;
  65. }
  66. else
  67. {
  68. g_h_boj[0].halfduplex=0;
  69. }
  70. protocol_init();
  71. protocol_add_chan(&g_h_boj[0]);
  72. }