29
29
#define INCLUDED_CY_RTOS_INTERFACE_H_
30
30
31
31
#include "cyabs_rtos_impl.h"
32
- #include < cy_result.h>
32
+ #include " cy_result.h"
33
33
#include <stdint.h>
34
34
#include <stdbool.h>
35
35
@@ -72,6 +72,8 @@ extern "C"
72
72
#define CY_RTOS_GENERAL_ERROR CY_RSLT_CREATE(CY_RSLT_TYPE_ERROR, CY_RSLT_MODULE_ABSTRACTION_OS, 2)
73
73
/** A bad argument was passed into the APIs */
74
74
#define CY_RTOS_BAD_PARAM CY_RSLT_CREATE(CY_RSLT_TYPE_ERROR, CY_RSLT_MODULE_ABSTRACTION_OS, 5)
75
+ /** A memory alignment issue was detected. Ensure memory provided is aligned per CY_RTOS_ALIGNMENT */
76
+ #define CY_RTOS_ALIGNMENT_ERROR CY_RSLT_CREATE(CY_RSLT_TYPE_ERROR, CY_RSLT_MODULE_ABSTRACTION_OS, 6)
75
77
76
78
/** \} group_abstraction_rtos_common */
77
79
@@ -146,7 +148,7 @@ typedef void (*cy_timer_callback_t)(cy_timer_callback_arg_t arg);
146
148
*
147
149
* \ingroup group_abstraction_rtos_common
148
150
*/
149
- extern cy_rtos_error_t cy_rtos_last_error ();
151
+ cy_rtos_error_t cy_rtos_last_error ();
150
152
151
153
/*********************************************** Threads **********************************************/
152
154
@@ -179,7 +181,7 @@ extern cy_rtos_error_t cy_rtos_last_error();
179
181
*
180
182
* @return The status of thread create request. [CY_RSLT_SUCCESS, CY_RTOS_NO_MEMORY, CY_RTOS_GENERAL_ERROR]
181
183
*/
182
- extern cy_rslt_t cy_rtos_create_thread (cy_thread_t * thread , cy_thread_entry_fn_t entry_function ,
184
+ cy_rslt_t cy_rtos_create_thread (cy_thread_t * thread , cy_thread_entry_fn_t entry_function ,
183
185
const char * name , void * stack , uint32_t stack_size , cy_thread_priority_t priority , cy_thread_arg_t arg );
184
186
185
187
@@ -196,7 +198,7 @@ extern cy_rslt_t cy_rtos_create_thread(cy_thread_t *thread, cy_thread_entry_fn_t
196
198
*
197
199
* @return The status of thread exit request. [CY_RSLT_SUCCESS, CY_RTOS_GENERAL_ERROR]
198
200
*/
199
- extern cy_rslt_t cy_rtos_exit_thread ();
201
+ cy_rslt_t cy_rtos_exit_thread ();
200
202
201
203
/** Terminates another thread.
202
204
*
@@ -212,40 +214,51 @@ extern cy_rslt_t cy_rtos_exit_thread();
212
214
*
213
215
* @returns The status of the thread terminate. [CY_RSLT_SUCCESS, CY_RTOS_GENERAL_ERROR]
214
216
*/
215
- extern cy_rslt_t cy_rtos_terminate_thread (cy_thread_t * thread );
217
+ cy_rslt_t cy_rtos_terminate_thread (cy_thread_t * thread );
218
+
219
+ /** Waits for a thread to complete.
220
+ *
221
+ * This must be called on any thread that can complete to ensure that any resources that
222
+ * were allocated for it are cleaned up.
223
+ *
224
+ * @param[in] thread Handle of the thread to wait for
225
+ *
226
+ * @returns The status of thread join request. [CY_RSLT_SUCCESS, CY_RTOS_GENERAL_ERROR]
227
+ */
228
+ cy_rslt_t cy_rtos_join_thread (cy_thread_t * thread );
216
229
217
230
/** Checks if the thread is running
218
231
*
219
- * This function is called to determine if a thread is running or not.
232
+ * This function is called to determine if a thread is running or not. For information on
233
+ * the thread state, use the cy_rtos_get_thread_state() function.
220
234
*
221
- * @param[in] thread handle of the terminated thread to delete
222
- * @param[out] running returns true if the thread is running, otherwise false
235
+ * @param[in] thread Handle of the terminated thread to delete
236
+ * @param[out] running Returns true if the thread is running, otherwise false
223
237
*
224
238
* @returns The status of the thread running check. [CY_RSLT_SUCCESS, CY_RTOS_GENERAL_ERROR]
225
239
*/
226
- extern cy_rslt_t cy_rtos_is_thread_running (cy_thread_t * thread , bool * running );
240
+ cy_rslt_t cy_rtos_is_thread_running (cy_thread_t * thread , bool * running );
227
241
228
242
/** Gets the state the thread is currently in
229
243
*
230
- * This function is called to determine if a thread is running or not .
244
+ * This function is called to determine if a thread is running/blocked/inactive/ready etc .
231
245
*
232
- * @param[in] thread handle of the terminated thread to delete
233
- * @param[out] state returns the state the thread is currently in
246
+ * @param[in] thread Handle of the terminated thread to delete
247
+ * @param[out] state Returns the state the thread is currently in
234
248
*
235
249
* @returns The status of the thread state check. [CY_RSLT_SUCCESS, CY_RTOS_GENERAL_ERROR]
236
250
*/
237
- extern cy_rslt_t cy_rtos_get_thread_state (cy_thread_t * thread , cy_thread_state_t * state );
251
+ cy_rslt_t cy_rtos_get_thread_state (cy_thread_t * thread , cy_thread_state_t * state );
238
252
239
- /** Waits for a thread to complete.
253
+ /** Get current thread handle
240
254
*
241
- * This must be called on any thread that can complete to ensure that any resources that
242
- * were allocated for it are cleaned up.
255
+ * Returns the unique thread handle of the current running thread.
243
256
*
244
- * @param[in ] thread Handle of the thread to wait for
257
+ * @param[out ] thread Handle of the current running thread
245
258
*
246
259
* @returns The status of thread join request. [CY_RSLT_SUCCESS, CY_RTOS_GENERAL_ERROR]
247
260
*/
248
- extern cy_rslt_t cy_rtos_join_thread (cy_thread_t * thread );
261
+ cy_rslt_t cy_rtos_get_thread_handle (cy_thread_t * thread );
249
262
250
263
/** \} group_abstraction_rtos_threads */
251
264
@@ -265,7 +278,7 @@ extern cy_rslt_t cy_rtos_join_thread(cy_thread_t *thread);
265
278
*
266
279
* @return The status of mutex creation request. [CY_RSLT_SUCCESS, CY_RTOS_NO_MEMORY, CY_RTOS_GENERAL_ERROR]
267
280
*/
268
- extern cy_rslt_t cy_rtos_init_mutex (cy_mutex_t * mutex );
281
+ cy_rslt_t cy_rtos_init_mutex (cy_mutex_t * mutex );
269
282
270
283
/** Get a mutex.
271
284
*
@@ -283,7 +296,7 @@ extern cy_rslt_t cy_rtos_init_mutex(cy_mutex_t *mutex);
283
296
* @return The status of the get mutex. Returns timeout if mutex was not acquired
284
297
* before timeout_ms period. [CY_RSLT_SUCCESS, CY_RTOS_TIMEOUT]
285
298
*/
286
- extern cy_rslt_t cy_rtos_get_mutex (cy_mutex_t * mutex , cy_time_t timeout_ms );
299
+ cy_rslt_t cy_rtos_get_mutex (cy_mutex_t * mutex , cy_time_t timeout_ms );
287
300
288
301
/** Set a mutex.
289
302
*
@@ -295,7 +308,7 @@ extern cy_rslt_t cy_rtos_get_mutex(cy_mutex_t *mutex, cy_time_t timeout_ms);
295
308
* @return The status of the set mutex request. [CY_RSLT_SUCCESS, CY_RTOS_TIMEOUT]
296
309
*
297
310
*/
298
- extern cy_rslt_t cy_rtos_set_mutex (cy_mutex_t * mutex );
311
+ cy_rslt_t cy_rtos_set_mutex (cy_mutex_t * mutex );
299
312
300
313
/** Deletes a mutex.
301
314
*
@@ -305,7 +318,7 @@ extern cy_rslt_t cy_rtos_set_mutex(cy_mutex_t *mutex);
305
318
*
306
319
* @return The status to the delete request. [CY_RSLT_SUCCESS, CY_RTOS_TIMEOUT]
307
320
*/
308
- extern cy_rslt_t cy_rtos_deinit_mutex (cy_mutex_t * mutex );
321
+ cy_rslt_t cy_rtos_deinit_mutex (cy_mutex_t * mutex );
309
322
310
323
/** \} group_abstraction_rtos_mutex */
311
324
@@ -327,7 +340,7 @@ extern cy_rslt_t cy_rtos_deinit_mutex(cy_mutex_t *mutex);
327
340
*
328
341
* @return The status of the sempahore creation. [CY_RSLT_SUCCESS, CY_RTOS_NO_MEMORY, CY_RTOS_GENERAL_ERROR]
329
342
*/
330
- extern cy_rslt_t cy_rtos_init_semaphore (cy_semaphore_t * semaphore , uint32_t maxcount , uint32_t initcount );
343
+ cy_rslt_t cy_rtos_init_semaphore (cy_semaphore_t * semaphore , uint32_t maxcount , uint32_t initcount );
331
344
332
345
/**
333
346
* Get/Acquire a semaphore
@@ -343,7 +356,7 @@ extern cy_rslt_t cy_rtos_init_semaphore(cy_semaphore_t *semaphore, uint32_t maxc
343
356
* @param[in] in_isr true if we are trying to get the semaphore from with an ISR
344
357
* @return The status of get semaphore operation [CY_RSLT_SUCCESS, CY_RTOS_NO_MEMORY, CY_RTOS_GENERAL_ERROR]
345
358
*/
346
- extern cy_rslt_t cy_rtos_get_semaphore (cy_semaphore_t * semaphore , cy_time_t timeout_ms , bool in_isr );
359
+ cy_rslt_t cy_rtos_get_semaphore (cy_semaphore_t * semaphore , cy_time_t timeout_ms , bool in_isr );
347
360
348
361
/**
349
362
* Set/Release a semaphore
@@ -355,7 +368,7 @@ extern cy_rslt_t cy_rtos_get_semaphore(cy_semaphore_t *semaphore, cy_time_t time
355
368
* Value of false indicates calling from normal thread context
356
369
* @return The status of set semaphore operation [CY_RSLT_SUCCESS, CY_RTOS_NO_MEMORY, CY_RTOS_GENERAL_ERROR]
357
370
*/
358
- extern cy_rslt_t cy_rtos_set_semaphore (cy_semaphore_t * semaphore , bool in_isr );
371
+ cy_rslt_t cy_rtos_set_semaphore (cy_semaphore_t * semaphore , bool in_isr );
359
372
360
373
/**
361
374
* Deletes a sempahore
@@ -366,7 +379,7 @@ extern cy_rslt_t cy_rtos_set_semaphore(cy_semaphore_t *semaphore, bool in_isr);
366
379
*
367
380
* @return The status of semaphore deletion [CY_RSLT_SUCCESS, CY_RTOS_NO_MEMORY, CY_RTOS_GENERAL_ERROR]
368
381
*/
369
- extern cy_rslt_t cy_rtos_deinit_semaphore (cy_semaphore_t * semaphore );
382
+ cy_rslt_t cy_rtos_deinit_semaphore (cy_semaphore_t * semaphore );
370
383
371
384
/** \} group_abstraction_rtos_semaphore */
372
385
@@ -387,7 +400,7 @@ extern cy_rslt_t cy_rtos_deinit_semaphore(cy_semaphore_t *semaphore);
387
400
* @return The status of the event initialization request.
388
401
* [CY_RSLT_SUCCESS, CY_RTOS_NO_MEMORY, CY_RTOS_GENERAL_ERROR]
389
402
*/
390
- extern cy_rslt_t cy_rtos_init_event (cy_event_t * event );
403
+ cy_rslt_t cy_rtos_init_event (cy_event_t * event );
391
404
392
405
/** Set the event flag bits.
393
406
*
@@ -400,7 +413,7 @@ extern cy_rslt_t cy_rtos_init_event(cy_event_t *event);
400
413
*
401
414
* @return The status of the set request. [CY_RSLT_SUCCESS, CY_RTOS_NO_MEMORY, CY_RTOS_GENERAL_ERROR]
402
415
*/
403
- extern cy_rslt_t cy_rtos_setbits_event (cy_event_t * event , uint32_t bits , bool in_isr ) ;
416
+ cy_rslt_t cy_rtos_setbits_event (cy_event_t * event , uint32_t bits , bool in_isr ) ;
404
417
405
418
/**
406
419
* Clear the event flag bits
@@ -413,7 +426,7 @@ extern cy_rslt_t cy_rtos_setbits_event(cy_event_t *event, uint32_t bits, bool in
413
426
*
414
427
* @return The status of the clear flags request. [CY_RSLT_SUCCESS, CY_RTOS_NO_MEMORY, CY_RTOS_GENERAL_ERROR]
415
428
*/
416
- extern cy_rslt_t cy_rtos_clearbits_event (cy_event_t * event , uint32_t bits , bool in_isr ) ;
429
+ cy_rslt_t cy_rtos_clearbits_event (cy_event_t * event , uint32_t bits , bool in_isr ) ;
417
430
418
431
/** Get the event bits.
419
432
*
@@ -424,7 +437,7 @@ extern cy_rslt_t cy_rtos_clearbits_event(cy_event_t *event, uint32_t bits, bool
424
437
*
425
438
* @return The status of the get request. [CY_RSLT_SUCCESS, CY_RTOS_NO_MEMORY, CY_RTOS_GENERAL_ERROR]
426
439
*/
427
- extern cy_rslt_t cy_rtos_getbits_event (cy_event_t * event , uint32_t * bits );
440
+ cy_rslt_t cy_rtos_getbits_event (cy_event_t * event , uint32_t * bits );
428
441
429
442
/** Wait for the event and return bits.
430
443
*
@@ -442,7 +455,7 @@ extern cy_rslt_t cy_rtos_getbits_event(cy_event_t *event, uint32_t *bits);
442
455
*
443
456
* @return The status of the wait for event request. [CY_RSLT_SUCCESS, CY_RTOS_NO_MEMORY, CY_RTOS_GENERAL_ERROR]
444
457
*/
445
- extern cy_rslt_t cy_rtos_waitbits_event (cy_event_t * event , uint32_t * bits , bool clear , bool all , cy_time_t timeout );
458
+ cy_rslt_t cy_rtos_waitbits_event (cy_event_t * event , uint32_t * bits , bool clear , bool all , cy_time_t timeout );
446
459
447
460
/** Deinitialize a event.
448
461
*
@@ -452,7 +465,7 @@ extern cy_rslt_t cy_rtos_waitbits_event(cy_event_t *event, uint32_t *bits, bool
452
465
*
453
466
* @return The status of the deletion request. [CY_RSLT_SUCCESS, CY_RTOS_GENERAL_ERROR]
454
467
*/
455
- extern cy_rslt_t cy_rtos_deinit_event (cy_event_t * event );
468
+ cy_rslt_t cy_rtos_deinit_event (cy_event_t * event );
456
469
457
470
/** \} group_abstraction_rtos_event */
458
471
@@ -474,7 +487,7 @@ extern cy_rslt_t cy_rtos_deinit_event(cy_event_t *event);
474
487
*
475
488
* @return The status of the creation request. [CY_RSLT_SUCCESS, CY_RTOS_NO_MEMORY, CY_RTOS_GENERAL_ERROR]
476
489
*/
477
- extern cy_rslt_t cy_rtos_init_queue (cy_queue_t * queue , size_t length , size_t itemsize );
490
+ cy_rslt_t cy_rtos_init_queue (cy_queue_t * queue , size_t length , size_t itemsize );
478
491
479
492
/** Put an item in a queue.
480
493
*
@@ -491,7 +504,7 @@ extern cy_rslt_t cy_rtos_init_queue(cy_queue_t *queue, size_t length, size_t ite
491
504
*
492
505
* @return The status of the creation request. [CY_RSLT_SUCCESS, CY_RTOS_NO_MEMORY, CY_RTOS_GENERAL_ERROR, CY_RTOS_QUEUE_FULL]
493
506
*/
494
- extern cy_rslt_t cy_rtos_put_queue (cy_queue_t * queue , const void * item_ptr , cy_time_t timeout_ms , bool in_isr );
507
+ cy_rslt_t cy_rtos_put_queue (cy_queue_t * queue , const void * item_ptr , cy_time_t timeout_ms , bool in_isr );
495
508
496
509
/** Gets an item in a queue.
497
510
*
@@ -508,7 +521,7 @@ extern cy_rslt_t cy_rtos_put_queue(cy_queue_t *queue, const void *item_ptr, cy_t
508
521
*
509
522
* @return The status of the creation request. [CY_RSLT_SUCCESS, CY_RTOS_NO_MEMORY, CY_RTOS_GENERAL_ERROR, CY_RTOS_QUEUE_EMPTY]
510
523
*/
511
- extern cy_rslt_t cy_rtos_get_queue (cy_queue_t * queue , void * item_ptr , cy_time_t timeout_ms , bool in_isr );
524
+ cy_rslt_t cy_rtos_get_queue (cy_queue_t * queue , void * item_ptr , cy_time_t timeout_ms , bool in_isr );
512
525
513
526
/** Return the number of items in the queue.
514
527
*
@@ -519,7 +532,7 @@ extern cy_rslt_t cy_rtos_get_queue(cy_queue_t *queue, void *item_ptr, cy_time_t
519
532
*
520
533
* @return The status of the creation request. [CY_RSLT_SUCCESS, CY_RTOS_GENERAL_ERROR]
521
534
*/
522
- extern cy_rslt_t cy_rtos_count_queue (cy_queue_t * queue , size_t * num_waiting );
535
+ cy_rslt_t cy_rtos_count_queue (cy_queue_t * queue , size_t * num_waiting );
523
536
524
537
/** Return the amount of empty space in the queue.
525
538
*
@@ -532,7 +545,7 @@ extern cy_rslt_t cy_rtos_count_queue(cy_queue_t *queue, size_t *num_waiting);
532
545
*
533
546
* @return The status of the creation request. [CY_RSLT_SUCCESS, CY_RTOS_GENERAL_ERROR]
534
547
*/
535
- extern cy_rslt_t cy_rtos_space_queue (cy_queue_t * queue , size_t * num_spaces );
548
+ cy_rslt_t cy_rtos_space_queue (cy_queue_t * queue , size_t * num_spaces );
536
549
537
550
/** Reset the queue.
538
551
*
@@ -542,7 +555,7 @@ extern cy_rslt_t cy_rtos_space_queue(cy_queue_t *queue, size_t *num_spaces);
542
555
*
543
556
* @return The status of the creation request. [CY_RSLT_SUCCESS, CY_RTOS_GENERAL_ERROR]
544
557
*/
545
- extern cy_rslt_t cy_rtos_reset_queue (cy_queue_t * queue );
558
+ cy_rslt_t cy_rtos_reset_queue (cy_queue_t * queue );
546
559
547
560
/** Deinitialize the queue handle.
548
561
*
@@ -553,7 +566,7 @@ extern cy_rslt_t cy_rtos_reset_queue(cy_queue_t *queue);
553
566
*
554
567
* @return The status of the creation request. [CY_RSLT_SUCCESS, CY_RTOS_GENERAL_ERROR]
555
568
*/
556
- extern cy_rslt_t cy_rtos_deinit_queue (cy_queue_t * queue );
569
+ cy_rslt_t cy_rtos_deinit_queue (cy_queue_t * queue );
557
570
558
571
/** \} group_abstraction_rtos_queue */
559
572
@@ -576,7 +589,7 @@ extern cy_rslt_t cy_rtos_deinit_queue(cy_queue_t *queue);
576
589
*
577
590
* @return The status of the creation request. [CY_RSLT_SUCCESS, CY_RTOS_GENERAL_ERROR]
578
591
*/
579
- extern cy_rslt_t cy_rtos_init_timer (cy_timer_t * timer , cy_timer_trigger_type_t type ,
592
+ cy_rslt_t cy_rtos_init_timer (cy_timer_t * timer , cy_timer_trigger_type_t type ,
580
593
cy_timer_callback_t fun , cy_timer_callback_arg_t arg );
581
594
582
595
/** Start a timer.
@@ -588,15 +601,15 @@ extern cy_rslt_t cy_rtos_init_timer(cy_timer_t *timer, cy_timer_trigger_type_t t
588
601
*
589
602
* @return The status of the creation request. [CY_RSLT_SUCCESS, CY_RTOS_GENERAL_ERROR]
590
603
*/
591
- extern cy_rslt_t cy_rtos_start_timer (cy_timer_t * timer , cy_time_t num_ms );
604
+ cy_rslt_t cy_rtos_start_timer (cy_timer_t * timer , cy_time_t num_ms );
592
605
593
606
/** Stop a timer.
594
607
*
595
608
* @param[in] timer Pointer to the timer handle
596
609
*
597
610
* @return The status of the creation request. [CY_RSLT_SUCCESS, CY_RTOS_GENERAL_ERROR]
598
611
*/
599
- extern cy_rslt_t cy_rtos_stop_timer (cy_timer_t * timer );
612
+ cy_rslt_t cy_rtos_stop_timer (cy_timer_t * timer );
600
613
601
614
/** Returns state of a timer.
602
615
*
@@ -605,7 +618,7 @@ extern cy_rslt_t cy_rtos_stop_timer(cy_timer_t *timer);
605
618
*
606
619
* @return The status of the creation request. [CY_RSLT_SUCCESS, CY_RTOS_GENERAL_ERROR]
607
620
*/
608
- extern cy_rslt_t cy_rtos_is_running_timer (cy_timer_t * timer , bool * state );
621
+ cy_rslt_t cy_rtos_is_running_timer (cy_timer_t * timer , bool * state );
609
622
610
623
/** Deinit the timer.
611
624
*
@@ -616,7 +629,7 @@ extern cy_rslt_t cy_rtos_is_running_timer(cy_timer_t *timer, bool *state);
616
629
*
617
630
* @return The status of the creation request. [CY_RSLT_SUCCESS, CY_RTOS_GENERAL_ERROR]
618
631
*/
619
- extern cy_rslt_t cy_rtos_deinit_timer (cy_timer_t * timer );
632
+ cy_rslt_t cy_rtos_deinit_timer (cy_timer_t * timer );
620
633
621
634
/** \} group_abstraction_rtos_timer */
622
635
@@ -635,7 +648,7 @@ extern cy_rslt_t cy_rtos_deinit_timer(cy_timer_t *timer);
635
648
*
636
649
* @returns Time in milliseconds since the RTOS started.
637
650
*/
638
- extern cy_rslt_t cy_rtos_get_time (cy_time_t * tval );
651
+ cy_rslt_t cy_rtos_get_time (cy_time_t * tval );
639
652
640
653
/** Delay for a number of milliseconds.
641
654
*
@@ -648,7 +661,7 @@ extern cy_rslt_t cy_rtos_get_time(cy_time_t *tval);
648
661
*
649
662
* @return The status of the creation request. [CY_RSLT_SUCCESS, CY_RTOS_GENERAL_ERROR]
650
663
*/
651
- extern cy_rslt_t cy_rtos_delay_milliseconds (cy_time_t num_ms );
664
+ cy_rslt_t cy_rtos_delay_milliseconds (cy_time_t num_ms );
652
665
653
666
/** \} group_abstraction_rtos_timer */
654
667
0 commit comments