Advertisement
Guest User

SPINLOCK.H

a guest
Nov 9th, 2015
245
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 0.93 KB | None | 0 0
  1. //this is Coto's spinlock , requires spinlock_sched() to be glued to some kind of irq trigger so it runs regardless the main program core.
  2.  
  3. #ifndef SPINLOCK_COTO
  4. #define SPINLOCK_COTO
  5.    
  6. #define spinlock_elements (10)
  7. #define spinlock_linearelements (spinlock_elements-1)
  8.  
  9. #define NULL_VAR 0
  10.  
  11. //spinlock example
  12.  
  13. typedef volatile struct{
  14.     u8 spinlock_id;
  15.     u8 status;  //0 unlocked | 1 locked
  16.     u32 func_ptr;  
  17. } spinlock_table;
  18.  
  19. typedef u32 (*u32cback_ptr)();
  20.  
  21. #endif
  22.  
  23. #ifdef __cplusplus
  24. extern "C" {
  25. #endif
  26.  
  27. extern u32 __attribute__ ((hot)) spinlock_sched();
  28. extern u32 spinlock_perm(u8 process_id,u8 status);
  29. extern u32 spinlock_createproc(u8 process_id,u8 status,u32cback_ptr new_callback);
  30. extern u32 spinlock_modifyproc(u8 process_id,u8 status,u32cback_ptr new_callback);
  31. extern u32 spinlock_deleteproc(u8 process_id);
  32.  
  33. extern volatile spinlock_table spinlock_handler[spinlock_elements];
  34.  
  35. #ifdef __cplusplus
  36. }
  37. #endif
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement