示例#1
0
// ******** OS_MailBox_Init ************
// Initialize communication channel
// Inputs:  none
// Outputs: none
void OS_MailBox_Init(void)
{
	OS_InitSemaphore(&mailBoxFree,1);
	OS_InitSemaphore(&dataValid,0);
	volatile uint32_t dataInMailBox = 0;
	
}
示例#2
0
文件: UART.c 项目: tllado/RTOS_Bus
// Initialize UART0
// Baud rate is 115200 bits/sec
void UART_Init(void){
	OS_InitSemaphore(&RxDataAvailable, 0);         // Rx Fifo initially has 0 elements
	OS_InitSemaphore(&TxRoomLeft, UART_FIFOSIZE);  // Tx Fifo initially has all room available
  SYSCTL_RCGCUART_R |= 0x01;            // activate UART0
  SYSCTL_RCGCGPIO_R |= 0x01;            // activate port A
  RxFifo_Init();                        // initialize empty FIFO. See FIFO.h
  TxFifo_Init();                        // initialize empty FIFO. See FIFO.h
  UART0_CTL_R &= ~UART_CTL_UARTEN;      // disable UART
  UART0_IBRD_R = 43;                    // IBRD = int(80,000,000 / (16 * 115,200)) = int(43.4028)
  UART0_FBRD_R = 26;                    // FBRD = int(0.4028 * 64 + 0.5) = 26
                                        // 8 bit word length (no parity bits, one stop bit, FIFOs)
  UART0_LCRH_R = (UART_LCRH_WLEN_8|UART_LCRH_FEN);
  UART0_IFLS_R &= ~0x3F;                // clear TX and RX interrupt FIFO level fields
                                        // configure interrupt for TX FIFO <= 1/8 full
                                        // configure interrupt for RX FIFO >= 1/8 full
  UART0_IFLS_R += (UART_IFLS_TX1_8|UART_IFLS_RX1_8);
                                        // enable TX and RX FIFO interrupts and RX time-out interrupt
  UART0_IM_R |= (UART_IM_RXIM|UART_IM_TXIM|UART_IM_RTIM);
  UART0_CTL_R |= 0x301;                 // enable UART
  GPIO_PORTA_AFSEL_R |= 0x03;           // enable alt funct on PA1-0
  GPIO_PORTA_DEN_R |= 0x03;             // enable digital I/O on PA1-0
                                        // configure PA1-0 as UART
  GPIO_PORTA_PCTL_R = (GPIO_PORTA_PCTL_R&0xFFFFFF00)+0x00000011;
  GPIO_PORTA_AMSEL_R = 0;               // disable analog functionality on PA
                                        // UART0=priority 2
  NVIC_PRI1_R = (NVIC_PRI1_R&0xFFFF00FF)|0x00004000; // bits 13-15
  NVIC_EN0_R = NVIC_EN0_INT5;           // enable interrupt 5 in NVIC
}
示例#3
0
文件: Lab3.c 项目: airlink/EE-345M
int main(void){        // lab 3 real main
  OS_Init();           // initialize, disable interrupts

  OS_InitSemaphore(&MailBoxEmpty,1);
  OS_InitSemaphore(&MailBoxFull,0);

  DataLost = 0;        // lost data between producer and consumer
  NumSamples = 0;

//********initialize communication channels
  OS_MailBox_Init();
  OS_Fifo_Init(64);    // ***note*** 4 is not big enough*****

//*******attach background tasks***********
  OS_AddButtonTask(&ButtonPush,2);
  OS_AddDownTask(&DownPush,3);
  OS_AddPeriodicThread(&DAS,PERIOD,1); // 2 kHz real time sampling

  NumCreated = 0 ;
// create initial foreground threads
  NumCreated += OS_AddThread(&Interpreter,128,2); 
  NumCreated += OS_AddThread(&Consumer,128,1); 
  NumCreated += OS_AddThread(&PID,128,3); 
 
  OS_Launch(TIMESLICE); // doesn't return, interrupts enabled in here
  return 0;             // this never executes
}
示例#4
0
// ******** OS_Fifo_Init ************
// Initialize the Fifo to be empty
// Inputs: size
// Outputs: none 
// In Lab 2, you can ignore the size field
// In Lab 3, you should implement the user-defined fifo size
// In Lab 3, you can put whatever restrictions you want on size
//    e.g., 4 to 64 elements
//    e.g., must be a power of 2,4,8,16,32,64,128
void OS_Fifo_Init(unsigned long size)
{ 
  OS_TxPutI = OS_TxGetI = 0;  // Empty
  OS_InitSemaphore(&mutex,1);
	//OS_InitSemaphore(&roomLeft,TXFIFOSIZE);
	OS_InitSemaphore(&dataAvailable,0);
}
示例#5
0
文件: OS.c 项目: tach4455/EE345M
// ******** OS_Fifo_Init ************
// Initialize the Fifo to be empty
// Inputs: size
// Outputs: none
// In Lab 2, you can ignore the size field
// In Lab 3, you should implement the user-defined fifo size
// In Lab 3, you can put whatever restrictions you want on size
//    e.g., 4 to 64 elements
//    e.g., must be a power of 2,4,8,16,32,64,128
void OS_Fifo_Init(unsigned long size) {

  OS_InitSemaphore(&FifoMutex, 1);
  OS_InitSemaphore(&CurrentSize, 0);
  OS_PutPt = &OS_Fifo[0];
  OS_GetPt = &OS_Fifo[0];

  return;
}
示例#6
0
文件: Lab3.c 项目: airlink/EE-345M
int testmain6(void){      // Testmain6
  volatile unsigned long delay;
  OS_Init();           // initialize, disable interrupts
  delay = add(3,4);

  SignalCount1 = 0;   // number of times s is signaled
  SignalCount2 = 0;   // number of times s is signaled
  SignalCount3 = 0;   // number of times s is signaled
  WaitCount1 = 0;     // number of times s is successfully waited on
  WaitCount2 = 0;     // number of times s is successfully waited on
  WaitCount3 = 0;	  // number of times s is successfully waited on
  OS_InitSemaphore(&s,0);	 // this is the test semaphore
  OS_AddPeriodicThread(&Signal1,(799*TIME_1MS)/1000,0);   // 0.799 ms, higher priority
  OS_AddPeriodicThread(&Signal2,(1111*TIME_1MS)/1000,1);  // 1.111 ms, lower priority
  NumCreated = 0 ;
  NumCreated += OS_AddThread(&Thread6,128,6);    	// idle thread to keep from crashing
  NumCreated += OS_AddThread(&OutputThread,128,2); 	// results output thread
  NumCreated += OS_AddThread(&Signal3,128,2); 	// signalling thread
  NumCreated += OS_AddThread(&Wait1,128,2); 	// waiting thread
  NumCreated += OS_AddThread(&Wait2,128,2); 	// waiting thread
  NumCreated += OS_AddThread(&Wait3,128,2); 	// waiting thread
 
  OS_Launch(TIMESLICE);  // 1ms, doesn't return, interrupts enabled in here
  return 0;             // this never executes
}
示例#7
0
文件: Lab2Main.c 项目: oujoshua/445M
//int count1 = 0;
void dummyTask1(void) {
//   int i;
//   #if PROFILING == 1
//     int myPin = 0x01;
//   #endif
  OS_InitSemaphore(&binarySemaphore, OS_BINARY_SEMAPHORE);
  while(1) {
    OS_bWait(&binarySemaphore);
    OLED_Out(TOP, "task 1 acquired");
//     for(i = 0; i < 100000; i++) {
//       #if PROFILING == 1
//         GPIO_PORTB_DATA_R ^= myPin;
//       #endif
//     }
    OS_Sleep(1000);
    OS_bSignal(&binarySemaphore);
    OLED_Out(TOP, "task 1 released");
    OS_Sleep(1000);
//     for(i = 0; i < 100000; i++) {
//       #if PROFILING == 1
//         GPIO_PORTB_DATA_R ^= myPin;
//       #endif
//     }
//     OLED_Out(TOP, "task 1 dead");
//     OS_AddThread(&dummyTask2, 0 ,1);
//     OS_Kill();
  }
}
示例#8
0
文件: CANL.c 项目: baw959/RTOS
void BCAN_init(unsigned long bitRate)
{
  tCANMsgObject sCANMessage;
  //unsigned char ucMsgData[8];
  
  GPIO_PORTE_AFSEL_R |= 0x30; //PORTE AFSEL bits 5,4
  GPIO_PORTE_PCTL_R = (GPIO_PORTE_PCTL_R&0xFF00FFFF)|0x00880000;
  GPIO_PORTE_DEN_R |= 0x30;
  GPIO_PORTE_DIR_R |= 0x20;
  
  CAN_RX_FIFOFifo_Init();
  OS_InitSemaphore(&CANmessagesReceived,0);
  
  CANInit(CAN0_BASE);
  CANBitRateSet(CAN0_BASE, 80000000, 250000);
  //CANIntEnable(CAN0_BASE, CAN_INT_MASTER | CAN_INT_ERROR | CAN_INT_STATUS);    //these are enabled later with a seperate call
  //IntEnable(INT_CAN0);                              //since the filesystem can't seem to initialize while the ECU is shooting out CAN messages
  //CANEnable(CAN0_BASE);
  
  sCANMessage.ulMsgID = 0; // CAN msg ID - 0 for any
  sCANMessage.ulMsgIDMask = 0; // mask is 0 for any ID
  sCANMessage.ulFlags = MSG_OBJ_RX_INT_ENABLE | MSG_OBJ_USE_ID_FILTER;
  sCANMessage.ulMsgLen = 8; // allow up to 8 bytes
  
  CANMessageSet(CAN0_BASE, 1, &sCANMessage, MSG_OBJ_TYPE_RX);
}
示例#9
0
文件: can0.c 项目: tllado/RTOS_Bus
// Initialize CAN port
void CAN0_Open(void){uint32_t volatile delay;
	CAN0_Fifo_Init(16);
  OS_InitSemaphore(&CAN0ReceiveFree, 1);

	PacketLost = 0;                            
	MailFlag = false;
 
  SYSCTL_RCGCCAN_R |= 0x00000001;  // CAN0 enable bit 0
  SYSCTL_RCGCGPIO_R |= 0x00000010;  // RCGC2 portE bit 4
  for(delay=0; delay<10; delay++){};
  GPIO_PORTE_AFSEL_R |= 0x30; //PORTE AFSEL bits 5,4
// PORTE PCTL 88 into fields for pins 5,4
  GPIO_PORTE_PCTL_R = (GPIO_PORTE_PCTL_R&0xFF00FFFF)|0x00880000;
  GPIO_PORTE_DEN_R |= 0x30;
  GPIO_PORTE_DIR_R |= 0x20;
      
  CANInit(CAN0_BASE);
  CANBitRateSet(CAN0_BASE, 80000000, CAN_BITRATE);
  CANEnable(CAN0_BASE);
// make sure to enable STATUS interrupts
  CANIntEnable(CAN0_BASE, CAN_INT_MASTER | CAN_INT_ERROR | CAN_INT_STATUS);
// Set up filter to receive these IDs
// in this case there is just one type, but you could accept multiple ID types
  CAN0_Setup_Message_Object(RCV_ID, MSG_OBJ_RX_INT_ENABLE, 8, NULL, RCV_ID, MSG_OBJ_TYPE_RX);
  NVIC_EN1_R = (1 << (INT_CAN0 - 48)); //IntEnable(INT_CAN0);
  return;
}
示例#10
0
文件: Lab3.c 项目: tach4455/EE345M
int testmain6(void){      // Testmain6
  volatile unsigned long delay;
  OS_Init();           // initialize, disable interrupts
  delay = add(3,4);
  SYSCTL_RCGC2_R |= SYSCTL_RCGC2_GPIOB; // activate port B
  delay = SYSCTL_RCGC2_R;     // allow time to finish activating
  GPIO_PORTB_DIR_R |= 0x07;   // make PB2, PB1, PB0 out
  GPIO_PORTB_DEN_R |= 0x07;   // enable digital I/O on PB2, PB1, PB0
  SignalCount1 = 0;   // number of times s is signaled
  SignalCount2 = 0;   // number of times s is signaled
  SignalCount3 = 0;   // number of times s is signaled
  WaitCount1 = 0;     // number of times s is successfully waited on
  WaitCount2 = 0;     // number of times s is successfully waited on
  WaitCount3 = 0;	  // number of times s is successfully waited on
  OS_InitSemaphore(&s,0);	 // this is the test semaphore
  OS_AddPeriodicThread(&Signal1,1,(799*TIME_1MS)/1000,0);   // 0.799 ms, higher priority
  OS_AddPeriodicThread(&Signal2,2,(1111*TIME_1MS)/1000,1);  // 1.111 ms, lower priority
  NumCreated = 0 ;
  NumCreated += OS_AddThread(&Thread6,128,6);    	// idle thread to keep from crashing
  NumCreated += OS_AddThread(&OutputThread,128,2); 	// results output thread
  NumCreated += OS_AddThread(&Signal3,128,2); 	// signalling thread
  NumCreated += OS_AddThread(&Wait1,128,2); 	// waiting thread
  NumCreated += OS_AddThread(&Wait2,128,2); 	// waiting thread
  NumCreated += OS_AddThread(&Wait3,128,2); 	// waiting thread
 
  OS_Launch(TIME_1MS);  // 1ms, doesn't return, interrupts enabled in here
  return 0;             // this never executes
}
示例#11
0
//*****************************************************************************
//
//! Initialize the OLED display.
//!
//! \param ulFrequency specifies the SSI Clock Frequency to be used.
//!
//! This function initializes the SSI interface to the OLED display and
//! configures the SSD1329 controller on the panel.
//!
//! \return None.
//
//*****************************************************************************
void
RIT128x96x4Init(unsigned long ulFrequency)
{
    unsigned long ulIdx;

	
    // Initialize the semaphore
    OS_InitSemaphore(&oLEDFree, 1);

    //
    // Enable the SSI0 and GPIO port blocks as they are needed by this driver.
    //
    SysCtlPeripheralEnable(SYSCTL_PERIPH_SSI0);
    SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOA);
    SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIO_OLEDDC);

    //
    // Configure the SSI0CLK and SSIOTX pins for SSI operation.
    //
    GPIOPinTypeSSI(GPIO_PORTA_BASE, GPIO_PIN_2 | GPIO_PIN_3 | GPIO_PIN_5);
    GPIOPadConfigSet(GPIO_PORTA_BASE, GPIO_PIN_2 | GPIO_PIN_3 | GPIO_PIN_5,
                     GPIO_STRENGTH_8MA, GPIO_PIN_TYPE_STD_WPU);

    //
    // Configure the GPIO port pin used as a D/Cn signal for OLED device,
    // and the port pin used to enable power to the OLED panel.
    //
    GPIOPinTypeGPIOOutput(GPIO_OLEDDC_BASE, GPIO_OLEDDC_PIN | GPIO_OLEDEN_PIN);
    GPIOPadConfigSet(GPIO_OLEDDC_BASE, GPIO_OLEDDC_PIN | GPIO_OLEDEN_PIN,
                     GPIO_STRENGTH_8MA, GPIO_PIN_TYPE_STD);
    GPIOPinWrite(GPIO_OLEDDC_BASE, GPIO_OLEDDC_PIN | GPIO_OLEDEN_PIN,
                 GPIO_OLEDDC_PIN | GPIO_OLEDEN_PIN);
    HWREGBITW(&g_ulSSIFlags, FLAG_DC_HIGH) = 1;

    //
    // Configure and enable the SSI0 port for master mode.
    //
    RIT128x96x4Enable(ulFrequency);

    //
    // Clear the frame buffer.
    //
    RIT128x96x4Clear();

    //
    // Initialize the SSD1329 controller.  Loop through the initialization
    // sequence array, sending each command "string" to the controller.
    //
    for(ulIdx = 0; ulIdx < sizeof(g_pucRIT128x96x4Init);
        ulIdx += g_pucRIT128x96x4Init[ulIdx] + 1)
    {
        //
        // Send this command.
        //
        RITWriteCommand(g_pucRIT128x96x4Init + ulIdx + 1,
                        g_pucRIT128x96x4Init[ulIdx] - 1);
    }
}
示例#12
0
文件: Lab3.c 项目: tach4455/EE345M
void Thread2d(void){
  OS_InitSemaphore(&Readyd,0);
  Count1 = 0;          
  Count2 = 0;          
  for(;;){
    OS_bWait(&Readyd);
    Count2++;     
  }
}
示例#13
0
文件: fifo.c 项目: jrife/rtos
/*
 * Sets up and returns a FIFO struct, containing all data about the state of of
 * a FIFO data structure.
 *
 * fifoDataPtr - a pointer to the block of memory which is to contain the fifo
 *    most likely an array
 * fifoCapacity - the number of elements that can be contained in the block
 *    pointed to by fifoDataPtr of the given length
 * itemSizeBytes - the size of each item in the fifo in bytes ( result of sizeof )
 *
 * returns - a FIFO struct ready to be manipulated by the other FIFO functions
 */
void FIFOInit(FIFO* result, void* fifoDataPtr, size_t fifoCapacity, size_t itemSizeBytes) {
	OS_InitSemaphore(&(result->fifoFree),UNLOCKED); // Initialize the binary semaphore

	result->fifoDataPtr = fifoDataPtr;
	result->capacity = fifoCapacity;
	result->length = 0;
	result->itemSizeBytes = itemSizeBytes;
	result->tailIndex = 0;
	result->headIndex = 0;
}
示例#14
0
文件: Lab3.c 项目: tach4455/EE345M
void Thread2c(void){
  OS_InitSemaphore(&Readyc,0);
  Count1 = 0;    // number of times signal is called      
  Count2 = 0;    
  Count5 = 0;    // Count2 + Count5 should equal Count1 
  NumCreated += OS_AddThread(&Thread5c,128,3);  
  OS_AddPeriodicThread(&BackgroundThread1c,1,TIME_1MS,1); 
  for(;;){
    OS_Wait(&Readyc);
    Count2++;   // Count2 + Count5 should equal Count1, Count5 may be 0
  }
}
示例#15
0
文件: Lab3.c 项目: jrife/rtos
int mytestmain(void){       // my test main
  OS_Init();          // initialize, disable interrupts
  NumCreated = 0;
	OS_InitSemaphore(&Ready,LOCKED);
  NumCreated += OS_AddThread(&Threader1,128,1); 
  NumCreated += OS_AddThread(&Threader2,128,2); 
  NumCreated += OS_AddThread(&Threader3,128,3); 
	
  // Count1 runs, Count2 and Count3 are 0 because of starvation
  // change priority to equal to see round robin
  OS_Launch(TIMESLICE); // doesn't return, interrupts enabled in here
  return 0;             // this never executes
}
示例#16
0
文件: Ping.c 项目: zlalanne/EE345M
void Ping_Init(void) {
    volatile unsigned long delay;
    OS_DisableInterrupts();
    SYSCTL_RCGC2_R |= SYSCTL_RCGC2_GPIOB; // activate port B
    delay = SYSCTL_RCGC2_R;
    // **** Port B Edge Trigger Initialization ****
    GPIO_PORTB_DIR_R |= 0x03;   // make PB0-1 out
    GPIO_PORTB_DEN_R |= 0x03;   // enable digital I/O on PB0-1
    GPIO_PORTB_PUR_R |= 0x03;		// enable pull up on PB0-1
    GPIO_PORTB_IEV_R |= 0x03;	  // make PB0-1 rising edge triggered
    GPIO_PORTB_IS_R &= ~0x03;		// make PB0-1 edge-sensitive
    GPIO_PORTB_ICR_R = 0x03;		// clear flag
    NVIC_PRI0_R = (NVIC_PRI1_R&0xFFFF00FF)|0x00006000;  // priority 3
    NVIC_EN0_R |= NVIC_EN0_INT1;

    OS_InitSemaphore(&Sensor0Free, 1);
    OS_InitSemaphore(&Sensor1Free, 1);
    OS_InitSemaphore(&Sensor0DataAvailable, 0);
    OS_InitSemaphore(&Sensor1DataAvailable, 0);

    OS_EnableInterrupts();
}
示例#17
0
文件: lab17Rxf.c 项目: alandy/pacman
// ******** RxFifo_Init ************
// Initialize RxFifo to be empty
// Inputs: none
// Outputs: none 
void RxFifo_Init(void){
  RxPutPt = RxGetPt = &RxFifo[0];     // Empty when RxPutPt=RxGetPt 
  OS_InitSemaphore(&RxAvailable, 0);  // Initially empty 
}
示例#18
0
// ******** OS_Init ************
// initialize operating system, disable interrupts until OS_Launch
// initialize OS controlled I/O: serial, ADC, systick, select switch and timer2 
// input:  none
// output: none
void OS_Init(void){
	DisableInterrupts();
	RUNPT=0;
	JitterInit();
	deleteme=0;

// Enable processor interrupts.
    //
    //IntMasterEnable();
	TIMELORD=0; //initialize the system counter for use with thingies (no shit)
	NUMBLOCKEDTHREADS=0;
	TOTALNUMTHREADS=0;
    SDEBOUNCEPREV = 0;
    btndown_time = 0;
    

	SysCtlClockSet(SYSCTL_SYSDIV_4 | SYSCTL_USE_OSC | SYSCTL_OSC_MAIN | SYSCTL_XTAL_8MHZ);	//Init System Clock

	//Systick Init (Thread Scheduler)
	//taken care of in OS_Launch
     
	// Timers galore!
	SysCtlPeripheralEnable(SYSCTL_PERIPH_TIMER0);
	TimerConfigure(TIMER0_BASE, (TIMER_CFG_16_BIT_PAIR | TIMER_CFG_A_PERIODIC | TIMER_CFG_B_PERIODIC));
	//TimerControlTrigger(TIMER0_BASE, TIMER_A, false);  // TIMELORD Updater
	//TimerControlTrigger(TIMER0_BASE, TIMER_B, true);  // ADC_Collect Timer
	TimerLoadSet(TIMER0_BASE, TIMER_A, SysCtlClockGet()/1000);
	TimerIntEnable(TIMER0_BASE, TIMER_TIMA_TIMEOUT);
	TimerIntEnable(TIMER0_BASE, TIMER_TIMB_TIMEOUT);
	TimerEnable(TIMER0_BASE, TIMER_BOTH);
	IntEnable(INT_TIMER0A);
	  
	SysCtlPeripheralEnable(SYSCTL_PERIPH_TIMER1);
	TimerConfigure(TIMER1_BASE, TIMER_CFG_16_BIT_PAIR | TIMER_CFG_A_PERIODIC | TIMER_CFG_B_PERIODIC);
	TimerControlTrigger(TIMER1_BASE, TIMER_A, true);  // Periodic Timer 1
	TimerControlTrigger(TIMER1_BASE, TIMER_B, true);  // Periodic Timer 2
	TimerIntEnable(TIMER1_BASE, TIMER_TIMA_TIMEOUT);
	TimerIntEnable(TIMER1_BASE, TIMER_TIMB_TIMEOUT);
	  
	SysCtlPeripheralEnable(SYSCTL_PERIPH_TIMER2);
	TimerConfigure(TIMER2_BASE, TIMER_CFG_16_BIT_PAIR | TIMER_CFG_A_PERIODIC | TIMER_CFG_B_PERIODIC);
	TimerControlTrigger(TIMER2_BASE, TIMER_A, true);  // Periodic Timer 3
	TimerControlTrigger(TIMER2_BASE, TIMER_B, true);  // Periodic Timer 4
	TimerIntEnable(TIMER2_BASE, TIMER_TIMA_TIMEOUT);
	TimerIntEnable(TIMER2_BASE, TIMER_TIMB_TIMEOUT);
	
	// Init ADC Stuff
    SysCtlPeripheralEnable(SYSCTL_PERIPH_ADC0);
    SysCtlADCSpeedSet(SYSCTL_ADCSPEED_1MSPS);  
	  
	// Init Debugging LED
	SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOF);
	GPIOPinTypeGPIOOutput(GPIO_PORTF_BASE, GPIO_PIN_0);
	GPIOPinWrite(GPIO_PORTF_BASE, GPIO_PIN_0, GPIO_PIN_0);

	//Semaphores, OS Stuff
    OS_InitSemaphore(&oled_free,1);
	OS_InitSemaphore(&OSMailBoxSema4,0);
	OS_MailBox_Init();
	
	//UART & OLED 
	UARTInit();
	RIT128x96x4Init(1000000); //Init OLED
	//RIT128x96x4StringDraw("Hello World", 0, 12, 15);
	
	//ADC
    ADC_Init(); // Init ADC to run @ 1KHz

	//Select Switch (button press) Init	(select switch is PF1) (pulled from page 67 of the book and modified for PF1...i think)
	//SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOF);
  /*GPIOPinTypeGPIOInput(GPIO_PORTF_BASE, GPIO_PIN_1);
  IntEnable(INT_GPIOF);  
  //IntPrioritySet(INT_GPIOF, 0x00);
  GPIOIntTypeSet(GPIO_PORTF_BASE, GPIO_PIN_1, GPIO_BOTH_EDGES);
  GPIOPinIntEnable(GPIO_PORTF_BASE, GPIO_PIN_1);*/
  //NVIC_EN0_R |= 0x40000000;     // (h) enable interrupt 2 in NVIC (Not sure what Stellarisware function replaces this)
  
  
  /* This works for now, but Stellarisware Function owuld be nice */
  SYSCTL_RCGC2_R |= 0x00000020; // (a) activate port F
