7 #if defined(PIOS_INCLUDE_RCVR)
11 enum pios_rcvr_dev_magic {
12 PIOS_RCVR_DEV_MAGIC = 0x99aabbcc,
15 struct pios_rcvr_dev {
16 enum pios_rcvr_dev_magic
magic;
21 static bool PIOS_RCVR_validate(
struct pios_rcvr_dev * rcvr_dev)
23 return (rcvr_dev->magic == PIOS_RCVR_DEV_MAGIC);
26 static struct pios_rcvr_dev * PIOS_RCVR_alloc(
void)
28 struct pios_rcvr_dev * rcvr_dev;
30 rcvr_dev = (
struct pios_rcvr_dev *)
PIOS_malloc(
sizeof(*rcvr_dev));
31 if (!rcvr_dev)
return (NULL);
33 rcvr_dev->magic = PIOS_RCVR_DEV_MAGIC;
38 static uint32_t rcvr_last_wake;
52 struct pios_rcvr_dev * rcvr_dev;
61 rcvr_dev = (
struct pios_rcvr_dev *) PIOS_RCVR_alloc();
62 if (!rcvr_dev)
goto out_fail;
64 rcvr_dev->driver = driver;
65 rcvr_dev->lower_id = lower_id;
67 *rcvr_id = (uintptr_t)rcvr_dev;
81 struct pios_rcvr_dev *dev = (
struct pios_rcvr_dev*)rcvr_id;
83 if (!PIOS_RCVR_validate(dev))
109 struct pios_rcvr_dev * rcvr_dev = (
struct pios_rcvr_dev *)rcvr_id;
111 if (!PIOS_RCVR_validate(rcvr_dev)) {
118 return rcvr_dev->driver->read(rcvr_dev->lower_id, channel);
121 #define MIN_WAKE_INTERVAL_uS 4000
149 PIOS_Thread_FakeClock_UpdateBarrier(100);
uint32_t PIOS_DELAY_DiffuS(uint32_t raw)
Subtract raw time from now and convert to us.
int32_t PIOS_IRQ_Enable(void)
Main PiOS header to include all the compiled in PiOS options.
#define PIOS_DEBUG_Assert(test)
void * PIOS_malloc(size_t size)
bool PIOS_Semaphore_Give_FromISR(struct pios_semaphore *sema, bool *woken)
void PIOS_RCVR_ActiveFromISR()
int32_t PIOS_RCVR_Init(uintptr_t *rcvr_id, const struct pios_rcvr_driver *driver, const uintptr_t lower_id)
struct pios_semaphore * PIOS_Semaphore_Create(void)
Creates a binary semaphore.
bool PIOS_Semaphore_Give(struct pios_semaphore *sema)
Gives binary semaphore.
uintptr_t PIOS_RCVR_GetLowerDevice(uintptr_t rcvr_id)
int32_t PIOS_IRQ_Disable(void)
void PIOS_Thread_Sleep(uint32_t time_ms)
int32_t PIOS_RCVR_Read(uintptr_t rcvr_id, uint8_t channel)
bool PIOS_Semaphore_Take(struct pios_semaphore *sema, uint32_t timeout_ms)
Takes binary semaphore.
bool PIOS_RCVR_WaitActivity(uint32_t timeout_ms)
#define PIOS_Assert(test)
USART private definitions.
bool PIOS_Thread_FakeClock_IsActive(void)
uint32_t PIOS_DELAY_GetRaw()
Get the raw delay timer, useful for timing.