RZ/A1H CMSIS-RTOS RTX BSP for GR-PEACH.
Dependents: GR-PEACH_Azure_Speech ImageZoomInout_Sample ImageRotaion_Sample ImageScroll_Sample ... more
Fork of R_BSP by
R_BSP_Aio.h
00001 /******************************************************************************* 00002 * DISCLAIMER 00003 * This software is supplied by Renesas Electronics Corporation and is only 00004 * intended for use with Renesas products. No other uses are authorized. This 00005 * software is owned by Renesas Electronics Corporation and is protected under 00006 * all applicable laws, including copyright laws. 00007 * THIS SOFTWARE IS PROVIDED "AS IS" AND RENESAS MAKES NO WARRANTIES REGARDING 00008 * THIS SOFTWARE, WHETHER EXPRESS, IMPLIED OR STATUTORY, INCLUDING BUT NOT 00009 * LIMITED TO WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE 00010 * AND NON-INFRINGEMENT. ALL SUCH WARRANTIES ARE EXPRESSLY DISCLAIMED. 00011 * TO THE MAXIMUM EXTENT PERMITTED NOT PROHIBITED BY LAW, NEITHER RENESAS 00012 * ELECTRONICS CORPORATION NOR ANY OF ITS AFFILIATED COMPANIES SHALL BE LIABLE 00013 * FOR ANY DIRECT, INDIRECT, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES FOR 00014 * ANY REASON RELATED TO THIS SOFTWARE, EVEN IF RENESAS OR ITS AFFILIATES HAVE 00015 * BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. 00016 * Renesas reserves the right, without notice, to make changes to this software 00017 * and to discontinue the availability of this software. By using this software, 00018 * you agree to the additional terms and conditions found by accessing the 00019 * following link: 00020 * http://www.renesas.com/disclaimer* 00021 * Copyright (C) 2015 Renesas Electronics Corporation. All rights reserved. 00022 *******************************************************************************/ 00023 /**************************************************************************//** 00024 * @file R_BSP_Aio.h 00025 * @brief R_BSP_Aio API 00026 ******************************************************************************/ 00027 00028 #ifndef R_BSP_AIO_H 00029 #define R_BSP_AIO_H 00030 00031 #include <stdint.h> 00032 #include "rtos.h" 00033 00034 /** Callback function type 00035 * 00036 * @param p_data Location of the data. 00037 * @param result Number of bytes transmit on success. negative number on error. 00038 * @param p_app_data User definition data. 00039 */ 00040 typedef void (*rbsp_notify_func_t)(void * p_data, int32_t result, void * p_app_data); 00041 00042 /** Asynchronous control block structure */ 00043 typedef struct { 00044 rbsp_notify_func_t p_notify_func; /**< Callback function type. */ 00045 void * p_app_data; /**< User definition data. */ 00046 } rbsp_data_conf_t; 00047 00048 /** 00049 * A class to communicate a R_BSP_Aio 00050 */ 00051 class R_BSP_Aio { 00052 00053 public: 00054 00055 /** Write count bytes to the file associated 00056 * 00057 * @param p_data Location of the data. 00058 * @param data_size Number of bytes to write. 00059 * @param p_data_conf Asynchronous control block structure. 00060 * @return Number of bytes written on success. negative number on error. 00061 */ 00062 int32_t write(void * const p_data, uint32_t data_size, const rbsp_data_conf_t * const p_data_conf = NULL); 00063 00064 /** Read count bytes to the file associated 00065 * 00066 * @param p_data Location of the data. 00067 * @param data_size Number of bytes to read. 00068 * @param p_data_conf Asynchronous control block structure. 00069 * @return Number of bytes read on success. negative number on error. 00070 */ 00071 int32_t read(void * const p_data, uint32_t data_size, const rbsp_data_conf_t * const p_data_conf = NULL); 00072 00073 protected: 00074 00075 /** Constructor 00076 * 00077 */ 00078 R_BSP_Aio(); 00079 00080 /** Destructor 00081 * 00082 */ 00083 virtual ~R_BSP_Aio(); 00084 00085 /** Write init 00086 * 00087 * @param handle channel handle. 00088 * @param p_func_a Pointer of write function. 00089 * @param max_buff_num The upper limit of write buffer. 00090 */ 00091 void write_init(void * handle, void * p_func_a, int32_t max_buff_num = 16) { 00092 init(&write_ctl, handle, p_func_a, max_buff_num); 00093 }; 00094 00095 /** Read init 00096 * 00097 * @param handle channel handle. 00098 * @param p_func_a Pointer of read function. 00099 * @param max_buff_num The upper limit of read buffer. 00100 */ 00101 void read_init(void * handle, void * p_func_a, int32_t max_buff_num = 16) { 00102 init(&read_ctl, handle, p_func_a, max_buff_num); 00103 }; 00104 private: 00105 typedef struct { 00106 rbsp_notify_func_t p_cb_func; 00107 void * p_cb_data; 00108 Semaphore * p_sem; 00109 void * p_aio; 00110 } rbsp_sival_t; 00111 00112 typedef struct { 00113 void * ch_handle; 00114 void * p_async_func; 00115 void * p_aio_top; 00116 int32_t index; 00117 rbsp_sival_t * p_sival_top; 00118 Semaphore * p_sem_ctl; 00119 int32_t MaxNum; 00120 } rbsp_serial_ctl_t; 00121 00122 typedef struct { 00123 Semaphore * p_sem; 00124 int32_t result; 00125 } rbsp_sync_t; 00126 00127 void init(rbsp_serial_ctl_t * p_ctl, void * handle, void * p_func_a, int32_t max_buff_num); 00128 static int32_t sync_trans(rbsp_serial_ctl_t * p_ctl, void * const p_data, uint32_t data_size); 00129 static void callback_sync_trans(void * p_data, int32_t result, void * p_app_data); 00130 static int32_t aio_trans(rbsp_serial_ctl_t * const p_ctl, void * const p_data, uint32_t data_size, 00131 const rbsp_data_conf_t * const p_data_conf); 00132 static void callback_aio_trans(union sigval signo); 00133 00134 rbsp_serial_ctl_t write_ctl; 00135 rbsp_serial_ctl_t read_ctl; 00136 }; 00137 #endif
Generated on Tue Jul 12 2022 20:43:58 by 1.7.2