/** * @brief Initialize the standard part of a @p MACDriver structure. * * @param[out] macp pointer to the @p MACDriver object * * @init */ void macObjectInit(MACDriver *macp) { macp->state = MAC_STOP; macp->config = NULL; osalThreadQueueObjectInit(&macp->tdqueue); osalThreadQueueObjectInit(&macp->rdqueue); #if MAC_USE_EVENTS == TRUE osalEventObjectInit(&macp->rdevent); #endif }
/** * @brief Initializes the standard part of a @p CANDriver structure. * * @param[out] canp pointer to the @p CANDriver object * * @init */ void canObjectInit(CANDriver *canp) { canp->state = CAN_STOP; canp->config = NULL; osalThreadQueueObjectInit(&canp->txqueue); osalThreadQueueObjectInit(&canp->rxqueue); osalEventObjectInit(&canp->rxfull_event); osalEventObjectInit(&canp->txempty_event); osalEventObjectInit(&canp->error_event); #if CAN_USE_SLEEP_MODE == TRUE osalEventObjectInit(&canp->sleep_event); osalEventObjectInit(&canp->wakeup_event); #endif }
/** * @brief Initializes an input queue. * @details A Semaphore is internally initialized and works as a counter of * the bytes contained in the queue. * @note The callback is invoked from within the S-Locked system state. * * @param[out] iqp pointer to an @p input_queue_t structure * @param[in] bp pointer to a memory area allocated as queue buffer * @param[in] size size of the queue buffer * @param[in] infy pointer to a callback function that is invoked when * data is read from the queue. The value can be @p NULL. * @param[in] link application defined pointer * * @init */ void iqObjectInit(input_queue_t *iqp, uint8_t *bp, size_t size, qnotify_t infy, void *link) { osalThreadQueueObjectInit(&iqp->q_waiting); iqp->q_counter = 0; iqp->q_buffer = bp; iqp->q_rdptr = bp; iqp->q_wrptr = bp; iqp->q_top = bp + size; iqp->q_notify = infy; iqp->q_link = link; }
/** * @brief Initializes an output queue. * @details A Semaphore is internally initialized and works as a counter of * the free bytes in the queue. * @note The callback is invoked from within the S-Locked system state. * * @param[out] oqp pointer to an @p output_queue_t structure * @param[in] bp pointer to a memory area allocated as queue buffer * @param[in] size size of the queue buffer * @param[in] onfy pointer to a callback function that is invoked when * data is written to the queue. The value can be @p NULL. * @param[in] link application defined pointer * * @init */ void oqObjectInit(output_queue_t *oqp, uint8_t *bp, size_t size, qnotify_t onfy, void *link) { osalThreadQueueObjectInit(&oqp->q_waiting); oqp->q_counter = size; oqp->q_buffer = bp; oqp->q_rdptr = bp; oqp->q_wrptr = bp; oqp->q_top = bp + size; oqp->q_notify = onfy; oqp->q_link = link; }
/** * @brief Initializes the standard part of a @p CANDriver structure. * * @param[out] canp pointer to the @p CANDriver object * * @init */ void canObjectInit(CANDriver *canp) { canp->state = CAN_STOP; canp->config = NULL; osalThreadQueueObjectInit(&canp->txqueue); osalThreadQueueObjectInit(&canp->rxqueue); #if CAN_ENFORCE_USE_CALLBACKS == FALSE osalEventObjectInit(&canp->rxfull_event); osalEventObjectInit(&canp->txempty_event); osalEventObjectInit(&canp->error_event); #if CAN_USE_SLEEP_MODE == TRUE osalEventObjectInit(&canp->sleep_event); osalEventObjectInit(&canp->wakeup_event); #endif #else /* CAN_ENFORCE_USE_CALLBACKS == TRUE */ canp->rxfull_cb = NULL; canp->txempty_cb = NULL; canp->error_cb = NULL; #if CAN_USE_SLEEP_MODE == TRUE canp->wakeup_cb = NULL; #endif #endif /* CAN_ENFORCE_USE_CALLBACKS == TRUE */ }