コード例 #1
0
ファイル: Lab5.c プロジェクト: AustinBlackstone/EE345M-S2012
void TestDisk(void){  DSTATUS result;  unsigned short block;  int i; unsigned long n;
  // simple test of eDisk
  printf("\n\rEE345M/EE380L, Lab 5 eDisk test\n\r");
  result = eDisk_Init(0);  // initialize disk
  if(result) diskError("eDisk_Init",result);
  printf("Writing blocks\n\r");
  n = 1;    // seed
  for(block = 0; block < MAXBLOCKS; block++){
    for(i=0;i<512;i++){
      n = (16807*n)%2147483647; // pseudo random sequence
      buffer[i] = 0xFF&n;        
    }
    GPIO_PF3 = 0x08;     // PF3 high for 100 block writes
    if(eDisk_WriteBlock(buffer,block))diskError("eDisk_WriteBlock",block); // save to disk
    GPIO_PF3 = 0x00;     
  }  
  printf("Reading blocks\n\r");
  n = 1;  // reseed, start over to get the same sequence
  for(block = 0; block < MAXBLOCKS; block++){
    GPIO_PF2 = 0x04;     // PF2 high for one block read
    if(eDisk_ReadBlock(buffer,block))diskError("eDisk_ReadBlock",block); // read from disk
    GPIO_PF2 = 0x00;
    for(i=0;i<512;i++){
      n = (16807*n)%2147483647; // pseudo random sequence
      if(buffer[i] != (0xFF&n)){
        printf("Read data not correct, block=%u, i=%u, expected %u, read %u\n\r",block,i,(0xFF&n),buffer[i]);
        OS_Kill();
      }      
    }
  }  
  printf("Successful test of %u blocks\n\r",MAXBLOCKS);
  OS_Kill();
}
コード例 #2
0
ファイル: Lab3.c プロジェクト: jrife/rtos
// }
void Thread7(void){  // foreground thread
  printf("\n\rEE345M/EE380L, Lab 3 Preparation 2\n\r");
  OS_Sleep(10000);   // 10 seconds        
  //Jitter();         // print jitter information
  printf("\n\r\n\r");
  OS_Kill();
}
コード例 #3
0
ファイル: Lab3.c プロジェクト: tach4455/EE345M
void Thread4d(void){ int i;
  for(i=0;i<640;i++){
    Count4++;
    OS_Sleep(1);
  }
  OS_Kill();
}
コード例 #4
0
ファイル: Lab3.c プロジェクト: tach4455/EE345M
void Thread7(void){  // foreground thread
  UART0_SendString("\n\rEE345M/EE380L, Lab 3 Preparation 2\n\r");
  OS_Sleep(5000);   // 10 seconds        
  Jitter();         // print jitter information
  UART0_SendString("\n\r\n\r");
  OS_Kill();
}
コード例 #5
0
ファイル: Lab2Main.c プロジェクト: oujoshua/445M
//************ButtonPush*************
// Called when Select Button pushed
// Adds another foreground task
// background threads execute once and return
void ButtonPush(void){
  if(OS_AddThread(&ButtonWork,100,1)){
    NumCreated++; 
  }
  OS_Kill();
  OS_Delay(OS_ARBITRARY_DELAY);
}
コード例 #6
0
ファイル: Lab3.c プロジェクト: tach4455/EE345M
void Signal3(void){       // foreground
  while(SignalCount3<98*MAXCOUNT){
    OS_Signal(&s);
    SignalCount3++;
  }
  OS_Kill();
}
コード例 #7
0
ファイル: Lab3.c プロジェクト: airlink/EE-345M
void Thread7(void){  // foreground thread
  OSuart_OutString(UART0_BASE,"\n\rEE345M/EE380L, Lab 3 Preparation 2\n\r");
  OS_Sleep(5000);   // 10 seconds        
  Jitter();         // print jitter information
  OSuart_OutString(UART0_BASE,"\n\r\n\r");
  OS_Kill();
}
コード例 #8
0
ファイル: Lab5.c プロジェクト: airlink/EE-345M
//******** Robot *************** 
// foreground thread, accepts data from producer
// inputs:  none
// outputs: none
void Robot(void){   
unsigned long data;      // ADC sample, 0 to 1023
unsigned long voltage;   // in mV,      0 to 3000
unsigned long time = 0;      // in 10msec,  0 to 1000 
unsigned long t=0;
unsigned int i;
  //OS_ClearMsTime();
  char string[100];    
  DataLost = 0;          // new run with no lost data 
  OSuart_OutString(UART0_BASE, "Robot running...");
  eFile_Create("Robot");
  eFile_RedirectToFile("Robot");
  OSuart_OutString(UART0_BASE, "time(sec)\tdata(volts)\n\r");
  for(i = 1000; i > 0; i--){
    t++;
    time+=OS_Time()/10000;            // 10ms resolution in this OS
    while(!OS_Fifo_Get(&data));        // 1000 Hz sampling get from producer
    voltage = (300*data)/1024;   // in mV
    sprintf(string, "%0u.%02u\t\t%0u.%03u\n\r",time/100,time%100,voltage/1000,voltage%1000);
    OSuart_OutString(UART0_BASE, string);
  }
  eFile_EndRedirectToFile();
  OSuart_OutString(UART0_BASE, "done.\n\r");										    
  Running = 0;                // robot no longer running
  OS_Kill();
}
コード例 #9
0
ファイル: Lab5.c プロジェクト: AustinBlackstone/EE345M-S2012
void TestFile(void){   int i; char data; 
  printf("\n\rEE345M/EE380L, Lab 5 eFile test\n\r");
  // simple test of eFile
  if(eFile_Init())              diskError("eFile_Init",0); 
  if(eFile_Format())            diskError("eFile_Format",0); 
  //eFile_Directory(&Serial_OutChar);
  eFile_Directory(&UARTPut);
  if(eFile_Create("file1"))     diskError("eFile_Create",0);
  if(eFile_WOpen("file1"))      diskError("eFile_WOpen",0);
  for(i=0;i<1000;i++){
    if(eFile_Write('a'+i%26))   diskError("eFile_Write",i);
    if(i%52==51){
      if(eFile_Write('\n'))     diskError("eFile_Write",i);  
      if(eFile_Write('\r'))     diskError("eFile_Write",i);
    }
  }
  if(eFile_WClose())            diskError("eFile_Close",0);
  //eFile_Directory(&Serial_OutChar);
  eFile_Directory(&UARTPut);
  if(eFile_ROpen("file1"))      diskError("eFile_ROpen",0);
  for(i=0;i<1000;i++){
    if(eFile_ReadNext(&data))   diskError("eFile_ReadNext",i);
    //Serial_OutChar(data);
	UARTPut(data);
  }
  if(eFile_Delete("file1"))     diskError("eFile_Delete",0);
  //eFile_Directory(&Serial_OutChar);
  eFile_Directory(&UARTPut);
  printf("Successful test of creating a file\n\r");
  OS_Kill();
}
コード例 #10
0
ファイル: Lab3.c プロジェクト: tach4455/EE345M
void Thread4c(void){ int i;
  for(i=0;i<64;i++){
    Count4++;
    OS_Sleep(10);
  }
  OS_Kill();
  Count4 = 0;
}
コード例 #11
0
ファイル: Lab3.c プロジェクト: AustinBlackstone/EE345M-S2012
void Thread7(void){  // foreground thread
  //print("\n\rEE345M/EE380L, Lab 3 Preparation 2\n\r");
  oLED_Message(1,0,"\n\rEE345M/EE380L, Lab 3 Preparation 2\n\r",-0);
  OS_Sleep(5000);   // 10 seconds        
  Jitter();         // print jitter information
  printf("\n\r\n\r");
  OS_Kill();
}
コード例 #12
0
ファイル: Lab3.c プロジェクト: jrife/rtos
void OutputThread(void){  // foreground thread
  printf("\n\rEE345M/EE380L, Lab 3 Preparation 4\n\r");
  while(SignalCount1+SignalCount2+SignalCount3<100*MAXCOUNT){
    OS_Sleep(1000);   // 1 second
    printf(".");
  }       
  printf(" done\n\r");
  printf("Signalled=%u, Waited=%u\n\r",SignalCount1+SignalCount2+SignalCount3,WaitCount1+WaitCount2+WaitCount3);

  OS_Kill();
}
コード例 #13
0
ファイル: Lab3.c プロジェクト: tach4455/EE345M
//******** Display *************** 
// foreground thread, accepts data from consumer
// displays calculated results on the LCD
// inputs:  none                            
// outputs: none
void Display(void){ 
unsigned long data,voltage;
  oLED_Message(0,0,"Run length is",(RUNLENGTH)/1000);   // top half used for Display
  while(NumSamples < RUNLENGTH) { 
    oLED_Message(0,1,"Time left is",(RUNLENGTH-NumSamples)/1000);   // top half used for Display
    data = OS_MailBox_Recv();
    voltage = 3000*data/1024;               // calibrate your device so voltage is in mV
    oLED_Message(0,2,"v(mV) =",voltage);  
  } 
  OS_Kill();  // done
} 
コード例 #14
0
ファイル: host-lib.c プロジェクト: Oldes/r3
*/	REBINT OS_Send_Signal(REBINT pid, REBINT signal)
/*
**		Send signal to a process
**
***********************************************************************/
{
	if (signal == 9 || signal == 15) { //SIGKILL || SIGTERM
		return OS_Kill(pid);
	}
	return OS_ENA;
}
コード例 #15
0
//------------------Task 2--------------------------------
// background thread executes with SW1 button
// one foreground task created with button push
// foreground treads run for 2 sec and die
// ***********ButtonWork*************
void ButtonWork(void){
unsigned long myId = OS_Id(); 
  PE1 ^= 0x02;
  ST7735_Message(1,0,"NumCreated =",NumCreated); 
  PE1 ^= 0x02;
  OS_Sleep(50);     // set this to sleep for 50msec
  ST7735_Message(1,1,"PIDWork     =",PIDWork);
  ST7735_Message(1,2,"DataLost    =",DataLost);
  ST7735_Message(1,3,"Jitter 0.1us=",MaxJitter);
  PE1 ^= 0x02;
  OS_Kill();  // done, OS does not return from a Kill
} 
コード例 #16
0
void thread(void)
{
	unsigned int id;
	
	id = OS_Id();
	PF3 ^= 0x08;
	Display_Message(0,line++, "Thread: ", id);
	OS_Sleep(2000);
	Display_Message(0,line++, "Thread dying ", id);
	PF3 ^= 0x08;
	OS_Kill();
}
コード例 #17
0
ファイル: Lab3.c プロジェクト: tach4455/EE345M
void OutputThread(void){  // foreground thread
  char buffer[60];
  UART0_SendString("\n\rEE345M/EE380L, Lab 3 Preparation 4\n\r");
  while(SignalCount1+SignalCount2+SignalCount3<100*MAXCOUNT){
    OS_Sleep(1000);   // 1 second
    UART0_SendString(".");
  }       
  UART0_SendString(" done\n\r");
  snprintf(buffer, 60, "Signalled=%u, Waited=%u\n\r",SignalCount1+SignalCount2+SignalCount3,WaitCount1+WaitCount2+WaitCount3);
  UART0_SendString(buffer);

  OS_Kill();
}
コード例 #18
0
ファイル: Lab5.c プロジェクト: airlink/EE-345M
void TestFile(void){   int i; char data; DSTATUS result; 
  OSuart_OutString(UART0_BASE, "\n\rEE345M/EE380L, Lab 5 eFile test\n\r");
  // simple test of eFile
  result = eDisk_Init(0);  // initialize disk
  if(result) diskError("eDisk_Init",result);
  if(eFile_Init())              diskError("eFile_Init",0); 
//  if(eFile_Format())            diskError("eFile_Format",0); 
  eFile_Directory();
  if(eFile_ROpen("file1"))      diskError("eFile_ROpen",0);
  eFile_Directory();
  for(i=0;i<1000;i++){
    if(eFile_ReadNext(&data))   diskError("eFile_ReadNext",i);
    OSuart_OutChar(UART0_BASE, data);
	SysCtlDelay(SysCtlClockGet()/10000);
  }
  eFile_Directory();	
  if(eFile_Create("file1"))     diskError("eFile_Create",0);
  if(eFile_WOpen("file1"))      diskError("eFile_WOpen",0);
  for(i=0;i<1000;i++){
    if(eFile_Write('a'+i%26))   diskError("eFile_Write",i);
    if(i%52==51){
      if(eFile_Write('\n'))     diskError("eFile_Write",i);  
      if(eFile_Write('\r'))     diskError("eFile_Write",i);
    }
  }
  if(eFile_WClose())            diskError("eFile_Close",0);
  eFile_Directory();
  if(eFile_Create("file2"))     diskError("eFile_Create",0);
  if(eFile_WOpen("file2"))      diskError("eFile_WOpen",0);
  for(i=0;i<1000;i++){
    if(eFile_Write('a'+i%26))   diskError("eFile_Write",i);
    if(i%52==51){
      if(eFile_Write('\n'))     diskError("eFile_Write",i);  
      if(eFile_Write('\r'))     diskError("eFile_Write",i);
    }
  }
  if(eFile_WClose())            diskError("eFile_Close",0);
  eFile_Directory();
/*  if(eFile_ROpen("file1"))      diskError("eFile_ROpen",0);
  eFile_Directory();
  for(i=0;i<1000;i++){
    if(eFile_ReadNext(&data))   diskError("eFile_ReadNext",i);
    OSuart_OutChar(UART0_BASE, data);
	SysCtlDelay(SysCtlClockGet()/10000);
  }
  eFile_Directory();
  if(eFile_Delete("file1"))     diskError("eFile_Delete",0);
//  eFile_Directory();	 */
  OSuart_OutString(UART0_BASE, "Successful test of creating a file\n\r");
  OS_Kill();
}
コード例 #19
0
//******** Display *************** 
// foreground thread, accepts data from consumer
// displays calculated results on the LCD
// inputs:  none                            
// outputs: none
void Display(void){ 
unsigned long data,voltage;
	//OS_DisableInterrupts();
  ST7735_Message(0,1,"Run length = ",(RUNLENGTH)/FS);   // top half used for Display
	//OS_EnableInterrupts();
  while(NumSamples < RUNLENGTH) { 
    data = OS_MailBox_Recv();
    voltage = 3000*data/4095;               // calibrate your device so voltage is in mV
    PE3 = 0x08;
    ST7735_Message(0,2,"v(mV) =",voltage);  
    PE3 = 0x00;
  } 
  OS_Kill();  // done
} 
コード例 #20
0
ファイル: Lab2.c プロジェクト: airlink/EE-345M
//------------------Task 2--------------------------------
// background thread executes with select button
// one foreground task created with button push
// foreground treads run for 2 sec and die
// ***********ButtonWork*************
void ButtonWork(void){
unsigned long i;
unsigned long myId = OS_Id(); 
  oLED_Message(1,0,"NumCreated =",NumCreated); 
  if(NumSamples < RUNLENGTH){   // finite time run
    for(i=0;i<20;i++){  // runs for 2 seconds
      //OS_Sleep(20);     // set this to sleep for 0.1 sec
    }
  }
  oLED_Message(1,1,"PIDWork    =",PIDWork);
  oLED_Message(1,2,"DataLost   =",DataLost);
  oLED_Message(1,3,"Jitter(us) =",MaxJitter-MinJitter);
  OS_Kill();  // done
} 
コード例 #21
0
ファイル: Lab3.c プロジェクト: tach4455/EE345M
//------------------Task 2--------------------------------
// background thread executes with select button
// one foreground task created with button push
// foreground treads run for 2 sec and die
// ***********ButtonWork*************
void ButtonWork(void){
unsigned long i;
unsigned long myId = OS_Id(); 
  oLED_Message(1,0,"NumCreated =",NumCreated); 
  if(NumSamples < RUNLENGTH){   // finite time run
    for(i=0;i<40;i++){  // runs for 2 seconds
      OS_Sleep(50);     // sleep for 50ms
    }
  }
  oLED_Message(1,1,"PIDWork    =",PIDWork);
  oLED_Message(1,2,"DataLost   =",DataLost);
  oLED_Message(1,3,"0.1u Jitter=",MaxJitter1-MinJitter1);

  OS_Kill();  // done
} 
コード例 #22
0
ファイル: Lab2Main.c プロジェクト: oujoshua/445M
void DisplayThread(void)
{
	char str[20];
	while(NumSamples < RUNLENGTH)
	{
		sprintf(str, "Time left is %d", (RUNLENGTH-NumSamples)/1000);
		_OLED_Message(TOP, 1, str, 15);
		sprintf(str, "v(mV) = %d", voltage);
		_OLED_Message(TOP, 2, str, 15);
//    OS_Suspend();
     OS_Sleep(500);
	}
	OS_Kill();
	OS_Delay(OS_ARBITRARY_DELAY);
}
コード例 #23
0
int main(void)
{
	unsigned int id;
	unsigned long time;	
	id = OS_Id();
	PF2 ^= 0x04;
	Display_Message(0,line++, "Hello world: ", id);
	OS_AddThread(thread, 128, 1);
  time = OS_Time();
	OS_Sleep(1000);
	time = (((OS_TimeDifference(time, OS_Time()))/1000ul)*125ul)/10000ul;
	Display_Message(0,line++, "Sleep time: ", time);
	PF2 ^= 0x04;
	OS_Kill();
}
コード例 #24
0
ファイル: Lab2Main.c プロジェクト: oujoshua/445M
void dummyTask3(void) {
  count3++;
  OS_Sleep(4000); // sleep for 4 seconds
  OLED_Out(BOTTOM, "task 3 Yaaaaaaaaaawn");
  NumCreated += OS_AddThread(&dummyTask3, 64, 2);
  OS_Kill();
//   #if PROFILING == 1
//     int myPin = 0x04;
//   #endif
//   while(1) {
//     count3++;
//     #if PROFILING == 1
//       GPIO_PORTB_DATA_R ^= myPin;
//     #endif
//   }
}
コード例 #25
0
ファイル: SmartBus.c プロジェクト: tllado/RTOS_Bus
void leftInTick(void) {
    uint8_t newBit = lDatIn;
    leftInByte += newBit << leftInCount;
    leftInCount++;
    
    if(leftInCount == 8) {
        int32_t status = StartCritical();
            FIFOWrite(right, leftInByte);
            if((leftInByte&ID_MASK) == sbID)
                FIFOWrite(up, leftInByte);
        EndCritical(status);
        leftInCount = 0;
    }

    OS_Kill();
}
コード例 #26
0
ファイル: Lab3.c プロジェクト: airlink/EE-345M
void OutputThread(void){  // foreground thread
  char sigStr[7], waitStr[7];
  OSuart_OutString(UART0_BASE,"\n\rEE345M/EE380L, Lab 3 Preparation 4\n\r");
  while(SignalCount1+SignalCount2+SignalCount3<100*MAXCOUNT){
    OS_Sleep(1000);   // 1 second
    OSuart_OutString(UART0_BASE,".");
  }       
  OSuart_OutString(UART0_BASE," done\n\r");
  Int2Str(SignalCount1+SignalCount2+SignalCount3, sigStr);
  Int2Str(WaitCount1+WaitCount2+WaitCount3, waitStr);
  OSuart_OutString(UART0_BASE,"Signalled = ");
  OSuart_OutString(UART0_BASE,sigStr);
  OSuart_OutString(UART0_BASE,"Waited = ");
  OSuart_OutString(UART0_BASE,waitStr);

  OS_Kill();
}
コード例 #27
0
ファイル: Lab3.c プロジェクト: tach4455/EE345M
//******** Consumer *************** 
// foreground thread, accepts data from producer
// calculates FFT, sends DC component to Display
// inputs:  none
// outputs: none
void Consumer(void){ 
unsigned long data,DCcomponent; // 10-bit raw ADC sample, 0 to 1023
unsigned long t;  // time in ms
unsigned long myId = OS_Id(); 
  ADC_Collect(0, 1000, &Producer); // start ADC sampling, channel 0, 1000 Hz
  NumCreated += OS_AddThread(&Display,128,0); 
  while(NumSamples < RUNLENGTH) { 
    for(t = 0; t < 64; t++){   // collect 64 ADC samples
      data = OS_Fifo_Get();    // get from producer
      x[t] = data;             // real part is 0 to 1023, imaginary part is 0
    }
    cr4_fft_64_stm32(y,x,64);  // complex FFT of last 64 ADC values
    DCcomponent = y[0]&0xFFFF; // Real part at frequency 0, imaginary part should be zero
    OS_MailBox_Send(DCcomponent);
  }
  OS_Kill();  // done
}
コード例 #28
0
ファイル: Lab3.c プロジェクト: airlink/EE-345M
void PID(void){ 
short err;  // speed error, range -100 to 100 RPM
unsigned long myId = OS_Id(); 
  PIDWork = 0;
  IntTerm = 0;
  PrevError = 0;
  Coeff[0] = 384;   // 1.5 = 384/256 proportional coefficient
  Coeff[1] = 128;   // 0.5 = 128/256 integral coefficient
  Coeff[2] = 64;    // 0.25 = 64/256 derivative coefficient*
  while(NumSamples < RUNLENGTH) { 
    for(err = -1000; err <= 1000; err++){    // made-up data
      Actuator = PID_stm32(err,Coeff)/256;
    }
	GPIO_B2 ^= 0x04; 
    PIDWork++;        // calculation finished
  }
  OS_Kill();          // done
}
コード例 #29
0
ファイル: Lab5.c プロジェクト: oujoshua/445M
void read_test(void) {
  int i;
  unsigned int then, now;
  eFile_Init();
  eFile_Format();
  OS_AddThread(&write_test, 128, 0);
  OS_Sleep(2000);
  then = OS_MsTime();
  // read 10 blocks
  for(i = 0; i < 10; i++) {
    eDisk_ReadBlock(buffer, i);
  }
  now = OS_MsTime();
  OS_AddThread(&SH_Shell, 128, 0);
	OS_Sleep(1000);
	OS_Suspend();
  printf("Read test took %d ms", now - then);
  eFile_Format();
  OS_Kill();
}
コード例 #30
0
ファイル: Lab2Main.c プロジェクト: oujoshua/445M
//******** Display *************** 
// foreground thread, accepts data from consumer
// displays calculated results on the LCD
// inputs:  none                            
// outputs: none
void Display(void){ 
unsigned long data;
  char str[20];
   sprintf(str, "Run length is %d", RUNLENGTH/1000);
  OLED_Out(TOP, str);   // top half used for Display
  NumCreated += OS_AddThread(&DisplayThread, 128, 5);
  while(NumSamples < RUNLENGTH) {
//    sprintf(str, "Time left is %d", (RUNLENGTH-NumSamples)/1000);
//     OS_LogEvent(EVENT_OLED_START);
//    OLED_Out(TOP, str);   // top half used for Display
//     OS_LogEvent(EVENT_OLED_FINISH);
    data = OS_MailBox_Recv();
    voltage = 3000*data/1024;               // calibrate your device so voltage is in mV
//		sprintf(str, "v(mV) = %d", voltage);
//		OLED_Out(TOP, str);
// 		OS_Delay(OS_ARBITRARY_DELAY);
  }
	OLED_Out(BOTTOM, "DONE");
	OS_Kill();  // done
  OS_Delay(OS_ARBITRARY_DELAY);
}