本文整理匯總了C++中BIT_CHECK函數的典型用法代碼示例。如果您正苦於以下問題:C++ BIT_CHECK函數的具體用法?C++ BIT_CHECK怎麽用?C++ BIT_CHECK使用的例子?那麽, 這裏精選的函數代碼示例或許可以為您提供幫助。
在下文中一共展示了BIT_CHECK函數的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的C++代碼示例。
示例1: RS485_ReceiveError
/****************************************************************************
* DESCRIPTION: Return true if a framing or overrun error is present
* RETURN: true if error
* ALGORITHM: autobaud - if there are a lot of errors, switch baud rate
* NOTES: Clears any error flags.
*****************************************************************************/
bool RS485_ReceiveError(
void)
{
bool ReceiveError = false;
uint8_t dummy_data;
/* check for framing error */
#if 0
if (BIT_CHECK(UCSRA, FE0)) {
/* FIXME: how do I clear the error flags? */
BITMASK_CLEAR(UCSRA, (_BV(FE) | _BV(DOR) | _BV(UPE)));
ReceiveError = true;
}
#endif
/* check for overrun error */
if (BIT_CHECK(UCSRA, DOR)) {
/* flush the receive buffer */
do {
dummy_data = UDR;
} while (BIT_CHECK(UCSRA, RXC));
ReceiveError = true;
}
return ReceiveError;
}
示例2: rs485_bytes_send
void rs485_bytes_send(
uint8_t * buffer, /* data to send */
uint16_t nbytes)
{ /* number of bytes of data */
led_on(LED_2);
while (!BIT_CHECK(UCSR0A, UDRE0)) {
/* do nothing - wait until Tx buffer is empty */
}
while (nbytes) {
/* Send the data byte */
UDR0 = *buffer;
while (!BIT_CHECK(UCSR0A, UDRE0)) {
/* do nothing - wait until Tx buffer is empty */
}
buffer++;
nbytes--;
}
/* was the frame sent? */
while (!BIT_CHECK(UCSR0A, TXC0)) {
/* do nothing - wait until the entire frame in the
Transmit Shift Register has been shifted out */
}
/* Clear the Transmit Complete flag by writing a one to it. */
BIT_SET(UCSR0A, TXC0);
timer_reset(TIMER_SILENCE);
led_off_delay(LED_2, 1);
return;
}
示例3: test_pin_state
/*************************************************************************
* Description: Get the state of the test pin
* Returns: true if on, false if off.
* Notes: none
*************************************************************************/
static inline bool test_pin_state(
void)
{
#if (BDK_VERSION==4)
return (BIT_CHECK(PIND, PD5));
#else
return (BIT_CHECK(PINB, PB0));
#endif
}
示例4: compress_directory
result_t compress_directory(struct pak_file* pak, struct paki_args* args, const char* subdir)
{
result_t r;
char directory[DH_PATH_MAX];
char filepath[DH_PATH_MAX];
char fullfilepath[DH_PATH_MAX];
strcpy(directory, args->path);
if (subdir[0] != 0) {
path_join(directory, directory, subdir, NULL);
}
WIN32_FIND_DATA fdata;
char filter[DH_PATH_MAX];
path_join(filter, directory, "*", NULL);
HANDLE find_hdl = FindFirstFile(filter, &fdata);
if (find_hdl == INVALID_HANDLE_VALUE) {
printf(TERM_BOLDRED "Creating pak failed: directory '%s' does not exist.\n" TERM_RESET,
directory);
return RET_FAIL;
}
/* read directory recuresively, and compress files into pak */
BOOL fr = TRUE;
while (fr) {
if (!str_isequal(fdata.cFileName, ".") && !str_isequal(fdata.cFileName, "..")) {
filepath[0] = 0;
if (subdir[0] != 0) {
strcpy(filepath, subdir);
}
if (!BIT_CHECK(fdata.dwFileAttributes, FILE_ATTRIBUTE_DIRECTORY)) {
/* put the file into the archive */
path_join(filepath, filepath, fdata.cFileName, NULL);
path_join(fullfilepath, directory, fdata.cFileName, NULL);
r = archive_put(pak, args, fullfilepath, filepath);
if (IS_OK(r) && BIT_CHECK(args->usage, PAKI_USAGE_VERBOSE)) {
puts(filepath);
} else if (IS_FAIL(r)) {
err_sendtolog(FALSE);
args->err_cnt ++;
}
args->file_cnt ++;
} else {
/* it's a directory, recurse */
path_join(filepath, filepath, fdata.cFileName, NULL);
compress_directory(pak, args, filepath);
}
}
fr = FindNextFile(find_hdl, &fdata);
}
FindClose(find_hdl);
return RET_OK;
}
示例5: awaitCommandResponse
uint32_t
awaitCommandResponse()
{
// NOTE: for dependencies between error flags and command complete in MMCHS_STAT see page 3157f
while ( 1 )
{
// NOTE: CTO occured, is mutually exclusive with CC and the errors CIE, CEB and CERR cannot occur with CTO.
if ( isCommandTimeout() )
{
// NOTE: CTO can occur at the same time as CCRC: it indicates a command abort due to a contention on CMD line. In this case no CC appears.
if ( BIT_CHECK( MMCHS_STAT, MMCHS_STAT_CCRC_BIT ) )
{
// NOTE: fuck it, don't care for this type of error
}
clearInterruptBits( MMCHS_STAT_CTO_BIT | MMCHS_STAT_CCRC_BIT );
// always need to reset CMD line after error
resetMMCICmdLine( 0xFF );
// reset DATA line after error occured during a command which transmits data
resetMMCIDataLine( 0xFF );
// return 1 to indicate failure
return 1;
}
// command complete
else if ( isCommandComplete() )
{
clearCommandComplete();
// NOTE: CC is set upon CIE, CEB, CCRC (if no CTO) and CERR => need to check for those errors anyway although command has completed
if ( BIT_CHECK( MMCHS_STAT, MMCHS_STAT_CIE_BIT ) ||
BIT_CHECK( MMCHS_STAT, MMCHS_STAT_CEB_BIT ) ||
BIT_CHECK( MMCHS_STAT, MMCHS_STAT_CCRC_BIT ) ||
BIT_CHECK( MMCHS_STAT, MMCHS_STAT_CERR_BIT ) )
{
clearInterruptBits( MMCHS_STAT_CIE_BIT | MMCHS_STAT_CEB_BIT | MMCHS_STAT_CCRC_BIT | MMCHS_STAT_CERR_BIT );
// Command index error / Command end bit error / Command CRC Error / Card error ?
// return 1 to indicate failure
return 1;
}
return 0;
}
else
{
// not yet completed, check again
}
}
}
示例6: setBusPower
uint32_t
setBusPower( bool enable )
{
if ( enable )
{
uint32_t i = 0;
BIT_SET( MMCHS_HCTL, MMCHS_HCTL_SDBP_BIT );
for ( i = 0xFF; i > 0; --i )
{
if ( BIT_CHECK( MMCHS_HCTL, MMCHS_HCTL_SDBP_BIT ) )
{
return 0;
}
}
return 1;
}
else
{
BIT_CLEAR( MMCHS_HCTL, MMCHS_HCTL_SDBP_BIT );
}
return 0;
}
示例7: get_random_number_from_candidate_list_and_remove_it
unsigned int get_random_number_from_candidate_list_and_remove_it(CandidateListType *list, unsigned int index)
{
unsigned int randomIndex; // index of the selected candidate in the list
unsigned int count; // number of remaining candidates in the list
unsigned int candidate; // selected candidate
assert(NULL != list && index < (NROWS*NCOLS) && "get_random_number_from_candidate_list_and_remove_it(): Bad input");
// 1. count how many remaining numbers we have (how many set bits)
count = count_bits(list[index]);
assert(count > 0 && "get_random_number_from_candidate_list_and_remove_it(): No candidate remaining");
// 2. generate random index (will be 0 when count is 1)
randomIndex = (unsigned int) arc4random() % count;
// 3. get the corresponding candidate
for (candidate = 0; candidate < NCOLS; ++candidate)
{
if (BIT_CHECK(list[index],candidate)) {
if (0 == randomIndex) {
break;
}
else {
--randomIndex;
}
}
}
assert(0 <= candidate && candidate < NCOLS && 0 == randomIndex && "get_random_number_from_candidate_list_and_remove_it(): Bad index");
// 4. remove it from the candidate list
BIT_CLEAR(list[index],candidate);
return (unsigned int)(candidate+1); // Indices start at 0 but values start at 1, need to increase
}
示例8: crea_POWER_CR
static void crea_POWER_CR(int c)
{
REGFN_BEGIN(POWER_CR);
int i;
for(i = 0; i < POWER_CR_SIZE(c); i++) { POWER_CR_SKIP(c); BIT_CHECK(i, i, (c==0?powercr9_strings:powercr7_strings)[i]); }
CREA_END();
}
示例9: crea_REG_SPICNT
static void crea_REG_SPICNT(int c)
{
REGFN_BEGIN(REG_SPICNT);
int i;
for(i = 0; i < 16; i++) { REG_SPICNT_SKIP(c);
if(REG_SPICNT_ISCHECK(c)) { BIT_CHECK(i, i, spicnt_strings[i]); }
else if(i == 0) { BIT_COMBO(i, "0-1", spicnt_strings[0]);
BIT_COMBO_ADD(i, "0= 4Mhz");
BIT_COMBO_ADD(i, "1= 2Mhz");
BIT_COMBO_ADD(i, "2= 1Mhz");
BIT_COMBO_ADD(i, "3= 512Khz");
BIT_COMBO_END(i); }
else if(i == 8) { BIT_COMBO(i, "8-9", spicnt_strings[8]);
BIT_COMBO_ADD(i, "0= Power management device");
BIT_COMBO_ADD(i, "1= Firmware");
BIT_COMBO_ADD(i, "2= Touchscreen/Microphone");
BIT_COMBO_ADD(i, "3= Reserved/Prohibited");
BIT_COMBO_END(i); }
else if(i == 10) { BIT_COMBO(i, "10", spicnt_strings[10]);
BIT_COMBO_ADD(i, "0= 8 bits");
BIT_COMBO_ADD(i, "1= 16 bits");
BIT_COMBO_END(i); }
}
CREA_END();
}
示例10: crea_REG_IPCFIFOCNT
static void crea_REG_IPCFIFOCNT(int c)
{
REGFN_BEGIN(REG_IPCFIFOCNT);
int i;
for(i = 0; i < 16; i++) { FIFOCNT_SKIP(c); BIT_CHECK(i, i, fifocnt_strings[i]); }
CREA_END();
}
示例11: crea_REG_IF
static void crea_REG_IF(int c)
{
REGFN_BEGIN(REG_IF);
int i;
for(i = 0; i < 24; i++) { INTERRUPT_SKIP(c); BIT_CHECK(i, i, interrupt_strings[i]); }
CREA_END();
}
示例12: PS2WaitInputBuffer
void PS2WaitInputBuffer() {
for(;;) {
/* Check if the input buffer flag is clear. */
if(!BIT_CHECK(PS2ReadStatus(), 1)) {
break;
}
}
}
示例13: eng_release
void eng_release()
{
if (g_eng == NULL)
return;
rs_release_resources();
lod_releasemgr();
#if !defined(_DEBUG_)
pak_close(&g_eng->data_pak);
#endif
prf_releasemgr();
sct_release();
wld_releasemgr();
scn_releasemgr();
cmp_releasemgr();
phx_release();
hud_release();
gfx_release();
rs_reportleaks();
rs_releasemgr();
tsk_releasemgr();
if (g_eng->timer != NULL)
timer_destroyinstance(g_eng->timer);
/* check for main memory leaks */
if (BIT_CHECK(g_eng->params.flags, ENG_FLAG_DEV)) {
int leak_cnt = mem_freelist_getleaks(&g_eng->data_freelist, NULL);
if (leak_cnt > 0)
log_printf(LOG_WARNING, "%d leaks found on dynamic 'data' memory", leak_cnt);
}
mem_freelist_destroy(&g_eng->data_freelist);
mem_stack_destroy(&g_eng->lsr_stack);
log_print(LOG_TEXT, "engine released.");
if (BIT_CHECK(g_eng->params.flags, ENG_FLAG_CONSOLE)) {
log_outputfunc(FALSE, NULL, NULL);
con_release();
}
FREE(g_eng);
g_eng = NULL;
}
示例14: load_pak
void load_pak(struct paki_args* args)
{
result_t r;
struct pak_file pak;
char filename[DH_PATH_MAX];
path_norm(args->pakfile, args->pakfile);
path_tounix(args->path, args->path);
r = pak_open(&pak, mem_heap(), args->pakfile, 0);
if (IS_FAIL(r)) {
err_sendtolog(FALSE);
return;
}
uint file_id = pak_findfile(&pak, args->path);
if (file_id == INVALID_INDEX) {
printf(TERM_BOLDRED "Extract failed: file '%s' not found in pak.\n" TERM_RESET, args->path);
pak_close(&pak);
return;
}
path_getfullfilename(filename, args->path);
file_t f = fio_createdisk(filename);
if (f == NULL) {
printf(TERM_BOLDRED "Extract failed: could not create '%s' for writing.\n" TERM_RESET,
filename);
pak_close(&pak);
err_sendtolog(FALSE);
return;
}
file_t src_file = pak_getfile(&pak, mem_heap(), mem_heap(), file_id, 0);
if (src_file == NULL) {
pak_close(&pak);
fio_close(f);
err_sendtolog(FALSE);
return;
}
size_t size;
struct allocator* alloc;
void* buffer = fio_detachmem(src_file, &size, &alloc);
fio_write(f, buffer, size, 1);
A_FREE(alloc, buffer);
fio_close(f);
pak_close(&pak);
if (BIT_CHECK(args->usage, PAKI_USAGE_VERBOSE)) {
printf(TERM_WHITE "%s -> %s\n" TERM_RESET, args->path, filename);
}
args->file_cnt ++;
// report
printf(TERM_BOLDWHITE "Finished: total %d file(s) - %d error(s), %d warning(s)\n" TERM_RESET,
args->file_cnt, args->err_cnt, args->warn_cnt);
}
示例15: gfx_csm_resize
result_t gfx_csm_resize(uint width, uint height)
{
if (BIT_CHECK(eng_get_params()->flags, ENG_FLAG_DEV)) {
csm_destroy_prevrt();
if (IS_FAIL(csm_create_prevrt(width, height)))
return RET_FAIL;
}
return RET_OK;
}