Basic mathematical and logical operations
This resource provides basic operations not supported by the programming language itself. This includes:
// Read the sensor value, LSB first and then MSB in a 16-bit SPI RX operation U16 temp; spiCfg(SPI_POL0_PHA0, 6); spiBegin(AUXIO_SPI_CSN_SENSOR); spiTx8bit(0x42); spiRx16bit(temp); spiEnd(AUXIO_SPI_CSN_SENSOR); // Swap endianess, store to the ring buffer and increment the ring buffer position U16 n = state.bufferPos; utilSwapEndianess(temp; output.pBuffer[n]); utilIncrAndWrap(n, BUFFER_SIZE; state.bufferPos);
U16 value = ...; // Find the correct histogram bin counter U16* pBinCounter; if (value > 1000) { pBinCounter = #output.highCount; } else { pBinCounter = #output.lowCount; } // Increment the histogram bin counter, saturating at 50000 utilIncrAndSat(*pBinCounter, 50000; *pBinCounter);
None.
None.
Prototype: utilIncrAndSat(value, #sat; incrValue)
Increments a variable, saturating at the specified value
Prototype: utilIncrAndWrap(value, #wrap; incrValue)
Increments a variable, wrapping to 0 at the specified value.
Prototype: utilSwapEndianess(initialValue; swappedValue)
Swaps the most and least significant bytes in a variable.