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

This file is part of the AFBR-S50 API. More...

#include "utility/int_math.h"
#include <stdbool.h>
#include <assert.h>
Include dependency graph for argus_map.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Macros

#define ARGUS_PIXELS_X   8
 The device pixel field size in x direction (long edge).
 
#define ARGUS_PIXELS_Y   4
 The device pixel field size in y direction (short edge).
 
#define ARGUS_PIXELS   ((ARGUS_PIXELS_X)*(ARGUS_PIXELS_Y))
 The total device pixel count.
 
#define PIXEL_XY2CH(x, y)   ((((y) << 3U) & 0x10U) | (((x) ^ 0x07U) << 1U) | ((y) & 0x01U))
 Macro to determine the pixel ADC channel number from the x-z-indices.
 
#define PIXEL_CH2X(c)   ((((c) >> 1U) ^ 0x07U) & 0x07U)
 Macro to determine the pixel x-index from the ADC channel number.
 
#define PIXEL_CH2Y(c)   ((((c) >> 3U) & 0x02U) | ((c) & 0x01U))
 Macro to determine the pixel y-index from the ADC channel number.
 
#define PIXEL_XY2N(x, y)   (((x) << 2U) | (y))
 Macro to determine the n-index from the x-y-indices.
 
#define PIXEL_N2X(n)   ((n) >> 2U)
 Macro to determine the pixel x-index from the n-index.
 
#define PIXEL_N2Y(n)   ((n) & 0x03U)
 Macro to determine the pixel y-index from the n-index.
 
#define PIXEL_N2CH(n)   ((((n) << 3U) & 0x10U) | ((((n) >> 1U) ^ 0x0EU) & 0x0EU) | ((n) & 0x01U))
 Macro to determine the pixel n-index from the ADC channel number.
 
#define PIXEL_CH2N(c)   (((((c) << 1U) ^ 0x1CU) & 0x1CU) | (((c) >> 3U) & 0x02U) | ((c) & 0x01U))
 Macro to determine the pixel.
 
#define PIXELN_MASK(n)   (0x01U << (n))
 Macro to create a pixel mask given by the pixels n-index.
 
#define PIXELN_ISENABLED(msk, n)   (((msk) >> (n)) & 0x01U)
 Macro to determine if a pixel given by the n-index is enabled in a pixel mask.
 
#define PIXELN_ENABLE(msk, n)   ((msk) |= (PIXELN_MASK(n)))
 Macro to enable a pixel given by the n-index in a pixel mask.
 
#define PIXELN_DISABLE(msk, n)   ((msk) &= (~PIXELN_MASK(n)))
 Macro disable a pixel given by the n-index in a pixel mask.
 
#define PIXELCH_MASK(c)   (0x01U << (PIXEL_CH2N(c)))
 Macro to create a pixel mask given by the pixels ADC channel number.
 
#define PIXELCH_ISENABLED(msk, c)   (PIXELN_ISENABLED(msk, PIXEL_CH2N(c)))
 Macro to determine if an ADC pixel channel is enabled from a pixel mask.
 
#define PIXELCH_ENABLE(msk, c)   (PIXELN_ENABLE(msk, PIXEL_CH2N(c)))
 Macro to enable an ADC pixel channel in a pixel mask.
 
#define PIXELCH_DISABLE(msk, c)   (PIXELN_DISABLE(msk, PIXEL_CH2N(c)))
 Macro to disable an ADC pixel channel in a pixel mask.
 
#define PIXELXY_MASK(x, y)   (0x01U << (PIXEL_XY2N(x, y)))
 Macro to create a pixel mask given by the pixel x-y-indices.
 
#define PIXELXY_ISENABLED(msk, x, y)   (PIXELN_ISENABLED(msk, PIXEL_XY2N(x, y)))
 Macro to determine if a pixel given by the x-y-indices is enabled in a pixel mask.
 
#define PIXELXY_ENABLE(msk, x, y)   (PIXELN_ENABLE(msk, PIXEL_XY2N(x, y)))
 Macro to enable a pixel given by the x-y-indices in a pixel mask.
 
#define PIXELXY_DISABLE(msk, x, y)   (PIXELN_DISABLE(msk, PIXEL_XY2N(x, y)))
 Macro disable a pixel given by the x-y-indices in a pixel mask.
 
#define CHANNELN_ISENABLED(msk, ch)   (((msk) >> ((ch) - 32U)) & 0x01U)
 Macro to determine if an ADC channel is enabled in a channel mask.
 
#define CHANNELN_ENABLE(msk, ch)   ((msk) |= (0x01U << ((ch) - 32U)))
 Macro to determine if an ADC channel is enabled in a channel mask.
 
#define CHANNELN_DISABLE(msk, ch)   ((msk) &= (~(0x01U << ((ch) - 32U))))
 Macro to determine if an ADC channel is disabled in a channel mask.
 
#define PIXEL_COUNT(pxmsk)   popcount(pxmsk)
 Macro to determine the number of enabled pixel/channels in a mask via a popcount algorithm.
 
#define CHANNEL_COUNT(pxmsk, chmsk)   (popcount(pxmsk) + popcount(chmsk))
 Macro to determine the number of enabled channels via a popcount algorithm.
 

Functions

static uint32_t ChannelToPixelMask (uint32_t msk)
 Converts a raw ADC channel mask to a x-y-sorted pixel mask.
 
static uint32_t PixelToChannelMask (uint32_t msk)
 Converts a x-y-sorted pixel mask to a raw ADC channel mask.
 
static uint32_t ShiftSelectedPixels (const uint32_t pixel_mask, const int8_t dx, const int8_t dy, const uint8_t center_y)
 Shifts a pixel mask by a given offset.
 
static uint32_t FillPixelMask (uint32_t pixel_mask, const uint8_t pixel_count, const uint8_t center_x, const uint8_t center_y)
 Fills a pixel mask to a specified number of pixels around a center pixel.
 
static uint32_t GetAdjacentPixelsMask (const uint_fast8_t x, const uint_fast8_t y)
 Fills a pixel mask with the direct neighboring pixels around a pixel.
 

Detailed Description

This file is part of the AFBR-S50 API.

Defines macros to work with pixel and ADC channel masks.

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.