moi nguoi giai thich minh cac lenh nay voi
#include "contiki.h"
#include "lib/sensors.h"
#include "dev/sky-sensors.h"
#include "dev/light-sensor.h"
#include <io.h>
/* Photodiode 1 (P64) on INCH_4 */
/* Photodiode 2 (P65) on INCH_5 */
#define INPUT_CHANNEL ((1 << INCH_4) | (1 << INCH_5))
#define INPUT_REFERENCE SREF_0
#define PHOTOSYNTHETIC_MEM ADC12MEM4
#define TOTAL_SOLAR_MEM ADC12MEM5
const struct sensors_sensor light_sensor;
/*---------------------------------------------------------------------------*/
static int
value(int type)
{
switch(type) {
/* Photosynthetically Active Radiation. */
case LIGHT_SENSOR_PHOTOSYNTHETIC:
return PHOTOSYNTHETIC_MEM;
/* Total Solar Radiation. */
case LIGHT_SENSOR_TOTAL_SOLAR:
return TOTAL_SOLAR_MEM;
}
return 0;
}
/*---------------------------------------------------------------------------*/
static int
status(int type)
{
return sky_sensors_status(INPUT_CHANNEL, type);
}
/*---------------------------------------------------------------------------*/
static int
configure(int type, int c)
{
return sky_sensors_configure(INPUT_CHANNEL, INPUT_REFERENCE, type, c);
}
/*---------------------------------------------------------------------------*/
SENSORS_SENSOR(light_sensor, "Light", value, configure, status);