File tree 2 files changed +40
-0
lines changed
simplicity_sdk/platform/emdrv/dmadrv
2 files changed +40
-0
lines changed Original file line number Diff line number Diff line change @@ -102,6 +102,8 @@ typedef bool (*DMADRV_Callback_t)(unsigned int channel,
102
102
103
103
Ecode_t DMADRV_AllocateChannel (unsigned int * channelId ,
104
104
void * capabilities );
105
+ Ecode_t DMADRV_AllocateChannelById (unsigned int channelId ,
106
+ void * capabilities );
105
107
Ecode_t DMADRV_DeInit (void );
106
108
Ecode_t DMADRV_FreeChannel (unsigned int channelId );
107
109
Ecode_t DMADRV_Init (void );
Original file line number Diff line number Diff line change @@ -165,6 +165,44 @@ Ecode_t DMADRV_AllocateChannel(unsigned int *channelId, void *capabilities)
165
165
return ECODE_EMDRV_DMADRV_CHANNELS_EXHAUSTED ;
166
166
}
167
167
168
+ /***************************************************************************/ /**
169
+ * @brief
170
+ * Allocate (reserve) the given DMA channel if he is free.
171
+ *
172
+ * @param[out] channelId
173
+ * The channel ID to be assigned by DMADRV.
174
+ *
175
+ * @param[in] capabilities
176
+ * Not used.
177
+ *
178
+ * @return
179
+ * @ref ECODE_EMDRV_DMADRV_OK on success. On failure, an appropriate
180
+ * DMADRV @ref Ecode_t is returned.
181
+ ******************************************************************************/
182
+ Ecode_t DMADRV_AllocateChannelById (unsigned int channelId , void * capabilities )
183
+ {
184
+ (void )capabilities ;
185
+ CORE_DECLARE_IRQ_STATE ;
186
+
187
+ if ( !initialized ) {
188
+ return ECODE_EMDRV_DMADRV_NOT_INITIALIZED ;
189
+ }
190
+
191
+ if ( channelId >= EMDRV_DMADRV_DMA_CH_COUNT ) {
192
+ return ECODE_EMDRV_DMADRV_PARAM_ERROR ;
193
+ }
194
+
195
+ CORE_ENTER_ATOMIC ();
196
+ if ( !chTable [channelId ].allocated ) {
197
+ chTable [channelId ].allocated = true;
198
+ chTable [channelId ].callback = NULL ;
199
+ CORE_EXIT_ATOMIC ();
200
+ return ECODE_EMDRV_DMADRV_OK ;
201
+ }
202
+ CORE_EXIT_ATOMIC ();
203
+ return ECODE_EMDRV_DMADRV_IN_USE ;
204
+ }
205
+
168
206
/***************************************************************************/ /**
169
207
* @brief
170
208
* Deinitialize DMADRV.
You can’t perform that action at this time.
0 commit comments