h->transport = param->transport;
 
+       /* set max read/write buffer size in bytes */
+       param->max_buffer = 512;
+
        const uint16_t vids[] = { param->vid, 0 };
        const uint16_t pids[] = { param->pid, 0 };
 
 
 
 #include <target/target.h>
 
-static struct hl_interface_s hl_if = { {0, 0, 0, 0, 0, 0}, 0, 0 };
+static struct hl_interface_s hl_if = { {0, 0, 0, 0, 0, 0, 0}, 0, 0 };
 
 int hl_interface_open(enum hl_transports tr)
 {
 
                uint32_t size, uint32_t count,
                uint8_t *buffer)
 {
+       struct hl_interface_s *adapter = target_to_adapter(target);
        int res;
-       uint32_t buffer_threshold = 128;
+       uint32_t buffer_threshold = (adapter->param.max_buffer / 4);
        uint32_t addr_increment = 4;
        uint32_t c;
-       struct hl_interface_s *adapter = target_to_adapter(target);
 
        if (!count || !buffer)
                return ERROR_COMMAND_SYNTAX_ERROR;
         */
        if (size != 4) {
                count *= size;
-               buffer_threshold = 64;
+               buffer_threshold = (adapter->param.max_buffer / 4) / 2;
                addr_increment = 1;
        }
 
                uint32_t size, uint32_t count,
                const uint8_t *buffer)
 {
+       struct hl_interface_s *adapter = target_to_adapter(target);
        int res;
-       uint32_t buffer_threshold = 128;
+       uint32_t buffer_threshold = (adapter->param.max_buffer / 4);
        uint32_t addr_increment = 4;
        uint32_t c;
-       struct hl_interface_s *adapter = target_to_adapter(target);
 
        if (!count || !buffer)
                return ERROR_COMMAND_SYNTAX_ERROR;
         */
        if (size != 4) {
                count *= size;
-               buffer_threshold = 64;
+               buffer_threshold = (adapter->param.max_buffer / 4) / 2;
                addr_increment = 1;
        }