/** * Send a message on a queue. * * Send / queue a message. * This service may panic if err parameter is NULL and: * -# queue parameter is invalid, or * -# the queue is already full, or * * Authorized execution levels: task, fiber, ISR. * * @param queue: handler on the queue (value returned by queue_create). * * @param message (in): pointer to the message to send. * * @param err (out): execution status: * -# E_OS_OK : a message was read * -# E_OS_ERR_OVERFLOW: the queue is full (message was not posted) * -# E_OS_ERR: invalid parameter */ void queue_send_message(T_QUEUE queue, T_QUEUE_MESSAGE message, OS_ERR_TYPE* err ) { OS_ERR_TYPE _err; queue_impl_t * q = (queue_impl_t*) queue; /* check input parameters */ if( queue_used(q) && q->sema != NULL ) { uint32_t it_mask = interrupt_lock(); _err = add_data(q, message); interrupt_unlock(it_mask); if(_err == E_OS_OK) { semaphore_give(q->sema, &_err); // signal new message in the queue to the listener. error_management (err, E_OS_OK); } else { error_management (err, _err); } } else { /* param invalid */ error_management (err, E_OS_ERR); } return; }
void i2c_task(void *params) { I2COperation op; while (TRUE) { state = I2C_STATE_IDLE; queue_peek(op_queue, &op, PORT_MAX_DELAY); // do operation here semaphore_give(op_signal); queue_receive(op_queue, &op, 0); } }
static void sensor_bus_callback_sleep(struct sba_request *req) { struct sensor_sba_req *sensor_req = (struct sensor_sba_req *)req; semaphore_give(sensor_req->sem, NULL); }
static void apds_sba_completion_callback(struct sba_request *req) { /* Give led sba semaphore to notify that the i2c transfer is complete */ semaphore_give((T_SEMAPHORE)(req->priv_data), NULL); }