示例#1
0
/*********************************************************************************************************
** Function name:           SetFanOnOff
** Descriptions:            
** input parameters:        
**                          
** Output parameters::      无
** Returned value:          
**                          
** Created by:     zhangwen          
** Created Date:            
**--------------------------------------------------------------------------------------------------------
** Modified by:            
** Modified date:          
**--------------------------------------------------------------------------------------------------------
*********************************************************************************************************/
s8 SetFanOnOff(u8 fanstatus)
{
    s8 ret = 0;
    u8 FanPwm = 0;
    if(fanstatus==0)
    {
        DBGPRINT(RT_DEBUG_TRACE,("Set Current Machine Fan  Off\r\n"));
    }
    else
    {
        DBGPRINT(RT_DEBUG_TRACE,("Set Current Machine Fan  On\r\n"));
    }
    g_u8FanStatus = fanstatus;
    SetFanSpeed(g_u8FanStatus);
	return ret;
}
void i2cTest() {

	int speed=0;
	double pressureReading=0;


	I2C i2c(0, 100000);

	while(1) {

		if((60>(pressureReading-2.5)) || 60>(pressureReading+2.5)){
			if(speed<10000){
				speed=speed+100;
			}
		}
		if((60<(pressureReading-2.5)) || 60<(pressureReading+2.5)){
			if(speed>500){
				speed=speed-100;
			}
		}
		printf("speed= %d\n",speed);
		SetFanSpeed(speed);

		uint8_t pressureData[3];
		uint8_t readPressureCmd = 0xF1;
		int16_t pressure = 0;


		if (i2c.transaction(0x40, &readPressureCmd, 1, pressureData, 3)) {
			/* Output temperature. */
			pressure = (pressureData[0] << 8) | pressureData[1];
			pressureReading = (pressure/240.0)*0.95;
			DEBUGOUT("Pressure read over I2C is %.1f Pa\r\n",	(pressure/240.0)*0.95);
		}
		else {
			DEBUGOUT("Error reading pressure.\r\n");
		}
		Sleep(500);
	}
}
示例#3
0
void CloseFan(void)												//Close the fan
{
	GpioWrite(FAN_POWER_CONTROL_PIN,0);
	PWM_TIMER->TASKS_START = 0;							//Stoping the pwm timer
	SetFanSpeed(0);
}
示例#4
0
void OpenFan(uint8_t duty_cycle)					//Open the fan and the speed is setted by the duty-cycle
{
	GpioWrite(FAN_POWER_CONTROL_PIN,1);
	PWM_TIMER->TASKS_START = 1;							//Starting the pwm timer
	SetFanSpeed(duty_cycle);							
}