static int pointinpoly(const int32_t *poly, int points, int32_t x, int32_t y) { int32_t p0, p1, l0, l1; int c = 0; /* Read the final point */ p0 = pgm_read_dword(&poly[points * 2 - 2]); p1 = pgm_read_dword(&poly[points * 2 - 1]); for(; points; points--, poly += 2) { l0 = p0; l1 = p1; p0 = pgm_read_dword(&poly[0]); p1 = pgm_read_dword(&poly[1]); if(y < p1 && y < l1) continue; if(y >= p1 && y >= l1) continue; if(x < p0 + (l0 - p0) * (y - p1) / (l1 - p1)) continue; c = !c; } return(c); }
static const uint64_t pgm_read_uint64_t_P(const uint64_t * p){ union { uint64_t v64; uint32_t v32[2]; } ret; ret.v32[0] = pgm_read_dword(p); ret.v32[1] = pgm_read_dword((uint8_t*)p + 4); return ret.v64; }
static uint64_t pgm_read_qword(const void *p){ union{ uint64_t v64; uint32_t v32[2]; }r; r.v32[0] = pgm_read_dword(p); r.v32[1] = pgm_read_dword((uint8_t*)p+4); return r.v64; }
/** @ingroup midi Converts midi note number to frequency with speed and accuracy. Q16n16_mtofLookup() is a fast alternative to (float) mtof(), and more accurate than (unsigned char) mtof(), using Q16n16 fixed-point format instead of floats or byte values. Q16n16_mtof() uses cheap linear interpolation between whole midi-note frequency equivalents stored in a lookup table, so is less accurate than the float version, mtof(), for non-whole midi values. @note Timing: ~8 us. @param midival_fractional a midi note number in Q16n16 format, for fractional values. @return the frequency represented by the input midi note number, in Q16n16 fixed point fractional integer format, where the lower word is a fractional value. */ Q16n16 Q16n16_mtof(Q16n16 midival_fractional) { Q16n16 diff_fraction; unsigned char index = midival_fractional >> 16; unsigned int fraction = (unsigned int) midival_fractional; // keeps low word Q16n16 freq1 = (Q16n16) pgm_read_dword(midiToFreq + index); Q16n16 freq2 = (Q16n16) pgm_read_dword((midiToFreq + 1) + index); Q16n16 difference = freq2 - freq1; if (difference>=65536) { diff_fraction = ((difference>>8) * fraction) >> 8; }
void doConfig(char** argv, char argc) { const struct ConfigTable* p; int i; int silent = (argc == 1 && argv[0][0] == '1' && argv[0][1] == '\0'); for(i = 0; pgm_read_dword(&g_lightTable[i]) != 0xffffffff; ++i) { unsigned long light = pgm_read_dword(&g_lightTable[i]); AMBILIGHT_LIGHT = i; AMBILIGHT_COMPONENT = 0; AMBILIGHT_DATA = LIGHT_XMIN(light); AMBILIGHT_COMPONENT = 1; AMBILIGHT_DATA = LIGHT_XMAX(light); AMBILIGHT_COMPONENT = 2; AMBILIGHT_DATA = LIGHT_YMIN(light); AMBILIGHT_COMPONENT = 3; AMBILIGHT_DATA = LIGHT_YMAX(light); AMBILIGHT_COMPONENT = 4; AMBILIGHT_DATA = LIGHT_SHIFT(light); AMBILIGHT_COMPONENT = 5; AMBILIGHT_DATA = LIGHT_OUTPUT(light); if(!silent) printf("OK\n"); } for(p = g_configTable; pgm_read_byte(&p->address) != 0; ++p) { unsigned char address = pgm_read_byte(&p->address); unsigned char subaddress = pgm_read_byte(&p->subaddress); unsigned char data = pgm_read_byte(&p->data); if(!silent) { printf("%d %d %d : ", address, subaddress, data); i2c_start(); printf("%s ", i2c_write(address) ? "ACK" : "NACK"); printf("%s ", i2c_write(subaddress) ? "ACK" : "NACK"); printf("%s\n", i2c_write(data) ? "ACK" : "NACK"); i2c_stop(); } else { i2c_start(); i2c_write(address); i2c_write(subaddress); i2c_write(data); i2c_stop(); } } }
int main () { int i; unsigned char z; for (i = 0; i < (int) (sizeof(t) / sizeof(t[0])); i++) { x.lo = pgm_read_dword (& t[i].x); y.lo = pgm_read_dword (& t[i].y); z = UNORDSF2 (x.fl, y.fl) ? 1 : 0; if (z != pgm_read_byte (& t[i].z)) EXIT (i + 1); } return 0; }
void shabal384_init(shabal_ctx_t* ctx){ uint8_t i; ctx->b = ctx->b_buffer; ctx->c = ctx->c_buffer; ctx->w.w64 = 1LL; for(i=0;i<SHABAL_R;++i){ ctx->a[i] = pgm_read_dword(&(shabal384_iv[i])); } for(i=0;i<16;++i){ ctx->b[i] = pgm_read_dword(&(shabal384_iv[SHABAL_R+i])); } for(i=0;i<16;++i){ ctx->c[i] = pgm_read_dword(&(shabal384_iv[SHABAL_R+16+i])); } }
mm1000_t CGCodeTools::GetHeight(toolnr_t tool) { uint8_t idx = GetToolIndex(tool); if (idx == NOTOOLINDEX) return 0; return pgm_read_dword(&_tools[idx].Height); }
void run_sprf (const struct sprf_s *pt, int testno) { static char s[300]; int n; int code; #ifdef __AVR__ n = sprintf_P (s, pt->fmt, pgm_read_dword (& pt->val)); #else n = sprintf (s, pt->fmt, pt->val); #endif if (n != (int)strlen_P (pt->pattern)) code = testno + 1000; else if (strcmp_P (s, pt->pattern)) code = testno; else return; #if !defined(__AVR__) printf ("\ntestno %3d: expect: %3d, \"%s\"," "\n output: %3d, \"%s\"\n", testno, strlen(pt->pattern), pt->pattern, n, s); exit (code < 256 ? testno : 255); #elif defined(DEBUG) exit ((int)s); #endif exit (code); }
void setup() { reset_cause = MCUSR; // only works if bootloader doesn' t set MCUSR to 0 MCUSR=0; #if USE_WATCHDOG_FOR_RESET wdt_disable(); // turn off watchdog #endif __malloc_margin = MIN_STACK_SIZE; writeStackLowWaterMarkPattern(); // initialize PaceMaker serial port to first value PSERIAL.begin(pgm_read_dword(&autodetect_baudrates[0])); if (sizeof(autodetect_baudrates)/sizeof(autodetect_baudrates[0])) autodetect_baudrates_index = 0xFF; // no need to autodetect #if DEBUG_ENABLED DSerial.begin(); #endif NVConfigStore::Initialize(); movement_ISR_init(); temperature_ISR_init(); apply_boot_initial_pin_state(); DEBUGLNPGM("starting"); apply_initial_configuration(); apply_debug_commands(); }
int GSM3SoftSerial::begin(long speed) { _rx_delay_centering = _rx_delay_intrabit = _rx_delay_stopbit = _tx_delay = 0; setTX(); setRX(); for (unsigned i=0; i<sizeof(table)/sizeof(table[0]); ++i) { long baud = pgm_read_dword(&table[i].baud); if (baud == speed) { _rx_delay_centering = pgm_read_word(&table[i].rx_delay_centering); _rx_delay_intrabit = pgm_read_word(&table[i].rx_delay_intrabit); _rx_delay_stopbit = pgm_read_word(&table[i].rx_delay_stopbit); _tx_delay = pgm_read_word(&table[i].tx_delay); break; } } // Set up RX interrupts, but only if we have a valid RX baud rate /* if (_rx_delay_stopbit) { pinMode(__RXPIN__, INPUT_PULLUP); tunedDelay(_tx_delay); // if we were low this establishes the end } */ io_DisableINT(); io_outpb(CROSSBARBASE + 0x90 + PIN86[__RXPIN__].gpN, 0x08); _activeObject = this; io_RestoreINT(); }
static uint16_t CopyValue( uint8_t** ppBuffer, uint32_t nValue) { static PROGMEM int32_t nDecTab[] = { 1000000000, 100000000, 10000000, 1000000, 100000, 10000, 1000, 100, 10, 1, 0 }; int32_t nDec; uint8_t nCurTabIndex = 0; char cNumber; uint8_t nBytes = 0; while ((nDec = pgm_read_dword(&nDecTab[nCurTabIndex])) != 0) { for (cNumber='0'; cNumber<'9'; cNumber++) { int32_t nTmp = nValue - nDec; if (nTmp < 0) break; nValue = nTmp; } **ppBuffer = cNumber; *ppBuffer = *ppBuffer + 1; nBytes++; nCurTabIndex++; } return nBytes; }
/** Retrieves the total size of the given locally stored (in PROGMEM) attribute Data Element container. * * \param[in] AttributeData Pointer to the start of the Attribute container, located in PROGMEM * \param[out] HeaderSize Pointer to a location where the header size of the data element is to be stored * * \return Size in bytes of the entire attribute container, including the header */ static uint32_t SDP_GetLocalAttributeContainerSize(const void* const AttributeData, uint8_t* const HeaderSize) { /* Fetch the size of the Data Element structure from the header */ uint8_t SizeIndex = (pgm_read_byte(AttributeData) & 0x07); uint32_t ElementValueSize; /* Convert the Data Element size index into a size in bytes */ switch (SizeIndex) { case SDP_DATASIZE_Variable8Bit: *HeaderSize = (1 + sizeof(uint8_t)); ElementValueSize = pgm_read_byte(AttributeData + 1); break; case SDP_DATASIZE_Variable16Bit: *HeaderSize = (1 + sizeof(uint16_t)); ElementValueSize = be16_to_cpu(pgm_read_word(AttributeData + 1)); break; case SDP_DATASIZE_Variable32Bit: *HeaderSize = (1 + sizeof(uint32_t)); ElementValueSize = be32_to_cpu(pgm_read_dword(AttributeData + 1)); break; default: *HeaderSize = 1; ElementValueSize = (1 << SizeIndex); break; } return ElementValueSize; }
void SoftwareSerial::begin(long speed) { _rx_delay_centering = _rx_delay_intrabit = _rx_delay_stopbit = _tx_delay = 0; for (unsigned i=0; i<sizeof(table)/sizeof(table[0]); ++i) { long baud = pgm_read_dword(&table[i].baud); if (baud == speed) { _rx_delay_centering = pgm_read_word(&table[i].rx_delay_centering); _rx_delay_intrabit = pgm_read_word(&table[i].rx_delay_intrabit); _rx_delay_stopbit = pgm_read_word(&table[i].rx_delay_stopbit); _tx_delay = pgm_read_word(&table[i].tx_delay); break; } } // Set up RX interrupts, but only if we have a valid RX baud rate if (_rx_delay_stopbit) { pinMode(_receivePin, INPUT_PULLUP); tunedDelay(_tx_delay); // if we were low this establishes the end } listen(); }
unsigned long MenloPlatform::GetMethodPointerFromMethodArray(char** array, int index) { PGM_P p; PGM_P array_p; unsigned long methodptr; array_p = (PGM_P)array; // // Calculate our effective address into the program // space table that is an array of string* also in program space. // p = array_p + (index * sizeof(unsigned long)); // // Note: C++ Method pointers declared as the following allocate // (2) pointer sized entries. The first is the 16 bit function // address, while the second is a compiler specific encoding for // the type of method. Since these are straightforward non-virtual // methods this information is all 0's for the current version of GCC // for AVR/Arduino. // // Here we load as a unsigned long 32 bit value of which represents // the function address. Most callers on AVR will truncate this // to a 16 bit target address ignoring the upper 0's. // methodptr = pgm_read_dword(p); return methodptr; }
// Called the first time that a client tries to kick the GPS to update. // // We detect the real GPS, then update the pointer we have been called through // and return. // bool AP_GPS_Auto::read(void) { static uint32_t last_baud_change_ms; static uint8_t last_baud; GPS *gps; uint32_t now = hal.scheduler->millis(); if (now - last_baud_change_ms > 1200) { // its been more than 1.2 seconds without detection on this // GPS - switch to another baud rate _port->begin(pgm_read_dword(&baudrates[last_baud]), 256, 16); last_baud++; last_baud_change_ms = now; if (last_baud == sizeof(baudrates) / sizeof(baudrates[0])) { last_baud = 0; } // write config strings for the types of GPS we support _send_progstr(_port, _mtk_set_binary, sizeof(_mtk_set_binary)); _send_progstr(_port, AP_GPS_UBLOX::_ublox_set_binary, AP_GPS_UBLOX::_ublox_set_binary_size); _send_progstr(_port, _sirf_set_binary, sizeof(_sirf_set_binary)); } _update_progstr(); if (NULL != (gps = _detect())) { // configure the detected GPS gps->init(_port, _nav_setting); hal.console->println_P(PSTR("OK")); *_gps = gps; return true; } return false; }
void HandleSwitchingObject(uint8_t switchingObject) { uint8_t delay_factor; uint8_t delayBaseIndex; if (switchingObject) { /* Switching On */ StopTimer(); /* Starting brightness */ uint8_t indexSwitchingOnBrightness = mem_ReadByte(APP_SWITCH_ON_BRIGHTNESS) & 0x0F; // indexSwitchingOnBrightness &= 0b00001111; SetSwitchingOnBrightness(indexSwitchingOnBrightness); /* Soft-On ? */ delay_factor = mem_ReadByte(APP_SOFT_ON_FACTOR_CH1); if (delay_factor == 0) { /* Soft-On no */ DirectJumpToOneColor(); } else { /* Soft-On yes */ delayBaseIndex = mem_ReadByte(APP_SOFT_ON_BASE) & 0x07; dimmTimerReload = (pgm_read_dword(&delay_bases[delayBaseIndex])) * (uint16_t) delay_factor; StartDimming(); FillOffsetArray(dimmingStepsBetweenLeds); } } else { /* Switching Off */ StopTimer(); color[RED_HUE].lastShutoffValue = color[RED_HUE].destinationValue; color[GREEN_SAT].lastShutoffValue = color[GREEN_SAT].destinationValue; color[BLUE_VAL].lastShutoffValue = color[BLUE_VAL].destinationValue; color[RED_HUE].destinationValue = 0; color[GREEN_SAT].destinationValue = 0; color[BLUE_VAL].destinationValue = 0; /* Soft-Off ? */ delay_factor = mem_ReadByte(APP_SOFT_OFF_FACTOR_CH1); if (delay_factor == 0) { /* Soft-Off no */ DirectJumpToOneColor(); } else { /* Soft-Off yes */ delayBaseIndex = mem_ReadByte(APP_SOFT_OFF_BASE) & 0x07; dimmTimerReload = (pgm_read_dword(&delay_bases[delayBaseIndex])) * (uint16_t) delay_factor; StartDimming(); FillOffsetArray(dimmingStepsBetweenLeds); } } }
uint32_t chksum_crc32_step(uint32_t crc, uint8_t byte) { #ifdef __AVR__ return ((crc >> 8) & 0x00FFFFFF) ^ pgm_read_dword(&crc_tab[(crc ^ byte) & (uint32_t) 0xFF]); #else return ((crc >> 8) & 0x00FFFFFF) ^ crc_tab[(crc ^ byte) & (uint32_t) 0xFF]; #endif }
void blake224_init(blake224_ctx_t* ctx){ uint8_t i; for(i=0; i<8; ++i){ ctx->h[i] = pgm_read_dword(&(blake224_iv[i])); } memset(ctx->s, 0, 4*4); ctx->counter = 0; ctx->appendone = 0; }
void tune_playnote (byte chan, byte note) { if (chan < NUM_CHANS) { if (note>MAX_NOTE) note=MAX_NOTE; decrement[chan] = pgm_read_dword(decrement_PGM + note); accumulator[chan] = ACCUM_RESTART; playing[chan]=true; } }
/* * Function altitudeCalculate * Desc Calculate altitide from Pressure. * Input Real Pressure value * Output Altitude, unit: 0.1m */ void HP03M::altitudeCalculate(void) { unsigned char ucCount; unsigned int uiBasicPress; unsigned int uiBiasTotal; unsigned int uiBiasPress; unsigned int uiBiasAltitude; unsigned int uiPress=Pressure/100; for(ucCount=0;;ucCount++) { uiBasicPress = MaxPress-(ucCount*10); if(uiBasicPress < uiPress) { break; } } uiPress= (long)pgm_read_dword(&Tab_BasicAltitude[ucCount]); uiBiasTotal = ((long)pgm_read_dword(&Tab_BasicAltitude[ucCount])) - ((long)pgm_read_dword(&Tab_BasicAltitude[ucCount-1])); uiBiasPress = Pressure - (long)(uiBasicPress*100); uiBiasAltitude = (long)uiBiasTotal * (long)uiBiasPress/1000; Altitude = ((long)pgm_read_dword(&Tab_BasicAltitude[ucCount])) - (long)uiBiasAltitude; ucCount = (abs(Altitude % 10));//round off if(Altitude < 0) { if(ucCount > 4) Altitude -= 10-ucCount; } else { if(ucCount>4) Altitude += 10-ucCount; else Altitude -= ucCount; } Altitude=Altitude/10; #if HP03M_Debug&0b00001000 Serial.print("Altitude ="); Serial.println(Altitude); #endif }
void PrintLD(uint32_t Value,int8_t Width) { uint8_t CharsPrinted = 0; uint8_t Index; char PadChar = ' '; // // If the Width field is > 100, then it's a signal to pad the // field with zeroes instead of spaces. // if( Width > 100 ) { Width -= 100; PadChar = '0'; } for( Index = 0; Index < 9; Index++ ) { uint32_t Divisor = pgm_read_dword(&Divisors[Index]); char OutChar = '0'; while( Value >= Divisor ) { Value -= Divisor; OutChar++; } if( OutChar != '0' || CharsPrinted ) { if( CharsPrinted == 0 && Width > 0 ) { uint8_t Chars = 5-Index; if( Width < Chars ) Width = Chars; while( Width > Chars ) { PrintChar(PadChar); Width--; } } PrintChar(OutChar); CharsPrinted++; } } // // Print out the last character. // if( CharsPrinted == 0 && Width > 0 ) while( --Width ) { PrintChar(PadChar); } PrintChar('0' + Value); // // If we were left justified, pad out the rest of the field. // if( Width < 0 ) while( ++CharsPrinted < -Width ) PrintChar(PadChar); }
static void blake_small_expand(uint32_t* v, const blake_small_ctx_t* ctx){ uint8_t i; memcpy(v, ctx->h, 8*4); for(i=0; i<8; ++i){ v[8+i] = pgm_read_dword(&(blake_c[i])); } memxor((uint8_t*)v+8, ctx->s, 4*4); }
static void md5_core(uint32_t* a, void* block, uint8_t as, uint8_t s, uint8_t i, uint8_t fi){ uint32_t t; md5_func_t* funcs[]={md5_F, md5_G, md5_H, md5_I}; as &= 0x3; /* a = b + ((a + F(b,c,d) + X[k] + T[i]) <<< s). */ t = a[as] + funcs[fi](a[(as+1)&3], a[(as+2)&3], a[(as+3)&3]) + *((uint32_t*)block) + pgm_read_dword(md5_T+i) ; a[as]=a[(as+1)&3] + ROTL32(t, s); }
/** * Cycle all patterns and search matching pattern. Execute command callback. * @param context * @result TRUE if context->paramlist is filled with correct values */ static scpi_bool_t findCommandHeader(scpi_t * context, const char * header, int len) { int32_t i; #if USE_64K_PROGMEM_FOR_CMD_LIST PGM_P pattern; for (i = 0; (pattern = (PGM_P)pgm_read_word(&context->cmdlist[i].pattern)) != 0; ++i) { strncpy_P(context->param_list.cmd_pattern_s, pattern, SCPI_MAX_CMD_PATTERN_SIZE); context->param_list.cmd_pattern_s[SCPI_MAX_CMD_PATTERN_SIZE] = '\0'; if (matchCommand(context->param_list.cmd_pattern_s, header, len, NULL, 0, 0)) { context->param_list.cmd_s.callback = (scpi_command_callback_t)pgm_read_word(&context->cmdlist[i].callback); #if USE_COMMAND_TAGS context->param_list.cmd_s.tag = (int32_t)pgm_read_dword(&context->cmdlist[i].tag); #endif return TRUE; } } #elif USE_FULL_PROGMEM_FOR_CMD_LIST uint_farptr_t p_cmd = context->cmdlist; uint_farptr_t p_pattern = context->cmdpatterns; uint16_t pattern_length; for (i = 0; (pattern_length = pgm_read_word_far(p_cmd + offsetof(scpi_command_t, pattern))) != 0; ++i, p_cmd += sizeof(scpi_command_t), p_pattern += pattern_length) { strncpy_PF(context->param_list.cmd_pattern_s, p_pattern, pattern_length); context->param_list.cmd_pattern_s[pattern_length] = '\0'; if (matchCommand(context->param_list.cmd_pattern_s, header, len, NULL, 0, 0)) { context->param_list.cmd_s.callback = (scpi_command_callback_t)pgm_read_word_far(p_cmd + offsetof(scpi_command_t, callback)); #if USE_COMMAND_TAGS context->param_list.cmd_s.tag = (int32_t)pgm_read_dword_far(p_cmd + offsetof(scpi_command_t, tag)); #endif return TRUE; } } #else const scpi_command_t * cmd; for (i = 0; context->cmdlist[i].pattern != NULL; i++) { cmd = &context->cmdlist[i]; if (matchCommand(cmd->pattern, header, len, NULL, 0, 0)) { context->param_list.cmd = cmd; return TRUE; } } #endif return FALSE; }
static void blake_small_compress(uint32_t *v, const void *m) { uint8_t r, i; uint8_t a, b, c, d, s0, s1, sigma_idx = 0; uint32_t lv[4]; for (r = 0; r < 14; ++r) { for (i = 0; i < 8; ++i) { a = pgm_read_byte(blake_index_lut + 4 * i + 0); b = pgm_read_byte(blake_index_lut + 4 * i + 1); c = pgm_read_byte(blake_index_lut + 4 * i + 2); d = pgm_read_byte(blake_index_lut + 4 * i + 3); s0 = pgm_read_byte(blake_sigma + sigma_idx); s1 = s0 & 0xf; s0 >>= 4; ++sigma_idx; if (sigma_idx >= 80) { sigma_idx -= 80; } lv[0] = v[a]; lv[1] = v[b]; lv[2] = v[c]; lv[3] = v[d]; lv[0] += lv[1] + (((uint32_t*) m)[s0] ^ pgm_read_dword(&(blake_c[s1]))); lv[3] = ROTR32(lv[3] ^ lv[0], 16); lv[2] += lv[3]; lv[1] = ROTR32(lv[1] ^ lv[2], 12); lv[0] += lv[1] + (((uint32_t*) m)[s1] ^ pgm_read_dword(&(blake_c[s0]))); lv[3] = ROTR32(lv[3] ^ lv[0], 8); lv[2] += lv[3]; lv[1] = ROTR32(lv[1] ^ lv[2], 7); v[a] = lv[0]; v[b] = lv[1]; v[c] = lv[2]; v[d] = lv[3]; } } }
// encode Parity from Data: Data is 5x 32-bit words = 160 bits, Parity is 1.5x 32-bit word = 48 bits void LDPC_Encode(const uint32_t *Data, uint32_t *Parity, const uint32_t ParityGen[48][5]) { uint8_t ParIdx=0; Parity[ParIdx]=0; uint32_t Mask=1; for(uint8_t Row=0; Row<48; Row++) { uint8_t Count=0; const uint32_t *Gen=ParityGen[Row]; for(uint8_t Idx=0; Idx<5; Idx++) { Count+=Count1s(Data[Idx]&pgm_read_dword(Gen+Idx)); } if(Count&1) Parity[ParIdx]|=Mask; Mask<<=1; if(Mask==0) { ParIdx++; Parity[ParIdx]=0; Mask=1; } } }
void rand_color_task(void* param){ uint16_t i = 0; for(;;){ for(uint8_t j=0; j<32; j++){ set_color(pgm_read_dword(&colors[i]), j); if(++i == MAX_COLOR){ i = 0; } } vTaskDelay(5000 / portTICK_PERIOD_MS); } }
int main () { int i; for (i = 0; i < (int) (sizeof(t) / sizeof(t[0])); i++) { x.lo = pgm_read_dword (& t[i].x); y.lo = pgm_read_dword (& t[i].y); if ((x.fl != y.fl) != pgm_read_byte (& t[i].ne)) x_exit (i+1, 1); if ((x.fl < y.fl) != pgm_read_byte (& t[i].lt)) x_exit (i+1, 2); if ((x.fl <= y.fl) != pgm_read_byte (& t[i].le)) x_exit (i+1, 3); if ((x.fl == y.fl) != pgm_read_byte (& t[i].eq)) x_exit (i+1, 4); if ((x.fl >= y.fl) != pgm_read_byte (& t[i].ge)) x_exit (i+1, 5); if ((x.fl > y.fl) != pgm_read_byte (& t[i].gt)) x_exit (i+1, 6); } return 0; }
/*private */TSTError TSTTone::playFrequency(register FrequencySequence const* ram, register FrequencySequence const PROGMEM* rom, register int length) { FrequencyType frequency; unsigned long duration; TSTError error(TSTERROR_OK); #if defined(OPTION_BUILD_MEMORYLOG) TSTMorikawa::saveMemoryLog(); #endif if (_morikawa != NULL) { if (!_morikawa->hasAbnormalShutdown()) { if (_morikawa->enableAudioBus() != TSTERROR_OK) { // force execute } while (true) { if (ram != NULL) { frequency = ram->frequency; duration = ram->duration; ++ram; } else { frequency = pgm_read_word(&rom->frequency); duration = pgm_read_dword(&rom->duration); ++rom; } if (frequency <= FREQUENCY_END) { break; } else if (length >= 0) { if (--length < 0) { break; } } else if (_morikawa->hasAbnormalShutdown()) { error = TSTERROR_ABNORMAL_SHUTDOWN; break; } executeFrequency(frequency, duration); } } else { error = TSTERROR_INVALID_STATE; } } else { error = TSTERROR_INVALID_STATE; } return error; }