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
SSIF
The SSIF driver implements transmission and reception functionality which uses the SSIF in the RZ/A Series.
Hello World!
Import program
00001 #include "mbed.h" 00002 #include "R_BSP_Ssif.h" 00003 #include "sine_data_tbl.h" 00004 00005 //I2S send only, The upper limit of write buffer is 8. 00006 R_BSP_Ssif ssif(P4_4, P4_5, P4_7, P4_6, 0x80, 8, 0); 00007 00008 static void callback_ssif_write_end(void * p_data, int32_t result, void * p_app_data) { 00009 if (result < 0) { 00010 printf("ssif write callback error %d\n", result); 00011 } 00012 } 00013 00014 int main() { 00015 rbsp_data_conf_t ssif_write_end_conf = {&callback_ssif_write_end, NULL}; 00016 ssif_channel_cfg_t ssif_cfg; 00017 int32_t result; 00018 00019 //I2S Master, 44.1kHz, 16bit, 2ch 00020 ssif_cfg.enabled = true; 00021 ssif_cfg.int_level = 0x78; 00022 ssif_cfg.slave_mode = false; 00023 ssif_cfg.sample_freq = 44100u; 00024 ssif_cfg.clk_select = SSIF_CFG_CKS_AUDIO_X1; 00025 ssif_cfg.multi_ch = SSIF_CFG_MULTI_CH_1; 00026 ssif_cfg.data_word = SSIF_CFG_DATA_WORD_16; 00027 ssif_cfg.system_word = SSIF_CFG_SYSTEM_WORD_32; 00028 ssif_cfg.bclk_pol = SSIF_CFG_FALLING; 00029 ssif_cfg.ws_pol = SSIF_CFG_WS_LOW; 00030 ssif_cfg.padding_pol = SSIF_CFG_PADDING_LOW; 00031 ssif_cfg.serial_alignment = SSIF_CFG_DATA_FIRST; 00032 ssif_cfg.parallel_alignment = SSIF_CFG_LEFT; 00033 ssif_cfg.ws_delay = SSIF_CFG_DELAY; 00034 ssif_cfg.noise_cancel = SSIF_CFG_DISABLE_NOISE_CANCEL; 00035 ssif_cfg.tdm_mode = SSIF_CFG_DISABLE_TDM; 00036 ssif_cfg.romdec_direct.mode = SSIF_CFG_DISABLE_ROMDEC_DIRECT; 00037 ssif_cfg.romdec_direct.p_cbfunc = NULL; 00038 result = ssif.ConfigChannel(&ssif_cfg); 00039 if (result < 0) { 00040 printf("ssif config error %d\n", result); 00041 } 00042 00043 while (1) { 00044 //The upper limit of write buffer is 8. 00045 result = ssif.write((void *)sin_data_44100Hz_16bit_2ch, 00046 sizeof(sin_data_44100Hz_16bit_2ch), &ssif_write_end_conf); 00047 if (result < 0) { 00048 printf("ssif write api error %d\n", result); 00049 } 00050 } 00051 }
API
Import library
Public Member Functions |
|
| R_BSP_Ssif (PinName sck, PinName ws, PinName tx, PinName rx, uint8_t int_level=0x80, int32_t max_write_num=16, int32_t max_read_num=16) | |
|
Constructor.
|
|
| virtual | ~R_BSP_Ssif () |
|
Destructor.
|
|
| int32_t | GetSsifChNo (void) |
|
Get a value of SSIF channel number.
|
|
| bool | ConfigChannel (const ssif_channel_cfg_t *const p_ch_cfg) |
|
Save configuration to the SSIF driver.
|
|
| bool | GetStatus (uint32_t *const p_status) |
|
Get a value of SSISR register.
|
|
| int32_t | write (void *const p_data, uint32_t data_size, const rbsp_data_conf_t *const p_data_conf=NULL) |
|
Write count bytes to the file associated.
|
|
| int32_t | read (void *const p_data, uint32_t data_size, const rbsp_data_conf_t *const p_data_conf=NULL) |
|
Read count bytes to the file associated.
|
|
Protected Member Functions |
|
| void | write_init (void *handle, void *p_func_a, int32_t max_buff_num=16) |
|
Write init.
|
|
| void | read_init (void *handle, void *p_func_a, int32_t max_buff_num=16) |
|
Read init.
|
|
Interface
See the Pinout page for more details
SCUX
The SCUX module consists of a sampling rate converter, a digital volume unit, and a mixer.
The SCUX driver can perform asynchronous and synchronous sampling rate conversions using the sampling rate converter. The SCUX driver uses the DMA transfer mode to input and output audio data.
Hello World!
Import program
00001 #include "mbed.h" 00002 #include "R_BSP_Scux.h" 00003 #include "USBHostMSD.h" 00004 00005 R_BSP_Scux scux(SCUX_CH_0); 00006 00007 #define WRITE_SAMPLE_NUM (128) 00008 #define READ_SAMPLE_NUM (2048) 00009 00010 const short sin_data[WRITE_SAMPLE_NUM] = { 00011 0x0000,0x0000,0x0C8C,0x0C8C,0x18F9,0x18F9,0x2528,0x2528 00012 ,0x30FB,0x30FB,0x3C56,0x3C56,0x471C,0x471C,0x5133,0x5133 00013 ,0x5A82,0x5A82,0x62F1,0x62F1,0x6A6D,0x6A6D,0x70E2,0x70E2 00014 ,0x7641,0x7641,0x7A7C,0x7A7C,0x7D89,0x7D89,0x7F61,0x7F61 00015 ,0x7FFF,0x7FFF,0x7F61,0x7F61,0x7D89,0x7D89,0x7A7C,0x7A7C 00016 ,0x7641,0x7641,0x70E2,0x70E2,0x6A6D,0x6A6D,0x62F1,0x62F1 00017 ,0x5A82,0x5A82,0x5133,0x5133,0x471C,0x471C,0x3C56,0x3C56 00018 ,0x30FB,0x30FB,0x2528,0x2528,0x18F9,0x18F9,0x0C8C,0x0C8C 00019 ,0x0000,0x0000,0xF374,0xF374,0xE707,0xE707,0xDAD8,0xDAD8 00020 ,0xCF05,0xCF05,0xC3AA,0xC3AA,0xB8E4,0xB8E4,0xAECD,0xAECD 00021 ,0xA57E,0xA57E,0x9D0F,0x9D0F,0x9593,0x9593,0x8F1E,0x8F1E 00022 ,0x89BF,0x89BF,0x8584,0x8584,0x8277,0x8277,0x809F,0x809F 00023 ,0x8001,0x8001,0x809F,0x809F,0x8277,0x8277,0x8584,0x8584 00024 ,0x89BF,0x89BF,0x8F1E,0x8F1E,0x9593,0x9593,0x9D0F,0x9D0F 00025 ,0xA57E,0xA57E,0xAECD,0xAECD,0xB8E4,0xB8E4,0xC3AA,0xC3AA 00026 ,0xCF05,0xCF05,0xDAD8,0xDAD8,0xE707,0xE707,0xF374,0xF374 00027 }; 00028 00029 #if defined(__ICCARM__) 00030 #pragma data_alignment=4 00031 short write_buff[WRITE_SAMPLE_NUM]@ ".mirrorram"; 00032 #pragma data_alignment=4 00033 short read_buff[READ_SAMPLE_NUM]@ ".mirrorram"; 00034 #else 00035 short write_buff[WRITE_SAMPLE_NUM] __attribute((section("NC_BSS"),aligned(4))); 00036 short read_buff[READ_SAMPLE_NUM] __attribute((section("NC_BSS"),aligned(4))); 00037 #endif 00038 00039 void scux_setup(void); 00040 void write_task(void const*); 00041 void file_output_to_usb(void); 00042 00043 int main(void) { 00044 // set up SRC parameters. 00045 scux_setup(); 00046 00047 printf("Sampling rate conversion Start.\n"); 00048 // start accepting transmit/receive requests. 00049 scux.TransStart(); 00050 00051 // create a new thread to write to SCUX. 00052 Thread writeTask(write_task, NULL, osPriorityNormal, 1024 * 4); 00053 00054 // receive request to the SCUX driver. 00055 scux.read(read_buff, sizeof(read_buff)); 00056 printf("Sampling rate conversion End.\n"); 00057 00058 // output binary file to USB port 0. 00059 file_output_to_usb(); 00060 } 00061 00062 void scux_setup(void) { 00063 scux_src_usr_cfg_t src_cfg; 00064 00065 src_cfg.src_enable = true; 00066 src_cfg.word_len = SCUX_DATA_LEN_16; 00067 src_cfg.mode_sync = true; 00068 src_cfg.input_rate = SAMPLING_RATE_48000HZ; 00069 src_cfg.output_rate = SAMPLING_RATE_96000HZ; 00070 src_cfg.select_in_data_ch[0] = SELECT_IN_DATA_CH_0; 00071 src_cfg.select_in_data_ch[1] = SELECT_IN_DATA_CH_1; 00072 00073 scux.SetSrcCfg(&src_cfg); 00074 } 00075 00076 void scux_flush_callback(int scux_ch) { 00077 // do nothing 00078 } 00079 00080 void write_task(void const*) { 00081 memcpy(write_buff, sin_data, sizeof(write_buff)); 00082 // send request to the SCUX driver. 00083 scux.write(write_buff, sizeof(write_buff)); 00084 00085 // stop the acceptance of transmit/receive requests. 00086 scux.FlushStop(&scux_flush_callback); 00087 } 00088 00089 void file_output_to_usb(void) { 00090 FILE * fp = NULL; 00091 int i; 00092 00093 USBHostMSD msd("usb"); 00094 00095 // try to connect a MSD device 00096 for(i = 0; i < 10; i++) { 00097 if (msd.connect()) { 00098 break; 00099 } 00100 wait(0.5); 00101 } 00102 00103 if (msd.connected()) { 00104 fp = fopen("/usb/scux_input.dat", "rb"); 00105 if (fp == NULL) { 00106 fp = fopen("/usb/scux_input.dat", "wb"); 00107 if (fp != NULL) { 00108 fwrite(write_buff, sizeof(short), WRITE_SAMPLE_NUM, fp); 00109 fclose(fp); 00110 printf("Output binary file(Input data) to USB.\n"); 00111 } else { 00112 printf("Failed to output binary file(Input data).\n"); 00113 } 00114 } else { 00115 printf("Binary file(Input data) exists.\n"); 00116 fclose(fp); 00117 } 00118 00119 fp = fopen("/usb/scux_output.dat", "rb"); 00120 if (fp == NULL) { 00121 fp = fopen("/usb/scux_output.dat", "wb"); 00122 if (fp != NULL) { 00123 fwrite(read_buff, sizeof(short), READ_SAMPLE_NUM, fp); 00124 fclose(fp); 00125 printf("Output binary file(Output data) to USB.\n"); 00126 } else { 00127 printf("Failed to output binary file(Output data).\n"); 00128 } 00129 } else { 00130 printf("Binary file(Output data) exists.\n"); 00131 fclose(fp); 00132 } 00133 } else { 00134 printf("Failed to connect to the USB device.\n"); 00135 } 00136 }
API
Import library
Public Member Functions |
|
| R_BSP_Scux ( scux_ch_num_t channel, uint8_t int_level=0x80, int32_t max_write_num=16, int32_t max_read_num=16) | |
|
Constructor: Initializes and opens the channel designated by the SCUX driver.
|
|
| virtual | ~R_BSP_Scux (void) |
|
Destructor: Closes the channel designated by the SCUX driver and exits.
|
|
| bool | TransStart (void) |
|
Sets up the SCUX HW and starts operation, then starts accepting write/read requests.
|
|
| bool | FlushStop (void(*const callback)(int32_t)) |
|
Stops accepting write/read requests, flushes out all data in the SCUX that is requested for transfer, then stops the HW operation.
|
|
| bool | ClearStop (void) |
|
Discards all data in the SCUX that is requested for transfer before stopping the hardware operation and stops accepting write/read requests.
|
|
| bool | SetSrcCfg (const scux_src_usr_cfg_t *const p_src_param) |
|
Sets up SRC parameters.
|
|
| bool | GetWriteStat (uint32_t *const p_write_stat) |
|
Obtains the state information of the write request.
|
|
| bool | GetReadStat (uint32_t *const p_read_stat) |
|
Obtains the state information of the read request.
|
|
| int32_t | write (void *const p_data, uint32_t data_size, const rbsp_data_conf_t *const p_data_conf=NULL) |
|
Write count bytes to the file associated.
|
|
| int32_t | read (void *const p_data, uint32_t data_size, const rbsp_data_conf_t *const p_data_conf=NULL) |
|
Read count bytes to the file associated.
|
|
Protected Member Functions |
|
| void | write_init (void *handle, void *p_func_a, int32_t max_buff_num=16) |
|
Write init.
|
|
| void | read_init (void *handle, void *p_func_a, int32_t max_buff_num=16) |
|
Read init.
|
|
Write request state transition diagram
Read request state transition diagram
Revision 7:30ebba78fff0, committed 2015-12-16
- Comitter:
- dkato
- Date:
- Wed Dec 16 06:33:17 2015 +0000
- Parent:
- 6:aa1fc6a5cc2a
- Child:
- 8:cbb9d60c8748
- Commit message:
- Standardization of processing
Changed in this revision
--- a/RenesasBSP/drv_inc/scux_if.h Fri Oct 02 03:03:25 2015 +0000 +++ b/RenesasBSP/drv_inc/scux_if.h Wed Dec 16 06:33:17 2015 +0000 @@ -40,6 +40,7 @@ #if(1) /* mbed */ #include "ioif_aio.h" #include "misratypes.h" +#include "R_BSP_mbed_fns.h" #include "R_BSP_ScuxDef.h" #else /* not mbed */ #include "ioif_public.h" @@ -448,14 +449,7 @@ ******************************************************************************/ #if(1) /* mbed */ -extern void *R_SCUX_InitOne(const int_t channel, const void * const p_config_data, int32_t * const p_errno); -extern int_t R_SCUX_UnInitOne(const int_t channel, const void * const p_driver_instance, int32_t * const p_errno); -extern int_t R_SCUX_Open(void * const p_driver_instance, const char_t * const p_path_name, const int_t flags, const int_t mode, int32_t * const p_errno); -extern int_t R_SCUX_Close(void * const p_fd, int32_t * const p_errno); -extern int_t R_SCUX_Ioctl(void * const p_fd, const int_t request, void * const p_buf, int32_t * const p_errno); -extern int_t R_SCUX_WriteAsync(void * const p_fd, AIOCB * const p_aio, int32_t * const p_errno); -extern int_t R_SCUX_ReadAsync(void * const p_fd, AIOCB * const p_aio, int32_t * const p_errno); -extern int_t R_SCUX_Cancel(void * const p_fd, AIOCB * const p_aio, int32_t * const p_errno); +RBSP_MBED_FNS* R_SCUX_MakeCbTbl_mbed(void); #else /* not mbed */ IOIF_DRV_API* R_SCUX_MakeCbTbl(void); #endif /* end mbed */
--- a/RenesasBSP/drv_inc/ssif_if.h Fri Oct 02 03:03:25 2015 +0000 +++ b/RenesasBSP/drv_inc/ssif_if.h Wed Dec 16 06:33:17 2015 +0000 @@ -42,6 +42,7 @@ #if(1) /* mbed */ #include "misratypes.h" #include "aioif.h" +#include "R_BSP_mbed_fns.h" #include "R_BSP_SsifDef.h" #else #include "ioif_public.h" @@ -56,14 +57,7 @@ Function Prototypes *****************************************************************************/ -extern void* R_SSIF_InitOne(const int_t channel, void* const config_data, int32_t* const p_errno); -extern int_t R_SSIF_UnInitOne(const int_t channel, void* const driver_instance, int32_t* const p_errno); -extern int_t R_SSIF_Open(void* const p_driver_instance, const char_t* const p_path_name, const int_t flags, const int_t mode, int32_t* const p_errno); -extern int_t R_SSIF_Close(void* const p_fd, int32_t* const p_errno); -extern int_t R_SSIF_Ioctl(void* const p_fd, const int_t request, void* const p_buf, int32_t* const p_errno); -extern int_t R_SSIF_WriteAsync(void* const p_fd, AIOCB* const p_aio, int32_t* const p_errno); -extern int_t R_SSIF_ReadAsync(void* const p_fd, AIOCB* const p_aio, int32_t* const p_errno); -extern int_t R_SSIF_Cancel(void* const p_fd, AIOCB* p_aio, int32_t* const p_errno); +extern RBSP_MBED_FNS* R_SSIF_MakeCbTbl_mbed(void); #else /****************************************************************************** Defines
--- a/RenesasBSP/drv_src/scux/scux.c Fri Oct 02 03:03:25 2015 +0000
+++ b/RenesasBSP/drv_src/scux/scux.c Wed Dec 16 06:33:17 2015 +0000
@@ -345,28 +345,7 @@
* ENOMEM : Making semaphore is failed.
* EFAULT : Internal error is occured.
******************************************************************************/
-#else /* not mbed */
-/**************************************************************************//**
-* Function Name: SCUX_Initialize
-* @brief Init SCUX driver.
-*
-* Description:<br>
-*
-* @param[in] p_scux_init_param :Initialize parameter for SCUX.
-* @retval ESUCCESS -
-* Operation successful.
-* EERROR -
-* Error occured.
-* error code -
-* ENOMEM : Making semaphore is failed.
-* EFAULT : Internal error is occured.
-******************************************************************************/
-#endif /* end mbed */
-#if(1) /* mbed */
int_t SCUX_InitializeOne(const int_t channel, const scux_channel_cfg_t * const p_scux_init_param)
-#else /* not mbed */
-int_t SCUX_Initialize(const scux_channel_cfg_t * const p_scux_init_param)
-#endif /* end mbed */
{
int_t retval = ESUCCESS;
osStatus sem_ercd;
@@ -377,28 +356,23 @@
bool_t init_shared_flag = false;
int_t was_masked;
volatile uint8_t dummy_buf;
-#if(1) /* mbed */
uint32_t scux_init_count;
int_t uninit_ercd;
bool_t init_start_flag = false;
bool_t uninit_all_flag = false;
uint32_t i;
-#endif /* end mbed */
if (NULL == p_scux_init_param)
{
retval = EFAULT;
}
-#if(1) /* mbed */
else if (false == p_scux_init_param->enabled)
{
retval = EFAULT;
}
-#endif /* end mbed */
else
{
/* init channel management information */
-#if(1) /* mbed */
scux_ch_count = channel;
for (i = 0; ((i < INIT_WAIT_NUM) && (false == init_start_flag)); i++)
@@ -463,44 +437,17 @@
}
else
{
-#else /* not mbed */
- for (scux_ch_count = 0; scux_ch_count < SCUX_CH_NUM; scux_ch_count++)
- {
- if (false == p_scux_init_param[scux_ch_count].enabled)
{
- /* set disable parameter */
- gb_scux_info_drv.info_ch[scux_ch_count].enabled = false;
- gb_scux_info_drv.info_ch[scux_ch_count].ch_stat = SCUX_CH_UNINIT;
- }
- else
-#endif /* end mbed */
- {
-#if(1) /* mbed */
-#else /* not mbed */
- gb_scux_info_drv.info_ch[scux_ch_count].enabled = true;
-#endif /* end mbed */
/* copy parameter */
/* set interrupt parameter */
-#if(1) /* mbed */
gb_scux_info_drv.info_ch[scux_ch_count].int_level = p_scux_init_param->int_level;
-#else /* not mbed */
- gb_scux_info_drv.info_ch[scux_ch_count].int_level = p_scux_init_param[scux_ch_count].int_level;
-#endif /* end mbed */
/* set route parameter */
-#if(1) /* mbed */
gb_scux_info_drv.info_ch[scux_ch_count].route_set = p_scux_init_param->route;
-#else /* not mbed */
- gb_scux_info_drv.info_ch[scux_ch_count].route_set = p_scux_init_param[scux_ch_count].route;
-#endif /* end mbed */
/* set SRC paramter */
-#if(1) /* mbed */
SCUX_IoctlSetSrcCfg(scux_ch_count, &p_scux_init_param->src_cfg);
-#else /* not mbed */
- SCUX_IoctlSetSrcCfg(scux_ch_count, &p_scux_init_param[scux_ch_count].src_cfg);
-#endif /* end mbed */
/* init SCUX parameter */
if ((SCUX_CH_0 == scux_ch_count) || (SCUX_CH_1 == scux_ch_count))
@@ -700,18 +647,10 @@
}
}
-#if(1) /* mbed */
-#else /* not mbed */
- if (false == init_shared_flag)
- {
- init_shared_flag = true;
- }
-#endif /* end mbed */
gb_scux_info_drv.info_ch[scux_ch_count].ch_stat = SCUX_CH_INIT;
}
-#if(1) /* mbed */
if (ESUCCESS != retval)
{
/* uninit each resouces */
@@ -770,73 +709,16 @@
{
gb_scux_info_drv.drv_stat = SCUX_DRV_INIT;
}
-#endif /* end mbed */
}
}
-#if(1) /* mbed */
-#else /* not mbed */
- if (ESUCCESS != retval)
- {
- for (scux_ch_count = SCUX_SSIF_CH_0; scux_ch_count < SCUX_CH_NUM; scux_ch_count++)
- {
- if (false != gb_scux_info_drv.info_ch[scux_ch_count].enabled)
- {
- /* semaphore delete */
- sem_ercd = osSemaphoreDelete(gb_scux_info_drv.info_ch[scux_ch_count].sem_ch_scux_access);
- /* semaphore error check */
- if (osOK != sem_ercd)
- {
- /* set error return value */
- retval = EFAULT;
- }
-
- gb_scux_info_drv.info_ch[scux_ch_count].enabled = false;
- gb_scux_info_drv.info_ch[scux_ch_count].ch_stat = SCUX_CH_UNINIT;
- }
- }
-
- for (ssif_ch_count = SCUX_SSIF_CH_0; ssif_ch_count < SCUX_SSIF_CH_NUM; ssif_ch_count++)
- {
- sem_ercd = osSemaphoreDelete(gb_scux_ssif_info[ssif_ch_count].sem_ch_scux_ssif_access);
- /* semaphore error check */
- if (osOK != sem_ercd)
- {
- /* set error return value */
- retval = EFAULT;
- }
- }
-
- sem_ercd = osSemaphoreDelete(gb_scux_info_drv.shared_info.sem_shared_access);
- /* semaphore error check */
- if (osOK != sem_ercd)
- {
- /* set error return value */
- retval = EFAULT;
- }
-
- gb_scux_info_drv.drv_stat = SCUX_DRV_UNINIT;
- }
- else
- {
- gb_scux_info_drv.drv_stat = SCUX_DRV_INIT;
- }
-#endif /* end mbed */
-
return retval;
}
-#if(1) /* mbed */
/******************************************************************************
End of function SCUX_InitializeOne
******************************************************************************/
-#else /* not mbed */
-/******************************************************************************
-End of function SCUX_Initialize
-******************************************************************************/
-#endif /* end mbed */
-#if(1) /* mbed */
/**************************************************************************//**
* Function Name: SCUX_UnInitializeOne
* @brief Uninit SCUX driver.
@@ -846,111 +728,59 @@
* @param[in] channel :unInitialize channel number.
* @retval None.
******************************************************************************/
-#else /* not mbed */
-/**************************************************************************//**
-* Function Name: SCUX_UnInitialize
-* @brief Uninit SCUX driver.
-*
-* Description:<br>
-*
-* @param[in] None.
-* @retval None.
-******************************************************************************/
-#endif /* end mbed */
-#if(1) /* mbed */
void SCUX_UnInitializeOne(const int_t channel)
-#else /* not mbed */
-void SCUX_UnInitialize(void)
-#endif /* end mbed */
{
osStatus sem_ercd;
int_t ercd;
int_t scux_ch_count;
int_t ssif_ch_count;
-#if(1) /* mbed */
bool_t uninit_all_flag = false;
uint32_t i;
-#else /* not mbed */
- uint32_t cpg_value;
-#endif /* end mbed */
int_t was_masked;
-#if(1) /* mbed */
scux_ch_count = channel;
-#else /* not mbed */
- for (scux_ch_count = 0; scux_ch_count < SCUX_CH_NUM; scux_ch_count++)
-#endif /* end mbed */
+ if (false != gb_scux_info_drv.info_ch[scux_ch_count].enabled)
{
- if (false != gb_scux_info_drv.info_ch[scux_ch_count].enabled)
+ /* check ch_stat whether going transfer */
+ if ((SCUX_CH_UNINIT != gb_scux_info_drv.info_ch[scux_ch_count].ch_stat) &&
+ (SCUX_CH_INIT != gb_scux_info_drv.info_ch[scux_ch_count].ch_stat) &&
+ (SCUX_CH_STOP != gb_scux_info_drv.info_ch[scux_ch_count].ch_stat))
{
- /* check ch_stat whether going transfer */
- if ((SCUX_CH_UNINIT != gb_scux_info_drv.info_ch[scux_ch_count].ch_stat) &&
- (SCUX_CH_INIT != gb_scux_info_drv.info_ch[scux_ch_count].ch_stat) &&
- (SCUX_CH_STOP != gb_scux_info_drv.info_ch[scux_ch_count].ch_stat))
- {
- /* The exclusive access control (interrupt disabled) starts */
+ /* The exclusive access control (interrupt disabled) starts */
#if defined (__ICCARM__)
- was_masked = __disable_irq_iar();
+ was_masked = __disable_irq_iar();
#else
- was_masked = __disable_irq();
+ was_masked = __disable_irq();
#endif
- /* This exclusive access control ends in the SCUX_IoctlClearStop */
- /* call the __enable_irq in the SCUX_IoctlClearStop */
- ercd = SCUX_IoctlClearStop(scux_ch_count, was_masked);
- if (ESUCCESS != ercd)
- {
- /* NON_NOTICE_ASSERT: SCUX stop failed */
- }
-
- ercd = R_DMA_Free(gb_scux_info_drv.info_ch[scux_ch_count].dma_tx_ch, NULL);
- if (ESUCCESS != ercd)
- {
- /* NON_NOTICE_ASSERT: DMA release failed */
- }
+ /* This exclusive access control ends in the SCUX_IoctlClearStop */
+ /* call the __enable_irq in the SCUX_IoctlClearStop */
+ ercd = SCUX_IoctlClearStop(scux_ch_count, was_masked);
+ if (ESUCCESS != ercd)
+ {
+ /* NON_NOTICE_ASSERT: SCUX stop failed */
+ }
+
+ ercd = R_DMA_Free(gb_scux_info_drv.info_ch[scux_ch_count].dma_tx_ch, NULL);
+ if (ESUCCESS != ercd)
+ {
+ /* NON_NOTICE_ASSERT: DMA release failed */
}
}
}
-#if(1) /* mbed */
-#else /* not mbed */
- /* software reset */
- SCUX.SWRSR_CIM &= ~SWRSR_CIM_SWRST_SET;
-
- for (scux_ch_count = 0; scux_ch_count < SCUX_CH_NUM; scux_ch_count++)
-#endif /* end mbed */
+ if (false != gb_scux_info_drv.info_ch[scux_ch_count].enabled)
{
- if (false != gb_scux_info_drv.info_ch[scux_ch_count].enabled)
+ if (gb_scux_info_drv.info_ch[scux_ch_count].ch_stat == SCUX_CH_UNINIT)
{
- if (gb_scux_info_drv.info_ch[scux_ch_count].ch_stat == SCUX_CH_UNINIT)
- {
- /* NON_NOTICE_ASSERT: abnormal status */
- }
-
- /* uninit each resouces */
- gb_scux_info_drv.info_ch[scux_ch_count].ch_stat = SCUX_CH_UNINIT;
-
-#if(1) /* mbed */
- if (NULL != gb_scux_info_drv.info_ch[scux_ch_count].sem_ch_scux_access)
- {
- /* delete each semaphore */
- sem_ercd = osSemaphoreRelease(gb_scux_info_drv.info_ch[scux_ch_count].sem_ch_scux_access);
- /* semaphore error check */
- if (osOK != sem_ercd)
- {
- /* NON_NOTICE_ASSERT: semaphore error */
- }
-
- sem_ercd = osSemaphoreDelete(gb_scux_info_drv.info_ch[scux_ch_count].sem_ch_scux_access);
- /* semaphore error check */
- if (osOK != sem_ercd)
- {
- /* NON_NOTICE_ASSERT: semaphore error */
- }
-
- gb_scux_info_drv.info_ch[scux_ch_count].sem_ch_scux_access = NULL;
- }
-#else /* not mbed */
+ /* NON_NOTICE_ASSERT: abnormal status */
+ }
+
+ /* uninit each resouces */
+ gb_scux_info_drv.info_ch[scux_ch_count].ch_stat = SCUX_CH_UNINIT;
+
+ if (NULL != gb_scux_info_drv.info_ch[scux_ch_count].sem_ch_scux_access)
+ {
/* delete each semaphore */
sem_ercd = osSemaphoreRelease(gb_scux_info_drv.info_ch[scux_ch_count].sem_ch_scux_access);
/* semaphore error check */
@@ -958,26 +788,24 @@
{
/* NON_NOTICE_ASSERT: semaphore error */
}
-
+
sem_ercd = osSemaphoreDelete(gb_scux_info_drv.info_ch[scux_ch_count].sem_ch_scux_access);
/* semaphore error check */
if (osOK != sem_ercd)
{
/* NON_NOTICE_ASSERT: semaphore error */
}
-
+
gb_scux_info_drv.info_ch[scux_ch_count].sem_ch_scux_access = NULL;
-#endif /* end mbed */
-
- /* delete queue */
- ahf_cancelall(&gb_scux_info_drv.info_ch[scux_ch_count].tx_que);
- ahf_destroy(&gb_scux_info_drv.info_ch[scux_ch_count].tx_que);
- ahf_cancelall(&gb_scux_info_drv.info_ch[scux_ch_count].rx_que);
- ahf_destroy(&gb_scux_info_drv.info_ch[scux_ch_count].rx_que);
}
+
+ /* delete queue */
+ ahf_cancelall(&gb_scux_info_drv.info_ch[scux_ch_count].tx_que);
+ ahf_destroy(&gb_scux_info_drv.info_ch[scux_ch_count].tx_que);
+ ahf_cancelall(&gb_scux_info_drv.info_ch[scux_ch_count].rx_que);
+ ahf_destroy(&gb_scux_info_drv.info_ch[scux_ch_count].rx_que);
}
-#if(1) /* mbed */
was_masked = __disable_irq();
gb_scux_info_drv.info_ch[scux_ch_count].enabled = false;
@@ -1034,7 +862,419 @@
gb_scux_info_drv.drv_stat = SCUX_DRV_UNINIT;
}
-#else /* not mbed */
+}
+
+/******************************************************************************
+End of function SCUX_UnInitializeOne
+******************************************************************************/
+#endif /* end mbed */
+
+/**************************************************************************//**
+* Function Name: SCUX_Initialize
+* @brief Init SCUX driver.
+*
+* Description:<br>
+*
+* @param[in] p_scux_init_param :Initialize parameter for SCUX.
+* @retval ESUCCESS -
+* Operation successful.
+* EERROR -
+* Error occured.
+* error code -
+* ENOMEM : Making semaphore is failed.
+* EFAULT : Internal error is occured.
+******************************************************************************/
+int_t SCUX_Initialize(const scux_channel_cfg_t * const p_scux_init_param)
+{
+ int_t retval = ESUCCESS;
+ osStatus sem_ercd;
+ int_t scux_ch_count;
+ int_t audio_ch_count;
+ scux_ssif_ch_num_t ssif_ch_count;
+ uint32_t cpg_value;
+ bool_t init_shared_flag = false;
+ int_t was_masked;
+ volatile uint8_t dummy_buf;
+
+ if (NULL == p_scux_init_param)
+ {
+ retval = EFAULT;
+ }
+ else
+ {
+ /* init channel management information */
+ for (scux_ch_count = 0; scux_ch_count < SCUX_CH_NUM; scux_ch_count++)
+ {
+ if (false == p_scux_init_param[scux_ch_count].enabled)
+ {
+ /* set disable parameter */
+ gb_scux_info_drv.info_ch[scux_ch_count].enabled = false;
+ gb_scux_info_drv.info_ch[scux_ch_count].ch_stat = SCUX_CH_UNINIT;
+ }
+ else
+ {
+ gb_scux_info_drv.info_ch[scux_ch_count].enabled = true;
+
+ /* copy parameter */
+ /* set interrupt parameter */
+ gb_scux_info_drv.info_ch[scux_ch_count].int_level = p_scux_init_param[scux_ch_count].int_level;
+
+ /* set route parameter */
+ gb_scux_info_drv.info_ch[scux_ch_count].route_set = p_scux_init_param[scux_ch_count].route;
+
+ /* set SRC paramter */
+ SCUX_IoctlSetSrcCfg(scux_ch_count, &p_scux_init_param[scux_ch_count].src_cfg);
+
+ /* init SCUX parameter */
+ if ((SCUX_CH_0 == scux_ch_count) || (SCUX_CH_1 == scux_ch_count))
+ {
+ gb_scux_info_drv.info_ch[scux_ch_count].fifo_size = SCUX_FIFO_SIZE_CH0_1;
+ }
+ else
+ {
+ gb_scux_info_drv.info_ch[scux_ch_count].fifo_size = SCUX_FIFO_SIZE_CH2_3;
+ }
+ gb_scux_info_drv.info_ch[scux_ch_count].dma_resource_tx = gb_dma_res_select_tx[scux_ch_count];
+ gb_scux_info_drv.info_ch[scux_ch_count].dma_resource_rx = gb_dma_res_select_rx[scux_ch_count];
+ gb_scux_info_drv.info_ch[scux_ch_count].futsel_cim_value = FUTSEL_CIM_INIT_VALUE;
+ gb_scux_info_drv.info_ch[scux_ch_count].err_stat_backup = ESUCCESS;
+
+ /* init DVU parameter */
+ for (audio_ch_count = SCUX_AUDIO_CH_0; audio_ch_count < SCUX_AUDIO_CH_MAX; audio_ch_count++)
+ {
+ gb_scux_info_drv.info_ch[scux_ch_count].dvu_cfg.dvu_zc_mute.zc_mute_enable[audio_ch_count] = false;
+ }
+ gb_scux_info_drv.info_ch[scux_ch_count].dvu_setup = false;
+
+ if (false == init_shared_flag)
+ {
+ /* init MIX parameter */
+ gb_scux_info_drv.shared_info.mix_setup = false;
+ gb_scux_info_drv.shared_info.mix_run_ch = 0U;
+ gb_scux_info_drv.shared_info.mix_ssif_ch = 0U;
+
+ /* init SSIF parameter */
+ for (ssif_ch_count = SCUX_SSIF_CH_0; ssif_ch_count < SCUX_SSIF_CH_NUM; ssif_ch_count++)
+ {
+ gb_scux_ssif_info[ssif_ch_count].ssif_setup = false;
+ gb_scux_ssif_info[ssif_ch_count].ssif_cfg.ssif_ch_num = ssif_ch_count;
+ gb_scux_ssif_info[ssif_ch_count].scux_channel = 0;
+ gb_scux_ssif_info[ssif_ch_count].pin_mode = SCUX_PIN_MODE_INDEPEND;
+ }
+
+ /* init regsiter store value */
+ gb_scux_info_drv.shared_info.ssictrl_cim_value = SSICTRL_CIM_INIT_VALUE;
+ }
+
+ /* set register address */
+ gb_scux_info_drv.info_ch[scux_ch_count].p_scux_reg = &p_scux_ch_reg_addr_table[scux_ch_count];
+
+ if (false == init_shared_flag) {
+#if defined (__ICCARM__)
+ was_masked = __disable_irq_iar();
+#else
+ was_masked = __disable_irq();
+#endif
+
+ /* supply clock for SCUX */
+ cpg_value = (uint32_t)CPG.STBCR8 & ~(CPG_STBCR8_BIT_MSTP81);
+ CPG.STBCR8 = (uint8_t)cpg_value;
+ dummy_buf = CPG.STBCR8;
+
+ if (0 == was_masked)
+ {
+ __enable_irq();
+ }
+
+ /* software reset */
+ SCUX.SWRSR_CIM &= ~SWRSR_CIM_SWRST_SET;
+ SCUX.SWRSR_CIM |= SWRSR_CIM_SWRST_SET;
+ }
+
+ /* init DVU register */
+ gb_scux_info_drv.info_ch[scux_ch_count].p_scux_reg->p_dvu_reg->DVUIR_DVU0_0 = DVUIR_DVU0_INIT_VALUE;
+ gb_scux_info_drv.info_ch[scux_ch_count].p_scux_reg->p_dvu_reg->VADIR_DVU0_0 = VADIR_DVU0_INIT_VALUE;
+ gb_scux_info_drv.info_ch[scux_ch_count].p_scux_reg->p_dvu_reg->DVUBR_DVU0_0 = DVUBR_DVU0_INIT_VALUE;
+ gb_scux_info_drv.info_ch[scux_ch_count].p_scux_reg->p_dvu_reg->DVUCR_DVU0_0 = DVUCR_DVU0_INIT_VALUE;
+ gb_scux_info_drv.info_ch[scux_ch_count].p_scux_reg->p_dvu_reg->ZCMCR_DVU0_0 = ZCMCR_DVU0_INIT_VALUE;
+ gb_scux_info_drv.info_ch[scux_ch_count].p_scux_reg->p_dvu_reg->VRCTR_DVU0_0 = VRCTR_DVU0_INIT_VALUE;
+ gb_scux_info_drv.info_ch[scux_ch_count].p_scux_reg->p_dvu_reg->VRPDR_DVU0_0 = VRPDR_DVU0_INIT_VALUE;
+ gb_scux_info_drv.info_ch[scux_ch_count].p_scux_reg->p_dvu_reg->VRDBR_DVU0_0 = VRDBR_DVU0_INIT_VALUE;
+ gb_scux_info_drv.info_ch[scux_ch_count].p_scux_reg->p_dvu_reg->VRWTR_DVU0_0 = VRWTR_DVU0_INIT_VALUE;
+ gb_scux_info_drv.info_ch[scux_ch_count].p_scux_reg->p_dvu_reg->VOL0R_DVU0_0 = VOL_N_R_DVU0_INIT_VALUE;
+ gb_scux_info_drv.info_ch[scux_ch_count].p_scux_reg->p_dvu_reg->VOL1R_DVU0_0 = VOL_N_R_DVU0_INIT_VALUE;
+ gb_scux_info_drv.info_ch[scux_ch_count].p_scux_reg->p_dvu_reg->VOL2R_DVU0_0 = VOL_N_R_DVU0_INIT_VALUE;
+ gb_scux_info_drv.info_ch[scux_ch_count].p_scux_reg->p_dvu_reg->VOL3R_DVU0_0 = VOL_N_R_DVU0_INIT_VALUE;
+ gb_scux_info_drv.info_ch[scux_ch_count].p_scux_reg->p_dvu_reg->VOL4R_DVU0_0 = VOL_N_R_DVU0_INIT_VALUE;
+ gb_scux_info_drv.info_ch[scux_ch_count].p_scux_reg->p_dvu_reg->VOL5R_DVU0_0 = VOL_N_R_DVU0_INIT_VALUE;
+ gb_scux_info_drv.info_ch[scux_ch_count].p_scux_reg->p_dvu_reg->VOL6R_DVU0_0 = VOL_N_R_DVU0_INIT_VALUE;
+ gb_scux_info_drv.info_ch[scux_ch_count].p_scux_reg->p_dvu_reg->VOL7R_DVU0_0 = VOL_N_R_DVU0_INIT_VALUE;
+ gb_scux_info_drv.info_ch[scux_ch_count].p_scux_reg->p_dvu_reg->DVUER_DVU0_0 = DVUER_DVU0_INIT_VALUE;
+ gb_scux_info_drv.info_ch[scux_ch_count].p_scux_reg->p_dvu_reg->VEVMR_DVU0_0 = VEVMR_DVU0_INIT_VALUE;
+ gb_scux_info_drv.info_ch[scux_ch_count].p_scux_reg->p_dvu_reg->VEVCR_DVU0_0 = VEVCR_DVU0_INIT_VALUE;
+
+ /* init SRC register */
+ gb_scux_info_drv.info_ch[scux_ch_count].p_scux_reg->p_src_reg->SRCIR0_2SRC0_0 = SRCIR_2SRC0_INIT_VALUE;
+ gb_scux_info_drv.info_ch[scux_ch_count].p_scux_reg->p_src_reg->SADIR0_2SRC0_0 = SADIR_2SRC0_INIT_VALUE;
+ gb_scux_info_drv.info_ch[scux_ch_count].p_scux_reg->p_src_reg->SRCBR0_2SRC0_0 = SRCBR_2SRC0_INIT_VALUE;
+ gb_scux_info_drv.info_ch[scux_ch_count].p_scux_reg->p_src_reg->IFSCR0_2SRC0_0 = IFSCR_2SRC0_INIT_VALUE;
+ gb_scux_info_drv.info_ch[scux_ch_count].p_scux_reg->p_src_reg->IFSVR0_2SRC0_0 = IFSVR_2SRC0_INIT_VALUE;
+ gb_scux_info_drv.info_ch[scux_ch_count].p_scux_reg->p_src_reg->SRCCR0_2SRC0_0 = (SRCCR_2SRC0_INIT_VALUE | SRCCR_2SRC0_BASE_VALUE);
+ gb_scux_info_drv.info_ch[scux_ch_count].p_scux_reg->p_src_reg->MNFSR0_2SRC0_0 = MNFSR_2SRC0_INIT_VALUE;
+ gb_scux_info_drv.info_ch[scux_ch_count].p_scux_reg->p_src_reg->BFSSR0_2SRC0_0 = BFSSR_2SRC0_INIT_VALUE;
+ gb_scux_info_drv.info_ch[scux_ch_count].p_scux_reg->p_src_reg->WATSR0_2SRC0_0 = WATSR_2SRC0_INIT_VALUE;
+ gb_scux_info_drv.info_ch[scux_ch_count].p_scux_reg->p_src_reg->SEVMR0_2SRC0_0 = SEVMR_2SRC0_INIT_VALUE;
+ gb_scux_info_drv.info_ch[scux_ch_count].p_scux_reg->p_src_reg->SEVCR0_2SRC0_0 = SEVCR_2SRC0_INIT_VALUE;
+ gb_scux_info_drv.info_ch[scux_ch_count].p_scux_reg->p_src_reg->SRCIR1_2SRC0_0 = SRCIR_2SRC0_INIT_VALUE;
+ gb_scux_info_drv.info_ch[scux_ch_count].p_scux_reg->p_src_reg->SADIR1_2SRC0_0 = SADIR_2SRC0_INIT_VALUE;
+ gb_scux_info_drv.info_ch[scux_ch_count].p_scux_reg->p_src_reg->SRCBR1_2SRC0_0 = SRCBR_2SRC0_INIT_VALUE;
+ gb_scux_info_drv.info_ch[scux_ch_count].p_scux_reg->p_src_reg->IFSCR1_2SRC0_0 = IFSCR_2SRC0_INIT_VALUE;
+ gb_scux_info_drv.info_ch[scux_ch_count].p_scux_reg->p_src_reg->IFSVR1_2SRC0_0 = IFSVR_2SRC0_INIT_VALUE;
+ gb_scux_info_drv.info_ch[scux_ch_count].p_scux_reg->p_src_reg->SRCCR1_2SRC0_0 = (SRCCR_2SRC0_INIT_VALUE | SRCCR_2SRC0_BASE_VALUE);
+ gb_scux_info_drv.info_ch[scux_ch_count].p_scux_reg->p_src_reg->MNFSR1_2SRC0_0 = MNFSR_2SRC0_INIT_VALUE;
+ gb_scux_info_drv.info_ch[scux_ch_count].p_scux_reg->p_src_reg->BFSSR1_2SRC0_0 = BFSSR_2SRC0_INIT_VALUE;
+ gb_scux_info_drv.info_ch[scux_ch_count].p_scux_reg->p_src_reg->WATSR1_2SRC0_0 = WATSR_2SRC0_INIT_VALUE;
+ gb_scux_info_drv.info_ch[scux_ch_count].p_scux_reg->p_src_reg->SEVMR1_2SRC0_0 = SEVMR_2SRC0_INIT_VALUE;
+ gb_scux_info_drv.info_ch[scux_ch_count].p_scux_reg->p_src_reg->SEVCR1_2SRC0_0 = SEVCR_2SRC0_INIT_VALUE;
+ gb_scux_info_drv.info_ch[scux_ch_count].p_scux_reg->p_src_reg->SEVCR1_2SRC0_0 = SRCIR_2SRC0_INIT_VALUE;
+ gb_scux_info_drv.info_ch[scux_ch_count].p_scux_reg->p_src_reg->SRCIRR_2SRC0_0 = SRCIRR_2SRC0_INIT_VALUE;
+
+ /* init FFU register */
+ gb_scux_info_drv.info_ch[scux_ch_count].p_scux_reg->p_ffu_reg->FFUIR_FFU0_0 = FFUIR_FFU0_INIT_VALUE;
+ gb_scux_info_drv.info_ch[scux_ch_count].p_scux_reg->p_ffu_reg->FUAIR_FFU0_0 = FUAIR_FFU0_INIT_VALUE;
+ gb_scux_info_drv.info_ch[scux_ch_count].p_scux_reg->p_ffu_reg->URQSR_FFU0_0 = URQSR_FFU0_INIT_VALUE;
+ gb_scux_info_drv.info_ch[scux_ch_count].p_scux_reg->p_ffu_reg->FFUPR_FFU0_0 = FFUPR_FFU0_INIT_VALUE;
+ gb_scux_info_drv.info_ch[scux_ch_count].p_scux_reg->p_ffu_reg->UEVMR_FFU0_0 = UEVMR_FFU0_INIT_VALUE;
+ gb_scux_info_drv.info_ch[scux_ch_count].p_scux_reg->p_ffu_reg->UEVCR_FFU0_0 = UEVCR_FFU0_INIT_VALUE;
+
+ /* init FFD register */
+ gb_scux_info_drv.info_ch[scux_ch_count].p_scux_reg->p_ffd_reg->FFDIR_FFD0_0 = FFDIR_FFD0_INIT_VALUE;
+ gb_scux_info_drv.info_ch[scux_ch_count].p_scux_reg->p_ffd_reg->FDAIR_FFD0_0 = FDAIR_FFD0_INIT_VALUE;
+ gb_scux_info_drv.info_ch[scux_ch_count].p_scux_reg->p_ffd_reg->DRQSR_FFD0_0 = DRQSR_FFD0_INIT_VALUE;
+ gb_scux_info_drv.info_ch[scux_ch_count].p_scux_reg->p_ffd_reg->FFDPR_FFD0_0 = FFDPR_FFD0_INIT_VALUE;
+ gb_scux_info_drv.info_ch[scux_ch_count].p_scux_reg->p_ffd_reg->FFDBR_FFD0_0 = FFDBR_FFD0_INIT_VALUE;
+ gb_scux_info_drv.info_ch[scux_ch_count].p_scux_reg->p_ffd_reg->DEVMR_FFD0_0 = DEVMR_FFD0_INIT_VALUE;
+ gb_scux_info_drv.info_ch[scux_ch_count].p_scux_reg->p_ffd_reg->DEVCR_FFD0_0 = DEVCR_FFD0_INIT_VALUE;
+
+ /* init OPC register */
+ gb_scux_info_drv.info_ch[scux_ch_count].p_scux_reg->p_opc_reg->OPCIR_OPC0_0 = OPCIR_OPC0_INIT_VALUE;
+ gb_scux_info_drv.info_ch[scux_ch_count].p_scux_reg->p_opc_reg->OPSLR_OPC0_0 = OPSLR_OPC0_INIT_VALUE;
+
+ /* init IPC register */
+ gb_scux_info_drv.info_ch[scux_ch_count].p_scux_reg->p_ipc_reg->IPCIR_IPC0_0 = IPCIR_IPC0_INIT_VALUE;
+ gb_scux_info_drv.info_ch[scux_ch_count].p_scux_reg->p_ipc_reg->IPSLR_IPC0_0 = IPSLR_IPC0_INIT_VALUE;
+
+ /* init MIX register for each channel */
+ *(gb_scux_info_drv.info_ch[scux_ch_count].p_scux_reg->mdb_n_r_mix0_0) = MDB_N_R_MIX0_0_INIT_VALUE;
+
+ /* init CIM register for each channel */
+ *(gb_scux_info_drv.info_ch[scux_ch_count].p_scux_reg->fdtsel_n_cim) = FDTSEL_CIM_INIT_VALUE;
+ *(gb_scux_info_drv.info_ch[scux_ch_count].p_scux_reg->futsel_n_cim) = FUTSEL_CIM_INIT_VALUE;
+ *(gb_scux_info_drv.info_ch[scux_ch_count].p_scux_reg->srcrsel_n_cim) = SRCRSEL_CIM_INIT_VALUE;
+
+ /* init shared register */
+ if (false == init_shared_flag)
+ {
+ *(gb_scux_info_drv.info_ch[scux_ch_count].p_scux_reg->mixir_mix0_0) = MIXIR_MIX0_0_INIT_VALUE;
+ *(gb_scux_info_drv.info_ch[scux_ch_count].p_scux_reg->madir_mix0_0) = MADIR_MIX0_0_INIT_VALUE;
+ *(gb_scux_info_drv.info_ch[scux_ch_count].p_scux_reg->mixbr_mix0_0) = MIXBR_MIX0_0_INIT_VALUE;
+ *(gb_scux_info_drv.info_ch[scux_ch_count].p_scux_reg->mixmr_mix0_0) = MIXMR_MIX0_0_INIT_VALUE;
+ *(gb_scux_info_drv.info_ch[scux_ch_count].p_scux_reg->mvpdr_mix0_0) = MVPDR_MIX0_0_INIT_VALUE;
+ *(gb_scux_info_drv.info_ch[scux_ch_count].p_scux_reg->mdber_mix0_0) = MDBER_MIX0_0_INIT_VALUE;
+ *(gb_scux_info_drv.info_ch[scux_ch_count].p_scux_reg->dmacr_cim) = DMACR_CIM_INIT_VALUE;
+ *(gb_scux_info_drv.info_ch[scux_ch_count].p_scux_reg->ssirsel_cim) = SSIRSEL_CIM_INIT_VALUE;
+ *(gb_scux_info_drv.info_ch[scux_ch_count].p_scux_reg->ssipmd_cim) = SSIPMD_CIM_INIT_VALUE;
+ *(gb_scux_info_drv.info_ch[scux_ch_count].p_scux_reg->ssictrl_cim) = SSICTRL_CIM_INIT_VALUE;
+ *(gb_scux_info_drv.info_ch[scux_ch_count].p_scux_reg->mixrsel_cim) = MIXRSEL_CIM_INIT_VALUE;
+ }
+
+ if (false == init_shared_flag)
+ {
+ /* set SSIF register */
+ for (ssif_ch_count = SCUX_SSIF_CH_0; ssif_ch_count < SCUX_SSIF_CH_NUM; ssif_ch_count++)
+ {
+ gb_scux_ssif_info[ssif_ch_count].p_scux_ssif_reg = p_scux_ssif_ch_reg_addr[ssif_ch_count];
+ }
+ }
+
+ /* set semaphore parameter */
+ gb_scux_info_drv.info_ch[scux_ch_count].sem_ch_scux_access = osSemaphoreCreate(p_semdef_ch_scux_access[scux_ch_count], 1);
+ if (NULL == gb_scux_info_drv.info_ch[scux_ch_count].sem_ch_scux_access)
+ {
+ retval = ENOMEM;
+ }
+ if ((ESUCCESS == retval) && (false == init_shared_flag))
+ {
+ for (ssif_ch_count = SCUX_SSIF_CH_0; ((ssif_ch_count < SCUX_SSIF_CH_NUM) && (ESUCCESS == retval)); ssif_ch_count++)
+ {
+ gb_scux_ssif_info[ssif_ch_count].sem_ch_scux_ssif_access = osSemaphoreCreate(p_semdef_ch_scux_ssif_access[ssif_ch_count], 1);
+ if (NULL == gb_scux_ssif_info[ssif_ch_count].sem_ch_scux_ssif_access)
+ {
+ retval = ENOMEM;
+ }
+ }
+ }
+ if ((ESUCCESS == retval) && (false == init_shared_flag))
+ {
+ gb_scux_info_drv.shared_info.sem_shared_access = osSemaphoreCreate(osSemaphore(scux_shared_access), 1);
+ if (NULL == gb_scux_info_drv.shared_info.sem_shared_access)
+ {
+ retval = ENOMEM;
+ }
+ }
+
+ if (false == init_shared_flag)
+ {
+ init_shared_flag = true;
+ }
+
+ gb_scux_info_drv.info_ch[scux_ch_count].ch_stat = SCUX_CH_INIT;
+ }
+ }
+ }
+
+ if (ESUCCESS != retval)
+ {
+ for (scux_ch_count = SCUX_SSIF_CH_0; scux_ch_count < SCUX_CH_NUM; scux_ch_count++)
+ {
+ if (false != gb_scux_info_drv.info_ch[scux_ch_count].enabled)
+ {
+ /* semaphore delete */
+ sem_ercd = osSemaphoreDelete(gb_scux_info_drv.info_ch[scux_ch_count].sem_ch_scux_access);
+ /* semaphore error check */
+ if (osOK != sem_ercd)
+ {
+ /* set error return value */
+ retval = EFAULT;
+ }
+
+ gb_scux_info_drv.info_ch[scux_ch_count].enabled = false;
+ gb_scux_info_drv.info_ch[scux_ch_count].ch_stat = SCUX_CH_UNINIT;
+ }
+ }
+
+ for (ssif_ch_count = SCUX_SSIF_CH_0; ssif_ch_count < SCUX_SSIF_CH_NUM; ssif_ch_count++)
+ {
+ sem_ercd = osSemaphoreDelete(gb_scux_ssif_info[ssif_ch_count].sem_ch_scux_ssif_access);
+ /* semaphore error check */
+ if (osOK != sem_ercd)
+ {
+ /* set error return value */
+ retval = EFAULT;
+ }
+ }
+
+ sem_ercd = osSemaphoreDelete(gb_scux_info_drv.shared_info.sem_shared_access);
+ /* semaphore error check */
+ if (osOK != sem_ercd)
+ {
+ /* set error return value */
+ retval = EFAULT;
+ }
+
+ gb_scux_info_drv.drv_stat = SCUX_DRV_UNINIT;
+ }
+ else
+ {
+ gb_scux_info_drv.drv_stat = SCUX_DRV_INIT;
+ }
+
+ return retval;
+}
+
+/******************************************************************************
+End of function SCUX_Initialize
+******************************************************************************/
+
+/**************************************************************************//**
+* Function Name: SCUX_UnInitialize
+* @brief Uninit SCUX driver.
+*
+* Description:<br>
+*
+* @param[in] None.
+* @retval None.
+******************************************************************************/
+void SCUX_UnInitialize(void)
+{
+ osStatus sem_ercd;
+ int_t ercd;
+ int_t scux_ch_count;
+ int_t ssif_ch_count;
+ uint32_t cpg_value;
+ int_t was_masked;
+
+ for (scux_ch_count = 0; scux_ch_count < SCUX_CH_NUM; scux_ch_count++)
+ {
+ if (false != gb_scux_info_drv.info_ch[scux_ch_count].enabled)
+ {
+ /* check ch_stat whether going transfer */
+ if ((SCUX_CH_UNINIT != gb_scux_info_drv.info_ch[scux_ch_count].ch_stat) &&
+ (SCUX_CH_INIT != gb_scux_info_drv.info_ch[scux_ch_count].ch_stat) &&
+ (SCUX_CH_STOP != gb_scux_info_drv.info_ch[scux_ch_count].ch_stat))
+ {
+#if defined (__ICCARM__)
+ was_masked = __disable_irq_iar();
+#else
+ was_masked = __disable_irq();
+#endif
+
+ /* This exclusive access control ends in the SCUX_IoctlClearStop */
+ ercd = SCUX_IoctlClearStop(scux_ch_count, was_masked);
+ if (ESUCCESS != ercd)
+ {
+ /* NON_NOTICE_ASSERT: SCUX stop failed */
+ }
+
+ ercd = R_DMA_Free(gb_scux_info_drv.info_ch[scux_ch_count].dma_tx_ch, NULL);
+ if (ESUCCESS != ercd)
+ {
+ /* NON_NOTICE_ASSERT: DMA release failed */
+ }
+ }
+ }
+ }
+
+ /* software reset */
+ SCUX.SWRSR_CIM &= ~SWRSR_CIM_SWRST_SET;
+
+ for (scux_ch_count = 0; scux_ch_count < SCUX_CH_NUM; scux_ch_count++)
+ {
+ if (false != gb_scux_info_drv.info_ch[scux_ch_count].enabled)
+ {
+ if (gb_scux_info_drv.info_ch[scux_ch_count].ch_stat == SCUX_CH_UNINIT)
+ {
+ /* NON_NOTICE_ASSERT: abnormal status */
+ }
+
+ /* uninit each resouces */
+ gb_scux_info_drv.info_ch[scux_ch_count].ch_stat = SCUX_CH_UNINIT;
+
+ /* delete each semaphore */
+ sem_ercd = osSemaphoreRelease(gb_scux_info_drv.info_ch[scux_ch_count].sem_ch_scux_access);
+ /* semaphore error check */
+ if (osOK != sem_ercd)
+ {
+ /* NON_NOTICE_ASSERT: semaphore error */
+ }
+
+ sem_ercd = osSemaphoreDelete(gb_scux_info_drv.info_ch[scux_ch_count].sem_ch_scux_access);
+ /* semaphore error check */
+ if (osOK != sem_ercd)
+ {
+ /* NON_NOTICE_ASSERT: semaphore error */
+ }
+
+ gb_scux_info_drv.info_ch[scux_ch_count].sem_ch_scux_access = NULL;
+
+ /* delete queue */
+ ahf_cancelall(&gb_scux_info_drv.info_ch[scux_ch_count].tx_que);
+ ahf_destroy(&gb_scux_info_drv.info_ch[scux_ch_count].tx_que);
+ ahf_cancelall(&gb_scux_info_drv.info_ch[scux_ch_count].rx_que);
+ ahf_destroy(&gb_scux_info_drv.info_ch[scux_ch_count].rx_que);
+ }
+ }
+
for (ssif_ch_count = 0; ssif_ch_count < SCUX_SSIF_CH_NUM; ssif_ch_count++)
{
sem_ercd = osSemaphoreRelease(gb_scux_ssif_info[ssif_ch_count].sem_ch_scux_ssif_access);
@@ -1087,18 +1327,11 @@
}
gb_scux_info_drv.drv_stat = SCUX_DRV_UNINIT;
-#endif /* end mbed */
}
-#if(1) /* mbed */
-/******************************************************************************
-End of function SCUX_UnInitializeOne
-******************************************************************************/
-#else /* not mbed */
/******************************************************************************
End of function SCUX_UnInitialize
******************************************************************************/
-#endif /* end mbed */
/**************************************************************************//**
* Function Name: SCUX_OpenChannel
@@ -2517,7 +2750,6 @@
/******************************************************************************
End of function SCUX_StrNLen
******************************************************************************/
-
#if(1) /* mbed */
/**************************************************************************//**
* Function Name: SCUX_CmnUnInitialize
--- a/RenesasBSP/drv_src/scux/scux.h Fri Oct 02 03:03:25 2015 +0000 +++ b/RenesasBSP/drv_src/scux/scux.h Wed Dec 16 06:33:17 2015 +0000 @@ -722,10 +722,9 @@ #if(1) /* mbed */ int_t SCUX_InitializeOne(const int_t channel, const scux_channel_cfg_t * const p_scux_init_param); void SCUX_UnInitializeOne(const int_t channel); -#else /* not mbed */ +#endif /* end mbed */ int_t SCUX_Initialize(const scux_channel_cfg_t * const p_scux_init_param); void SCUX_UnInitialize(void); -#endif /* end mbed */ int_t SCUX_OpenChannel(const int_t channel, const int_t flags); int_t SCUX_CloseChannel(const int_t channel); int_t SCUX_IoctlTransStart(const int_t channel);
--- a/RenesasBSP/drv_src/scux/scux_if.c Fri Oct 02 03:03:25 2015 +0000
+++ b/RenesasBSP/drv_src/scux/scux_if.c Wed Dec 16 06:33:17 2015 +0000
@@ -71,7 +71,9 @@
Function prototypes
*****************************************************************************/
#if(1) /* mbed */
-#else /* not mbed */
+static void *R_SCUX_InitOne(const int_t channel, const void * const p_config_data, int32_t * const p_errno);
+static int_t R_SCUX_UnInitOne(const int_t channel, const void* const p_driver_instance, int32_t * const p_errno);
+#endif /* end mbed */
static void* R_SCUX_Init(void * p_config_data, int32_t * const p_errno);
static int_t R_SCUX_UnInit(void *p_driver_instance, int32_t * const p_errno);
static int_t R_SCUX_Open(void * const p_driver_instance, const char_t * p_path_name, const int_t flags, int_t mode, int32_t * const p_errno);
@@ -80,7 +82,6 @@
static int_t R_SCUX_WriteAsync(void * const p_fd, AIOCB * const p_aio, int32_t * const p_errno);
static int_t R_SCUX_ReadAsync(void * const p_fd, AIOCB * const p_aio, int32_t * const p_errno);
static int_t R_SCUX_Cancel(void * const p_fd, AIOCB * const p_aio, int32_t * const p_errno);
-#endif /* end mbed */
static void SCUX_SetErrCode(const int_t error_code, int32_t * const p_errno);
/******************************************************************************
@@ -88,7 +89,36 @@
******************************************************************************/
#if(1) /* mbed */
-#else /* not mbed */
+/**************************************************************************//**
+* Function Name: R_SCUX_MakeCbTbl_mbed
+* @brief Returns the SCUX driver callback function table.
+*
+* Description:<br>
+*
+* @param none
+* @retval pointer of sample driver callback table
+******************************************************************************/
+/* ->IPA M1.1.1 If this function is the whole system, it will be called. */
+RBSP_MBED_FNS* R_SCUX_MakeCbTbl_mbed(void)
+/* <-IPA M1.1.1 */
+{
+ static RBSP_MBED_FNS scux_apitbl_mbed;
+
+ scux_apitbl_mbed.initialise_one = &R_SCUX_InitOne;
+ scux_apitbl_mbed.uninitialise_one = &R_SCUX_UnInitOne;
+ scux_apitbl_mbed.open = &R_SCUX_Open;
+ scux_apitbl_mbed.close = &R_SCUX_Close;
+ scux_apitbl_mbed.ioctl = &R_SCUX_Ioctl;
+ scux_apitbl_mbed.write_a = &R_SCUX_WriteAsync;
+ scux_apitbl_mbed.read_a = &R_SCUX_ReadAsync;
+
+ return &scux_apitbl_mbed;
+}
+/******************************************************************************
+End of function R_SCUX_MakeCbTbl_mbed
+******************************************************************************/
+#else
+
/**************************************************************************//**
* Function Name: R_SCUX_MakeCbTbl
* @brief Returns the SCUX driver callback function table.
@@ -102,6 +132,7 @@
IOIF_DRV_API* R_SCUX_MakeCbTbl(void)
/* <-IPA M1.1.1 */
{
+ static IOIF_DRV_API gb_ioif_scux_cb_table;
IOIF_DRV_API* const p_api = &gb_ioif_scux_cb_table;
/* ->MISRA 16.4, IPA M4.5.1 This description is based on the way to fill out OS defined. */
@@ -172,7 +203,141 @@
* EERROR -
* Error occured.
******************************************************************************/
-#else /* not mbed */
+static void *R_SCUX_InitOne(const int_t channel, const void * const p_config_data, int32_t * const p_errno)
+{
+ int_t ercd;
+ void *ret;
+ scux_info_drv_t * const p_info_drv = SCUX_GetDrvInstance();
+ scux_info_ch_t * p_info_ch;
+
+ if (NULL == p_info_drv)
+ {
+ ercd = EFAULT;
+ }
+ else if ((SCUX_CH_0 > channel) || ( SCUX_CH_NUM <= channel))
+ {
+ ercd = EFAULT;
+ }
+ else
+ {
+ p_info_ch = SCUX_GetDrvChInfo(channel);
+
+ if (NULL == p_info_ch)
+ {
+ ercd = EFAULT;
+ }
+ else if (false != p_info_ch->enabled)
+ {
+ ercd = EBUSY;
+ }
+ else
+ {
+ if (NULL == p_config_data)
+ {
+ /* set error return value */
+ ercd = EFAULT;
+ }
+ else
+ {
+ /* init SCUX driver */
+ ercd = SCUX_InitializeOne(channel, (const scux_channel_cfg_t *)p_config_data);
+ }
+ }
+ }
+
+ if (ESUCCESS == ercd)
+ {
+ ret = (void *)p_info_drv;
+ }
+ else
+ {
+ ret = (void *)(EERROR);
+ }
+
+ SCUX_SetErrCode(ercd, p_errno);
+
+ return ret;
+}
+/******************************************************************************
+End of function R_SCUX_InitOne
+******************************************************************************/
+
+/**************************************************************************//**
+* Function Name: R_SCUX_UnInitOne
+* @brief Uninit SCUX driver.
+*
+* Description:<br>
+*
+* @param[in] channel :Uninitialize channel number.
+* @param[in] p_driver_instance :which was returned by R_SCUX_Init
+* @param[in,out] p_errno :pointer of error code
+* error code -
+* EBADF : Driver status isn't SCUX_DRV_INIT.
+* @retval ESUCCESS -
+* Operation successful.
+* EERROR -
+* Error occured.
+******************************************************************************/
+/* ->MISRA 16.7 'p_driver_instance' is based on the way to fill out OS defined. */
+/* ->IPA M1.11.1 */
+static int_t R_SCUX_UnInitOne(const int_t channel, const void* const p_driver_instance, int32_t * const p_errno)
+/* <-IPA M1.11.1 */
+/* <-MISRA 16.7 */
+{
+ int_t retval = ESUCCESS;
+ int_t ercd = ESUCCESS;
+ scux_info_drv_t * const p_info_drv = SCUX_GetDrvInstance();
+ scux_info_ch_t * p_info_ch;
+
+ UNUSED_ARG(p_driver_instance);
+
+ if (NULL == p_info_drv)
+ {
+ ercd = EFAULT;
+ }
+ else if ((SCUX_CH_0 > channel) || ( SCUX_CH_NUM <= channel))
+ {
+ ercd = EFAULT;
+ }
+ else
+ {
+ if (SCUX_DRV_INIT != p_info_drv->drv_stat)
+ {
+ ercd = EBADF;
+ }
+ else
+ {
+ p_info_ch = SCUX_GetDrvChInfo(channel);
+
+ if (NULL == p_info_ch)
+ {
+ ercd = EFAULT;
+ }
+ else if (false == p_info_ch->enabled)
+ {
+ ercd = EBADF;
+ }
+ else
+ {
+ SCUX_UnInitializeOne(channel);
+ }
+ }
+ }
+
+ if (ESUCCESS != ercd)
+ {
+ retval = EERROR;
+ }
+ SCUX_SetErrCode(ercd, p_errno);
+
+ return retval;
+}
+
+/******************************************************************************
+End of function R_SCUX_UnInitOne
+******************************************************************************/
+#endif /* end mbed */
+
/**************************************************************************//**
* Function Name: R_SCUX_Init
* @brief Init SCUX driver.
@@ -191,53 +356,26 @@
* EERROR -
* Error occured.
******************************************************************************/
-#endif /* end mbed */
/* ->MISRA 16.7 'p_config_data' is based on the way to fill out OS defined. */
/* ->IPA M1.11.1 */
-#if(1) /* mbed */
-void *R_SCUX_InitOne(const int_t channel, const void * const p_config_data, int32_t * const p_errno)
-#else /* not mbed */
static void *R_SCUX_Init(void * p_config_data, int32_t * const p_errno)
-#endif /* end mbed */
/* <-IPA M1.11.1 */
/* <-MISRA 16.7 */
{
int_t ercd;
void *ret;
scux_info_drv_t * const p_info_drv = SCUX_GetDrvInstance();
-#if(1) /* mbed */
- scux_info_ch_t * p_info_ch;
-#endif /* end mbed */
if (NULL == p_info_drv)
{
ercd = EFAULT;
}
-#if(1) /* mbed */
- else if ((SCUX_CH_0 > channel) || ( SCUX_CH_NUM <= channel))
- {
- ercd = EFAULT;
- }
-#endif /* end mbed */
else
{
-#if(1) /* mbed */
- p_info_ch = SCUX_GetDrvChInfo(channel);
-
- if (NULL == p_info_ch)
- {
- ercd = EFAULT;
- }
- else if (false != p_info_ch->enabled)
- {
- ercd = EBUSY;
- }
-#else /* not mbed */
if (SCUX_DRV_UNINIT != p_info_drv->drv_stat)
{
ercd = EBUSY;
}
-#endif /* end mbed */
else
{
if (NULL == p_config_data)
@@ -248,11 +386,7 @@
else
{
/* init SCUX driver */
-#if(1) /* mbed */
- ercd = SCUX_InitializeOne(channel, (const scux_channel_cfg_t *)p_config_data);
-#else /* not mbed */
ercd = SCUX_Initialize((scux_channel_cfg_t *)p_config_data);
-#endif /* end mbed */
}
}
}
@@ -271,34 +405,10 @@
return ret;
}
-#if(1) /* mbed */
-/******************************************************************************
-End of function R_SCUX_InitOne
-******************************************************************************/
-#else /* not mbed */
/******************************************************************************
End of function R_SCUX_Init
******************************************************************************/
-#endif /* end mbed */
-#if(1) /* mbed */
-/**************************************************************************//**
-* Function Name: R_SCUX_UnInitOne
-* @brief Uninit SCUX driver.
-*
-* Description:<br>
-*
-* @param[in] channel :Uninitialize channel number.
-* @param[in] p_driver_instance :which was returned by R_SCUX_Init
-* @param[in,out] p_errno :pointer of error code
-* error code -
-* EBADF : Driver status isn't SCUX_DRV_INIT.
-* @retval ESUCCESS -
-* Operation successful.
-* EERROR -
-* Error occured.
-******************************************************************************/
-#else /* not mbed */
/**************************************************************************//**
* Function Name: R_SCUX_UnInit
* @brief Uninit SCUX driver.
@@ -314,23 +424,15 @@
* EERROR -
* Error occured.
******************************************************************************/
-#endif /* end mbed */
/* ->MISRA 16.7 'p_driver_instance' is based on the way to fill out OS defined. */
/* ->IPA M1.11.1 */
-#if(1) /* mbed */
-int_t R_SCUX_UnInitOne(const int_t channel, const void* const p_driver_instance, int32_t * const p_errno)
-#else /* not mbed */
static int_t R_SCUX_UnInit(void* p_driver_instance, int32_t * const p_errno)
-#endif /* end mbed */
/* <-IPA M1.11.1 */
/* <-MISRA 16.7 */
{
int_t retval = ESUCCESS;
int_t ercd = ESUCCESS;
scux_info_drv_t * const p_info_drv = SCUX_GetDrvInstance();
-#if(1) /* mbed */
- scux_info_ch_t * p_info_ch;
-#endif /* end mbed */
UNUSED_ARG(p_driver_instance);
@@ -338,12 +440,6 @@
{
ercd = EFAULT;
}
-#if(1) /* mbed */
- else if ((SCUX_CH_0 > channel) || ( SCUX_CH_NUM <= channel))
- {
- ercd = EFAULT;
- }
-#endif /* end mbed */
else
{
if (SCUX_DRV_INIT != p_info_drv->drv_stat)
@@ -352,24 +448,7 @@
}
else
{
-#if(1) /* mbed */
- p_info_ch = SCUX_GetDrvChInfo(channel);
-
- if (NULL == p_info_ch)
- {
- ercd = EFAULT;
- }
- else if (false == p_info_ch->enabled)
- {
- ercd = EBADF;
- }
- else
- {
- SCUX_UnInitializeOne(channel);
- }
-#else /* not mbed */
SCUX_UnInitialize();
-#endif /* end mbed */
}
}
@@ -382,15 +461,9 @@
return retval;
}
-#if(1) /* mbed */
-/******************************************************************************
-End of function R_SCUX_UnInitOne
-******************************************************************************/
-#else /* not mbed */
/******************************************************************************
End of function R_SCUX_UnInit
******************************************************************************/
-#endif /* end mbed */
/**************************************************************************//**
* Function Name: R_SCUX_Open
@@ -420,11 +493,7 @@
* Error occured.
******************************************************************************/
/* ->IPA M1.11.1 This description is based on the way to fill out OS defined. */
-#if(1) /* mbed */
-int_t R_SCUX_Open(void * const p_driver_instance, const char_t * const p_path_name, const int_t flags, const int_t mode, int32_t * const p_errno)
-#else /* not mbed */
static int_t R_SCUX_Open(void * const p_driver_instance, const char_t * p_path_name, const int_t flags, int_t mode , int32_t * const p_errno)
-#endif /* end mbed */
/* <-IPA M1.11.1 */
{
int_t ercd = ESUCCESS;
@@ -592,11 +661,7 @@
* EERROR -
* Error occured.
******************************************************************************/
-#if(1) /* mbed */
-int_t R_SCUX_Close(void * const p_fd, int32_t * const p_errno)
-#else /* not mbed */
static int_t R_SCUX_Close(void * const p_fd, int32_t * const p_errno)
-#endif /* end mbed */
{
int_t retval = ESUCCESS;
int_t ercd = ESUCCESS;
@@ -697,11 +762,7 @@
* EERROR -
* Error occured.
******************************************************************************/
-#if(1) /* mbed */
-int_t R_SCUX_Ioctl(void * const p_fd, const int_t request, void * const p_buf, int32_t * const p_errno)
-#else /* not mbed */
static int_t R_SCUX_Ioctl(void * const p_fd, const int_t request, void * const p_buf, int32_t * const p_errno)
-#endif /* end mbed */
{
int_t retval = ESUCCESS;
int_t ercd = ESUCCESS;
@@ -1351,11 +1412,7 @@
* EERROR -
* Error occured.
******************************************************************************/
-#if(1) /* mbed */
-int_t R_SCUX_WriteAsync(void * const p_fd, AIOCB * const p_aio, int32_t * const p_errno)
-#else /* not mbed */
static int_t R_SCUX_WriteAsync(void * const p_fd, AIOCB * const p_aio, int32_t * const p_errno)
-#endif /* end mbed */
{
int_t retval = ESUCCESS;
int_t ercd = ESUCCESS;
@@ -1512,11 +1569,7 @@
* EERROR -
* Error occured.
******************************************************************************/
-#if(1) /* mbed */
-int_t R_SCUX_ReadAsync(void * const p_fd, AIOCB * const p_aio, int32_t * const p_errno)
-#else /* not mbed */
static int_t R_SCUX_ReadAsync(void * const p_fd, AIOCB * const p_aio, int32_t * const p_errno)
-#endif /* end mbed */
{
int_t retval = ESUCCESS;
int_t ercd = ESUCCESS;
@@ -1684,11 +1737,7 @@
* EERROR -
* Error occured.
******************************************************************************/
-#if(1) /* mbed */
-int_t R_SCUX_Cancel(void * const p_fd, AIOCB * const p_aio, int32_t * const p_errno)
-#else /* not mbed */
static int_t R_SCUX_Cancel(void * const p_fd, AIOCB * const p_aio, int32_t * const p_errno)
-#endif /* end mbed */
{
int_t retval = ESUCCESS;
int_t ercd = ESUCCESS;
--- a/RenesasBSP/drv_src/ssif/ssif.c Fri Oct 02 03:03:25 2015 +0000
+++ b/RenesasBSP/drv_src/ssif/ssif.c Wed Dec 16 06:33:17 2015 +0000
@@ -86,17 +86,18 @@
Exported global functions (to be accessed by other files)
******************************************************************************/
+#if(1) /* mbed */
/******************************************************************************
-* Function Name: SSIF_Initialise
+* Function Name: SSIF_InitialiseOne
* @brief Initialize the SSIF driver's internal data
*
* Description:<br>
*
+* @param[in] channel :channel number
* @param[in] p_cfg_data :pointer of several parameters array per channels
* @retval ESUCCESS :Success.
* @retval error code :Failure.
******************************************************************************/
-#if(1) /* mbed */
int_t SSIF_InitialiseOne(const int_t channel, const ssif_channel_cfg_t* const p_cfg_data)
{
int_t ercd = ESUCCESS;
@@ -133,7 +134,41 @@
return ercd;
}
-#else
+/******************************************************************************
+* Function Name: SSIF_UnInitialiseOne
+* @brief UnInitialize the SSIF driver's internal data
+*
+* Description:<br>
+*
+* @param[in] channel :channel number
+* @retval ESUCCESS :Success.
+******************************************************************************/
+int_t SSIF_UnInitialiseOne(const int_t channel)
+{
+ const int_t ercd = ESUCCESS;
+ ssif_info_ch_t* p_info_ch;
+
+ p_info_ch = &g_ssif_info_drv.info_ch[channel];
+
+ if (false != p_info_ch->enabled)
+ {
+ SSIF_UnInitChannel(p_info_ch);
+ }
+
+ return ercd;
+}
+
+#endif /* end mbed */
+/******************************************************************************
+* Function Name: SSIF_Initialise
+* @brief Initialize the SSIF driver's internal data
+*
+* Description:<br>
+*
+* @param[in] p_cfg_data :pointer of several parameters array per channels
+* @retval ESUCCESS :Success.
+* @retval error code :Failure.
+******************************************************************************/
int_t SSIF_Initialise(const ssif_channel_cfg_t* const p_cfg_data)
{
uint32_t ssif_ch;
@@ -180,7 +215,6 @@
return ercd;
}
-#endif
/******************************************************************************
* Function Name: SSIF_UnInitialise
@@ -191,22 +225,6 @@
* @param none
* @retval ESUCCESS :Success.
******************************************************************************/
-#if(1) /* mbed */
-int_t SSIF_UnInitialiseOne(const int_t channel)
-{
- const int_t ercd = ESUCCESS;
- ssif_info_ch_t* p_info_ch;
-
- p_info_ch = &g_ssif_info_drv.info_ch[channel];
-
- if (false != p_info_ch->enabled)
- {
- SSIF_UnInitChannel(p_info_ch);
- }
-
- return ercd;
-}
-#else
int_t SSIF_UnInitialise(void)
{
uint32_t ssif_ch;
@@ -225,7 +243,6 @@
return ercd;
}
-#endif
/******************************************************************************
* Function Name: SSIF_EnableChannel
--- a/RenesasBSP/drv_src/ssif/ssif.h Fri Oct 02 03:03:25 2015 +0000 +++ b/RenesasBSP/drv_src/ssif/ssif.h Wed Dec 16 06:33:17 2015 +0000 @@ -238,10 +238,9 @@ #if(1) /* mbed */ int_t SSIF_InitialiseOne(const int_t channel, const ssif_channel_cfg_t* const p_cfg_data); int_t SSIF_UnInitialiseOne(const int_t channel); -#else +#endif /* end mbed */ int_t SSIF_Initialise(const ssif_channel_cfg_t* const p_cfg_data); int_t SSIF_UnInitialise(void); -#endif int_t SSIF_EnableChannel(ssif_info_ch_t* const p_info_ch); int_t SSIF_DisableChannel(ssif_info_ch_t* const p_info_ch); void SSIF_ErrorRecovery(ssif_info_ch_t* const p_info_ch);
--- a/RenesasBSP/drv_src/ssif/ssif_if.c Fri Oct 02 03:03:25 2015 +0000
+++ b/RenesasBSP/drv_src/ssif/ssif_if.c Wed Dec 16 06:33:17 2015 +0000
@@ -33,6 +33,7 @@
*******************************************************************************/
#include "cmsis_os.h"
#if(1) /* mbed */
+#include "r_bsp_cmn.h"
#else
#include "ioif_public.h"
#endif
@@ -59,7 +60,10 @@
#if(1) /* mbed */
static ssif_drv_stat_t ch_drv_stat[SSIF_NUM_CHANS] = {SSIF_DRVSTS_UNINIT};
-#else
+
+static void* R_SSIF_InitOne(const int_t channel, const void* const config_data, int32_t* const p_errno);
+static int_t R_SSIF_UnInitOne(const int_t channel, const void* const driver_instance, int32_t* const p_errno);
+#endif /* end mbed */
static void* R_SSIF_Init(void* const config_data, int32_t* const p_errno);
static int_t R_SSIF_UnInit(void* const driver_instance, int32_t* const p_errno);
static int_t R_SSIF_Open(void* const p_driver_instance, const char_t* const p_path_name, const int_t flags, const int_t mode, int32_t* const p_errno);
@@ -68,7 +72,6 @@
static int_t R_SSIF_WriteAsync(void* const p_fd, AIOCB* const p_aio, int32_t* const p_errno);
static int_t R_SSIF_ReadAsync(void* const p_fd, AIOCB* const p_aio, int32_t* const p_errno);
static int_t R_SSIF_Cancel(void* const p_fd, AIOCB* p_aio, int32_t* const p_errno);
-#endif
static size_t SSIF_StrnLen(const char_t p_str[], const size_t maxlen);
static int32_t SSIF_Strncmp(const char_t p_str1[], const char_t p_str2[], const uint32_t maxlen);
@@ -79,6 +82,31 @@
******************************************************************************/
#if(1) /* mbed */
+/******************************************************************************
+* Function Name: R_SSIF_MakeCbTbl_mbed
+* @brief Make the SSIF driver function callback table
+*
+* Description:<br>
+*
+* @param none
+* @retval pointer of SSIF driver function callback table
+******************************************************************************/
+/* ->IPA M1.1.1 : This is liblary funciotn that is called from other module. */
+RBSP_MBED_FNS* R_SSIF_MakeCbTbl_mbed(void)
+/* <-IPA M1.1.1 */
+{
+ static RBSP_MBED_FNS ssif_apitbl_mbed;
+
+ ssif_apitbl_mbed.initialise_one = &R_SSIF_InitOne;
+ ssif_apitbl_mbed.uninitialise_one = &R_SSIF_UnInitOne;
+ ssif_apitbl_mbed.open = &R_SSIF_Open;
+ ssif_apitbl_mbed.close = &R_SSIF_Close;
+ ssif_apitbl_mbed.ioctl = &R_SSIF_Ioctl;
+ ssif_apitbl_mbed.read_a = &R_SSIF_ReadAsync;
+ ssif_apitbl_mbed.write_a = &R_SSIF_WriteAsync;
+
+ return &ssif_apitbl_mbed;
+}
#else
/******************************************************************************
* Function Name: R_SSIF_MakeCbTbl
@@ -109,7 +137,7 @@
return &ssif_apitbl;
}
-#endif
+#endif /* end mbed */
/******************************************************************************
* Function Name: R_SSIF_SWLtoLen
@@ -129,20 +157,21 @@
Private functions
******************************************************************************/
+#if(1) /* mbed */
/******************************************************************************
-* Function Name: R_SSIF_Init
+* Function Name: R_SSIF_InitOne
* @brief Initialise the SSIF driver.
*
* Description:<br>
*
+* @param[in] channel :channel number
* @param[in] config_data :pointer of several parameters array per channels
* @param[in,out] p_errno :pointer of error code
* @retval not ERRROR :driver instance.
* @retval EERROR :Failure.
******************************************************************************/
/* ->MISRA 16.7, IPA M1.11.1 : This is IOIF library API type definitnon that can't be modified. */
-#if(1) /* mbed */
-void* R_SSIF_InitOne(const int_t channel, void* const config_data, int32_t* const p_errno)
+static void* R_SSIF_InitOne(const int_t channel, const void* const config_data, int32_t* const p_errno)
/* <-MISRA 16.7, IPA M1.11.1 */
{
int_t ercd;
@@ -158,9 +187,10 @@
}
else
{
+ g_ssif_info_drv.drv_stat = SSIF_DRVSTS_INIT;
ch_drv_stat[channel] = SSIF_DRVSTS_INIT;
- ercd = SSIF_InitialiseOne(channel, (ssif_channel_cfg_t*)config_data);
+ ercd = SSIF_InitialiseOne(channel, (const ssif_channel_cfg_t*)config_data);
if (ESUCCESS == ercd)
{
@@ -176,7 +206,69 @@
return p_ret;
}
-#else
+
+/******************************************************************************
+* Function Name: R_SSIF_UnInitOne
+* @brief Uninitialise the SSIF deiver.
+*
+* Description:<br>
+*
+* @param[in] channel :channel number
+* @param[in,out] driver_instance :driver instance which was returned by<br>
+ R_SSIF_Init
+* @param[in,out] p_errno :pointer of error code
+* @retval ESUCCESS :Success.
+* @retval EERROR :Failure.
+******************************************************************************/
+static int_t R_SSIF_UnInitOne(const int_t channel, const void* const driver_instance, int32_t* const p_errno)
+{
+ int_t ercd;
+ int_t ret = ESUCCESS;
+
+ if (NULL == driver_instance)
+ {
+ ercd = EFAULT;
+ }
+ else if (channel >= SSIF_NUM_CHANS)
+ {
+ ercd = EFAULT;
+ }
+ else
+ {
+ if (SSIF_DRVSTS_INIT != ch_drv_stat[channel])
+ {
+ ercd = EFAULT;
+ }
+ else
+ {
+ ercd = SSIF_UnInitialiseOne(channel);
+ ch_drv_stat[channel] = SSIF_DRVSTS_UNINIT;
+ }
+ }
+
+ if (ESUCCESS != ercd)
+ {
+ ret = EERROR;
+ }
+ SSIF_SetErrCode(ercd, p_errno);
+
+ return ret;
+}
+
+#endif /* end mbed */
+
+/******************************************************************************
+* Function Name: R_SSIF_Init
+* @brief Initialise the SSIF driver.
+*
+* Description:<br>
+*
+* @param[in] config_data :pointer of several parameters array per channels
+* @param[in,out] p_errno :pointer of error code
+* @retval not ERRROR :driver instance.
+* @retval EERROR :Failure.
+******************************************************************************/
+/* ->MISRA 16.7, IPA M1.11.1 : This is IOIF library API type definitnon that can't be modified. */
static void* R_SSIF_Init(void* const config_data, int32_t* const p_errno)
/* <-MISRA 16.7, IPA M1.11.1 */
{
@@ -211,7 +303,6 @@
return p_ret;
}
-#endif
/******************************************************************************
* Function Name: R_SSIF_UnInit
@@ -225,43 +316,6 @@
* @retval ESUCCESS :Success.
* @retval EERROR :Failure.
******************************************************************************/
-#if(1) /* mbed */
-int_t R_SSIF_UnInitOne(const int_t channel, void* const driver_instance, int32_t* const p_errno)
-{
- int_t ercd;
- int_t ret = ESUCCESS;
- ssif_info_drv_t* const p_info_drv = driver_instance;
-
- if (NULL == p_info_drv)
- {
- ercd = EFAULT;
- }
- else if (channel >= SSIF_NUM_CHANS)
- {
- ercd = EFAULT;
- }
- else
- {
- if (SSIF_DRVSTS_INIT != ch_drv_stat[channel])
- {
- ercd = EFAULT;
- }
- else
- {
- ercd = SSIF_UnInitialiseOne(channel);
- ch_drv_stat[channel] = SSIF_DRVSTS_UNINIT;
- }
- }
-
- if (ESUCCESS != ercd)
- {
- ret = EERROR;
- }
- SSIF_SetErrCode(ercd, p_errno);
-
- return ret;
-}
-#else
static int_t R_SSIF_UnInit(void* const driver_instance, int32_t* const p_errno)
{
int_t ercd;
@@ -293,7 +347,6 @@
return ret;
}
-#endif
/******************************************************************************
* Function Name: R_SSIF_Open
@@ -311,11 +364,7 @@
* @retval not EERROR :channel handle
* @retval EERROR :Failure.
******************************************************************************/
-#if(1) /* mbed */
-int_t R_SSIF_Open(void* const p_driver_instance, const char_t* const p_path_name, const int_t flags, const int_t mode, int32_t* const p_errno)
-#else
static int_t R_SSIF_Open(void* const p_driver_instance, const char_t* const p_path_name, const int_t flags, const int_t mode, int32_t* const p_errno)
-#endif
{
uint32_t ssif_ch;
void* p_channelHandle;
@@ -351,8 +400,6 @@
ercd = ENOENT;
}
-#if(1) /* mbed */
-#else
if (ESUCCESS == ercd)
{
if (SSIF_DRVSTS_INIT != p_info_drv->drv_stat)
@@ -360,7 +407,6 @@
ercd = EFAULT;
}
}
-#endif
if (ESUCCESS == ercd)
{
@@ -461,11 +507,7 @@
* @retval ESUCCESS :Success.
* @retval EERROR :Failure.
******************************************************************************/
-#if(1) /* mbed */
-int_t R_SSIF_Close(void* const p_fd, int32_t* const p_errno)
-#else
static int_t R_SSIF_Close(void* const p_fd, int32_t* const p_errno)
-#endif
{
ssif_info_ch_t* const p_info_ch = p_fd;
int_t ret = ESUCCESS;
@@ -538,11 +580,7 @@
* @retval ESUCCESS :Success.
* @retval EERROR :Failure.
******************************************************************************/
-#if(1) /* mbed */
-int_t R_SSIF_Ioctl(void* const p_fd, const int_t request, void* const p_buf, int32_t* const p_errno)
-#else
static int_t R_SSIF_Ioctl(void* const p_fd, const int_t request, void* const p_buf, int32_t* const p_errno)
-#endif
{
ssif_info_ch_t* const p_info_ch = p_fd;
int_t ret = ESUCCESS;
@@ -639,11 +677,7 @@
* @retval ESUCCESS :Success.
* @retval EERROR :Failure.
******************************************************************************/
-#if(1) /* mbed */
-int_t R_SSIF_WriteAsync(void* const p_fd, AIOCB* const p_aio, int32_t* const p_errno)
-#else
static int_t R_SSIF_WriteAsync(void* const p_fd, AIOCB* const p_aio, int32_t* const p_errno)
-#endif
{
ssif_info_ch_t* const p_info_ch = p_fd;
int_t ret = ESUCCESS;
@@ -691,11 +725,7 @@
* @retval ESUCCESS :Success.
* @retval EERROR :Failure.
******************************************************************************/
-#if(1) /* mbed */
-int_t R_SSIF_ReadAsync(void* const p_fd, AIOCB* const p_aio, int32_t* const p_errno)
-#else
static int_t R_SSIF_ReadAsync(void* const p_fd, AIOCB* const p_aio, int32_t* const p_errno)
-#endif
{
ssif_info_ch_t* const p_info_ch = p_fd;
int_t ret = ESUCCESS;
@@ -745,11 +775,7 @@
* @retval ESUCCESS :Success.
* @retval EERROR :Failure.
******************************************************************************/
-#if(1) /* mbed */
-int_t R_SSIF_Cancel(void* const p_fd, AIOCB* const p_aio, int32_t* const p_errno)
-#else
static int_t R_SSIF_Cancel(void* const p_fd, AIOCB* const p_aio, int32_t* const p_errno)
-#endif
{
ssif_info_ch_t* const p_info_ch = p_fd;
int_t ret = ESUCCESS;
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/api/R_BSP_Aio.h Wed Dec 16 06:33:17 2015 +0000
@@ -0,0 +1,137 @@
+/*******************************************************************************
+* DISCLAIMER
+* This software is supplied by Renesas Electronics Corporation and is only
+* intended for use with Renesas products. No other uses are authorized. This
+* software is owned by Renesas Electronics Corporation and is protected under
+* all applicable laws, including copyright laws.
+* THIS SOFTWARE IS PROVIDED "AS IS" AND RENESAS MAKES NO WARRANTIES REGARDING
+* THIS SOFTWARE, WHETHER EXPRESS, IMPLIED OR STATUTORY, INCLUDING BUT NOT
+* LIMITED TO WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE
+* AND NON-INFRINGEMENT. ALL SUCH WARRANTIES ARE EXPRESSLY DISCLAIMED.
+* TO THE MAXIMUM EXTENT PERMITTED NOT PROHIBITED BY LAW, NEITHER RENESAS
+* ELECTRONICS CORPORATION NOR ANY OF ITS AFFILIATED COMPANIES SHALL BE LIABLE
+* FOR ANY DIRECT, INDIRECT, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES FOR
+* ANY REASON RELATED TO THIS SOFTWARE, EVEN IF RENESAS OR ITS AFFILIATES HAVE
+* BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES.
+* Renesas reserves the right, without notice, to make changes to this software
+* and to discontinue the availability of this software. By using this software,
+* you agree to the additional terms and conditions found by accessing the
+* following link:
+* http://www.renesas.com/disclaimer*
+* Copyright (C) 2015 Renesas Electronics Corporation. All rights reserved.
+*******************************************************************************/
+/**************************************************************************//**
+* @file R_BSP_Aio.h
+* @brief R_BSP_Aio API
+******************************************************************************/
+
+#ifndef R_BSP_AIO_H
+#define R_BSP_AIO_H
+
+#include <stdint.h>
+#include "rtos.h"
+
+/** Callback function type
+ *
+ * @param p_data Location of the data.
+ * @param result Number of bytes transmit on success. negative number on error.
+ * @param p_app_data User definition data.
+ */
+typedef void (*rbsp_notify_func_t)(void * p_data, int32_t result, void * p_app_data);
+
+/** Asynchronous control block structure */
+typedef struct {
+ rbsp_notify_func_t p_notify_func; /**< Callback function type. */
+ void * p_app_data; /**< User definition data. */
+} rbsp_data_conf_t;
+
+/**
+ * A class to communicate a R_BSP_Aio
+ */
+class R_BSP_Aio {
+
+public:
+
+ /** Write count bytes to the file associated
+ *
+ * @param p_data Location of the data.
+ * @param data_size Number of bytes to write.
+ * @param p_data_conf Asynchronous control block structure.
+ * @return Number of bytes written on success. negative number on error.
+ */
+ int32_t write(void * const p_data, uint32_t data_size, const rbsp_data_conf_t * const p_data_conf = NULL);
+
+ /** Read count bytes to the file associated
+ *
+ * @param p_data Location of the data.
+ * @param data_size Number of bytes to read.
+ * @param p_data_conf Asynchronous control block structure.
+ * @return Number of bytes read on success. negative number on error.
+ */
+ int32_t read(void * const p_data, uint32_t data_size, const rbsp_data_conf_t * const p_data_conf = NULL);
+
+protected:
+
+ /** Constructor
+ *
+ */
+ R_BSP_Aio();
+
+ /** Destructor
+ *
+ */
+ virtual ~R_BSP_Aio();
+
+ /** Write init
+ *
+ * @param handle channel handle.
+ * @param p_func_a Pointer of write function.
+ * @param max_buff_num The upper limit of write buffer.
+ */
+ void write_init(void * handle, void * p_func_a, int32_t max_buff_num = 16) {
+ init(&write_ctl, handle, p_func_a, max_buff_num);
+ };
+
+ /** Read init
+ *
+ * @param handle channel handle.
+ * @param p_func_a Pointer of read function.
+ * @param max_buff_num The upper limit of read buffer.
+ */
+ void read_init(void * handle, void * p_func_a, int32_t max_buff_num = 16) {
+ init(&read_ctl, handle, p_func_a, max_buff_num);
+ };
+private:
+ typedef struct {
+ rbsp_notify_func_t p_cb_func;
+ void * p_cb_data;
+ Semaphore * p_sem;
+ void * p_aio;
+ } rbsp_sival_t;
+
+ typedef struct {
+ void * ch_handle;
+ void * p_async_func;
+ void * p_aio_top;
+ int32_t index;
+ rbsp_sival_t * p_sival_top;
+ Semaphore * p_sem_ctl;
+ int32_t MaxNum;
+ } rbsp_serial_ctl_t;
+
+ typedef struct {
+ Semaphore * p_sem;
+ int32_t result;
+ } rbsp_sync_t;
+
+ void init(rbsp_serial_ctl_t * p_ctl, void * handle, void * p_func_a, int32_t max_buff_num);
+ static int32_t sync_trans(rbsp_serial_ctl_t * p_ctl, void * const p_data, uint32_t data_size);
+ static void callback_sync_trans(void * p_data, int32_t result, void * p_app_data);
+ static int32_t aio_trans(rbsp_serial_ctl_t * const p_ctl, void * const p_data, uint32_t data_size,
+ const rbsp_data_conf_t * const p_data_conf);
+ static void callback_aio_trans(union sigval signo);
+
+ rbsp_serial_ctl_t write_ctl;
+ rbsp_serial_ctl_t read_ctl;
+};
+#endif
--- a/api/R_BSP_Scux.h Fri Oct 02 03:03:25 2015 +0000
+++ b/api/R_BSP_Scux.h Wed Dec 16 06:33:17 2015 +0000
@@ -143,8 +143,6 @@
bool GetReadStat(uint32_t * const p_read_stat);
private:
- void * instance;
- void * ch_handle;
int32_t scux_ch;
};
#endif /* R_BSP_SCUX_H */
--- a/api/R_BSP_SerialFamily.h Fri Oct 02 03:03:25 2015 +0000
+++ b/api/R_BSP_SerialFamily.h Wed Dec 16 06:33:17 2015 +0000
@@ -25,113 +25,49 @@
* @brief R_BSP_SerialFamily API
******************************************************************************/
-#ifndef R_BSP_SERIAL_H
-#define R_BSP_SERIAL_H
+#ifndef R_BSP_IOIF_H
+#define R_BSP_IOIF_H
#include <stdint.h>
+#include <stdarg.h>
+#include "R_BSP_Aio.h"
+#include "R_BSP_mbed_fns.h"
#include "rtos.h"
-/** Callback function type
- *
- * @param p_data Location of the data.
- * @param result Number of bytes transmit on success. negative number on error.
- * @param p_app_data User definition data.
- */
-typedef void (*rbsp_notify_func_t)(void * p_data, int32_t result, void * p_app_data);
-
-/** Asynchronous control block structure */
-typedef struct {
- rbsp_notify_func_t p_notify_func; /**< Callback function type. */
- void * p_app_data; /**< User definition data. */
-} rbsp_data_conf_t;
-
-/**
- * A class to communicate a R_BSP_SerialFamily
+/** A class to communicate a R_BSP_SerialFamily
+ *
*/
-class R_BSP_SerialFamily {
+class R_BSP_SerialFamily : public R_BSP_Aio {
public:
-
- /** Write count bytes to the file associated
+ /** Manipulates the underlying device parameters of special files
*
- * @param p_data Location of the data.
- * @param data_size Number of bytes to write.
- * @param p_data_conf Asynchronous control block structure.
- * @return Number of bytes written on success. negative number on error.
+ * @param request has encoded in it whether the argument is an "in" parameter or "out" parameter,
+ * and the size of the argument argp in bytes.
+ * @return true = success, false = failure
*/
- int32_t write(void * const p_data, uint32_t data_size, const rbsp_data_conf_t * const p_data_conf = NULL);
-
- /** Read count bytes to the file associated
- *
- * @param p_data Location of the data.
- * @param data_size Number of bytes to read.
- * @param p_data_conf Asynchronous control block structure.
- * @return Number of bytes read on success. negative number on error.
- */
- int32_t read(void * const p_data, uint32_t data_size, const rbsp_data_conf_t * const p_data_conf = NULL);
+ bool ioctl(int request, ...);
protected:
-
- /** Constructor
- *
- */
- R_BSP_SerialFamily();
-
/** Destructor
*
*/
virtual ~R_BSP_SerialFamily();
- /** Write init
+ /** Channel init
*
- * @param handle channel handle.
- * @param p_func_a Pointer of write function.
- * @param max_buff_num The upper limit of write buffer.
+ * @param function_list pointer of driver function callback table
+ * @param channel channel number
+ * @param config_data pointer of several parameters for a channel
+ * @param max_write_num The upper limit of write buffer
+ * @param max_read_num The upper limit of read buffer
*/
- void write_init(void * handle, void * p_func_a, int32_t max_buff_num = 16) {
- init(&write_ctl, handle, p_func_a, max_buff_num);
- };
+ bool init_channel(RBSP_MBED_FNS * function_list, int channel, void * const config_data, int32_t max_write_num = 16, int32_t max_read_num = 16);
- /** Read init
- *
- * @param handle channel handle.
- * @param p_func_a Pointer of read function.
- * @param max_buff_num The upper limit of read buffer.
- */
- void read_init(void * handle, void * p_func_a, int32_t max_buff_num = 16) {
- init(&read_ctl, handle, p_func_a, max_buff_num);
- };
private:
- typedef struct {
- rbsp_notify_func_t p_cb_func;
- void * p_cb_data;
- Semaphore * p_sem;
- void * p_aio;
- } rbsp_sival_t;
-
- typedef struct {
- void * ch_handle;
- void * p_async_func;
- void * p_aio_top;
- int32_t index;
- rbsp_sival_t * p_sival_top;
- Semaphore * p_sem_ctl;
- int32_t MaxNum;
- } rbsp_serial_ctl_t;
-
- typedef struct {
- Semaphore * p_sem;
- int32_t result;
- } rbsp_sync_t;
-
- void init(rbsp_serial_ctl_t * p_ctl, void * handle, void * p_func_a, int32_t max_buff_num);
- static int32_t sync_trans(rbsp_serial_ctl_t * p_ctl, void * const p_data, uint32_t data_size);
- static void callback_sync_trans(void * p_data, int32_t result, void * p_app_data);
- static int32_t aio_trans(rbsp_serial_ctl_t * const p_ctl, void * const p_data, uint32_t data_size,
- const rbsp_data_conf_t * const p_data_conf);
- static void callback_aio_trans(union sigval signo);
-
- rbsp_serial_ctl_t write_ctl;
- rbsp_serial_ctl_t read_ctl;
+ void * instance;
+ void * ch_handle;
+ int32_t ch_no;
+ RBSP_MBED_FNS * functions;
};
#endif
--- a/api/R_BSP_Ssif.h Fri Oct 02 03:03:25 2015 +0000
+++ b/api/R_BSP_Ssif.h Wed Dec 16 06:33:17 2015 +0000
@@ -81,8 +81,6 @@
bool GetStatus(uint32_t* const p_status);
private:
- void * instance;
- void * ch_handle;
ssif_channel_cfg_t ssif_cfg;
int32_t ssif_ch;
};
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/common/R_BSP_Aio.cpp Wed Dec 16 06:33:17 2015 +0000
@@ -0,0 +1,159 @@
+/*******************************************************************************
+* DISCLAIMER
+* This software is supplied by Renesas Electronics Corporation and is only
+* intended for use with Renesas products. No other uses are authorized. This
+* software is owned by Renesas Electronics Corporation and is protected under
+* all applicable laws, including copyright laws.
+* THIS SOFTWARE IS PROVIDED "AS IS" AND RENESAS MAKES NO WARRANTIES REGARDING
+* THIS SOFTWARE, WHETHER EXPRESS, IMPLIED OR STATUTORY, INCLUDING BUT NOT
+* LIMITED TO WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE
+* AND NON-INFRINGEMENT. ALL SUCH WARRANTIES ARE EXPRESSLY DISCLAIMED.
+* TO THE MAXIMUM EXTENT PERMITTED NOT PROHIBITED BY LAW, NEITHER RENESAS
+* ELECTRONICS CORPORATION NOR ANY OF ITS AFFILIATED COMPANIES SHALL BE LIABLE
+* FOR ANY DIRECT, INDIRECT, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES FOR
+* ANY REASON RELATED TO THIS SOFTWARE, EVEN IF RENESAS OR ITS AFFILIATES HAVE
+* BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES.
+* Renesas reserves the right, without notice, to make changes to this software
+* and to discontinue the availability of this software. By using this software,
+* you agree to the additional terms and conditions found by accessing the
+* following link:
+* http://www.renesas.com/disclaimer*
+* Copyright (C) 2015 Renesas Electronics Corporation. All rights reserved.
+*******************************************************************************/
+
+#include "cmsis_os.h"
+#include "r_typedefs.h"
+#include "r_errno.h"
+#include "misratypes.h"
+#include "aioif.h"
+#include "R_BSP_Aio.h"
+
+typedef int32_t (*rbsp_read_write_a_func_t)(void* const p_fd, AIOCB* const p_aio, int32_t* const p_errno);
+
+R_BSP_Aio::R_BSP_Aio() {
+}
+
+R_BSP_Aio::~R_BSP_Aio() {
+ if (write_ctl.MaxNum != 0) {
+ delete [] (rbsp_sival_t *)write_ctl.p_sival_top;
+ delete [] (AIOCB *)write_ctl.p_aio_top;
+ delete write_ctl.p_sem_ctl;
+ }
+ if (read_ctl.MaxNum != 0) {
+ delete [] (rbsp_sival_t *)read_ctl.p_sival_top;
+ delete [] (AIOCB *)read_ctl.p_aio_top;
+ delete read_ctl.p_sem_ctl;
+ }
+}
+
+void R_BSP_Aio::init(rbsp_serial_ctl_t * p_ctl, void * handle, void * p_func_a, int32_t max_buff_num) {
+ if (handle != NULL) {
+ p_ctl->ch_handle = handle;
+ p_ctl->MaxNum = max_buff_num;
+ p_ctl->p_aio_top = NULL;
+ p_ctl->index = 0;
+ p_ctl->p_async_func = p_func_a;
+ if (p_ctl->MaxNum != 0) {
+ p_ctl->p_sem_ctl = new Semaphore(p_ctl->MaxNum);
+ p_ctl->p_aio_top = new AIOCB[p_ctl->MaxNum];
+ p_ctl->p_sival_top = new rbsp_sival_t[p_ctl->MaxNum];
+ }
+ }
+}
+
+int32_t R_BSP_Aio::write(void * const p_data, uint32_t data_size, const rbsp_data_conf_t * const p_data_conf) {
+ if (p_data_conf == NULL) {
+ return sync_trans(&write_ctl, p_data, data_size);
+ } else {
+ return aio_trans(&write_ctl, p_data, data_size, p_data_conf);
+ }
+}
+
+int32_t R_BSP_Aio::read(void * const p_data, uint32_t data_size, const rbsp_data_conf_t * const p_data_conf) {
+ if (p_data_conf == NULL) {
+ return sync_trans(&read_ctl, p_data, data_size);
+ } else {
+ return aio_trans(&read_ctl, p_data, data_size, p_data_conf);
+ }
+}
+
+/* static */ int32_t R_BSP_Aio::sync_trans(rbsp_serial_ctl_t * p_ctl, void * const p_data, uint32_t data_size) {
+ rbsp_sync_t sync_info;
+ rbsp_data_conf_t data_conf;
+ Semaphore * p_sem_wait = new Semaphore(0);
+
+ sync_info.result = -1;
+ if (p_sem_wait != NULL) {
+ sync_info.p_sem = p_sem_wait;
+
+ data_conf.p_notify_func = &callback_sync_trans;
+ data_conf.p_app_data = &sync_info;
+
+ if (aio_trans(p_ctl, p_data, data_size, &data_conf) == ESUCCESS) {
+ p_sem_wait->wait(osWaitForever);
+ }
+ delete p_sem_wait;
+ }
+
+ return sync_info.result;
+}
+
+/* static */ void R_BSP_Aio::callback_sync_trans(void * p_data, int32_t result, void * p_app_data) {
+ rbsp_sync_t * p_sync_info = (rbsp_sync_t *)p_app_data;
+
+ p_sync_info->result = result;
+ p_sync_info->p_sem->release();
+}
+
+/* static */ int32_t R_BSP_Aio::aio_trans(rbsp_serial_ctl_t * const p_ctl,
+ void * const p_data, uint32_t data_size, const rbsp_data_conf_t * const p_data_conf) {
+ int32_t wk_errno;
+ AIOCB * p_rbsp_aio;
+ rbsp_sival_t * p_sival;
+ rbsp_read_write_a_func_t p_func = (rbsp_read_write_a_func_t)p_ctl->p_async_func;
+
+ if ((p_data_conf == NULL) || (p_data == NULL)) {
+ wk_errno = ENOSPC;
+ } else if (p_ctl->p_sem_ctl->wait(osWaitForever) == -1) {
+ wk_errno = EIO;
+ } else {
+ p_rbsp_aio = (AIOCB *)p_ctl->p_aio_top + p_ctl->index;
+ p_sival = p_ctl->p_sival_top + p_ctl->index;
+
+ p_sival->p_cb_func = p_data_conf->p_notify_func;
+ p_sival->p_cb_data = p_data_conf->p_app_data;
+ p_sival->p_sem = p_ctl->p_sem_ctl;
+ p_sival->p_aio = p_rbsp_aio;
+
+ p_rbsp_aio->aio_fildes = 0;
+ p_rbsp_aio->aio_buf = p_data;
+ p_rbsp_aio->aio_nbytes = data_size;
+ p_rbsp_aio->aio_offset = 0;
+ p_rbsp_aio->aio_sigevent.sigev_notify = SIGEV_THREAD;
+ p_rbsp_aio->aio_sigevent.sigev_value.sival_ptr = (void*)p_sival;
+ p_rbsp_aio->aio_sigevent.sigev_notify_function = &callback_aio_trans;
+ p_func(p_ctl->ch_handle, p_rbsp_aio, &wk_errno);
+
+ if (wk_errno == ESUCCESS) {
+ if ((p_ctl->index + 1) >= p_ctl->MaxNum) {
+ p_ctl->index = 0;
+ } else {
+ p_ctl->index++;
+ }
+ } else {
+ p_ctl->p_sem_ctl->release();
+ }
+ }
+
+ return wk_errno;
+}
+
+/* static */ void R_BSP_Aio::callback_aio_trans(union sigval signo) {
+ rbsp_sival_t * p_sival = (rbsp_sival_t *)signo.sival_ptr;
+ AIOCB * p_aio_result = (AIOCB *)p_sival->p_aio;
+
+ if ((p_sival->p_cb_func != NULL) && (p_aio_result != NULL)) {
+ p_sival->p_cb_func((void *)p_aio_result->aio_buf, p_aio_result->aio_return, p_sival->p_cb_data);
+ }
+ p_sival->p_sem->release();
+}
--- a/common/R_BSP_Scux.cpp Fri Oct 02 03:03:25 2015 +0000
+++ b/common/R_BSP_Scux.cpp Wed Dec 16 06:33:17 2015 +0000
@@ -29,12 +29,6 @@
#define INT_LEVEL_MAX (0xF7) /* The maximum value of the interrupt level */
#define REQ_BUFF_NUM_MIN (1) /* The minimum value of the request buffer */
#define REQ_BUFF_NUM_MAX (128) /* The maximum value of the request buffer */
-#define PATH_NAME_LENGTH (3) /* Path name length */
-#define PATH_TOP_PART (0) /* Path top part */
-#define CH_ID_PART (1) /* Channel identifier part */
-#define TERM_CHAR_PART (2) /* Termination character part */
-#define PATH_SEPARATOR ('\\') /* Path separator */
-#define CHARACTER_0 (0x30) /* character 0 */
#define INPUT_DIV_INIT_VALUE (1000U) /* The initial value of input divide ratio */
#define OUTPUT_DIV_INIT_VALUE (0U) /* The initial value of output divide ratio */
#define INPUT_WS_INIT_VALUE (1U) /* The initial value of input WS frequency */
@@ -57,9 +51,7 @@
R_BSP_Scux::R_BSP_Scux(scux_ch_num_t channel, uint8_t int_level, int32_t max_write_num, int32_t max_read_num) {
scux_channel_cfg_t scux_cfg;
int32_t result;
- int32_t wk_errno;
bool init_result;
- char_t path_name[PATH_NAME_LENGTH];
if (channel >= SCUX_CH_NUM) {
result = EERROR;
@@ -97,22 +89,9 @@
}
init_result = set_src_init_cfg(&scux_cfg.src_cfg);
- if (init_result == true) {
- instance = R_SCUX_InitOne(scux_ch, &scux_cfg, &wk_errno);
- if ((int32_t)instance != EERROR) {
- path_name[PATH_TOP_PART] = PATH_SEPARATOR;
- path_name[CH_ID_PART] = CHARACTER_0 + scux_ch;
- path_name[TERM_CHAR_PART] = '\0';
-
- ch_handle = (void *)R_SCUX_Open(instance, path_name, O_RDWR, 0, &wk_errno);
- if ((int32_t)ch_handle != EERROR) {
- write_init(ch_handle, (void *)&R_SCUX_WriteAsync, max_write_num);
- read_init(ch_handle, (void *)&R_SCUX_ReadAsync, max_read_num);
- } else {
- (void)R_SCUX_UnInitOne(scux_ch, instance, NULL);
- result = EERROR;
- }
- } else {
+ if (init_result != false) {
+ init_result = init_channel(R_SCUX_MakeCbTbl_mbed(), (int32_t)channel, &scux_cfg, max_write_num, max_read_num);
+ if (init_result == false) {
result = EERROR;
}
} else {
@@ -122,80 +101,32 @@
}
if (result != ESUCCESS) {
- instance = NULL;
- ch_handle = NULL;
scux_ch = CH_ERR_NUM;
}
}
R_BSP_Scux::~R_BSP_Scux(void) {
- if (ch_handle != NULL) {
- (void)R_SCUX_Close(ch_handle, NULL);
- }
-
- if ((scux_ch != CH_ERR_NUM) && (instance != NULL)) {
- (void)R_SCUX_UnInitOne(scux_ch, instance, NULL);
- }
}
bool R_BSP_Scux::TransStart(void) {
- int32_t result;
- bool ret = true;
-
- if (ch_handle == NULL) {
- ret = false;
- } else {
- result = R_SCUX_Ioctl(ch_handle, SCUX_IOCTL_SET_START, NULL, NULL);
- if (result != ESUCCESS) {
- ret = false;
- }
- }
-
- return ret;
+ return ioctl(SCUX_IOCTL_SET_START, NULL);
}
bool R_BSP_Scux::FlushStop(void (* const callback)(int32_t)) {
- int32_t result;
- bool ret = true;
-
- if (ch_handle == NULL) {
- ret = false;
- } else if (callback == NULL) {
- ret = false;
- } else {
- result = R_SCUX_Ioctl(ch_handle, SCUX_IOCTL_SET_FLUSH_STOP, (void *)callback, NULL);
- if (result != ESUCCESS) {
- ret = false;
- }
- }
-
- return ret;
+ return ioctl(SCUX_IOCTL_SET_FLUSH_STOP, (void *)callback);
}
bool R_BSP_Scux::ClearStop(void) {
- int32_t result;
- bool ret = true;
-
- if (ch_handle == NULL) {
- ret = false;
- } else {
- result = R_SCUX_Ioctl(ch_handle, SCUX_IOCTL_SET_CLEAR_STOP, NULL, NULL);
- if (result != ESUCCESS) {
- ret = false;
- }
- }
-
- return ret;
+ return ioctl(SCUX_IOCTL_SET_CLEAR_STOP, NULL);
}
bool R_BSP_Scux::SetSrcCfg(const scux_src_usr_cfg_t * const p_src_param) {
scux_src_cfg_t src_cfg;
- int32_t result;
bool init_result;
bool ret = true;
int32_t i;
- if (ch_handle == NULL) {
+ if (scux_ch == CH_ERR_NUM) {
ret = false;
} else if (p_src_param == NULL) {
ret = false;
@@ -360,10 +291,7 @@
}
if (ret == true) {
- result = R_SCUX_Ioctl(ch_handle, SCUX_IOCTL_SET_SRC_CFG, (void *)&src_cfg, NULL);
- if (result != ESUCCESS) {
- ret = false;
- }
+ ret = ioctl(SCUX_IOCTL_SET_SRC_CFG, (void *)&src_cfg);
}
}
}
@@ -372,39 +300,11 @@
}
bool R_BSP_Scux::GetWriteStat(uint32_t * const p_write_stat) {
- int32_t result;
- bool ret = true;
-
- if (ch_handle == NULL) {
- ret = false;
- } else if (p_write_stat == NULL) {
- ret = false;
- } else {
- result = R_SCUX_Ioctl(ch_handle, SCUX_IOCTL_GET_WRITE_STAT, (void *)p_write_stat, NULL);
- if (result != ESUCCESS) {
- ret = false;
- }
- }
-
- return ret;
+ return ioctl(SCUX_IOCTL_GET_WRITE_STAT, (void *)p_write_stat);
}
bool R_BSP_Scux::GetReadStat(uint32_t * const p_read_stat) {
- int32_t result;
- bool ret = true;
-
- if (ch_handle == NULL) {
- ret = false;
- } else if (p_read_stat == NULL) {
- ret = false;
- } else {
- result = R_SCUX_Ioctl(ch_handle, SCUX_IOCTL_GET_READ_STAT, (void *)p_read_stat, NULL);
- if (result != ESUCCESS) {
- ret = false;
- }
- }
-
- return ret;
+ return ioctl(SCUX_IOCTL_GET_READ_STAT, (void *)p_read_stat);
}
/**************************************************************************//**
--- a/common/R_BSP_SerialFamily.cpp Fri Oct 02 03:03:25 2015 +0000
+++ b/common/R_BSP_SerialFamily.cpp Wed Dec 16 06:33:17 2015 +0000
@@ -21,139 +21,91 @@
* Copyright (C) 2015 Renesas Electronics Corporation. All rights reserved.
*******************************************************************************/
-#include "cmsis_os.h"
-#include "r_typedefs.h"
-#include "r_errno.h"
-#include "misratypes.h"
-#include "aioif.h"
+#include "r_bsp_cmn.h"
#include "R_BSP_SerialFamily.h"
-
-typedef int32_t (*rbsp_read_write_a_func_t)(void* const p_fd, AIOCB* const p_aio, int32_t* const p_errno);
+#include "posix_types.h"
+#include "r_errno.h"
-R_BSP_SerialFamily::R_BSP_SerialFamily() {
-}
+#define PATH_NAME_LENGTH (3) /* Path name length */
+#define PATH_TOP_PART (0) /* Path top part */
+#define CH_ID_PART (1) /* Channel identifier part */
+#define TERM_CHAR_PART (2) /* Termination character part */
+#define PATH_SEPARATOR ('\\') /* Path separator */
+#define CHARACTER_0 (0x30) /* character 0 */
R_BSP_SerialFamily::~R_BSP_SerialFamily() {
- if (write_ctl.MaxNum != 0) {
- delete [] (rbsp_sival_t *)write_ctl.p_sival_top;
- delete [] (AIOCB *)write_ctl.p_aio_top;
- delete write_ctl.p_sem_ctl;
- }
- if (read_ctl.MaxNum != 0) {
- delete [] (rbsp_sival_t *)read_ctl.p_sival_top;
- delete [] (AIOCB *)read_ctl.p_aio_top;
- delete read_ctl.p_sem_ctl;
- }
-}
-
-void R_BSP_SerialFamily::init(rbsp_serial_ctl_t * p_ctl, void * handle, void * p_func_a, int32_t max_buff_num) {
- if (handle != NULL) {
- p_ctl->ch_handle = handle;
- p_ctl->MaxNum = max_buff_num;
- p_ctl->p_aio_top = NULL;
- p_ctl->index = 0;
- p_ctl->p_async_func = p_func_a;
- if (p_ctl->MaxNum != 0) {
- p_ctl->p_sem_ctl = new Semaphore(p_ctl->MaxNum);
- p_ctl->p_aio_top = new AIOCB[p_ctl->MaxNum];
- p_ctl->p_sival_top = new rbsp_sival_t[p_ctl->MaxNum];
+ if (functions != NULL) {
+ if ((ch_handle != NULL) && (functions->close != NULL)) {
+ (void)functions->close(ch_handle, NULL);
+ }
+ if ((ch_no != -1) && (instance != NULL) && (functions->uninitialise_one != NULL)) {
+ (void)functions->uninitialise_one(ch_no, instance, NULL);
}
}
}
-int32_t R_BSP_SerialFamily::write(void * const p_data, uint32_t data_size, const rbsp_data_conf_t * const p_data_conf) {
- if (p_data_conf == NULL) {
- return sync_trans(&write_ctl, p_data, data_size);
- } else {
- return aio_trans(&write_ctl, p_data, data_size, p_data_conf);
- }
-}
-
-int32_t R_BSP_SerialFamily::read(void * const p_data, uint32_t data_size, const rbsp_data_conf_t * const p_data_conf) {
- if (p_data_conf == NULL) {
- return sync_trans(&read_ctl, p_data, data_size);
- } else {
- return aio_trans(&read_ctl, p_data, data_size, p_data_conf);
- }
-}
+bool R_BSP_SerialFamily::init_channel(RBSP_MBED_FNS * function_list, int channel, void * const config_data,
+ int32_t max_write_num, int32_t max_read_num) {
+ bool ret = false;
+ int32_t wk_errno;
+ char_t path_name[PATH_NAME_LENGTH];
-/* static */ int32_t R_BSP_SerialFamily::sync_trans(rbsp_serial_ctl_t * p_ctl, void * const p_data, uint32_t data_size) {
- rbsp_sync_t sync_info;
- rbsp_data_conf_t data_conf;
- Semaphore * p_sem_wait = new Semaphore(0);
-
- sync_info.result = -1;
- if (p_sem_wait != NULL) {
- sync_info.p_sem = p_sem_wait;
-
- data_conf.p_notify_func = &callback_sync_trans;
- data_conf.p_app_data = &sync_info;
-
- if (aio_trans(p_ctl, p_data, data_size, &data_conf) == ESUCCESS) {
- p_sem_wait->wait(osWaitForever);
- }
- delete p_sem_wait;
- }
-
- return sync_info.result;
-}
-
-/* static */ void R_BSP_SerialFamily::callback_sync_trans(void * p_data, int32_t result, void * p_app_data) {
- rbsp_sync_t * p_sync_info = (rbsp_sync_t *)p_app_data;
+ if ((channel >= 0) && (channel <= 9) && (function_list != NULL)) {
+ ch_no = channel;
+ functions = function_list;
- p_sync_info->result = result;
- p_sync_info->p_sem->release();
-}
-
-/* static */ int32_t R_BSP_SerialFamily::aio_trans(rbsp_serial_ctl_t * const p_ctl,
- void * const p_data, uint32_t data_size, const rbsp_data_conf_t * const p_data_conf) {
- int32_t wk_errno;
- AIOCB * p_rbsp_aio;
- rbsp_sival_t * p_sival;
- rbsp_read_write_a_func_t p_func = (rbsp_read_write_a_func_t)p_ctl->p_async_func;
-
- if ((p_data_conf == NULL) || (p_data == NULL)) {
- wk_errno = ENOSPC;
- } else if (p_ctl->p_sem_ctl->wait(osWaitForever) == -1) {
- wk_errno = EIO;
- } else {
- p_rbsp_aio = (AIOCB *)p_ctl->p_aio_top + p_ctl->index;
- p_sival = p_ctl->p_sival_top + p_ctl->index;
-
- p_sival->p_cb_func = p_data_conf->p_notify_func;
- p_sival->p_cb_data = p_data_conf->p_app_data;
- p_sival->p_sem = p_ctl->p_sem_ctl;
- p_sival->p_aio = p_rbsp_aio;
-
- p_rbsp_aio->aio_fildes = 0;
- p_rbsp_aio->aio_buf = p_data;
- p_rbsp_aio->aio_nbytes = data_size;
- p_rbsp_aio->aio_offset = 0;
- p_rbsp_aio->aio_sigevent.sigev_notify = SIGEV_THREAD;
- p_rbsp_aio->aio_sigevent.sigev_value.sival_ptr = (void*)p_sival;
- p_rbsp_aio->aio_sigevent.sigev_notify_function = &callback_aio_trans;
- p_func(p_ctl->ch_handle, p_rbsp_aio, &wk_errno);
-
- if (wk_errno == ESUCCESS) {
- if ((p_ctl->index + 1) >= p_ctl->MaxNum) {
- p_ctl->index = 0;
- } else {
- p_ctl->index++;
+ if ((functions->initialise_one != NULL) && (functions->open != NULL)) {
+ R_BSP_CMN_Init();
+ instance = functions->initialise_one(ch_no, config_data, &wk_errno);
+ if ((int32_t)instance != EERROR) {
+ path_name[PATH_TOP_PART] = PATH_SEPARATOR;
+ path_name[CH_ID_PART] = CHARACTER_0 + ch_no;
+ path_name[TERM_CHAR_PART] = '\0';
+ ch_handle = (void *)functions->open(instance, path_name, O_RDWR, 0, &wk_errno);
+ if ((int32_t)ch_handle != EERROR) {
+ if (functions->write_a != NULL) {
+ write_init(ch_handle, (void *)functions->write_a, max_write_num);
+ }
+ if (functions->read_a != NULL) {
+ read_init(ch_handle, (void *)functions->read_a, max_read_num);
+ }
+ ret = true;
+ } else {
+ (void)((RBSP_MBED_FNS *)functions)->uninitialise_one(ch_no, instance, NULL);
+ }
}
- } else {
- p_ctl->p_sem_ctl->release();
}
}
- return wk_errno;
+ if (ret == false) {
+ functions = NULL;
+ instance = NULL;
+ ch_handle = NULL;
+ ch_no = -1;
+ }
+
+ return ret;
}
-/* static */ void R_BSP_SerialFamily::callback_aio_trans(union sigval signo) {
- rbsp_sival_t * p_sival = (rbsp_sival_t *)signo.sival_ptr;
- AIOCB * p_aio_result = (AIOCB *)p_sival->p_aio;
+bool R_BSP_SerialFamily::ioctl(int request, ...) {
+ bool ret = true;
+ int32_t wk_errno;
+ void *buf;
+ va_list ap;
- if ((p_sival->p_cb_func != NULL) && (p_aio_result != NULL)) {
- p_sival->p_cb_func((void *)p_aio_result->aio_buf, p_aio_result->aio_return, p_sival->p_cb_data);
+ if (functions == NULL) {
+ ret = false;
+ } else if (functions->ioctl == NULL) {
+ ret = false;
+ } else {
+ va_start(ap, request);
+ buf = (void *)va_arg(ap, void*);
+ functions->ioctl(ch_handle, request, buf, &wk_errno);
+ va_end(ap);
+ if (wk_errno != ESUCCESS) {
+ ret = false;
+ }
}
- p_sival->p_sem->release();
+
+ return ret;
}
--- a/common/R_BSP_Ssif.cpp Fri Oct 02 03:03:25 2015 +0000
+++ b/common/R_BSP_Ssif.cpp Wed Dec 16 06:33:17 2015 +0000
@@ -27,16 +27,11 @@
#include "ssif_api.h"
R_BSP_Ssif::R_BSP_Ssif(PinName sck, PinName ws, PinName tx, PinName rx, uint8_t int_level, int32_t max_write_num, int32_t max_read_num) {
- int32_t wk_errno;
int32_t wk_channel;
- char_t path_name[3];
wk_channel = ssif_init(sck, ws, tx, rx);
if (wk_channel != NC) {
- R_BSP_CMN_Init();
-
ssif_ch = wk_channel;
- ch_handle = 0;
ssif_cfg.enabled = true;
ssif_cfg.int_level = 0x78;
@@ -57,18 +52,7 @@
ssif_cfg.romdec_direct.mode = SSIF_CFG_DISABLE_ROMDEC_DIRECT;
ssif_cfg.romdec_direct.p_cbfunc = NULL;
- instance = R_SSIF_InitOne(ssif_ch, &ssif_cfg, &wk_errno);
- if (wk_errno != -1) {
- path_name[0] = '\\';
- path_name[1] = 0x30 + ssif_ch;
- path_name[2] = '\0';
-
- ch_handle = (void *)R_SSIF_Open(instance, path_name, O_RDWR, 0, &wk_errno);
- write_init(ch_handle, (void *)&R_SSIF_WriteAsync, max_write_num);
- read_init(ch_handle, (void *)&R_SSIF_ReadAsync, max_read_num);
- } else {
- instance = NULL;
- }
+ init_channel(R_SSIF_MakeCbTbl_mbed(), ssif_ch, &ssif_cfg, max_write_num, max_read_num);
}
}
@@ -77,18 +61,9 @@
}
bool R_BSP_Ssif::ConfigChannel(const ssif_channel_cfg_t* const p_ch_cfg) {
- int32_t wk_errno;
-
- R_SSIF_Ioctl(ch_handle, SSIF_CONFIG_CHANNEL, (void *)p_ch_cfg, &wk_errno);
-
- return (wk_errno == ESUCCESS);
+ return ioctl(SSIF_CONFIG_CHANNEL, (void *)p_ch_cfg);
}
bool R_BSP_Ssif::GetStatus(uint32_t* const p_status) {
- int32_t wk_errno;
-
- R_SSIF_Ioctl(ch_handle, SSIF_CONFIG_CHANNEL, (void *)p_status, &wk_errno);
-
- return (wk_errno == ESUCCESS);
+ return ioctl(SSIF_CONFIG_CHANNEL, (void *)p_status);
}
-
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/tools/R_BSP_mbed_fns.h Wed Dec 16 06:33:17 2015 +0000
@@ -0,0 +1,52 @@
+/*******************************************************************************
+* DISCLAIMER
+* This software is supplied by Renesas Electronics Corporation and is only
+* intended for use with Renesas products. No other uses are authorized. This
+* software is owned by Renesas Electronics Corporation and is protected under
+* all applicable laws, including copyright laws.
+* THIS SOFTWARE IS PROVIDED "AS IS" AND RENESAS MAKES NO WARRANTIES REGARDING
+* THIS SOFTWARE, WHETHER EXPRESS, IMPLIED OR STATUTORY, INCLUDING BUT NOT
+* LIMITED TO WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE
+* AND NON-INFRINGEMENT. ALL SUCH WARRANTIES ARE EXPRESSLY DISCLAIMED.
+* TO THE MAXIMUM EXTENT PERMITTED NOT PROHIBITED BY LAW, NEITHER RENESAS
+* ELECTRONICS CORPORATION NOR ANY OF ITS AFFILIATED COMPANIES SHALL BE LIABLE
+* FOR ANY DIRECT, INDIRECT, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES FOR
+* ANY REASON RELATED TO THIS SOFTWARE, EVEN IF RENESAS OR ITS AFFILIATES HAVE
+* BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES.
+* Renesas reserves the right, without notice, to make changes to this software
+* and to discontinue the availability of this software. By using this software,
+* you agree to the additional terms and conditions found by accessing the
+* following link:
+* http://www.renesas.com/disclaimer*
+* Copyright (C) 2015 Renesas Electronics Corporation. All rights reserved.
+*******************************************************************************/
+
+
+#ifndef R_BSP_MBED_FNS_H
+#define R_BSP_MBED_FNS_H
+
+/******************************************************************************
+Includes <System Includes> , "Project Includes"
+******************************************************************************/
+#include "r_typedefs.h"
+
+#ifdef __cplusplus
+extern "C"
+{
+#endif /* __cplusplus */
+
+typedef struct {
+ void *(*initialise_one)(const int_t channel, const void* const config_data, int32_t* const p_errno);
+ int_t (*uninitialise_one)(const int_t channel, const void* const driver_instance, int32_t* const p_errno);
+ int_t (*open)(void *driver_instance, const char_t *pathname, int_t flags, int_t mode, int32_t* p_errno);
+ int_t (*close)(void *fd, int32_t* p_errno);
+ int_t (*ioctl)(void *fd, int_t request, void *buf, int32_t* p_errno);
+ int_t (*read_a)(void *fd, struct aiocb *p_aio, int32_t* p_errno);
+ int_t (*write_a)(void *fd, struct aiocb *p_aio, int32_t* p_errno);
+} RBSP_MBED_FNS;
+
+#ifdef __cplusplus
+}
+#endif /* __cplusplus */
+
+#endif /* R_BSP_MBED_FNS_H */
