1 /***************************************************************************//**
2 * \file cy_map_hostbuffer.c
3 *
4 * \brief
5 * Implements a set of mapping functions for M2M DMA host buffer routines.
6 *
7 ********************************************************************************
8 * \copyright
9 * Copyright 2021-2022 Cypress Semiconductor Corporation (an Infineon company) or
10 * an affiliate of Cypress Semiconductor Corporation
11 *
12 * SPDX-License-Identifier: Apache-2.0
13 *
14 * Licensed under the Apache License, Version 2.0 (the "License");
15 * you may not use this file except in compliance with the License.
16 * You may obtain a copy of the License at
17 *
18 * http://www.apache.org/licenses/LICENSE-2.0
19 *
20 * Unless required by applicable law or agreed to in writing, software
21 * distributed under the License is distributed on an "AS IS" BASIS,
22 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
23 * See the License for the specific language governing permissions and
24 * limitations under the License.
25 *******************************************************************************/
26
27 #include "wiced_osl.h"
28 #include "cy_network_buffer.h"
29
30 #if defined(__cplusplus)
31 extern "C" {
32 #endif /* __cplusplus */
33
34 #define HOST_BUFFER_WAIT_MS (1000UL)
35
36 /*******************************************************************************
37 * Host buffer functions
38 *******************************************************************************/
39
host_buffer_get(wiced_buffer_t * buffer,wwd_buffer_dir_t direction,uint16_t size,bool wait)40 cy_rslt_t host_buffer_get(wiced_buffer_t* buffer, wwd_buffer_dir_t direction,
41 uint16_t size, bool wait)
42 {
43 uint32_t timeout_ms = wait ? HOST_BUFFER_WAIT_MS : 0UL;
44
45 return (cy_rslt_t)cy_host_buffer_get((whd_buffer_t*)buffer, (whd_buffer_dir_t)direction,
46 size, timeout_ms);
47 }
48
49
50 //--------------------------------------------------------------------------------------------------
51 // host_buffer_release
52 //--------------------------------------------------------------------------------------------------
host_buffer_release(wiced_buffer_t buffer,wwd_buffer_dir_t direction)53 void host_buffer_release(wiced_buffer_t buffer, wwd_buffer_dir_t direction)
54 {
55 cy_buffer_release((whd_buffer_t)buffer, (whd_buffer_dir_t)direction);
56 }
57
58
59 //--------------------------------------------------------------------------------------------------
60 // host_buffer_get_current_piece_data_pointer
61 //--------------------------------------------------------------------------------------------------
host_buffer_get_current_piece_data_pointer(wiced_buffer_t buffer)62 uint8_t* host_buffer_get_current_piece_data_pointer(wiced_buffer_t buffer)
63 {
64 return cy_buffer_get_current_piece_data_pointer((whd_buffer_t)buffer);
65 }
66
67
68 //--------------------------------------------------------------------------------------------------
69 // host_buffer_get_current_piece_size
70 //--------------------------------------------------------------------------------------------------
host_buffer_get_current_piece_size(wiced_buffer_t buffer)71 uint16_t host_buffer_get_current_piece_size(wiced_buffer_t buffer)
72 {
73 return cy_buffer_get_current_piece_size((whd_buffer_t)buffer);
74 }
75
76
77 //--------------------------------------------------------------------------------------------------
78 // host_buffer_set_size
79 //--------------------------------------------------------------------------------------------------
host_buffer_set_size(wiced_buffer_t buffer,uint16_t size)80 cy_rslt_t host_buffer_set_size(wiced_buffer_t buffer, uint16_t size)
81 {
82 return (cy_rslt_t)cy_buffer_set_size((whd_buffer_t)buffer, size);
83 }
84
85
86 //--------------------------------------------------------------------------------------------------
87 // host_buffer_add_remove_at_front
88 //--------------------------------------------------------------------------------------------------
host_buffer_add_remove_at_front(wiced_buffer_t * buffer,int32_t add_remove_amount)89 cy_rslt_t host_buffer_add_remove_at_front(wiced_buffer_t* buffer, int32_t add_remove_amount)
90 {
91 return (cy_rslt_t)cy_buffer_add_remove_at_front((whd_buffer_t*)buffer, add_remove_amount);
92 }
93
94
95 #if defined(__cplusplus)
96 }
97 #endif /* __cplusplus */
98