switchserialmode.h 1.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556
  1. #ifndef SWITCH_SERIAL_MODE
  2. #define SWITCH_SERIAL_MODE
  3. #include <stdint.h>
  4. #define ERROR -1
  5. #define SUCCESS 0
  6. typedef enum boardType {
  7. BASIC_BOARD = 0,
  8. ADVANCED_BOARD,
  9. ADVANCED_BOARD_PG1
  10. } boardType_e;
  11. typedef struct transceiver_ops {
  12. void (*transceiver_set_termination)( uint8_t onoff);
  13. void (*transceiver_switch_mode)(const uint8_t *mode);
  14. } transceiver_ops_t;
  15. typedef struct serial_ops {
  16. /*Device node*/
  17. uint8_t *devName;
  18. /*Init device resources*/
  19. int8_t (*init)(uint8_t *devName);
  20. /*Set serial mode,like rs232 rs485 rs422*/
  21. void (*setMode)(uint8_t *mode);
  22. /*Display current serial mode*/
  23. void (*getMode)(void);
  24. /*For the device which support setup and hold time*/
  25. void (*rs485HoldTime)(uint8_t time);
  26. void (*rs485SetupTime)(uint8_t time);
  27. /*Release*/
  28. void (*release)(void);
  29. void (*preProcess)(void *);
  30. } serial_ops_t;
  31. typedef struct controller_setting {
  32. uint32_t hold_time;
  33. uint32_t setup_time;
  34. } controller_setting_t;
  35. typedef struct platform {
  36. serial_ops_t *serOps;
  37. transceiver_ops_t *transOps;
  38. void *private_data;
  39. } platform_t;
  40. boardType_e get_board_type(void);
  41. #endif