//	delay = SYSCTL_RCGC2_R;		    //delay, cause i said so
	GPIO_PORTF_DIR_R &= ~0x02;    // (c) make PF1 in
	GPIO_PORTF_DEN_R |= 0x02;     //     enable digital I/O on PF1
	GPIO_PORTF_IS_R &= ~0x02;     // (d) PF1 is edge-sensitive
	GPIO_PORTF_IBE_R &= ~0x02;    //     PF1 is not both edges
	GPIO_PORTF_IEV_R &= ~0x02;    //     PF1 falling edge event
	GPIO_PORTF_ICR_R = 0x02;      // (e) clear flag4
	GPIO_PORTF_IM_R |= 0x02;      // (f) arm interrupt on PF1
	NVIC_PRI7_R = (NVIC_PRI7_R&0xFF00FFFF)|(0<<21); // (g) priority (shifted into place) (will get set in OS_AddButtonTask)
	NVIC_EN0_R |= 0x40000000;     // (h) enable interrupt 2 in NVIC
	//dont enable interrupts 
	GPIO_PORTF_PUR_R |= 0x02;	    //add pull up resistor, just for shits and giggles
  
/*	SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOF);	  	// Enable GPIOF
  	GPIOPinTypeGPIOInput(GPIO_PORTF_BASE, GPIO_PIN_1);	// make Pin 1 an Input
  	GPIOPinRead(GPIO_PORTF_BASE, GPIO_PIN_1);			//
*/

