Arrow / Mbed OS DAPLink Reset
Embed: (wiki syntax)

« Back to documentation index

Show/hide line numbers DAP_queue.h Source File

DAP_queue.h

Go to the documentation of this file.
00001 /**
00002  * @file    DAP_queue.h
00003  * @brief   DAP processing queue
00004  *
00005  * DAPLink Interface Firmware
00006  * Copyright (c) 2019, ARM Limited, All Rights Reserved
00007  * SPDX-License-Identifier: Apache-2.0
00008  *
00009  * Licensed under the Apache License, Version 2.0 (the "License"); you may
00010  * not use this file except in compliance with the License.
00011  * You may obtain a copy of the License at
00012  *
00013  * http://www.apache.org/licenses/LICENSE-2.0
00014  *
00015  * Unless required by applicable law or agreed to in writing, software
00016  * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
00017  * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
00018  * See the License for the specific language governing permissions and
00019  * limitations under the License.
00020  */
00021 
00022 #ifndef DAP_QUEUE_H
00023 #define DAP_QUEUE_H
00024 
00025 #include "usb_def.h"
00026 #include "DAP_config.h"
00027 #include "DAP.h"
00028 
00029 #ifdef __cplusplus
00030 extern "C" {
00031 #endif
00032 
00033 #define FREE_COUNT_INIT          (DAP_PACKET_COUNT)
00034 #define SEND_COUNT_INIT          0
00035 
00036 typedef struct _DAP_queue {
00037     uint8_t     USB_Request [DAP_PACKET_COUNT][DAP_PACKET_SIZE];  // Request  Buffer
00038     uint16_t    resp_size[DAP_PACKET_COUNT]; //track the return response size
00039     uint32_t    free_count;
00040     uint32_t    send_count;
00041     uint32_t    recv_idx;
00042     uint32_t    send_idx;
00043 } DAP_queue;
00044 
00045 void DAP_queue_init(DAP_queue * queue);
00046 
00047 /*
00048  *  Get the a buffer from the DAP_queue where the response to the request is stored
00049  *    Parameters:      queue - DAP queue, buf = return the buffer location, len = return the len of the response
00050  *    Return Value:    TRUE - Success, FALSE - Error
00051  */
00052 BOOL DAP_queue_get_send_buf(DAP_queue * queue, uint8_t ** buf, int * len);
00053 
00054 /*
00055  *  Execute a request and store result to the DAP_queue
00056  *    Parameters:      queue - DAP queue, reqbuf = buffer with DAP request, len = of the request buffer, retbuf = buffer to peek on the result of the DAP operation
00057  *    Return Value:    TRUE - Success, FALSE - Error
00058  */
00059 BOOL DAP_queue_execute_buf(DAP_queue * queue, const uint8_t *reqbuf, int len, uint8_t ** retbuf);
00060 
00061 #ifdef __cplusplus
00062 }
00063 #endif
00064 
00065 #endif