Repostiory containing DAPLink source code with Reset Pin workaround for HANI_IOT board.

Upstream: https://github.com/ARMmbed/DAPLink

Committer:
Pawel Zarembski
Date:
Tue Apr 07 12:55:42 2020 +0200
Revision:
0:01f31e923fe2
hani: DAPLink with reset workaround

Who changed what in which revision?

UserRevisionLine numberNew contents of line
Pawel Zarembski 0:01f31e923fe2 1 /**
Pawel Zarembski 0:01f31e923fe2 2 * @file circ_buf.h
Pawel Zarembski 0:01f31e923fe2 3 * @brief Implementation of a circular buffer
Pawel Zarembski 0:01f31e923fe2 4 *
Pawel Zarembski 0:01f31e923fe2 5 * DAPLink Interface Firmware
Pawel Zarembski 0:01f31e923fe2 6 * Copyright (c) 2016-2016, ARM Limited, All Rights Reserved
Pawel Zarembski 0:01f31e923fe2 7 * SPDX-License-Identifier: Apache-2.0
Pawel Zarembski 0:01f31e923fe2 8 *
Pawel Zarembski 0:01f31e923fe2 9 * Licensed under the Apache License, Version 2.0 (the "License"); you may
Pawel Zarembski 0:01f31e923fe2 10 * not use this file except in compliance with the License.
Pawel Zarembski 0:01f31e923fe2 11 * You may obtain a copy of the License at
Pawel Zarembski 0:01f31e923fe2 12 *
Pawel Zarembski 0:01f31e923fe2 13 * http://www.apache.org/licenses/LICENSE-2.0
Pawel Zarembski 0:01f31e923fe2 14 *
Pawel Zarembski 0:01f31e923fe2 15 * Unless required by applicable law or agreed to in writing, software
Pawel Zarembski 0:01f31e923fe2 16 * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
Pawel Zarembski 0:01f31e923fe2 17 * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
Pawel Zarembski 0:01f31e923fe2 18 * See the License for the specific language governing permissions and
Pawel Zarembski 0:01f31e923fe2 19 * limitations under the License.
Pawel Zarembski 0:01f31e923fe2 20 */
Pawel Zarembski 0:01f31e923fe2 21
Pawel Zarembski 0:01f31e923fe2 22 #ifndef CIRC_BUF_H
Pawel Zarembski 0:01f31e923fe2 23 #define CIRC_BUF_H
Pawel Zarembski 0:01f31e923fe2 24
Pawel Zarembski 0:01f31e923fe2 25 #include <stdbool.h>
Pawel Zarembski 0:01f31e923fe2 26 #include <stdint.h>
Pawel Zarembski 0:01f31e923fe2 27
Pawel Zarembski 0:01f31e923fe2 28 #ifdef __cplusplus
Pawel Zarembski 0:01f31e923fe2 29 extern "C" {
Pawel Zarembski 0:01f31e923fe2 30 #endif
Pawel Zarembski 0:01f31e923fe2 31
Pawel Zarembski 0:01f31e923fe2 32 typedef struct {
Pawel Zarembski 0:01f31e923fe2 33 uint32_t head;
Pawel Zarembski 0:01f31e923fe2 34 uint32_t tail;
Pawel Zarembski 0:01f31e923fe2 35 uint32_t size;
Pawel Zarembski 0:01f31e923fe2 36 uint8_t *buf;
Pawel Zarembski 0:01f31e923fe2 37 } circ_buf_t;
Pawel Zarembski 0:01f31e923fe2 38
Pawel Zarembski 0:01f31e923fe2 39 // Initialize or reinitialize a circular buffer
Pawel Zarembski 0:01f31e923fe2 40 void circ_buf_init(circ_buf_t *circ_buf, uint8_t *buffer, uint32_t size);
Pawel Zarembski 0:01f31e923fe2 41
Pawel Zarembski 0:01f31e923fe2 42 // Push a byte into the circular buffer
Pawel Zarembski 0:01f31e923fe2 43 void circ_buf_push(circ_buf_t *circ_buf, uint8_t data);
Pawel Zarembski 0:01f31e923fe2 44
Pawel Zarembski 0:01f31e923fe2 45 // Return a byte from the circular buffer
Pawel Zarembski 0:01f31e923fe2 46 uint8_t circ_buf_pop(circ_buf_t *circ_buf);
Pawel Zarembski 0:01f31e923fe2 47
Pawel Zarembski 0:01f31e923fe2 48 // Get the number of bytes in the circular buffer
Pawel Zarembski 0:01f31e923fe2 49 uint32_t circ_buf_count_used(circ_buf_t *circ_buf);
Pawel Zarembski 0:01f31e923fe2 50
Pawel Zarembski 0:01f31e923fe2 51 // Get the number of free spots left in the circular buffer
Pawel Zarembski 0:01f31e923fe2 52 uint32_t circ_buf_count_free(circ_buf_t *circ_buf);
Pawel Zarembski 0:01f31e923fe2 53
Pawel Zarembski 0:01f31e923fe2 54 // Attempt to read size bytes from the buffer. Return the number of bytes read
Pawel Zarembski 0:01f31e923fe2 55 uint32_t circ_buf_read(circ_buf_t *circ_buf, uint8_t *data, uint32_t size);
Pawel Zarembski 0:01f31e923fe2 56
Pawel Zarembski 0:01f31e923fe2 57 // Attempt to write size bytes to the buffer. Return the number of bytes written
Pawel Zarembski 0:01f31e923fe2 58 uint32_t circ_buf_write(circ_buf_t *circ_buf, const uint8_t *data, uint32_t size);
Pawel Zarembski 0:01f31e923fe2 59
Pawel Zarembski 0:01f31e923fe2 60 #ifdef __cplusplus
Pawel Zarembski 0:01f31e923fe2 61 }
Pawel Zarembski 0:01f31e923fe2 62 #endif
Pawel Zarembski 0:01f31e923fe2 63
Pawel Zarembski 0:01f31e923fe2 64 #endif