//TODO: i have no f*****g clue what to do here...

return;
}
示例#19
0
文件: OS.c 项目: tach4455/EE345M
// ******** OS_MailBox_Init ************
// Initialize communication channel
// Inputs:  none
// Outputs: none
void OS_MailBox_Init(void) {
  OS_InitSemaphore(&BoxFree, 1);
  OS_InitSemaphore(&DataValid, 0);
  Mailbox = 0;
  return;
}
示例#20
0
文件: can0.c 项目: tllado/RTOS_Bus
// ******** CAN0_Fifo_Init ************
// Initialize the Fifo to be empty
// Inputs: size
// Outputs: none
void CAN0_Fifo_Init(unsigned long size){
  CAN0PutPt = &CAN0Fifo[0];
	CAN0GetPt = &CAN0Fifo[0];
	OS_InitSemaphore(&CAN0CurrentSize, 0);  // Nothing in fifo initially
	OS_InitSemaphore(&CAN0FifoMutex, 1);    // Fifo is available initially
}
示例#21
0
/* Initializes the OLED devices to be used as a
		split screen interface
 * param: unsigned char color, grayscale text color value
 * return: none
 */
void OLED_Init(unsigned char color)
{
	RIT128x96x4Init(1000000);
	OLED_Set_Color(color);
  OS_InitSemaphore(&OLED_Semaphore, OS_BINARY_SEMAPHORE);
}
示例#22
0
// ******** OS_Init ************
// initialize operating system, disable interrupts until OS_Launch
// initialize OS controlled I/O: serial, ADC, systick, select switch and timer2 
// input:  none
// output: none
void OS_Init(void){
	DisableInterrupts();
	RUNPT=0;

// Enable processor interrupts.
    //
    //IntMasterEnable();
	TIMELORD=0; //initialize the system counter for use with thingies (no shit)
    SDEBOUNCEPREV = 0;
    btndown_time = 0;
    
	SysCtlClockSet(SYSCTL_SYSDIV_4 | SYSCTL_USE_OSC | SYSCTL_OSC_MAIN | SYSCTL_XTAL_8MHZ);	//Init System Clock

	//Systick Init (Thread Scheduler)
	//taken care of in OS_Launch
     
	// Timers galore!
	SysCtlPeripheralEnable(SYSCTL_PERIPH_TIMER0);
	TimerConfigure(TIMER0_BASE, (TIMER_CFG_16_BIT_PAIR | TIMER_CFG_A_PERIODIC | TIMER_CFG_B_PERIODIC));
	TimerControlTrigger(TIMER0_BASE, TIMER_A, true);  // TIMELORD Updater
	TimerControlTrigger(TIMER0_BASE, TIMER_B, true);  // ADC_Collect Timer
	TimerLoadSet(TIMER0_BASE, TIMER_A, SysCtlClockGet()/1000);
	TimerIntEnable(TIMER0_BASE, TIMER_TIMA_TIMEOUT);
	TimerIntEnable(TIMER0_BASE, TIMER_TIMB_TIMEOUT);
	IntEnable(INT_TIMER0A);
	  
	SysCtlPeripheralEnable(SYSCTL_PERIPH_TIMER1);
	TimerConfigure(TIMER1_BASE, TIMER_CFG_16_BIT_PAIR | TIMER_CFG_A_PERIODIC | TIMER_CFG_B_PERIODIC);
	TimerControlTrigger(TIMER1_BASE, TIMER_A, true);  // Periodic Timer 1
	TimerControlTrigger(TIMER1_BASE, TIMER_B, true);  // Periodic Timer 2
	TimerIntEnable(TIMER1_BASE, TIMER_TIMA_TIMEOUT);
	TimerIntEnable(TIMER1_BASE, TIMER_TIMB_TIMEOUT);
	  
	SysCtlPeripheralEnable(SYSCTL_PERIPH_TIMER2);
	TimerConfigure(TIMER2_BASE, TIMER_CFG_16_BIT_PAIR | TIMER_CFG_A_PERIODIC | TIMER_CFG_B_PERIODIC);
	TimerControlTrigger(TIMER2_BASE, TIMER_A, true);  // Periodic Timer 3
	TimerControlTrigger(TIMER2_BASE, TIMER_B, true);  // Periodic Timer 4
	TimerIntEnable(TIMER2_BASE, TIMER_TIMA_TIMEOUT);
	TimerIntEnable(TIMER2_BASE, TIMER_TIMB_TIMEOUT);
	
	// Init ADC Stuff
    SysCtlPeripheralEnable(SYSCTL_PERIPH_ADC0);
    SysCtlADCSpeedSet(SYSCTL_ADCSPEED_1MSPS);  
	  
	// Init Debugging LED
	SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOF);
	GPIOPinTypeGPIOOutput(GPIO_PORTF_BASE, GPIO_PIN_0);
	GPIOPinWrite(GPIO_PORTF_BASE, GPIO_PIN_0, GPIO_PIN_0);

	//Semaphores, OS Stuff
    OS_InitSemaphore(&oled_free,1);
	OS_InitSemaphore(&OSMailBoxSema4,0);
	OS_MailBox_Init();
	
	//UART & OLED 
	UARTInit();
	RIT128x96x4Init(1000000); //Init OLED
	//RIT128x96x4StringDraw("Hello World", 0, 12, 15);
	
	//ADC
    ADC_Init(); // Init ADC to run @ 1KHz
        
	//Eval Buttons
	SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOE);
    GPIOPinTypeGPIOInput(GPIO_PORTE_BASE, GPIO_PIN_1);
    GPIOPadConfigSet(GPIO_PORTE_BASE, GPIO_PIN_1, GPIO_STRENGTH_2MA, GPIO_PIN_TYPE_STD_WPU);
    GPIOIntTypeSet(GPIO_PORTE_BASE, GPIO_PIN_1, GPIO_FALLING_EDGE);
    GPIOPinIntClear(GPIO_PORTE_BASE, GPIO_PIN_1);
    GPIOPinIntEnable(GPIO_PORTE_BASE, GPIO_PIN_1);
    IntEnable(INT_GPIOE);  
    
  	//SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOF);
    GPIOPinTypeGPIOInput(GPIO_PORTF_BASE, GPIO_PIN_1);
    GPIOPadConfigSet(GPIO_PORTF_BASE, GPIO_PIN_1, GPIO_STRENGTH_2MA, GPIO_PIN_TYPE_STD_WPU);
    GPIOIntTypeSet(GPIO_PORTF_BASE, GPIO_PIN_1, GPIO_FALLING_EDGE);
    GPIOPinIntClear(GPIO_PORTF_BASE, GPIO_PIN_1);
    GPIOPinIntEnable(GPIO_PORTF_BASE, GPIO_PIN_1);
    IntEnable(INT_GPIOF);  
  
    /* This works for now, but Stellarisware Function owuld be nice */
    /*SYSCTL_RCGC2_R |= 0x00000020; // (a) activate port F
//	delay = SYSCTL_RCGC2_R;		    //delay, cause i said so
	GPIO_PORTF_DIR_R &= ~0x02;    // (c) make PF1 in
	GPIO_PORTF_DEN_R |= 0x02;     //     enable digital I/O on PF1
	GPIO_PORTF_IS_R &= ~0x02;     // (d) PF1 is edge-sensitive
	GPIO_PORTF_IBE_R &= ~0x02;    //     PF1 is not both edges
	GPIO_PORTF_IEV_R &= ~0x02;    //     PF1 falling edge event
	GPIO_PORTF_ICR_R = 0x02;      // (e) clear flag4
	GPIO_PORTF_IM_R |= 0x02;      // (f) arm interrupt on PF1
	NVIC_PRI7_R = (NVIC_PRI7_R&0xFF00FFFF)|(0<<21); // (g) priority (shifted into place) (will get set in OS_AddButtonTask)
	NVIC_EN0_R |= 0x40000000;     // (h) enable interrupt 2 in NVIC
	//dont enable interrupts 
	GPIO_PORTF_PUR_R |= 0x02;	    //add pull up resistor, just for shits and giggles
    */
}
示例#23
0
// ******** OS_MailBox_Init ************
// Initialize communication channel
// Inputs:  none
// Outputs: none
void OS_MailBox_Init(void){
	OS_InitSemaphore(&OSMailBoxSema4,0);
	return;
}
示例#24
0
文件: Lab17OS2.c 项目: alandy/pacman
//******** OS_OpenDataChannel *************** 
// Initialize data transfer channel
// inputs:  none
// outputs: none
void OS_OpenDataChannel(void){
  OS_InitSemaphore(&DataAvailable, 0);  // Initially empty
  DataPutPt = DataGetPt = &DataFifo[0];
}