AFBR-S50 API Reference Manual v1.5.6
AFBR-S50 Time-of-Flight Sensor SDK for Embedded Software
Loading...
Searching...
No Matches
explorer_tasks.c File Reference

This file is part of the AFBR-S50 Explorer Demo Application. More...

#include "core/core_device.h"
#include "core/core_cfg.h"
#include "core/explorer_config.h"
#include "api/explorer_api.h"
#include "explorer_tasks.h"
#include "explorer_app.h"
#include "argus.h"
#include "sci/sci.h"
#include "tasks/task_scheduler.h"
#include "debug.h"
#include <assert.h>
#include <string.h>
Include dependency graph for explorer_tasks.c:

Macros

#define ARGUSRESULTBUFFER_SIZE   (2U * EXPLORER_DEVICE_COUNT)
 
#define EVENTQ_SIZE   (2U + 2U * EXPLORER_DEVICE_COUNT)
 
#define PING_PERIOD_MS   333U
 

Enumerations

enum  buffer_status_t {
  BUFFER_EMTPY = 0 ,
  BUFFER_BUSY = 1 ,
  BUFFER_FULL = 2 ,
  BUFFER_ERROR = -1
}
 

Functions

static void Task_EvaluateMeasurementData (argus_hnd_t *argus)
 
static void Task_SendMeasurementData (argus_resultsbuffer_t *buffer)
 
static void Task_HandleCommand (sci_frame_t *frame)
 
static void Task_Error (error_event_t *e)
 
static void Task_Idle (idle_event_t *e)
 
static status_t SCI_RxCommandCallbackHandler (sci_frame_t *cmd)
 
static void SCI_ErrorCallbackHandler (status_t status)
 
status_t ExplorerApp_InitTasks ()
 Initializes the scheduler tasks.
 
void ExplorerApp_Run (void)
 This runs the state machine.
 
void ExplorerApp_SwitchContext (void)
 Switches the scheduler task context.
 
static status_t OnError (status_t status, char *message)
 
status_t ExplorerApp_MeasurementReadyCallback (status_t status, argus_hnd_t *argus)
 Callback function after measurement cycle was finished.
 

Variables

static scheduler_t * myScheduler = NULL
 
static task_event_t EventQ_Error [EVENTQ_SIZE] = {0}
 
static task_event_t EventQ_Idle [EVENTQ_SIZE] = {0}
 
static task_event_t EventQ_SendResults [EVENTQ_SIZE] = {0}
 
static task_event_t EventQ_EvalData [EVENTQ_SIZE] = {0}
 
static task_event_t EventQ_HandleCommand [2 *EVENTQ_SIZE] = {0}
 

Detailed Description

This file is part of the AFBR-S50 Explorer Demo Application.

This file contains the main functionality of the Explorer Application.

Copyright (c) 2023, Broadcom Inc. All rights reserved.

Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:

  1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.
  2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution.
  3. Neither the name of the copyright holder nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission.

THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

Macro Definition Documentation

◆ ARGUSRESULTBUFFER_SIZE

#define ARGUSRESULTBUFFER_SIZE   (2U * EXPLORER_DEVICE_COUNT)

Size of the Argus results data buffer.

◆ EVENTQ_SIZE

#define EVENTQ_SIZE   (2U + 2U * EXPLORER_DEVICE_COUNT)

Size of the event queue.

◆ PING_PERIOD_MS

#define PING_PERIOD_MS   333U

The period to trigger a SPI ping signal to the device.

Enumeration Type Documentation

◆ buffer_status_t

Buffer status type.

Enumerator
BUFFER_EMTPY 

Data buffer empty. Ready to write.

BUFFER_BUSY 

Data buffer is currently processed.

BUFFER_FULL 

Data buffer is full. Ready to read.

BUFFER_ERROR 

An error occurred and needs to be handled.

Function Documentation

◆ OnError()

static status_t OnError ( status_t  status,
char *  message 
)
static

◆ SCI_ErrorCallbackHandler()

static void SCI_ErrorCallbackHandler ( status_t  status)
static

Callback function for error occurred within the SCI/UART module.

◆ SCI_RxCommandCallbackHandler()

static status_t SCI_RxCommandCallbackHandler ( sci_frame_t cmd)
static

Callback function for new command received from SCI module.

◆ Task_Error()

static void Task_Error ( error_event_t *  e)
static

◆ Task_EvaluateMeasurementData()

static void Task_EvaluateMeasurementData ( argus_hnd_t argus)
static

◆ Task_HandleCommand()

static void Task_HandleCommand ( sci_frame_t frame)
static

◆ Task_Idle()

static void Task_Idle ( idle_event_t *  e)
static

◆ Task_SendMeasurementData()

static void Task_SendMeasurementData ( argus_resultsbuffer_t *  buffer)
static

Variable Documentation

◆ EventQ_Error

task_event_t EventQ_Error[EVENTQ_SIZE] = {0}
static

◆ EventQ_EvalData

task_event_t EventQ_EvalData[EVENTQ_SIZE] = {0}
static

◆ EventQ_HandleCommand

task_event_t EventQ_HandleCommand[2 *EVENTQ_SIZE] = {0}
static

◆ EventQ_Idle

task_event_t EventQ_Idle[EVENTQ_SIZE] = {0}
static

◆ EventQ_SendResults

task_event_t EventQ_SendResults[EVENTQ_SIZE] = {0}
static

◆ myScheduler

scheduler_t* myScheduler = NULL
static