Пример #1
0
void main(void){
//------------------------------------------------------------------------------
// Main Program
// This is the main routine for the program. Execution of code starts here.
// The operating system is Back Ground Fore Ground.
// 
//------------------------------------------------------------------------------
  Init_Ports();                             // Initialize Ports
  Init_Clocks();                            // Initialize Clock System 
  Init_Conditions();
  PJOUT |= LED1;                            // Turn LED 1 on to indicate boot
  Time_Sequence = 0;               // 
  Init_Timers();                            // Initialize Timers
  Init_LEDs();                              // Initialize LEDs

//------------------------------------------------------------------------------
// Begining of the "While" Operating System
//------------------------------------------------------------------------------
 while(ALWAYS) {                            // Can the Operating system run
  switch(Time_Sequence){
    case 250:                               // 1000 msec  
      if(one_time){
        Init_LEDs();                        // Initialize LEDs
        one_time = 0;
      }
      Time_Sequence = 0;                    // 
    case 200:                               // 1000 msec  
      if(one_time){
        PJOUT |= LED4;                      // Change State of LED 4
        P3OUT |= LED5;                      // Change State of LED 5
        one_time = 0;
      }
    case 150:                               // 750 msec  
      if(one_time){
        PJOUT |= LED3;                      // Change State of LED 3
        P3OUT |= LED6;                      // Change State of LED 6
        one_time = 0;
      }
    case 100:                               // 500 msec  
      if(one_time){
        PJOUT |= LED2;                      // Change State of LED 2
        P3OUT |= LED7;                      // Change State of LED 7
        one_time = 0;
      }
    case  50:                               // 250 msec  
      if(one_time){
        PJOUT |= LED1;                      // Change State of LED 1
        P3OUT |= LED8;                      // Change State of LED 8
        one_time = 0;
      }
      break;                                // 
    default: break; 
  }
  Switches_Process();                       // Check for switch state change 
  if(Time_Sequence > 250){
    Time_Sequence = 0;
  }
 }
//------------------------------------------------------------------------------
}
Пример #2
0
int main(void)
{
   /* perform the needed initialization here */
	Init_Leds();
    Init_Teclas();
    Init_Timers();
    Setear_Tiempo(TIEMPO_T);

   while(1)
   {
	 auxiliar =Chequea_T();
     switch(auxiliar)
			{
     case TEC1:
    	   arciris = 1;
    	   color=0;
    	   break;
     	 	}

     if (arciris)
     {
    	 Arcoiris();
     }
    }

    return 1;
}
void Init_System(void)
{

	Init_Buttons();
	Init_Timers();
	__enable_interrupt();   // enable global interrupts
}
Пример #4
0
void main(void)
{
	Init_Ports();                             // Initialize Ports
	Init_Clocks();                            // Initialize Clock System 
	Init_Conditions();
	Init_Interrupts();
	  
	TimeMsec = RESET_TIME;
	Init_Timers(); 				// Initialize Timers
	Init_LCD();				// Initialize LCD    
        
        
	//          "0123456789abcdef"
	display_1 = "   Homework 9   ";
	display_2 = "                ";
	Display_Process();
	
/* ---------- Begining of the "While" Operating System ------------- */
	while(ALWAYS) 										// Can the Operating system run
	{                            
                ADC_Process();
                Control_Process();
                Menu_Process();
                
          
                if(TimeMsec % EVERY_50 == RESET_TIME)
                {
                        Display_Process();
                }	
	}
}
Пример #5
0
int main(void)
{
   /* perform the needed initialization here */
	Init_Leds();

	while (!Init_Teclas(&pulsador[0],0,4,1,0,0));
	/*
	    Ejemplo:
	    En EDU CIA el Pulsador 0, TEC 1 //
	    Se instanciaría de la siguiente forma:
	    tecla puls0;
	    Init_Teclas(&pulsador[0],0,4,1,0,0)
	    donde:
	    *puerto = 0; // GPIO port 0 -4
	    *pin_loc = 4;
	    *pin_group = 1; // Grupo 1 de pines (P1_0)
	    *pin_num = 0; //Pin 0
	    *func = 0; //Func0
	*/

	while (!Init_Teclas(&pulsador[1],0,8,1,1,0));
	while (!Init_Teclas(&pulsador[2],0,9,1,2,0));
	while (!Init_Teclas(&pulsador[3],1,9,1,6,0));

    Init_Timers();
    Setear_Tiempo(TIEMPO_T);

   while(1)
   {
   }

    return 1;
}
Пример #6
0
void main(void){
//==============================================================================
// Main Program
// 
// Description: This function contains the while loop that runs continuously
// to act for the operating system. It also calls all the functions to
// initialize the system.
//
// Passed : no variables passed
// Locals: no variables declared
// Returned: no values returned
// Globals:     volatile unsigned int Time_Sequence;
//              volatile char one_time;
//              char* display_1
//              char* display_2
//              char* display_3
//              char* display_4
//              slow_input_down
//              control_state[CNTL_STATE_INDEX]
//              char big
//              char size_count;
//              char posL1
//              char posL2
//              char posL3
//              char posL4
//
// Author: David Pryor
// Date: Feb 2016
// Compiler: Built with IAR Embedded Workbench Version: V4.10A/W32 (6.4.1)
//==============================================================================
  Init_Ports();                             // Initialize Ports
  Init_Clocks();                            // Initialize Clock System 
  Init_Conditions();
  Time_Sequence = SWITCH_OFF;               // 
  Init_Timers();                            // Initialize Timers
  Init_LEDs();                              // Initialize LEDs
  Init_LCD();                               // Initialize LCD
  Init_ADC();                               // Initialize ADC

//------------------------------------------------------------------------------
// Begining of the "While" Operating System
//------------------------------------------------------------------------------
  while(ALWAYS) {                            // Can the Operating system run
    Menu_Process();
    ADC_Process();              // call sampling function
    if(display_count >= FOR_FOURTH_SECOND){    // update screen every 250 msec
      Display_Process();
      display_count = SWITCH_OFF;
    }
    if(menu_items == FALSE){  
      display_4 = "SW2: Menu";
    }
    if(switch_two_pressed){
      menu_items = TRUE;
      switch_two_pressed = SWITCH_OFF;
    }
  }
//------------------------------------------------------------------------------
}
Пример #7
0
//--------------------------------------------------------------------------//
// Function:	main														//
//--------------------------------------------------------------------------//
void main(void)
{
	Init_Flags();
	Init_Timers();
	Init_Interrupts();

	while(1);
}
Пример #8
0
//--------------------------------------------------------------------------//
// Function:	main														//
//--------------------------------------------------------------------------//
int main(void)
{
	Init_Flags();
	Init_Timers();
	Init_Interrupts();

	while(1);
	return 0;
}
void main(void)
{
    // Hardware Initialization
    TRISIO = 0xFF; // All IO are inputs to be safe
    GPIO = 0x00; // All IO to 0
    //ANSEL = 0x00; // Turn off ADC
    CMCON = 7; // Turn off Comparators

    Init_Timers(); // Initialize Timers (TMR0)

    Init_IO(); // Initialize In-and-Outputs

    while (On) // Infinite loop
    {
        CLRWDT();
    }
}
Пример #10
0
void main(void)
{
	Init_Ports();                             // Initialize Ports
	Init_Clocks();                            // Initialize Clock System 
	Init_Conditions();
	Init_Interrupts();
       
	//PJOUT |= LED1;                          // Turn LED 1 on to indicate boot
	  
	TimeMsec = RESET_TIME;
	Init_Timers(); 				// Initialize Timers
	Init_LCD();				// Initialize LCD
	//Init_LEDs();                            // Initialize LEDs       
        
        
        
	//          "0123456789abcdef"
	display_1 = "   PROJECT  5   ";
	display_2 = "                ";
	Display_Process();
	
	P1OUT |= IR_LED;
	waitMsec(10);
	
/* ---------- Begining of the "While" Operating System ------------- */
	while(ALWAYS) 										// Can the Operating system run
	{                            
		if(TimeMsec % EVERY_50 == RESET_TIME)
			Display_Process();					//Refreshes screen every 50 'ticks'
                
		if(TimeMsec % EVERY_2 == RESET_TIME)
		{
			Switches_Process();                 // Poll for switch state change every other 'tick'
			ADC_Process();
		}
		
		Motors_Process();
		Control_Process();
	}
}
Пример #11
0
int main() {
	GPIO_InitTypeDef GPIO_InitDef;
	
	SystemClock_Config();
	SystemCoreClockUpdate();
	
	HAL_Init();
	
	/* driver init */
	lsm303dlhc_init();
	l3gd20_init();
	
	osKernelInitialize();
	Init_Timers();
	
	
	handlerThread_id = osThreadCreate(osThread(handlerThread), NULL);
	gyroHandlerThread_id = osThreadCreate(osThread(gyroHandlerThread), NULL);
	visioThread_id = osThreadCreate(osThread(visioThread), NULL);
	
	accelBuffer_mutex_id = osMutexCreate(osMutex(accelBuffer_mutex));
	gyroBuffer_mutex_id = osMutexCreate(osMutex(gyroBuffer_mutex));
	
	// enable clock for GPIOE
	//__HAL_RCC_GPIOE_CLK_ENABLE();

	// init GPIO pin
	GPIO_InitDef.Pin = GPIO_PIN_9;
	GPIO_InitDef.Mode = GPIO_MODE_OUTPUT_PP;
	GPIO_InitDef.Speed = GPIO_SPEED_FREQ_LOW;
	
	HAL_GPIO_Init(GPIOE, &GPIO_InitDef);
	
	// set LD3
	HAL_GPIO_WritePin(GPIOE, GPIO_PIN_9, GPIO_PIN_SET);
	
	osKernelStart();
}
Пример #12
0
void main(void){
//==============================================================================
// Main Program
// 
// Description: This function contains the while loop that runs continuously
// to act for the operating system. It also calls all the functions to
// initialize the system.
//
// Passed : no variables passed
// Locals: no variables declared
// Returned: no values returned
// Globals:     volatile unsigned int Time_Sequence;
//              volatile char one_time;
//              char* display_1
//              char* display_2
//              char* display_3
//              char* display_4
//              slow_input_down
//              control_state[CNTL_STATE_INDEX]
//              char big
//              char size_count;
//              char posL1
//              char posL2
//              char posL3
//              char posL4
//
// Author: David Pryor
// Date: Feb 2016
// Compiler: Built with IAR Embedded Workbench Version: V4.10A/W32 (6.4.1)
//==============================================================================
  Init_Ports();                             // Initialize Ports
  Init_Clocks();                            // Initialize Clock System 
  Init_Conditions();
  Time_Sequence = SWITCH_OFF;               // 
  Init_Timers();                            // Initialize Timers
  Init_LEDs();                              // Initialize LEDs
  Init_LCD();                               // Initialize LCD
  Init_ADC();                               // Initialize ADC
  Init_Serial_UCA1(0);                      // BAUD rate 9600
  Init_Serial_UCA0(1);                      // BAUD rate 9600
  Five_msec_Delay(1);
  PJOUT |= IOT_STA_MINIAP; //turning on miniap (only works this way)
  IR_LED_OFF();
  lcd_BIG_mid();
  display_1 = "  David   ";
  display_2 = "Project  8";  
  display_3 = "  Pryor   ";
  display_4 = "";
  Display_Process();



//------------------------------------------------------------------------------
// Begining of the "While" Operating System
//------------------------------------------------------------------------------
  while(ALWAYS) {                            // Can the Operating system run
    
    ADC_Process();              // call sampling function
    if(MainFG){
        Menu_Process();
    }
    else if(BaudMenuFG==TRUE){
        Baud_Menu(); 
    }
    else if(IOTMenuFG==TRUE){
        IOT_Menu();
    }
    
    if(StartCommandFG){ //StartCommandFG is true once "." has been received
        commandTree();
    }
    printMacAddress(); //prints mac address to screen
    macFG=FALSE; //turn off command to print mac address
    clearReceiveBuffer();
    parseIOTData();
  }
//------------------------------------------------------------------------------
}
Пример #13
0
void main(void){
//==============================================================================
// Main Program
// 
// Description: This function contains the while loop that runs continuously
// to act for the operating system. It also calls all the functions to
// initialize the system.
//
// Passed : no variables passed
// Locals: no variables declared
// Returned: no values returned
// Globals:     volatile unsigned int Time_Sequence;
//              volatile char one_time;
//              char* display_1
//              char* display_2
//              char* display_3
//              char* display_4
//              slow_input_down
//              control_state[CNTL_STATE_INDEX]
//              char big
//              char size_count;
//              char posL1
//              char posL2
//              char posL3
//              char posL4
//
// Author: David Pryor
// Date: Feb 2016
// Compiler: Built with IAR Embedded Workbench Version: V4.10A/W32 (6.4.1)
//==============================================================================
  Init_Ports();                             // Initialize Ports
  Init_Clocks();                            // Initialize Clock System 
  Init_Conditions();
  Time_Sequence = SWITCH_OFF;               // 
  Init_Timers();                            // Initialize Timers
  five_msec_sleep(COUNT_TWOFIDDY_MSEC);     // 250 msec delay for the clock to settle (50)
  Init_LEDs();                              // Initialize LEDs
  Init_LCD();                               // Initialize LCD
  
//             1234567890
  display_1 = "NCSU";
  posL1 = LINE_POS_3;
  display_2 = "WOLFPACK";
  posL2 = LINE_POS_1;
  display_3 = "ECE306";
  posL3 = LINE_POS_2;
  display_4 = "D Pryor";
  posL4 = LINE_POS_1;
  big = SWITCH_OFF;
  Display_Process();
//------------------------------------------------------------------------------
// Begining of the "While" Operating System
//------------------------------------------------------------------------------
 while(ALWAYS) {                            // Can the Operating system run
  switch(Time_Sequence){
    case COUNT_TWELVEFIDDY_MSEC:            // 1250 msec  (250)
      if(one_time){
        Init_LEDs();                        // Initialize LEDs
        one_time = SWITCH_OFF;
      }
      Time_Sequence = SWITCH_OFF;           // 
    case COUNT_ONETHOUSAND_MSEC:            // 1000 msec  (200)  
      if(one_time){
        one_time = SWITCH_OFF;
      }
    case COUNT_SEVENFIDDY_MSEC:             // 750 msec   (150) 
      if(one_time){
        one_time = SWITCH_OFF;
      }
    case COUNT_FIVEHUNNED_MSEC:             // 500 msec   (100) 
      if(one_time){
        one_time = SWITCH_OFF;
      }
    case  COUNT_TWOFIDDY_MSEC:  	    // 250 msec   (50)
      if(one_time){
        one_time = SWITCH_OFF;
      }
      size_count++;
      if(size_count > MAX_SIZE_COUNT){
        size_count = SWITCH_OFF;
        if(big){
          //lcd_BIG_mid();
          big = SWITCH_OFF;
        }else{
          //lcd_4line();
          big = SWITCH_ON;
        }
      }
        Display_Process();
      break;                                // 
    default: break; 
  }
  Switches_Process();                       // Check for switch state change 
  if(Time_Sequence > COUNT_TWELVEFIDDY_MSEC){
    Time_Sequence = SWITCH_OFF;
  }
 }
//------------------------------------------------------------------------------
}
Пример #14
0
void main(void)
{                         
   /********************************************************************/
   //               System Initialization
   /********************************************************************/          
   // Initialize MEGA8 PORT
   Init_PORT();   
      // Initialize SPI to communicate with CH453
   CH453_I2C_Init();

   // Initialize Global Variable: 
   // "Init_Vars()" has to be placed after "bReadDataFromEeprom()" because
   Init_Vars();
      
   // Initialize UART, 8 data, 1 stop, no parity. Boardrate is 2400.                   
   UART_Init(); 
      // Timer (Interrupt) initialization
   safesys();
   digi_cprint("88888888",0,8);

                
   init_digi_Led();
   Init_Timers();
   // initialize golbal interrupt.
   #asm("sei")  

    //init the DMM
    nav_command(NAV_INIT);              
    sleepms(200*ONEMS);                                
    navto1v();
    nav_command(NAV_SLOWMODE);
    sleepms(200*ONEMS);
    nav_command(NAV_AFLTON);
    sleepms(200*ONEMS);
                     
    update_led(0);
    
    
    sysdata.R0 = 0;
	 while(1)
	 {
	        if(keycode != KEY_INVALID)
	        {
                        HandleKey(keycode);
                        keycode = KEY_INVALID;
                        continue;
                }
         
		if(dlg_cnt > 1)
		{         
       			dlg_cnt--;
			continue;
		}
                timer_tick();		
		if(IS_THERM_MODE)                    
		{
        	        if(therm_state() == 0)
		                continue;     
                }
		if(IS_BORE_MODE)
		{
	        	if(bore_state() == 0)
		                continue;
		}     
			
                //shift to next channel 
                       
                if(sysdata.chan == CHAN_1)
                       ch_to_search = 0;
                else if(sysdata.chan == CHAN_2)
                       ch_to_search = 1;                                
                else 
                     ch_to_search = 1 - ch_to_search&0x01;                                
        }                      
}
Пример #15
0
/**
 * @details Where all the magic happens
 * @return Shouldn't return
 */
