ykush3.h 2.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128
  1. /*******************************************************************************
  2. Copyright 2017 Yepkit Lda (www.yepkit.com)
  3. Licensed under the Apache License, Version 2.0 (the "License");
  4. you may not use this file except in compliance with the License.
  5. You may obtain a copy of the License at
  6. http://www.apache.org/licenses/LICENSE-2.0
  7. Unless required by applicable law or agreed to in writing, software
  8. distributed under the License is distributed on an "AS IS" BASIS,
  9. WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  10. See the License for the specific language governing permissions and
  11. limitations under the License.
  12. *******************************************************************************/
  13. #ifndef _YKUSH3_H_
  14. #define _YKUSH3_H_
  15. #include <yk_usb_device.h>
  16. #include <command_parser.h>
  17. enum ykush3Action {
  18. YKUSH3_PORT_UP,
  19. YKUSH3_PORT_DOWN,
  20. YKUSH3_PORT_STATUS,
  21. YKUSH3_LIST_BOARDS,
  22. YKUSH3_GET_STATUS,
  23. YKUSH3_EXT_CTRL_ON,
  24. YKUSH3_EXT_CTRL_OFF,
  25. YKUSH3_READ_IO,
  26. YKUSH3_WRITE_IO,
  27. YKUSH3_CONFIG,
  28. YKUSH3_RESET,
  29. YKUSH3_GPIO_EN,
  30. YKUSH3_GPIO_DIS,
  31. YKUSH3_ENTER_BOOTLOADER,
  32. //I2C
  33. YKUSH3_I2C_CONTROL_ENABLE,
  34. YKUSH3_YKUSH3_I2C_CONTROL_DISABLE,
  35. YKUSH3_I2C_GATEWAY_ENABLE,
  36. YKUSH3_I2C_GATEWAY_DISABLE,
  37. YKUSH3_I2C_SET_ADRRESS,
  38. YKUSH3_I2C_WRITE,
  39. YKUSH3_I2C_READ,
  40. YKUSH3_FIRMWARE_VERSION,
  41. YKUSH3_BOOTLOADER_VERSION,
  42. YKUSH3_HELP
  43. };
  44. class Ykush3 : public UsbDevice
  45. {
  46. public:
  47. Ykush3()
  48. : UsbDevice(0x04D8, 0xF11B)
  49. {
  50. usb_serial = NULL;
  51. }
  52. //Downstream ports and 5V EXT port control
  53. int get_port_status(char *serial, char port); //get downstream port status
  54. int port_up(char *serial, char port);
  55. int port_down(char *serial, char port);
  56. //GPIO control
  57. int write_io(char *serial, char port, char value);
  58. int read_io(char *serial, char port);
  59. int gpio_ctrl_enable(char *serial);
  60. int gpio_ctrl_disable(char *serial);
  61. int enter_bootloader(char *serial);
  62. //Configurations control
  63. int config_port(char *serial, char port, char value);
  64. //Reset
  65. int reset(char *serial);
  66. //Help
  67. void print_help(void);
  68. //I2C
  69. int i2c_enable_disable_control(bool enable_flag); //ToDo
  70. int i2c_enable_disable_gateway(bool enable_flag); //ToDo
  71. int i2c_set_address(char *i2c_address); //ToDo
  72. int i2c_write(char *i2c_address_ASCII, char *num_bytes_ASCII, char **data_to_write_ASCII); //ToDo
  73. int i2c_read(char *i2c_address_ASCII, char *num_bytes_ASCII, unsigned char *data_buffer, int *bytes_read); //ToDo
  74. //Versioning
  75. int display_version_bootloader (void);
  76. int display_version_firmware (void);
  77. int set_usb_serial(char *serial);
  78. private:
  79. char *usb_serial;
  80. };
  81. //---------------------------------
  82. //FUNCTIONS
  83. //---------------------------------
  84. int ykush3_cmd_parser(int argc, char** argv);
  85. int ykush3_list_attached(void);
  86. #endif