Beispiel #1
0
/*******************************************************************************
* Function Name: main
********************************************************************************
*
* Summary:
*  Main function performs following functions:
*   1: Initializes the LCD
*   2: Get the temperature of the Die
*   3: Print the Die Temperature value in LCD
*   4: Print the Status value in the LCD
*
* Parameters:
*  None.
*
* Return:
*  None.
*
*******************************************************************************/
int main()
{
    cystatus Status;
    int16 temperature;

    /* Initializing the LCD */
    LCD_Char_1_Start();

    while(1)
    {
        /* Providing some delay */
        CyDelay(50);

        /* Reading the Die Temperature value */
        Status = DieTemp_1_GetTemp(&temperature);
       

        /* Displaying the Die Temperature value on the LCD */
        LCD_Char_1_Position(0u, 0u);
        LCD_Char_1_PrintString("Temp = ");

        if (temperature >= 0)
        {
            LCD_Char_1_PrintString("+");
        }
        else
        {
            /* If the temperature value is negative, display "-" sign and make value positive */
            LCD_Char_1_PrintString("-");
            temperature = (uint16)(~temperature + 1u);
        }
        
        LCD_Char_1_PrintNumber((uint16) (temperature));
        LCD_Char_1_PrintString(" ");
        
        LCD_Char_1_PutChar(LCD_Char_1_CUSTOM_7);
        LCD_Char_1_PrintString("C");

        /* Displaying the status value on the LCD */
        LCD_Char_1_Position(1u, 0u);
        LCD_Char_1_PrintString("Status = ");
        LCD_Char_1_PrintInt8((uint8) Status);
    }
}
Beispiel #2
0
//Initialize and enables all the peripherals
void init_peripherals(void)
{
	//Motor control variables & peripherals:
	init_motor();
	
	//Init Control:
	init_ctrl_data_structure();
	
	//Timebases:
	init_tb_timers();
	
	//UART 2 - RS-485
	init_rs485();
	
	//Analog, expansion port:
	init_analog();
	
	//Clutch:
	init_clutch();	
	
	//Enable Global Interrupts
    CyGlobalIntEnable; 
	
	//I2C1 (internal, potentiometers, Safety-CoP & IMU)
	init_i2c1();
	
	//Peripherals that depend on I2C:
	#ifdef USE_I2C_INT	
		
		//MPU-6500 IMU:
		#ifdef USE_IMU
		init_imu();
		CyDelay(25);
		init_imu();
		CyDelay(25);
		init_imu();
		CyDelay(25);
		#endif	//USE_IMU
		
		//Strain amplifier:
		#ifdef USE_STRAIN
		init_strain();
		#endif	//USE_STRAIN
		
	#endif	//USE_I2C_INT	
	
	//I2C2 (external)	
	#ifdef USE_I2C_EXT
	
	//Enable pull-ups:
	I2C_OPT_PU_Write(1);
		
	//I2C2 peripheral:
	init_i2c2();
	
	//Set RGB LED - Starts Green
	i2c_write_minm_rgb(SET_RGB, 0, 255, 0);
	
	#endif //USE_I2C_EXT
	
	//Magnetic encoder:
	init_as5047();
	
	// First DieTemp reading is always inaccurate -- throw out the first one
	#ifdef USE_DIETEMP	
	DieTemp_1_GetTemp(&temp);
	#endif
	
	//USB CDC
	#ifdef USE_USB	
	init_usb();
	#endif	//USE_USB
}