int main(void) {

	Init_Core();
	Init_SM();
	Init_Board();
	Init_Globals();
	Init_CAN();
	Init_Timers();

	// ------------------------------------------------
	// Begin

	DEBUG_Print("Started Up\r\n");

	while(1) {

		uint8_t count;
		if ((count = Chip_UART_Read(LPC_USART, Rx_Buf, UART_RX_BUF_SIZE)) != 0) {
			switch (Rx_Buf[0]) {
				case 'a': // Print out Brusa Mains Info
					DEBUG_Print("Actual Mains Voltage: ");
					itoa(brusa_actual_1.mains_mVolts, str, 10);
					DEBUG_Print(str);
					DEBUG_Print("\r\n");

					DEBUG_Print("Mains type: ");
					itoa(brusa_actual_1.mains_cAmps, str, 10);
					DEBUG_Print(str);
					DEBUG_Print("\r\n");

					DEBUG_Print("Temp: ");
					itoa((brusa_temp.power_temp / 10) - 40 , str, 10);
					DEBUG_Print(str);
					DEBUG_Print("\r\n");

					DEBUG_Print("Temp: 0x");
					itoa(brusa_temp.power_temp , str, 16);
					DEBUG_Print(str);
					DEBUG_Print("\r\n");
					break;
				case 'b': // Print out Actual Brusa Output
					DEBUG_Print("Actual Out Voltage: ");
					itoa(brusa_actual_1.output_mVolts, str, 10);
					DEBUG_Println(str);

					DEBUG_Print("Actual Out Current: ");
					itoa(brusa_actual_1.output_cAmps, str, 10);
					DEBUG_Println(str);
					break;
				case 'f': // Print out Pack State
					itoa(pack_state.pack_min_mVolts, str, 10);
					DEBUG_Print("Pack Min Voltage: ");
					DEBUG_Print(str);
					DEBUG_Print("\r\n");
					itoa(pack_state.pack_max_mVolts, str, 10);
					DEBUG_Print("Pack Max Voltage: ");
					DEBUG_Print(str);
					DEBUG_Print("\r\n");

					break;
				case 'y': // Print out Module Balance State
					itoa(PackManager_GetExtModId(0), str, 16);
					DEBUG_Print("Mod 0x");
					DEBUG_Print(str);
					itoa(PackManager_GetExtBal(0), str, 2);
					DEBUG_Print(": 0b");
					DEBUG_Println(str);
					itoa(PackManager_GetExtModId(1), str, 16);
					DEBUG_Print("Mod 0x");
					DEBUG_Print(str);
					itoa(PackManager_GetExtBal(1), str, 2);
					DEBUG_Print(": 0b");
					DEBUG_Println(str);
					break;
				case 'e': 
					itoa(brusa_error,str, 2);
					DEBUG_Println(str);
					break;
				case 'm': // Print out charge mode and brusa error
					DEBUG_Print("Charge Mode: ");
					itoa(Charge_GetMode(), str, 10);
					DEBUG_Println(str);
					DEBUG_Print("Error Messages: ");
					itoa((uint64_t)brusa_error, str, 2);
					DEBUG_Println(str);
					break;
				default:
					DEBUG_Print("Unknown Command\r\n");
			}
		}

		//-----------------------------
		// Detect Input Changes (Default to IDLE)

		MODE_INPUT_T inp = INP_IDLE;
		if (!Board_Switch_Read()) {
			inp = INP_CHRG;
		} else {
			inp = INP_IDLE;
		}

		//-----------------------------
		// Update pack_state
		pack_state.contactors_closed = Board_Contactors_Closed();
		pack_state.msTicks = msTicks;
		pack_state.brusa_error = brusa_error;
		pack_state.pack_cAmps_in = brusa_actual_1.output_cAmps;

		//-----------------------------
		// SSM Step
		ERROR_T result = SSM_Step(&pack_state, inp, &out_state);
		if (result != ERROR_NONE) {
			_error(result, true, false);
		}

		//-----------------------------
		// Check if SSM has Changed State
		// Currently only changes Poll Frequency
		// [TODO] Set a status LED!!
		if (SSM_GetMode() != mode) {
			mode = SSM_GetMode();
			switch (SSM_GetMode()) {
				case IDLE:
					Chip_TIMER_SetMatch(LPC_TIMER32_1, 0, Hertz2Ticks(BCM_POLL_IDLE_FREQ));
					Chip_TIMER_Reset(LPC_TIMER32_1); // Otherwise shit gets F****D
					break;
				case CHARGING:
					Chip_TIMER_SetMatch(LPC_TIMER32_1, 0, Hertz2Ticks(BCM_POLL_CHARGING_FREQ));
					Chip_TIMER_Reset(LPC_TIMER32_1);
					break;
				case DRAINING:
					Chip_TIMER_SetMatch(LPC_TIMER32_1, 0, Hertz2Ticks(BCM_POLL_DRAINING_FREQ));
					Chip_TIMER_Reset(LPC_TIMER32_1);
					break;
			}
		}

		//-----------------------------
		// Carry out out_state
		if (out_state.close_contactors && !Board_Contactors_Closed()) {
			Board_Close_Contactors(true);
		} else if (!out_state.close_contactors && Board_Contactors_Closed()) {
			Board_Close_Contactors(false);
		}

		if (out_state.brusa_output) {
			brusa_control.clear_error = out_state.brusa_clear_latch;
			brusa_control.output_mVolts = out_state.brusa_mVolts;
			brusa_control.output_cAmps = out_state.brusa_cAmps;
			Chip_TIMER_Enable(LPC_TIMER32_0);
		} else {
			brusa_control.output_mVolts = 0;
			brusa_control.output_cAmps = 0;
			Chip_TIMER_Disable(LPC_TIMER32_0);
		}

		//-----------------------------
		// Retrieve available brusa messages
		int8_t tmp = MCP2515_GetFullReceiveBuffer();
		int8_t res = 0;
		if (tmp == 2) {
			MCP2515_ReadBuffer(&mcp_msg_obj, 0);
			res = Brusa_Decode(&brusa_messages, &mcp_msg_obj);
			if (res == -1) {
				DEBUG_Println("Brusa Decode Error");
				res = 0;
			}
			MCP2515_ReadBuffer(&mcp_msg_obj, 1);
			res = Brusa_Decode(&brusa_messages, &mcp_msg_obj);
		} else if (tmp == 0) { // Receive Buffer 0 Full
			MCP2515_ReadBuffer(&mcp_msg_obj, tmp);
			res = Brusa_Decode(&brusa_messages, &mcp_msg_obj);
		} else if (tmp == 1) { //Receive buffer 1 full
			MCP2515_ReadBuffer(&mcp_msg_obj, tmp);
			res = Brusa_Decode(&brusa_messages, &mcp_msg_obj);
		} 

		if (res == -1) {
			DEBUG_Println("Brusa Decode Error");
			res = 0;
		}

		//-----------------------------
		// Send brusa message if its time
		if (brusa_message_send) {
			brusa_message_send = false;
			Brusa_MakeCTL(&brusa_control, &mcp_msg_obj);
			MCP2515_LoadBuffer(0, &mcp_msg_obj);
			MCP2515_SendBuffer(0);
		}
		
		//-----------------------------
		// Check for and decode A123 Messages
		if (!RingBuffer_IsEmpty(&rx_buffer)) {

			CCAN_MSG_OBJ_T temp_msg;
			RingBuffer_Pop(&rx_buffer, &temp_msg);
			res = PackManager_Update(&temp_msg);

			if (new_std_msg_sent) {
				PackManager_Commit(&pack_state);
				new_std_msg_sent = false;
			}
			
		}

		if (res == -1) {
			DEBUG_Println("A123 Decode Error");
		}

		//-----------------------------
		// Timed output
		if (msTicks - last_debug_message > TIMED_MESSAGE_DELAY) {
			message_count++;
			last_debug_message = msTicks;
			switch (message_count % 7) {
				case 0:
					if (out_state.balance) {
						itoa(mbb_cmd.balance_target_mVolts, str, 10);
						DEBUG_Print("Balancing to: ");
						DEBUG_Println(str);
					} else {
						DEBUG_Println("Not balancing");
					}
					
					break;
				case 1:
					itoa(brusa_control.output_mVolts, str, 10);
					DEBUG_Print("Brusa out V: ");
					DEBUG_Println(str);
					break;
				case 2:
					itoa(brusa_control.output_cAmps, str, 10);
					DEBUG_Print("Brusa out C: ");
					DEBUG_Println(str);
					break;
				case 3:
					DEBUG_Print("Actual Out Voltage: ");
					itoa(brusa_actual_1.output_mVolts, str, 10);
					DEBUG_Println(str);
					break;
				case 4:
					DEBUG_Print("Actual Out Current: ");
					itoa(brusa_actual_1.output_cAmps, str, 10);
					DEBUG_Println(str);
					break;
				case 5:
					DEBUG_Print("Mode: ");
					DEBUG_Println((SSM_GetMode() == CHARGING) ? "Chrg":"Idle");
					break;
				case 6:
					DEBUG_Print("Brusa Output: ");
					itoa(out_state.brusa_output, str, 2);
					DEBUG_Println(str);

					DEBUG_Print("\r\n");
					break;

			}
		}
	}

	return 0;
}
Пример #16
0
void main(void){
//==============================================================================
// Main Program
// 
// Description: This function contains the while loop that runs continuously
// to act for the operating system. It also calls all the functions to
// initialize the system.
//
// Passed : no variables passed
// Locals: no variables declared
// Returned: no values returned
// Globals:     volatile unsigned int Time_Sequence;
//              volatile char one_time;
//              char* display_1
//              char* display_2
//              char* display_3
//              char* display_4
//              slow_input_down
//              control_state[CNTL_STATE_INDEX]
//              char big
//              char size_count;
//              char posL1
//              char posL2
//              char posL3
//              char posL4
//
// Author: David Pryor
// Date: Feb 2016
// Compiler: Built with IAR Embedded Workbench Version: V4.10A/W32 (6.4.1)
//==============================================================================
  Init_Ports();                             // Initialize Ports
  Init_Clocks();                            // Initialize Clock System 
  Init_Conditions();
  Time_Sequence = SWITCH_OFF;               // 
  Init_Timers();                            // Initialize Timers
  Init_LEDs();                              // Initialize LEDs
  Init_LCD();                               // Initialize LCD
  

//------------------------------------------------------------------------------
// Begining of the "While" Operating System
//------------------------------------------------------------------------------
 while(ALWAYS) {                            // Can the Operating system run
   if(do_this == TRUE){
      Five_msec_Delay(FOR_ONE_SECOND);                     //pause
      display_2 = "FORWARD";                    //change display
      posL2 = LINE_POS_1;
      Display_Process();                        //push display
      straight_line();                          //forward
      
      Five_msec_Delay(FOR_ONE_SECOND);                     //pause
      display_2 = "REVERSE";                    //change display
      posL2 = LINE_POS_1;
      Display_Process();                        //push display
      straight_line_reverse();                  //reverse
      
      Five_msec_Delay(FOR_ONE_SECOND);
      display_2 = "FORWARD";                    //change display
      posL2 = LINE_POS_1;
      Display_Process();                        //push display
      straight_line();                          //forward
      
      Five_msec_Delay(FOR_ONE_SECOND);
      display_2 = "CW-SPIN";                   //change display
      posL2 = LINE_POS_1;
      Display_Process();                         //push display
      clockwise_spin();                          //forward
      
      Five_msec_Delay(FOR_ONE_SECOND);
      display_2 = "CCW-SPIN";                   //change display
      posL2 = LINE_POS_1;
      Display_Process();                         //push display
      counterclockwise_spin();                          //forward
      
      Five_msec_Delay(FOR_ONE_SECOND);                     //pause
      display_2 = "";                           //clear display
      posL2 = LINE_POS_1;
      Display_Process();                        //push display
      do_this = FALSE;
   }
 }
//------------------------------------------------------------------------------
}