Part Number: AM6442
Hello,
I try to access the PRU_ICSSG Spinlocks (of the AM6442 ) to protect a critical path that is shared between PRU 0 and PRU1.
The code I'm using right now is:
#define SPINLOCK_DEV 0x90 /* PRU XFR Device für Spinlocks */
#define BASE_REGISTER 1
#define USE_REMAPPING 0
static inline void spinlock_acquire(uint8_t lock_id) {
uint32_t obj = lock_id & 0x3FU;
do {
__xin(SPINLOCK_DEV, BASE_REGISTER, USE_REMAPPING, obj);
// result bit is in R1.b3
if (((obj >> 24) & 0x01) == 1) {
//acquired
return;
}
// not acquired
} while (1);
}
static inline void spinlock_release(uint8_t lock_id) {
uint32_t obj = (lock_id & 0x3F) << 24; // why do I have to shift here???
__xout(SPINLOCK_DEV, BASE_REGISTER, USE_REMAPPING, obj);
}
The question is alread in the code: I have no idea, why I need to shift to release the lock. If I don't shift, it doesn't work. Maybe I just misunderstand Table 6-98 (p632) in the TRM, but the comment states: "This assertion will clear the flag selected by R1.b0/own_req_vector".
Also I find it very difficult to find (C-) sample code for that topic.
Thank you for your help!
