static portTASK_FUNCTION(Task2, pvParameters) { (void) pvParameters; //parameter not used for (;;) { LEDB_Off(); LEDR_Off(); LEDG_On(); //FRTOS1_vTaskDelay(500/portTICK_RATE_MS); } }
/* ** =================================================================== ** Method : LEDB_SetRatio16 (component LED) ** Description : ** Method to specify the duty cycle. If using a PWM pin, this ** means the duty cycle is set. For On/off pins, values smaller ** 0x7FFF means off, while values greater means on. ** Parameters : ** NAME - DESCRIPTION ** ratio - Ratio value, where 0 means 'off' and ** 0xffff means 'on' ** Returns : Nothing ** =================================================================== */ void LEDB_SetRatio16(word ratio) { /* on/off LED: binary on or off */ if (ratio<(0xffff/2)) { LEDB_Off(); } else { LEDB_On(); } }
void blink_blue(const int n) { int i; i = 0; for (i = 0; i < (2*n); i++) { LEDB_Neg(); WAIT1_Waitms(BLINKTIME); } LEDB_Off(); }
/*lint -save -e970 Disable MISRA rule (6.3) checking. */ int main(void) /*lint -restore Enable MISRA rule (6.3) checking. */ { /* Write your local variable definition here */ /*** Processor Expert internal initialization. DON'T REMOVE THIS CODE!!! ***/ PE_low_level_init(); /*** End of Processor Expert internal initialization. ***/ for(;;) { LEDR_On(); WAIT1_Waitms(500); LEDR_Off(); WAIT1_Waitms(500); LEDG_On(); WAIT1_Waitms(500); LEDG_Off(); LEDB_On(); WAIT1_Waitms(500); LEDB_Off(); LEDR_SetRatio16(0xc000); WAIT1_Waitms(500); LEDR_SetRatio16(0x8000); WAIT1_Waitms(500); LEDR_SetRatio16(0x4000); WAIT1_Waitms(500); LEDR_SetRatio16(0x1000); WAIT1_Waitms(500); LEDR_SetRatio16(0x500); WAIT1_Waitms(500); LEDR_SetRatio16(0x100); WAIT1_Waitms(500); } /*** Don't write any code pass this line, or it will be deleted during code generation. ***/ /*** RTOS startup code. Macro PEX_RTOS_START is defined by the RTOS component. DON'T MODIFY THIS CODE!!! ***/ #ifdef PEX_RTOS_START PEX_RTOS_START(); /* Startup of the selected RTOS. Macro is defined by the RTOS component. */ #endif /*** End of RTOS startup code. ***/ /*** Processor Expert end of main routine. DON'T MODIFY THIS CODE!!! ***/ for(;;){} /*** Processor Expert end of main routine. DON'T WRITE CODE BELOW!!! ***/ } /*** End of main routine. DO NOT MODIFY THIS TEXT!!! ***/
void LOGIC_Run(void) { unsigned long data; unsigned char cmd; int i = 0; TU1Handl = TP1_initTimer(); // TP1_enableTimer(TU1Handl); DMAT1_Init(); // prepare SUMP variables triggerData[0].mask = 0; triggerData[0].values = 0; triggerData[0].configuration = 0; triggerData[1].mask = 0; triggerData[1].values = 0; triggerData[1].configuration = 0; triggerData[2].mask = 0; triggerData[2].values = 0; triggerData[2].configuration = 0; triggerData[3].mask = 0; triggerData[3].values = 0; triggerData[3].configuration = 0; // and preset Timer freqDivider = DEFAULT_CLOCK_DIVIDER; setSampleFrequency(); TP1_setTimerValue(TU1Handl, brg); for (;;) { i++; if (i > heartBeat) { /* heartbeat LED (red) if not sampling */ if (!doSampling) { LEDR_Neg(); } i = 0; } if (finishedSampling) { finishedSampling = FALSE; doSampling = FALSE; triggered = FALSE; SendData(); LEDB_Off(); LEDG_Off(); } if (AS1_GetCharsInRxBuf() != 0) { cmd = GetChar(); switch (cmd) { case SUMP_RESET: TP1_disableTimer(TU1Handl); DMAT1_DisableChannel0(); finishedSampling = FALSE; doSampling = FALSE; triggered = FALSE; LEDB_Off(); LEDG_Off(); break; case SUMP_RUN: bufferSize = BUFFERSIZE; finishedSampling = FALSE; doSampling = TRUE; DMAT1_EnableChannel0(); if (TP1_setTimerValue(TU1Handl, brg) != ERR_OK || DMAT1_SetDestinationAddress0( (LDD_DMA_TAddress) &sampleBuffer[0]) != ERR_OK || DMAT1_SetDestinationTransferSize0( bufferSize) != ERR_OK) { DMAT1_DisableChannel0(); doSampling = FALSE; triggered = FALSE; // Keep Blue AND Red LED ON as error signal LEDB_On(); LEDR_On(); LEDG_Off(); break; } doSampling = TRUE; if (triggerData[0].mask == 0) { // no trigger active, simply start sampling LEDR_Off(); LEDB_On(); triggered = TRUE; DMAT1_EnableChannel0(); // see also: SUMP Protocol f = clock / ( divider+1) // start LPTMR Timer and enable DMA TP1_enableTimer(TU1Handl); } else { LEDR_Off(); LEDG_On(); while (!triggered) { // Use short (fast) loop to detect trigger data = (Byte1_GetVal() & 0xFF); /* for now, we support only reading from 8 Probes data = ( Byte2_GetVal() & 0xFF ) << 8; data = ( Byte3_GetVal() & 0xFF ) << 16; data = ( Byte4_GetVal() & 0xFF ) << 24; */ /* use this, if single condition mask (AND) needed */ { if (!triggered && triggerData[0].mask != 0) { if ((data & triggerData[0].mask) == triggerData[0].values) { /* matching trigger */ /* use this, if multiple conditions (OR) are needed for (i = 0; i < DEVICE_NOF_PROBES; i++) { // we can handle all supported 32 Bits if ((triggerData[0].mask & 1 << i) > 0) { // if mask bit is set, check if values bit meets the probe bit if ((triggerData[0].values & 1 << i) == (data & 1 << i)) { // yes, we start if any trigger bit meets condition (primitive trigger only) */ LEDG_Off(); LEDB_On(); triggered = TRUE; // enable DMA AND Trigger first transfer to pick up Trigger // port value from Port // TODO: replace trigger handling by GPIO external trigger // for Level and Edge DMAT1_EnableChannel0(); DMAT1_StartTransfer0(); // see also: SUMP Protocol f = clock / ( divider+1) // start LPTMR Timer and enable DMA TP1_enableTimer(TU1Handl); break; } } } // BUT : do not lockup the analyzer!!! if (AS1_GetCharsInRxBuf() != 0 && GetChar() == SUMP_RESET) { TP1_disableTimer(TU1Handl); DMAT1_DisableChannel0(); finishedSampling = FALSE; doSampling = FALSE; triggered = FALSE; LEDB_Off(); LEDG_Off(); break; // leave the While(!triggered) loop } } } break; case SUMP_ID: PutString("1ALS"); break; case SUMP_GET_METADATA: /* device name: */ PutChar(0x01); PutString(DEVICE_NAME); PutChar(0x00); /* 'Firmware version: */ PutChar(0x02); PutString(DEVICE_FW_VERSION); PutChar(0x00); /* 'Ancillary' version: */ PutChar(0x03); PutString(DEVICE_ANCILLARY); PutChar(0x00); /* amount of sample memory available (bytes) */ SUMP_sendmeta_uint32(0x21, BUFFERSIZE); /* maximum sample rate (Hz) */ SUMP_sendmeta_uint32(0x23, MAX_SAMPLERATE); /* number of usable probes (short) */ SUMP_sendmeta_uint8(0x40, DEVICE_NOF_PROBES); /* protocol version (short) */ SUMP_sendmeta_uint8(0x41, DEVICE_PROTOCOL_VERSION); /* end of meta data */ PutChar(0x00); break; /* long commands.. consume bytes from UART, NYI */ /* Set Trigger Mask*/ case 0xC0: triggerData[0].mask = GetChar(); triggerData[0].mask |= GetChar() << 8; triggerData[0].mask |= GetChar() << 16; triggerData[0].mask |= GetChar() << 24; break; case 0xC4: triggerData[1].mask = GetChar(); triggerData[1].mask |= GetChar() << 8; triggerData[1].mask |= GetChar() << 16; triggerData[1].mask |= GetChar() << 24; break; case 0xC8: triggerData[2].mask = GetChar(); triggerData[2].mask |= GetChar() << 8; triggerData[2].mask |= GetChar() << 16; triggerData[2].mask |= GetChar() << 24; break; case 0xCC: triggerData[3].mask = GetChar(); triggerData[3].mask |= GetChar() << 8; triggerData[3].mask |= GetChar() << 16; triggerData[3].mask |= GetChar() << 24; break; /* Set Trigger Values */ case 0xC1: triggerData[0].values = GetChar(); triggerData[0].values |= GetChar() << 8; triggerData[0].values |= GetChar() << 16; triggerData[0].values |= GetChar() << 24; break; case 0xC5: triggerData[1].values = GetChar(); triggerData[1].values |= GetChar() << 8; triggerData[1].values |= GetChar() << 16; triggerData[1].values |= GetChar() << 24; break; case 0xC9: triggerData[2].values = GetChar(); triggerData[2].values |= GetChar() << 8; triggerData[2].values |= GetChar() << 16; triggerData[2].values |= GetChar() << 24; break; case 0xCD: triggerData[3].values = GetChar(); triggerData[3].values |= GetChar() << 8; triggerData[3].values |= GetChar() << 16; triggerData[3].values |= GetChar() << 24; break; /* Set Trigger Configuration */ case 0xC2: triggerData[0].configuration = GetChar(); triggerData[0].configuration |= GetChar() << 8; triggerData[0].configuration |= GetChar() << 16; triggerData[0].configuration |= GetChar() << 24; break; case 0xC6: triggerData[1].configuration = GetChar(); triggerData[1].configuration |= GetChar() << 8; triggerData[1].configuration |= GetChar() << 16; triggerData[1].configuration |= GetChar() << 24; break; case 0xCA: triggerData[2].configuration = GetChar(); triggerData[2].configuration |= GetChar() << 8; triggerData[2].configuration |= GetChar() << 16; triggerData[2].configuration |= GetChar() << 24; break; case 0xCE: triggerData[3].configuration = GetChar(); triggerData[3].configuration |= GetChar() << 8; triggerData[3].configuration |= GetChar() << 16; triggerData[3].configuration |= GetChar() << 24; break; case SUMP_SET_DIVIDER: // preliminary; received divider values seems to need more testing freqDivider = GetChar(); freqDivider |= GetChar() << 8; freqDivider |= GetChar() << 16; (void) GetChar(); setSampleFrequency(); break; case SUMP_SET_READ_DELAY_COUNT: rdCount = GetChar(); rdCount |= GetChar() << 8; rdCount |= GetChar() << 16; rdCount |= GetChar() << 24; break; /* Set Flag */ case SUMP_SET_FLAGS: flags = GetChar(); flags |= (GetChar() << 8); flags |= (GetChar() << 16); flags |= (GetChar() << 24); break; default: break; } /* switch */ } } }