#include "board/board_config.h"
#include "driver/irq.h"
#ifndef DEVICE_COUNT
#define DEVICE_COUNT 4
#endif
#ifndef SPI_SLAVE1
#define SPI_SLAVE1 (SPI_SLAVE)
#endif
#ifndef SPI_SLAVE2
#define SPI_SLAVE2 (SPI_SLAVE1 + 1)
#endif
#ifndef SPI_SLAVE3
#define SPI_SLAVE3 (SPI_SLAVE2 + 1)
#endif
#ifndef SPI_SLAVE4
#define SPI_SLAVE4 (SPI_SLAVE3 + 1)
#endif
#define FIFO_SIZE 8
typedef struct fifo_t
{
size_t volatile Load;
} fifo_t;
static fifo_t DataReadyEventQueue = { 0 };
{
return device;
}
{
(void)device;
assert(DataReadyEventQueue.Load < FIFO_SIZE);
*DataReadyEventQueue.WrPtr = device;
DataReadyEventQueue.WrPtr++;
if (DataReadyEventQueue.WrPtr >= DataReadyEventQueue.Buffer + FIFO_SIZE)
DataReadyEventQueue.WrPtr = DataReadyEventQueue.Buffer;
DataReadyEventQueue.Load++;
}
{
print(
"#%06d: %4d.%06d s; Range: %5d mm; Amplitude: %4d LSB; Quality: %3d; Status: %d\n",
id,
}
{
const uint8_t a = (uint8_t)((value >> 24) & 0xFFU);
const uint8_t b = (uint8_t)((value >> 16) & 0xFFU);
const uint8_t c = (uint8_t)(value & 0xFFFFU);
print(
"\n##### AFBR-S50 API - Multi-Device Example #####################\n"
" API Version: v%d.%d.%d\n", a, b, c);
for (uint8_t d = 0; d < device_count; d++)
{
print(
" Chip ID #%d: %d\n"
" Module #%d: %s\n",
d + 1, id, d + 1, m);
}
print(
"###############################################################\n\n");
}
{
HardwareInit();
const s2pi_slave_t slaves[] = { SPI_SLAVE1, SPI_SLAVE2, SPI_SLAVE3, SPI_SLAVE4 };
DataReadyEventQueue.WrPtr = DataReadyEventQueue.Buffer;
DataReadyEventQueue.RdPtr = DataReadyEventQueue.Buffer;
DataReadyEventQueue.Load = 0;
for (uint8_t d = 0; d < DEVICE_COUNT; d++)
{
}
for (uint8_t d = 0; d < DEVICE_COUNT; d++)
{
}
for (;;)
{
if (DataReadyEventQueue.Load > 0)
{
DataReadyEventQueue.Load--;
DataReadyEventQueue.RdPtr++;
if (DataReadyEventQueue.RdPtr >= DataReadyEventQueue.Buffer + FIFO_SIZE)
DataReadyEventQueue.RdPtr = DataReadyEventQueue.Buffer;
}
}
}