mirror of
https://github.com/hathach/tinyusb.git
synced 2025-01-31 05:52:55 +08:00
264 lines
35 KiB
HTML
264 lines
35 KiB
HTML
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
|
|
<html xmlns="http://www.w3.org/1999/xhtml">
|
|
<head>
|
|
<meta http-equiv="Content-Type" content="text/xhtml;charset=UTF-8"/>
|
|
<meta http-equiv="X-UA-Compatible" content="IE=9"/>
|
|
<meta name="generator" content="Doxygen 1.8.6"/>
|
|
<title>tinyusb: tinyusb/osal/osal_cmsis_rtx.h Source File</title>
|
|
<link href="tabs.css" rel="stylesheet" type="text/css"/>
|
|
<script type="text/javascript" src="jquery.js"></script>
|
|
<script type="text/javascript" src="dynsections.js"></script>
|
|
<link href="navtree.css" rel="stylesheet" type="text/css"/>
|
|
<script type="text/javascript" src="resize.js"></script>
|
|
<script type="text/javascript" src="navtree.js"></script>
|
|
<script type="text/javascript">
|
|
$(document).ready(initResizable);
|
|
$(window).load(resizeHeight);
|
|
</script>
|
|
<link href="doxygen.css" rel="stylesheet" type="text/css" />
|
|
</head>
|
|
<body>
|
|
<div id="top"><!-- do not remove this div, it is closed by doxygen! -->
|
|
<div id="titlearea">
|
|
<table cellspacing="0" cellpadding="0">
|
|
<tbody>
|
|
<tr style="height: 56px;">
|
|
<td style="padding-left: 0.5em;">
|
|
<div id="projectname">tinyusb
|
|
</div>
|
|
</td>
|
|
</tr>
|
|
</tbody>
|
|
</table>
|
|
</div>
|
|
<!-- end header part -->
|
|
<!-- Generated by Doxygen 1.8.6 -->
|
|
<div id="navrow1" class="tabs">
|
|
<ul class="tablist">
|
|
<li><a href="index.html"><span>Main Page</span></a></li>
|
|
<li><a href="pages.html"><span>Related Pages</span></a></li>
|
|
<li><a href="modules.html"><span>Modules</span></a></li>
|
|
<li><a href="annotated.html"><span>Data Structures</span></a></li>
|
|
<li class="current"><a href="files.html"><span>Files</span></a></li>
|
|
</ul>
|
|
</div>
|
|
<div id="navrow2" class="tabs2">
|
|
<ul class="tablist">
|
|
<li><a href="files.html"><span>File List</span></a></li>
|
|
<li><a href="globals.html"><span>Globals</span></a></li>
|
|
</ul>
|
|
</div>
|
|
</div><!-- top -->
|
|
<div id="side-nav" class="ui-resizable side-nav-resizable">
|
|
<div id="nav-tree">
|
|
<div id="nav-tree-contents">
|
|
<div id="nav-sync" class="sync"></div>
|
|
</div>
|
|
</div>
|
|
<div id="splitbar" style="-moz-user-select:none;"
|
|
class="ui-resizable-handle">
|
|
</div>
|
|
</div>
|
|
<script type="text/javascript">
|
|
$(document).ready(function(){initNavTree('osal__cmsis__rtx_8h_source.html','');});
|
|
</script>
|
|
<div id="doc-content">
|
|
<div class="header">
|
|
<div class="headertitle">
|
|
<div class="title">osal_cmsis_rtx.h</div> </div>
|
|
</div><!--header-->
|
|
<div class="contents">
|
|
<a href="osal__cmsis__rtx_8h.html">Go to the documentation of this file.</a><div class="fragment"><div class="line"><a name="l00001"></a><span class="lineno"> 1</span> <span class="comment">/**************************************************************************/</span></div>
|
|
<div class="line"><a name="l00037"></a><span class="lineno"> 37</span> <span class="comment">/**************************************************************************/</span></div>
|
|
<div class="line"><a name="l00038"></a><span class="lineno"> 38</span> </div>
|
|
<div class="line"><a name="l00044"></a><span class="lineno"> 44</span> <span class="preprocessor">#ifndef _TUSB_OSAL_CMSIS_RTX_H_</span></div>
|
|
<div class="line"><a name="l00045"></a><span class="lineno"> 45</span> <span class="preprocessor"></span><span class="preprocessor">#define _TUSB_OSAL_CMSIS_RTX_H_</span></div>
|
|
<div class="line"><a name="l00046"></a><span class="lineno"> 46</span> <span class="preprocessor"></span></div>
|
|
<div class="line"><a name="l00047"></a><span class="lineno"> 47</span> <span class="preprocessor">#include "<a class="code" href="osal__common_8h.html">osal_common.h</a>"</span></div>
|
|
<div class="line"><a name="l00048"></a><span class="lineno"> 48</span> <span class="preprocessor">#include "cmsis_os.h"</span></div>
|
|
<div class="line"><a name="l00049"></a><span class="lineno"> 49</span> </div>
|
|
<div class="line"><a name="l00050"></a><span class="lineno"> 50</span> <span class="preprocessor">#ifdef __cplusplus</span></div>
|
|
<div class="line"><a name="l00051"></a><span class="lineno"> 51</span> <span class="preprocessor"></span> <span class="keyword">extern</span> <span class="stringliteral">"C"</span> {</div>
|
|
<div class="line"><a name="l00052"></a><span class="lineno"> 52</span> <span class="preprocessor">#endif</span></div>
|
|
<div class="line"><a name="l00053"></a><span class="lineno"> 53</span> <span class="preprocessor"></span></div>
|
|
<div class="line"><a name="l00054"></a><span class="lineno"> 54</span> <span class="comment">//--------------------------------------------------------------------+</span></div>
|
|
<div class="line"><a name="l00055"></a><span class="lineno"> 55</span> <span class="comment">// TICK API</span></div>
|
|
<div class="line"><a name="l00056"></a><span class="lineno"> 56</span> <span class="comment">//--------------------------------------------------------------------+</span></div>
|
|
<div class="line"><a name="l00057"></a><span class="lineno"> 57</span> <span class="preprocessor">#define osal_tick_get osKernelSysTick</span></div>
|
|
<div class="line"><a name="l00058"></a><span class="lineno"> 58</span> <span class="preprocessor"></span></div>
|
|
<div class="line"><a name="l00059"></a><span class="lineno"> 59</span> <span class="comment">//--------------------------------------------------------------------+</span></div>
|
|
<div class="line"><a name="l00060"></a><span class="lineno"> 60</span> <span class="comment">// TASK API</span></div>
|
|
<div class="line"><a name="l00061"></a><span class="lineno"> 61</span> <span class="comment">//--------------------------------------------------------------------+</span></div>
|
|
<div class="line"><a name="l00062"></a><span class="lineno"> 62</span> <span class="preprocessor">#define OSAL_TASK_FUNCTION(task_func, p_para) void task_func(void const * p_para)</span></div>
|
|
<div class="line"><a name="l00063"></a><span class="lineno"> 63</span> <span class="preprocessor"></span></div>
|
|
<div class="line"><a name="l00064"></a><span class="lineno"> 64</span> <span class="keyword">typedef</span> osThreadDef_t <a class="code" href="structosal__task__t.html">osal_task_t</a>;</div>
|
|
<div class="line"><a name="l00065"></a><span class="lineno"> 65</span> </div>
|
|
<div class="line"><a name="l00066"></a><span class="lineno"> 66</span> <span class="preprocessor">#define OSAL_TASK_DEF(task_code, task_stack_depth, task_prio) \</span></div>
|
|
<div class="line"><a name="l00067"></a><span class="lineno"> 67</span> <span class="preprocessor"> osThreadDef(task_code, (osPriority) task_prio, 1, task_stack_depth*4) // stack depth is in bytes</span></div>
|
|
<div class="line"><a name="l00068"></a><span class="lineno"> 68</span> <span class="preprocessor"></span></div>
|
|
<div class="line"><a name="l00069"></a><span class="lineno"> 69</span> <span class="preprocessor">#define OSAL_TASK_REF(task_name) osThread(task_name)</span></div>
|
|
<div class="line"><a name="l00070"></a><span class="lineno"> 70</span> <span class="preprocessor"></span></div>
|
|
<div class="line"><a name="l00071"></a><span class="lineno"> 71</span> <span class="keyword">static</span> <span class="keyword">inline</span> <a class="code" href="group___group___error.html#ga225612897c510054ef4026586562f716">tusb_error_t</a> osal_task_create(<span class="keyword">const</span> osal_task_t *task) <a class="code" href="group___group___func_attr.html#gaa61f3d1a169c3d97d95072b1ee6493fd">ATTR_WARN_UNUSED_RESULT</a> <a class="code" href="group___group___func_attr.html#ga18a61fcb06b815274b12b7f626993ac6">ATTR_ALWAYS_INLINE</a>;</div>
|
|
<div class="line"><a name="l00072"></a><span class="lineno"> 72</span> <span class="keyword">static</span> <span class="keyword">inline</span> <a class="code" href="group___group___error.html#ga225612897c510054ef4026586562f716">tusb_error_t</a> osal_task_create(<span class="keyword">const</span> osal_task_t *task)</div>
|
|
<div class="line"><a name="l00073"></a><span class="lineno"> 73</span> {</div>
|
|
<div class="line"><a name="l00074"></a><span class="lineno"> 74</span>  <span class="keywordflow">return</span> ( osThreadCreate(task, NULL) != NULL ) ? TUSB_ERROR_NONE : TUSB_ERROR_OSAL_TASK_CREATE_FAILED;</div>
|
|
<div class="line"><a name="l00075"></a><span class="lineno"> 75</span> }</div>
|
|
<div class="line"><a name="l00076"></a><span class="lineno"> 76</span> </div>
|
|
<div class="line"><a name="l00077"></a><span class="lineno"> 77</span> <span class="preprocessor">#define osal_task_delay(msec) osDelay(msec)</span></div>
|
|
<div class="line"><a name="l00078"></a><span class="lineno"> 78</span> <span class="preprocessor"></span></div>
|
|
<div class="line"><a name="l00079"></a><span class="lineno"> 79</span> <span class="comment">//--------------------------------------------------------------------+</span></div>
|
|
<div class="line"><a name="l00080"></a><span class="lineno"> 80</span> <span class="comment">// Semaphore API</span></div>
|
|
<div class="line"><a name="l00081"></a><span class="lineno"> 81</span> <span class="comment">//--------------------------------------------------------------------+</span></div>
|
|
<div class="line"><a name="l00082"></a><span class="lineno"><a class="line" href="structosal__semaphore__t.html"> 82</a></span> <span class="keyword">typedef</span> <span class="keyword">struct </span>{</div>
|
|
<div class="line"><a name="l00083"></a><span class="lineno"> 83</span>  uint32_t sem_cb[2];</div>
|
|
<div class="line"><a name="l00084"></a><span class="lineno"> 84</span> }<a class="code" href="structosal__semaphore__t.html">osal_semaphore_t</a>;</div>
|
|
<div class="line"><a name="l00085"></a><span class="lineno"> 85</span> </div>
|
|
<div class="line"><a name="l00086"></a><span class="lineno"> 86</span> <span class="keyword">typedef</span> osSemaphoreId osal_semaphore_handle_t;</div>
|
|
<div class="line"><a name="l00087"></a><span class="lineno"> 87</span> </div>
|
|
<div class="line"><a name="l00088"></a><span class="lineno"> 88</span> <span class="preprocessor">#define OSAL_SEM_DEF(name) osal_semaphore_t name</span></div>
|
|
<div class="line"><a name="l00089"></a><span class="lineno"> 89</span> <span class="preprocessor"></span><span class="preprocessor">#define OSAL_SEM_REF(name) (&name)</span></div>
|
|
<div class="line"><a name="l00090"></a><span class="lineno"> 90</span> <span class="preprocessor"></span></div>
|
|
<div class="line"><a name="l00091"></a><span class="lineno"> 91</span> <span class="keyword">static</span> <span class="keyword">inline</span> osal_semaphore_handle_t osal_semaphore_create(<a class="code" href="structosal__semaphore__t.html">osal_semaphore_t</a> * p_sem) <a class="code" href="group___group___func_attr.html#gaa61f3d1a169c3d97d95072b1ee6493fd">ATTR_WARN_UNUSED_RESULT</a> <a class="code" href="group___group___func_attr.html#ga18a61fcb06b815274b12b7f626993ac6">ATTR_ALWAYS_INLINE</a>;</div>
|
|
<div class="line"><a name="l00092"></a><span class="lineno"> 92</span> <span class="keyword">static</span> <span class="keyword">inline</span> osal_semaphore_handle_t osal_semaphore_create(<a class="code" href="structosal__semaphore__t.html">osal_semaphore_t</a> * p_sem)</div>
|
|
<div class="line"><a name="l00093"></a><span class="lineno"> 93</span> {</div>
|
|
<div class="line"><a name="l00094"></a><span class="lineno"> 94</span>  <span class="keywordflow">return</span> osSemaphoreCreate( &(osSemaphoreDef_t) { p_sem }, 0 );</div>
|
|
<div class="line"><a name="l00095"></a><span class="lineno"> 95</span> }</div>
|
|
<div class="line"><a name="l00096"></a><span class="lineno"> 96</span> </div>
|
|
<div class="line"><a name="l00097"></a><span class="lineno"> 97</span> <span class="comment">// TODO add timeout (with instant return from ISR option) for semaphore post & queue send</span></div>
|
|
<div class="line"><a name="l00098"></a><span class="lineno"> 98</span> <span class="keyword">static</span> <span class="keyword">inline</span> <a class="code" href="group___group___error.html#ga225612897c510054ef4026586562f716">tusb_error_t</a> osal_semaphore_post(osal_semaphore_handle_t <span class="keyword">const</span> sem_hdl) <a class="code" href="group___group___func_attr.html#ga18a61fcb06b815274b12b7f626993ac6">ATTR_ALWAYS_INLINE</a>;</div>
|
|
<div class="line"><a name="l00099"></a><span class="lineno"> 99</span> <span class="keyword">static</span> <span class="keyword">inline</span> <a class="code" href="group___group___error.html#ga225612897c510054ef4026586562f716">tusb_error_t</a> osal_semaphore_post(osal_semaphore_handle_t <span class="keyword">const</span> sem_hdl)</div>
|
|
<div class="line"><a name="l00100"></a><span class="lineno"> 100</span> {</div>
|
|
<div class="line"><a name="l00101"></a><span class="lineno"> 101</span>  <span class="keywordflow">return</span> (osSemaphoreRelease(sem_hdl) == osOK) ? TUSB_ERROR_NONE : TUSB_ERROR_OSAL_SEMAPHORE_FAILED;</div>
|
|
<div class="line"><a name="l00102"></a><span class="lineno"> 102</span> }</div>
|
|
<div class="line"><a name="l00103"></a><span class="lineno"> 103</span> </div>
|
|
<div class="line"><a name="l00104"></a><span class="lineno"> 104</span> <span class="keyword">static</span> <span class="keyword">inline</span> <span class="keywordtype">void</span> osal_semaphore_wait(osal_semaphore_handle_t <span class="keyword">const</span> sem_hdl, uint32_t msec, <a class="code" href="group___group___error.html#ga225612897c510054ef4026586562f716">tusb_error_t</a> *p_error) <a class="code" href="group___group___func_attr.html#ga18a61fcb06b815274b12b7f626993ac6">ATTR_ALWAYS_INLINE</a>;</div>
|
|
<div class="line"><a name="l00105"></a><span class="lineno"> 105</span> <span class="keyword">static</span> <span class="keyword">inline</span> <span class="keywordtype">void</span> osal_semaphore_wait(osal_semaphore_handle_t <span class="keyword">const</span> sem_hdl, uint32_t msec, <a class="code" href="group___group___error.html#ga225612897c510054ef4026586562f716">tusb_error_t</a> *p_error)</div>
|
|
<div class="line"><a name="l00106"></a><span class="lineno"> 106</span> {</div>
|
|
<div class="line"><a name="l00107"></a><span class="lineno"> 107</span>  (*p_error) = ( osSemaphoreWait(sem_hdl, msec) > 0 ) ? TUSB_ERROR_NONE : TUSB_ERROR_OSAL_TIMEOUT;</div>
|
|
<div class="line"><a name="l00108"></a><span class="lineno"> 108</span> }</div>
|
|
<div class="line"><a name="l00109"></a><span class="lineno"> 109</span> </div>
|
|
<div class="line"><a name="l00110"></a><span class="lineno"> 110</span> <span class="keyword">static</span> <span class="keyword">inline</span> <span class="keywordtype">void</span> osal_semaphore_reset(osal_semaphore_handle_t <span class="keyword">const</span> sem_hdl) <a class="code" href="group___group___func_attr.html#ga18a61fcb06b815274b12b7f626993ac6">ATTR_ALWAYS_INLINE</a>;</div>
|
|
<div class="line"><a name="l00111"></a><span class="lineno"> 111</span> <span class="keyword">static</span> <span class="keyword">inline</span> <span class="keywordtype">void</span> osal_semaphore_reset(osal_semaphore_handle_t <span class="keyword">const</span> sem_hdl)</div>
|
|
<div class="line"><a name="l00112"></a><span class="lineno"> 112</span> {</div>
|
|
<div class="line"><a name="l00113"></a><span class="lineno"> 113</span>  osSemaphoreWait(sem_hdl, 0); <span class="comment">// instant return without putting caller to suspend</span></div>
|
|
<div class="line"><a name="l00114"></a><span class="lineno"> 114</span> }</div>
|
|
<div class="line"><a name="l00115"></a><span class="lineno"> 115</span> </div>
|
|
<div class="line"><a name="l00116"></a><span class="lineno"> 116</span> <span class="comment">//--------------------------------------------------------------------+</span></div>
|
|
<div class="line"><a name="l00117"></a><span class="lineno"> 117</span> <span class="comment">// MUTEX API (priority inheritance)</span></div>
|
|
<div class="line"><a name="l00118"></a><span class="lineno"> 118</span> <span class="comment">//--------------------------------------------------------------------+</span></div>
|
|
<div class="line"><a name="l00119"></a><span class="lineno"><a class="line" href="structosal__mutex__t.html"> 119</a></span> <span class="keyword">typedef</span> <span class="keyword">struct </span>{</div>
|
|
<div class="line"><a name="l00120"></a><span class="lineno"> 120</span>  uint32_t mutex_cb[3];</div>
|
|
<div class="line"><a name="l00121"></a><span class="lineno"> 121</span> }<a class="code" href="structosal__mutex__t.html">osal_mutex_t</a>;</div>
|
|
<div class="line"><a name="l00122"></a><span class="lineno"> 122</span> </div>
|
|
<div class="line"><a name="l00123"></a><span class="lineno"> 123</span> <span class="keyword">typedef</span> osMutexId osal_mutex_handle_t;</div>
|
|
<div class="line"><a name="l00124"></a><span class="lineno"> 124</span> </div>
|
|
<div class="line"><a name="l00125"></a><span class="lineno"> 125</span> <span class="preprocessor">#define OSAL_MUTEX_DEF(name) osal_mutex_t name</span></div>
|
|
<div class="line"><a name="l00126"></a><span class="lineno"> 126</span> <span class="preprocessor"></span><span class="preprocessor">#define OSAL_MUTEX_REF(name) (&name)</span></div>
|
|
<div class="line"><a name="l00127"></a><span class="lineno"> 127</span> <span class="preprocessor"></span></div>
|
|
<div class="line"><a name="l00128"></a><span class="lineno"> 128</span> <span class="keyword">static</span> <span class="keyword">inline</span> osal_mutex_handle_t osal_mutex_create(<a class="code" href="structosal__mutex__t.html">osal_mutex_t</a> * p_mutex) <a class="code" href="group___group___func_attr.html#gaa61f3d1a169c3d97d95072b1ee6493fd">ATTR_WARN_UNUSED_RESULT</a> <a class="code" href="group___group___func_attr.html#ga18a61fcb06b815274b12b7f626993ac6">ATTR_ALWAYS_INLINE</a>;</div>
|
|
<div class="line"><a name="l00129"></a><span class="lineno"> 129</span> <span class="keyword">static</span> <span class="keyword">inline</span> osal_mutex_handle_t osal_mutex_create(<a class="code" href="structosal__mutex__t.html">osal_mutex_t</a> * p_mutex)</div>
|
|
<div class="line"><a name="l00130"></a><span class="lineno"> 130</span> {</div>
|
|
<div class="line"><a name="l00131"></a><span class="lineno"> 131</span>  <span class="keywordflow">return</span> osMutexCreate( &(osMutexDef_t) {p_mutex} );</div>
|
|
<div class="line"><a name="l00132"></a><span class="lineno"> 132</span> }</div>
|
|
<div class="line"><a name="l00133"></a><span class="lineno"> 133</span> </div>
|
|
<div class="line"><a name="l00134"></a><span class="lineno"> 134</span> <span class="keyword">static</span> <span class="keyword">inline</span> <a class="code" href="group___group___error.html#ga225612897c510054ef4026586562f716">tusb_error_t</a> osal_mutex_release(osal_mutex_handle_t <span class="keyword">const</span> mutex_hdl) <a class="code" href="group___group___func_attr.html#ga18a61fcb06b815274b12b7f626993ac6">ATTR_ALWAYS_INLINE</a>;</div>
|
|
<div class="line"><a name="l00135"></a><span class="lineno"> 135</span> <span class="keyword">static</span> <span class="keyword">inline</span> <a class="code" href="group___group___error.html#ga225612897c510054ef4026586562f716">tusb_error_t</a> osal_mutex_release(osal_mutex_handle_t <span class="keyword">const</span> mutex_hdl)</div>
|
|
<div class="line"><a name="l00136"></a><span class="lineno"> 136</span> {</div>
|
|
<div class="line"><a name="l00137"></a><span class="lineno"> 137</span>  <span class="keywordflow">return</span> (osMutexRelease(mutex_hdl) == osOK) ? TUSB_ERROR_NONE : TUSB_ERROR_OSAL_MUTEX_FAILED;</div>
|
|
<div class="line"><a name="l00138"></a><span class="lineno"> 138</span> }</div>
|
|
<div class="line"><a name="l00139"></a><span class="lineno"> 139</span> </div>
|
|
<div class="line"><a name="l00140"></a><span class="lineno"> 140</span> <span class="keyword">static</span> <span class="keyword">inline</span> <span class="keywordtype">void</span> osal_mutex_wait(osal_mutex_handle_t <span class="keyword">const</span> mutex_hdl, uint32_t msec, <a class="code" href="group___group___error.html#ga225612897c510054ef4026586562f716">tusb_error_t</a> *p_error) <a class="code" href="group___group___func_attr.html#ga18a61fcb06b815274b12b7f626993ac6">ATTR_ALWAYS_INLINE</a>;</div>
|
|
<div class="line"><a name="l00141"></a><span class="lineno"> 141</span> <span class="keyword">static</span> <span class="keyword">inline</span> <span class="keywordtype">void</span> osal_mutex_wait(osal_mutex_handle_t <span class="keyword">const</span> mutex_hdl, uint32_t msec, <a class="code" href="group___group___error.html#ga225612897c510054ef4026586562f716">tusb_error_t</a> *p_error)</div>
|
|
<div class="line"><a name="l00142"></a><span class="lineno"> 142</span> {</div>
|
|
<div class="line"><a name="l00143"></a><span class="lineno"> 143</span>  (*p_error) = ( osMutexWait(mutex_hdl, msec) == osOK ) ? TUSB_ERROR_NONE : TUSB_ERROR_OSAL_TIMEOUT;</div>
|
|
<div class="line"><a name="l00144"></a><span class="lineno"> 144</span> }</div>
|
|
<div class="line"><a name="l00145"></a><span class="lineno"> 145</span> </div>
|
|
<div class="line"><a name="l00146"></a><span class="lineno"> 146</span> <span class="keyword">static</span> <span class="keyword">inline</span> <span class="keywordtype">void</span> osal_mutex_reset(osal_mutex_handle_t <span class="keyword">const</span> mutex_hdl) <a class="code" href="group___group___func_attr.html#ga18a61fcb06b815274b12b7f626993ac6">ATTR_ALWAYS_INLINE</a>;</div>
|
|
<div class="line"><a name="l00147"></a><span class="lineno"> 147</span> <span class="keyword">static</span> <span class="keyword">inline</span> <span class="keywordtype">void</span> osal_mutex_reset(osal_mutex_handle_t <span class="keyword">const</span> mutex_hdl)</div>
|
|
<div class="line"><a name="l00148"></a><span class="lineno"> 148</span> {</div>
|
|
<div class="line"><a name="l00149"></a><span class="lineno"> 149</span>  osMutexRelease(mutex_hdl);</div>
|
|
<div class="line"><a name="l00150"></a><span class="lineno"> 150</span> }</div>
|
|
<div class="line"><a name="l00151"></a><span class="lineno"> 151</span> </div>
|
|
<div class="line"><a name="l00152"></a><span class="lineno"> 152</span> <span class="comment">//--------------------------------------------------------------------+</span></div>
|
|
<div class="line"><a name="l00153"></a><span class="lineno"> 153</span> <span class="comment">// QUEUE API (for RTX: osMailQId is osMessageQDef_t.pool)</span></div>
|
|
<div class="line"><a name="l00154"></a><span class="lineno"> 154</span> <span class="comment">//--------------------------------------------------------------------+</span></div>
|
|
<div class="line"><a name="l00155"></a><span class="lineno"> 155</span> <span class="keyword">typedef</span> osMailQDef_t <a class="code" href="structosal__queue__t.html">osal_queue_t</a>;</div>
|
|
<div class="line"><a name="l00156"></a><span class="lineno"> 156</span> <span class="keyword">typedef</span> osal_queue_t * <a class="code" href="structosal__queue__t.html">osal_queue_handle_t</a>;</div>
|
|
<div class="line"><a name="l00157"></a><span class="lineno"> 157</span> </div>
|
|
<div class="line"><a name="l00158"></a><span class="lineno"> 158</span> <span class="preprocessor">#define OSAL_QUEUE_DEF(name, queue_depth, type)\</span></div>
|
|
<div class="line"><a name="l00159"></a><span class="lineno"> 159</span> <span class="preprocessor"> osMailQDef(name, queue_depth, type);</span></div>
|
|
<div class="line"><a name="l00160"></a><span class="lineno"> 160</span> <span class="preprocessor"></span></div>
|
|
<div class="line"><a name="l00161"></a><span class="lineno"> 161</span> <span class="preprocessor">#define OSAL_QUEUE_REF(name) ((osal_queue_t*) osMailQ(name))</span></div>
|
|
<div class="line"><a name="l00162"></a><span class="lineno"> 162</span> <span class="preprocessor"></span></div>
|
|
<div class="line"><a name="l00163"></a><span class="lineno"> 163</span> <span class="keyword">static</span> <span class="keyword">inline</span> osal_queue_handle_t osal_queue_create(osal_queue_t * <span class="keyword">const</span> p_queue) <a class="code" href="group___group___func_attr.html#gaa61f3d1a169c3d97d95072b1ee6493fd">ATTR_WARN_UNUSED_RESULT</a> <a class="code" href="group___group___func_attr.html#ga18a61fcb06b815274b12b7f626993ac6">ATTR_ALWAYS_INLINE</a>;</div>
|
|
<div class="line"><a name="l00164"></a><span class="lineno"> 164</span> <span class="keyword">static</span> <span class="keyword">inline</span> osal_queue_handle_t osal_queue_create(osal_queue_t * <span class="keyword">const</span> p_queue)</div>
|
|
<div class="line"><a name="l00165"></a><span class="lineno"> 165</span> {</div>
|
|
<div class="line"><a name="l00166"></a><span class="lineno"> 166</span>  <span class="keywordflow">return</span> (NULL != osMailCreate( (osMailQDef_t <span class="keyword">const</span> *) p_queue, NULL)) ? p_queue : NULL;</div>
|
|
<div class="line"><a name="l00167"></a><span class="lineno"> 167</span> }</div>
|
|
<div class="line"><a name="l00168"></a><span class="lineno"> 168</span> </div>
|
|
<div class="line"><a name="l00169"></a><span class="lineno"> 169</span> <span class="keyword">static</span> <span class="keyword">inline</span> <span class="keywordtype">void</span> osal_queue_receive (osal_queue_handle_t <span class="keyword">const</span> queue_hdl, <span class="keywordtype">void</span> *p_data, uint32_t msec, <a class="code" href="group___group___error.html#ga225612897c510054ef4026586562f716">tusb_error_t</a> *p_error) <a class="code" href="group___group___func_attr.html#ga18a61fcb06b815274b12b7f626993ac6">ATTR_ALWAYS_INLINE</a>;</div>
|
|
<div class="line"><a name="l00170"></a><span class="lineno"> 170</span> <span class="keyword">static</span> <span class="keyword">inline</span> <span class="keywordtype">void</span> osal_queue_receive (osal_queue_handle_t <span class="keyword">const</span> queue_hdl, <span class="keywordtype">void</span> *p_data, uint32_t msec, <a class="code" href="group___group___error.html#ga225612897c510054ef4026586562f716">tusb_error_t</a> *p_error)</div>
|
|
<div class="line"><a name="l00171"></a><span class="lineno"> 171</span> {</div>
|
|
<div class="line"><a name="l00172"></a><span class="lineno"> 172</span>  osEvent evt = osMailGet(queue_hdl->pool, msec);</div>
|
|
<div class="line"><a name="l00173"></a><span class="lineno"> 173</span> </div>
|
|
<div class="line"><a name="l00174"></a><span class="lineno"> 174</span>  <span class="keywordflow">if</span> (evt.status != osEventMail)</div>
|
|
<div class="line"><a name="l00175"></a><span class="lineno"> 175</span>  {</div>
|
|
<div class="line"><a name="l00176"></a><span class="lineno"> 176</span>  (*p_error) = TUSB_ERROR_OSAL_TIMEOUT;</div>
|
|
<div class="line"><a name="l00177"></a><span class="lineno"> 177</span>  }<span class="keywordflow">else</span></div>
|
|
<div class="line"><a name="l00178"></a><span class="lineno"> 178</span>  {</div>
|
|
<div class="line"><a name="l00179"></a><span class="lineno"> 179</span>  memcpy(p_data, evt.value.p, queue_hdl->item_sz);</div>
|
|
<div class="line"><a name="l00180"></a><span class="lineno"> 180</span>  osMailFree(queue_hdl->pool, evt.value.p);</div>
|
|
<div class="line"><a name="l00181"></a><span class="lineno"> 181</span>  (*p_error) = TUSB_ERROR_NONE;</div>
|
|
<div class="line"><a name="l00182"></a><span class="lineno"> 182</span>  }</div>
|
|
<div class="line"><a name="l00183"></a><span class="lineno"> 183</span> }</div>
|
|
<div class="line"><a name="l00184"></a><span class="lineno"> 184</span> </div>
|
|
<div class="line"><a name="l00185"></a><span class="lineno"> 185</span> <span class="keyword">static</span> <span class="keyword">inline</span> <a class="code" href="group___group___error.html#ga225612897c510054ef4026586562f716">tusb_error_t</a> osal_queue_send(osal_queue_handle_t <span class="keyword">const</span> queue_hdl, <span class="keywordtype">void</span> <span class="keyword">const</span> * data) <a class="code" href="group___group___func_attr.html#ga18a61fcb06b815274b12b7f626993ac6">ATTR_ALWAYS_INLINE</a>;</div>
|
|
<div class="line"><a name="l00186"></a><span class="lineno"> 186</span> <span class="keyword">static</span> <span class="keyword">inline</span> <a class="code" href="group___group___error.html#ga225612897c510054ef4026586562f716">tusb_error_t</a> osal_queue_send(osal_queue_handle_t <span class="keyword">const</span> queue_hdl, <span class="keywordtype">void</span> <span class="keyword">const</span> * data)</div>
|
|
<div class="line"><a name="l00187"></a><span class="lineno"> 187</span> {</div>
|
|
<div class="line"><a name="l00188"></a><span class="lineno"> 188</span>  <span class="keywordtype">void</span> *p_buf = osMailAlloc(queue_hdl->pool, 0); <span class="comment">// instantly return in case of sending within ISR (mostly used)</span></div>
|
|
<div class="line"><a name="l00189"></a><span class="lineno"> 189</span>  <span class="keywordflow">if</span> (p_buf == NULL) <span class="keywordflow">return</span> TUSB_ERROR_OSAL_QUEUE_FAILED;</div>
|
|
<div class="line"><a name="l00190"></a><span class="lineno"> 190</span> </div>
|
|
<div class="line"><a name="l00191"></a><span class="lineno"> 191</span>  memcpy(p_buf, data, queue_hdl->item_sz);</div>
|
|
<div class="line"><a name="l00192"></a><span class="lineno"> 192</span>  osMailPut(queue_hdl->pool, p_buf);</div>
|
|
<div class="line"><a name="l00193"></a><span class="lineno"> 193</span>  <span class="keywordflow">return</span> TUSB_ERROR_NONE;</div>
|
|
<div class="line"><a name="l00194"></a><span class="lineno"> 194</span> }</div>
|
|
<div class="line"><a name="l00195"></a><span class="lineno"> 195</span> </div>
|
|
<div class="line"><a name="l00196"></a><span class="lineno"> 196</span> <span class="keyword">static</span> <span class="keyword">inline</span> <span class="keywordtype">void</span> osal_queue_flush(osal_queue_handle_t <span class="keyword">const</span> queue_hdl) <a class="code" href="group___group___func_attr.html#ga18a61fcb06b815274b12b7f626993ac6">ATTR_ALWAYS_INLINE</a>;</div>
|
|
<div class="line"><a name="l00197"></a><span class="lineno"> 197</span> <span class="keyword">static</span> <span class="keyword">inline</span> <span class="keywordtype">void</span> osal_queue_flush(osal_queue_handle_t <span class="keyword">const</span> queue_hdl)</div>
|
|
<div class="line"><a name="l00198"></a><span class="lineno"> 198</span> {</div>
|
|
<div class="line"><a name="l00199"></a><span class="lineno"> 199</span>  osEvent evt;</div>
|
|
<div class="line"><a name="l00200"></a><span class="lineno"> 200</span> </div>
|
|
<div class="line"><a name="l00201"></a><span class="lineno"> 201</span>  <span class="keywordflow">while</span>( (evt = osMailGet(queue_hdl->pool, 0) ).status == osEventMail )</div>
|
|
<div class="line"><a name="l00202"></a><span class="lineno"> 202</span>  {</div>
|
|
<div class="line"><a name="l00203"></a><span class="lineno"> 203</span>  osMailFree(queue_hdl->pool, evt.value.p);</div>
|
|
<div class="line"><a name="l00204"></a><span class="lineno"> 204</span>  }</div>
|
|
<div class="line"><a name="l00205"></a><span class="lineno"> 205</span> }</div>
|
|
<div class="line"><a name="l00206"></a><span class="lineno"> 206</span> </div>
|
|
<div class="line"><a name="l00207"></a><span class="lineno"> 207</span> <span class="preprocessor">#ifdef __cplusplus</span></div>
|
|
<div class="line"><a name="l00208"></a><span class="lineno"> 208</span> <span class="preprocessor"></span> }</div>
|
|
<div class="line"><a name="l00209"></a><span class="lineno"> 209</span> <span class="preprocessor">#endif</span></div>
|
|
<div class="line"><a name="l00210"></a><span class="lineno"> 210</span> <span class="preprocessor"></span></div>
|
|
<div class="line"><a name="l00211"></a><span class="lineno"> 211</span> <span class="preprocessor">#endif </span><span class="comment">/* _TUSB_OSAL_CMSIS_RTX_H_ */</span><span class="preprocessor"></span></div>
|
|
<div class="line"><a name="l00212"></a><span class="lineno"> 212</span> <span class="preprocessor"></span></div>
|
|
<div class="ttc" id="group___group___func_attr_html_gaa61f3d1a169c3d97d95072b1ee6493fd"><div class="ttname"><a href="group___group___func_attr.html#gaa61f3d1a169c3d97d95072b1ee6493fd">ATTR_WARN_UNUSED_RESULT</a></div><div class="ttdeci">#define ATTR_WARN_UNUSED_RESULT</div><div class="ttdoc">The warn_unused_result attribute causes a warning to be emitted if a caller of the function with this...</div><div class="ttdef"><b>Definition:</b> compiler_gcc.h:118</div></div>
|
|
<div class="ttc" id="osal__common_8h_html"><div class="ttname"><a href="osal__common_8h.html">osal_common.h</a></div></div>
|
|
<div class="ttc" id="structosal__mutex__t_html"><div class="ttname"><a href="structosal__mutex__t.html">osal_mutex_t</a></div><div class="ttdef"><b>Definition:</b> osal_cmsis_rtx.h:119</div></div>
|
|
<div class="ttc" id="structosal__queue__t_html"><div class="ttname"><a href="structosal__queue__t.html">osal_queue_t</a></div><div class="ttdef"><b>Definition:</b> osal_freeRTOS.h:160</div></div>
|
|
<div class="ttc" id="group___group___error_html_ga225612897c510054ef4026586562f716"><div class="ttname"><a href="group___group___error.html#ga225612897c510054ef4026586562f716">tusb_error_t</a></div><div class="ttdeci">tusb_error_t</div><div class="ttdoc">Error Code returned. </div><div class="ttdef"><b>Definition:</b> tusb_errors.h:100</div></div>
|
|
<div class="ttc" id="group___group___func_attr_html_ga18a61fcb06b815274b12b7f626993ac6"><div class="ttname"><a href="group___group___func_attr.html#ga18a61fcb06b815274b12b7f626993ac6">ATTR_ALWAYS_INLINE</a></div><div class="ttdeci">#define ATTR_ALWAYS_INLINE</div><div class="ttdoc">Generally, functions are not inlined unless optimization is specified. For functions declared inline...</div><div class="ttdef"><b>Definition:</b> compiler_gcc.h:89</div></div>
|
|
<div class="ttc" id="structosal__task__t_html"><div class="ttname"><a href="structosal__task__t.html">osal_task_t</a></div><div class="ttdef"><b>Definition:</b> osal_freeRTOS.h:69</div></div>
|
|
<div class="ttc" id="structosal__semaphore__t_html"><div class="ttname"><a href="structosal__semaphore__t.html">osal_semaphore_t</a></div><div class="ttdef"><b>Definition:</b> osal_cmsis_rtx.h:82</div></div>
|
|
</div><!-- fragment --></div><!-- contents -->
|
|
</div><!-- doc-content -->
|
|
<!-- start footer part -->
|
|
<div id="nav-path" class="navpath"><!-- id is needed for treeview function! -->
|
|
<ul>
|
|
<li class="navelem"><a class="el" href="dir_f44c0f1c8d3a85cc1de1e7f4648a56e6.html">tinyusb</a></li><li class="navelem"><a class="el" href="dir_9d1acc64d81cf90c0f17a906d08e7a0c.html">osal</a></li><li class="navelem"><a class="el" href="osal__cmsis__rtx_8h.html">osal_cmsis_rtx.h</a></li>
|
|
<li class="footer">Generated on Wed Mar 26 2014 16:23:16 for tinyusb by
|
|
<a href="http://www.doxygen.org/index.html">
|
|
<img class="footer" src="doxygen.png" alt="doxygen"/></a> 1.8.6 </li>
|
|
</ul>
|
|
</div>
|
|
</body>
|
|
</html>
|