本文整理汇总了C++中SANITY_CHECK函数的典型用法代码示例。如果您正苦于以下问题:C++ SANITY_CHECK函数的具体用法?C++ SANITY_CHECK怎么用?C++ SANITY_CHECK使用的例子?那么, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了SANITY_CHECK函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: TWI_DisableIt
/**
* \brief Disables the selected interrupts sources on a TWI peripheral.
* \param pTwi Pointer to an Twi instance.
* \param sources Bitwise OR of selected interrupt sources.
*/
void TWI_DisableIt(Twi *pTwi, uint32_t sources)
{
SANITY_CHECK(pTwi);
SANITY_CHECK((sources & 0xFFFFF088) == 0);
pTwi->TWI_IDR = sources;
}
示例2: TWI_DisableIt
//-----------------------------------------------------------------------------
/// Disables the selected interrupts sources on a TWI peripheral.
/// \param pTwi Pointer to an AT91S_TWI instance.
/// \param sources Bitwise OR of selected interrupt sources.
//-----------------------------------------------------------------------------
void TWI_DisableIt(AT91S_TWI *pTwi, unsigned int sources)
{
SANITY_CHECK(pTwi);
SANITY_CHECK((sources & 0xFFFFFEF8) == 0);
pTwi->TWI_IDR = sources;
}
示例3: AT45D_Write
//------------------------------------------------------------------------------
/// Writes data on the At45 at the specified address. Only one page of
/// data is written that way; if the address is not at the beginning of the
/// page, the data is written starting from this address and wraps around to
/// the beginning of the page.
/// \param pAt45 Pointer to a At45 driver instance.
/// \param pBuffer Buffer containing the data to write.
/// \param size Number of bytes to write.
/// \param address Destination address on the At45.
//------------------------------------------------------------------------------
void AT45D_Write(
At45 *pAt45,
unsigned char *pBuffer,
unsigned int size,
unsigned int address)
{
unsigned char error;
SANITY_CHECK(pAt45);
SANITY_CHECK(pBuffer);
SANITY_CHECK(size <= pAt45->pDesc->pageSize);
// Issue a page write through buffer 1 command
error = AT45_SendCommand(pAt45, AT45_PAGE_WRITE_BUF1, 4, pBuffer, size, address, 0, 0);
ASSERT(!error, "-F- AT45_Write: Could not issue command.\n\r");
// Wait until the command is sent
while (AT45_IsBusy(pAt45)) {
AT45D_Wait(pAt45);
}
// Wait until the At45 becomes ready again
AT45D_WaitReady(pAt45);
}
示例4: TDES_SetInputBuffer
//------------------------------------------------------------------------------
/// Sets the input data buffer to encrypt/decrypt when in PDC mode.
/// \param pInput Pointer to the input data.
/// \param size Size of buffer in bytes.
//------------------------------------------------------------------------------
void TDES_SetInputBuffer(const unsigned int *pInput, unsigned int size)
{
trace_LOG(trace_DEBUG, "-D- TDES_SetInputBuffer()\n\r");
SANITY_CHECK(pInput);
SANITY_CHECK((size > 0) && ((size % 8) == 0));
AT91C_BASE_TDES->TDES_TPR = (unsigned int) pInput;
AT91C_BASE_TDES->TDES_TCR = size / 4;
}
示例5: TDES_SetOutputBuffer
//------------------------------------------------------------------------------
/// Sets the output buffer which will receive the encrypted/decrypted data when
/// using the PDC.
/// \param pOutput Pointer to the output data.
/// \param size Size of buffer in bytes.
//------------------------------------------------------------------------------
void TDES_SetOutputBuffer(unsigned int *pOutput, unsigned int size)
{
trace_LOG(trace_DEBUG, "-D- TDES_SetOutputBuffer()\n\r");
SANITY_CHECK(pOutput);
SANITY_CHECK((size > 0) && ((size % 8) == 0));
AT91C_BASE_TDES->TDES_RPR = (unsigned int) pOutput;
AT91C_BASE_TDES->TDES_RCR = size / 4;
}
示例6: TWID_Initialize
//------------------------------------------------------------------------------
/// Initializes a TWI driver instance, using the given TWI peripheral. The
/// peripheral must have been initialized properly before calling this function.
/// \param pTwid Pointer to the Twid instance to initialize.
/// \param pTwi Pointer to the TWI peripheral to use.
//------------------------------------------------------------------------------
void TWID_Initialize(Twid *pTwid, AT91S_TWI *pTwi)
{
TRACE_DEBUG("TWID_Initialize()\n\r");
SANITY_CHECK(pTwid);
SANITY_CHECK(pTwi);
// Initialize driver
pTwid->pTwi = pTwi;
pTwid->pTransfer = 0;
}
示例7: decodeNotificationSpecImageHint
static QImage decodeNotificationSpecImageHint(const QDBusArgument& arg)
{
int width, height, rowStride, hasAlpha, bitsPerSample, channels;
QByteArray pixels;
char* ptr;
char* end;
arg.beginStructure();
arg >> width >> height >> rowStride >> hasAlpha >> bitsPerSample >> channels >> pixels;
arg.endStructure();
//qDebug() << width << height << rowStride << hasAlpha << bitsPerSample << channels;
#define SANITY_CHECK(condition) \
if (!(condition)) { \
qWarning() << "Sanity check failed on" << #condition; \
return QImage(); \
}
SANITY_CHECK(width > 0);
SANITY_CHECK(width < 2048);
SANITY_CHECK(height > 0);
SANITY_CHECK(height < 2048);
SANITY_CHECK(rowStride > 0);
#undef SANITY_CHECK
QImage::Format format = QImage::Format_Invalid;
void (*fcn)(QRgb*, const char*, int) = 0;
if (bitsPerSample == 8) {
if (channels == 4) {
format = QImage::Format_ARGB32;
fcn = copyLineARGB32;
} else if (channels == 3) {
format = QImage::Format_RGB32;
fcn = copyLineRGB32;
}
}
if (format == QImage::Format_Invalid) {
qWarning() << "Unsupported image format (hasAlpha:" << hasAlpha << "bitsPerSample:" << bitsPerSample << "channels:" << channels << ")";
return QImage();
}
QImage image(width, height, format);
ptr = pixels.data();
end = ptr + pixels.length();
for (int y=0; y<height; ++y, ptr += rowStride) {
if (ptr + channels * width > end) {
qWarning() << "Image data is incomplete. y:" << y << "height:" << height;
break;
}
fcn((QRgb*)image.scanLine(y), ptr, width);
}
return image;
}
示例8: adc_spi_cb
void adc_spi_cb(void)
{
if(gAdcDesc.state==ADC_SPI)
{
gAdcDesc.buf_wr=(gAdcDesc.buf_wr+1)%ADC_BUFSIZE;
SANITY_CHECK(gAdcDesc.buf_wr!=gAdcDesc.buf_rd);
gAdcDesc.state=ADC_PIO;
}
else
SANITY_CHECK(gAdcDesc.state==ADC_IDLE);
}
示例9: MCI_SetBusWidth
//------------------------------------------------------------------------------
/// Configure the MCI SDCBUS in the MCI_SDCR register. Only two modes available
///
/// \param pMci Pointer to the low level MCI driver.
/// \param busWidth MCI bus width mode.
//------------------------------------------------------------------------------
void MCI_SetBusWidth(Mci *pMci, unsigned char busWidth)
{
AT91S_MCI *pMciHw = pMci->pMciHw;
unsigned int mciSdcr;
SANITY_CHECK(pMci);
SANITY_CHECK(pMci->pMciHw);
mciSdcr = (READ_MCI(pMciHw, MCI_SDCR) & ~(AT91C_MCI_SCDBUS));
WRITE_MCI(pMciHw, MCI_SDCR, mciSdcr | busWidth);
}
示例10: FLASHD_IsLocked
//------------------------------------------------------------------------------
/// Returns the number of locked regions inside the given address range.
/// \param start Start address of range.
/// \param end End address of range.
//------------------------------------------------------------------------------
unsigned char FLASHD_IsLocked(unsigned int start, unsigned int end)
{
AT91S_EFC *pEfc;
unsigned short startPage, endPage;
unsigned char startRegion, endRegion;
unsigned int numPagesInRegion;
unsigned int status;
unsigned char error;
unsigned int numLockedRegions = 0;
SANITY_CHECK(end >= start);
#ifdef AT91C_BASE_EFC1
// Convert wrapped address to physical address.
start &= 0x19FFFF;
end &= 0x19FFFF;
// Check EFC crossover 2 bank
SANITY_CHECK(((start >=AT91C_IFLASH) && (end <= AT91C_IFLASH + AT91C_IFLASH_SIZE))
|| ((start >=AT91C_IFLASH1) && (end <= AT91C_IFLASH1 + AT91C_IFLASH1_SIZE)));
#else
SANITY_CHECK((start >=AT91C_IFLASH) && (end <= AT91C_IFLASH + AT91C_IFLASH_SIZE));
#endif
// Compute page numbers
EFC_TranslateAddress(&pEfc, start, &startPage, 0);
EFC_TranslateAddress(0, end, &endPage, 0);
// Compute region numbers
numPagesInRegion = AT91C_IFLASH_LOCK_REGION_SIZE / AT91C_IFLASH_PAGE_SIZE;
startRegion = startPage / numPagesInRegion;
endRegion = endPage / numPagesInRegion;
if ((endPage % numPagesInRegion) != 0) {
endRegion++;
}
// Retrieve lock status
error = EFC_PerformCommand(pEfc, AT91C_EFC_FCMD_GLB, 0);
ASSERT(!error, "-F- Error while trying to fetch lock bits status (0x%02X)\r\n", error);
status = EFC_GetResult(pEfc);
// Check status of each involved region
while (startRegion < endRegion) {
if ((status & (1 << startRegion)) != 0) {
numLockedRegions++;
}
startRegion++;
}
return numLockedRegions;
}
示例11: MCI_Enable
//------------------------------------------------------------------------------
/// Enable/disable a MCI driver instance.
/// \param pMci Pointer to a MCI driver instance.
/// \param enb 0 for disable MCI and 1 for enable MCI.
//------------------------------------------------------------------------------
void MCI_Enable(Mci *pMci, unsigned char enb)
{
AT91S_MCI *pMciHw = pMci->pMciHw;
SANITY_CHECK(pMci);
SANITY_CHECK(pMci->pMciHw);
// Set the Control Register: Enable/Disable MCI interface clock
if(enb == DISABLE) {
WRITE_MCI(pMciHw, MCI_CR, AT91C_MCI_MCIDIS);
}
else {
WRITE_MCI(pMciHw, MCI_CR, AT91C_MCI_MCIEN);
}
}
示例12: PWMC_SetDeadTime
/**
* \brief Sets the dead time used by a PWM channel.
* This function writes directly to the DT register if the channel is disabled;
* otherwise it uses the update register DTUPD.
* Note that the dead time must always be inferior or equal to the channel
* period.
*
* \param channel Channel number.
* \param timeH Dead time value for PWMHx output.
* \param timeL Dead time value for PWMLx output.
*/
void PWMC_SetDeadTime(uint8_t channel, uint16_t timeH, uint16_t timeL)
{
SANITY_CHECK(timeH <= PWM->PWM_CH_NUM[channel].PWM_CPRD);
SANITY_CHECK(timeL <= PWM->PWM_CH_NUM[channel].PWM_CPRD);
/* If channel is disabled, write to DT */
if ((PWM->PWM_SR & (1 << channel)) == 0) {
PWM->PWM_CH_NUM[channel].PWM_DT = timeH | (timeL << 16);
}
/* Otherwise use update register */
else {
PWM->PWM_CH_NUM[channel].PWM_DTUPD = timeH | (timeL << 16);
}
}
示例13: TSADCC_SetTriggerPeriod
//------------------------------------------------------------------------------
/// Sets the trigger period when using the TSADCC in periodic trigger mode.
/// As usual, this function requires TSADCC_SetAdcFrequency() to be called
/// before it.
/// \param period Trigger period in nanoseconds.
//------------------------------------------------------------------------------
void TSADCC_SetTriggerPeriod(unsigned int period)
{
unsigned int trgper;
unsigned int divisor = 100000000;
while ((period >= 10) && (divisor >= 10)) {
period /= 10;
divisor /= 10;
}
trgper = (period * lAdcclk) / divisor;
if ((trgper % 10) > 0) {
trgper /= 10;
}
else {
trgper /= 10;
if (trgper > 0) trgper--;
}
SANITY_CHECK((trgper & ~0xFFFF) == 0);
AT91C_BASE_TSADC->TSADC_TRGR = (AT91C_BASE_TSADC->TSADC_TRGR
& ~AT91C_TSADC_TRGPER)
| (trgper << 16);
}
示例14: DoVerticalFilter
static WEBP_INLINE void DoVerticalFilter(const uint8_t* in,
int width, int height, int stride,
int row, int num_rows,
int inverse, uint8_t* out) {
const uint8_t* preds;
const size_t start_offset = row * stride;
const int last_row = row + num_rows;
SANITY_CHECK(in, out);
in += start_offset;
out += start_offset;
preds = inverse ? out : in;
if (row == 0) {
// Very first top-left pixel is copied.
out[0] = in[0];
// Rest of top scan-line is left-predicted.
PredictLine(in + 1, preds, out + 1, width - 1, inverse);
row = 1;
in += stride;
out += stride;
} else {
// We are starting from in-between. Make sure 'preds' points to prev row.
preds -= stride;
}
// Filter line-by-line.
while (row < last_row) {
PredictLine(in, preds, out, width, inverse);
++row;
preds += stride;
in += stride;
out += stride;
}
}
示例15: AES_Configure
//------------------------------------------------------------------------------
/// Configures the AES peripheral to encrypt/decrypt, start mode (manual, auto,
/// PDC) and operating mode (ECB, CBC, OFB, CFB, CTR).
/// \param cipher Indicates if the peripheral should encrypt or decrypt data.
/// \param smode Start mode.
/// \param opmode Operating mode.
//------------------------------------------------------------------------------
void AES_Configure(
unsigned char cipher,
unsigned int smode,
unsigned int opmode)
{
TRACE_DEBUG("AES_Configure()\n\r");
SANITY_CHECK((cipher & 0xFFFFFFFE) == 0);
SANITY_CHECK((smode & 0xFFFFFCFF) == 0);
SANITY_CHECK((opmode & 0xFFFF8FFF) == 0);
// Reset the peripheral first
AT91C_BASE_AES->AES_CR = AT91C_AES_SWRST;
// Configure mode register
AT91C_BASE_AES->AES_MR = cipher | smode | opmode;
}