nRF51 SDK - S210 SoftDevice
 All Data Structures Functions Variables Typedefs Enumerations Enumerator Groups Pages
ADNS2080 driver

ADNS2080 mouse sensor driver. More...

Enumerations

enum  adns2080_status_t {
  ADNS2080_OK,
  ADNS2080_SERIAL_COMM_FAILURE,
  ADNS2080_CHIP_NOT_DETECTED,
  ADNS2080_INVALID_PARAMETER
}
 
enum  motion_output_polarity_t {
  ADNS2080_MOTION_OUTPUT_POLARITY_LOW = 0,
  ADNS2080_MOTION_OUTPUT_POLARITY_HIGH = 1
}
 
enum  motion_output_sensitivity_t {
  ADNS2080_MOTION_OUTPUT_SENSITIVITY_LEVEL = 0,
  ADNS2080_MOTION_OUTPUT_SENSITIVITY_EDGE = 1
}
 
enum  adns2080_resolution_t {
  ADNS2080_RESOLUTION_250DPI = 1,
  ADNS2080_RESOLUTION_500DPI = 2,
  ADNS2080_RESOLUTION_1000DPI = 0,
  ADNS2080_RESOLUTION_1250DPI = 3,
  ADNS2080_RESOLUTION_1500DPI = 4,
  ADNS2080_RESOLUTION_1750DPI = 5,
  ADNS2080_RESOLUTION_2000DPI = 6
}
 
enum  adns2080_mode_t {
  ADNS2080_MODE_NORMAL = 0,
  ADNS2080_MODE_REST1 = 1,
  ADNS2080_MODE_REST2 = 2,
  ADNS2080_MODE_REST3 = 3,
  ADNS2080_MODE_RUN1 = 4,
  ADNS2080_MODE_RUN2 = 5,
  ADNS2080_MODE_IDLE = 6
}
 
enum  adns2080_motion_bits_t {
  ADNS2080_MOTION_BITS_8 = 0,
  ADNS2080_MOTION_BITS_12 = 1
}
 

Functions

adns2080_status_t adns2080_init (void)
 Function for initializing the mouse sensor chip. More...
 
void adns2080_reset (void)
 Function for resetting the mouse sensor chip. More...
 
uint8_t adns2080_product_id_read (void)
 Function for reading mouse sensor product ID. More...
 
uint8_t adns2080_revision_id_read (void)
 Function for reading mouse sensor revision ID. More...
 
void adns2080_powerdown (void)
 Function for powering down the mouse sensor. More...
 
void adns2080_wakeup (void)
 Function for waking up the mouse sensor. More...
 
adns2080_status_t adns2080_motion_interrupt_set (motion_output_polarity_t polarity, motion_output_sensitivity_t sensitivity)
 Function for configuring the MOTION interrupt output pin. More...
 
adns2080_status_t adns2080_resolution_set (adns2080_resolution_t resolution)
 Function for setting mouse sensor resolution. More...
 
adns2080_status_t adns2080_motion_bits_set (adns2080_motion_bits_t motion_bits)
 Function for setting number of bits used for mouse sensor motion reporting. More...
 
adns2080_motion_bits_t adns2080_motion_bits_read (void)
 Function for reading number of bits used for mouse sensor motion reporting. More...
 
void adns2080_movement_read (int16_t *p_delta_x, int16_t *p_delta_y)
 Function for reading X- and Y-axis movement (in counts) since last report. More...
 
bool adns2080_is_motion_detected (void)
 Function for checking if motion has been detected since last call. More...
 
void adns2080_rest_periods_set (uint8_t rest1_period, uint8_t rest2_period, uint8_t rest3_period)
 Function for setting mouse sensor Rest1, Rest2 and Rest3 mode motion detection time period. More...
 
void adns2080_downshift_times_set (uint8_t run_to_rest1_mode_time, uint8_t rest1_to_rest2_mode_time, uint8_t rest2_to_rest3_mode_time)
 Function for setting mouse sensor mode downshift time periods. More...
 
void adns2080_force_mode_set (adns2080_mode_t mode)
 Function for forcing mouse sensor to a certain operating mode. More...
 
adns2080_mode_t adns2080_force_mode_read (void)
 Function for reading the current forced operating mode. More...
 

Detailed Description

ADNS2080 mouse sensor driver.

Enumeration Type Documentation

Mouse sensor forced mode options.

Enumerator
ADNS2080_MODE_NORMAL 

Normal operation mode

ADNS2080_MODE_REST1 

Rest1 operation mode

ADNS2080_MODE_REST2 

Rest2 operation mode

ADNS2080_MODE_REST3 

Rest3 operation mode

ADNS2080_MODE_RUN1 

Run1 operation mode

ADNS2080_MODE_RUN2 

Run2 operation mode

ADNS2080_MODE_IDLE 

Idle operation mode

Mouse sensor motion reporting bits.

Enumerator
ADNS2080_MOTION_BITS_8 

Motion reporting uses 8 bits

ADNS2080_MOTION_BITS_12 

Motion reporting uses 12 bits

Mouse sensor resolution values.

Enumerator
ADNS2080_RESOLUTION_250DPI 

250 dpi resolution

ADNS2080_RESOLUTION_500DPI 

500 dpi resolution

ADNS2080_RESOLUTION_1000DPI 

1000 dpi resolution

ADNS2080_RESOLUTION_1250DPI 

1250 dpi resolution

ADNS2080_RESOLUTION_1500DPI 

1500 dpi resolution

ADNS2080_RESOLUTION_1750DPI 

1750 dpi resolution

ADNS2080_RESOLUTION_2000DPI 

2000 dpi resolution

Describes return values for adns2080_init.

Enumerator
ADNS2080_OK 

Operation was succesful

ADNS2080_SERIAL_COMM_FAILURE 

Serial communication failed

ADNS2080_CHIP_NOT_DETECTED 

Product/Revision ID was not what was expected

ADNS2080_INVALID_PARAMETER 

Given parameters were not valid

ADNS2080 motion output pin polarity values.

Enumerator
ADNS2080_MOTION_OUTPUT_POLARITY_LOW 

Motion output polarity active low

ADNS2080_MOTION_OUTPUT_POLARITY_HIGH 

Motion output polarity active high

Motion output pin configuration.

Enumerator
ADNS2080_MOTION_OUTPUT_SENSITIVITY_LEVEL 

Motion output pin will be driven low/high (depending on the polarity setting) as long as there is motion data in DELTA registers

ADNS2080_MOTION_OUTPUT_SENSITIVITY_EDGE 

Motion output pin will be driven low/high (depending on the polarity setting) for 380 ns when motion is detected during rest modes

Function Documentation

void adns2080_downshift_times_set ( uint8_t  run_to_rest1_mode_time,
uint8_t  rest1_to_rest2_mode_time,
uint8_t  rest2_to_rest3_mode_time 
)

Function for setting mouse sensor mode downshift time periods.

Allowed range for run_to_rest1_mode_time period is 0x00 to 0xFF. Allowed range for rest1_to_rest2_mode_time period is 0x01 to 0xFF. Allowed range for rest2_to_rest3_mode_time period is 0x01 to 0xFF.

Chip is expected to be initialized before calling this function.

Parameters
run_to_rest1_mode_timeRun mode to Rest1 mode downshift time period (Time = run_to_rest1_mode_time * 8 * 4)
rest1_to_rest2_mode_timeRest1 mode to Rest2 mode downshift time period (Time = rest1_to_rest2_mode_time * rest1_period * 16)
rest2_to_rest3_mode_timeRest2 mode to Rest3 mode downshift time period (Time = rest2_to_rest3_mode_time * rest2_period * 128)
adns2080_mode_t adns2080_force_mode_read ( void  )

Function for reading the current forced operating mode.

Chip is expected to be initialized before calling this function.

Returns
Mode the sensor is forced to.
void adns2080_force_mode_set ( adns2080_mode_t  mode)

Function for forcing mouse sensor to a certain operating mode.

Chip is expected to be initialized before calling this function. Normal operation will not continue until this function is called with ADNS2080_MODE_NORMAL parameter.

Parameters
modeMode to force the sensor to.
adns2080_status_t adns2080_init ( void  )

Function for initializing the mouse sensor chip.

Valid mouse sensor information will be available 50 milliseconds after this function finishes.

Returns
Return values
ADNS2080_OKMouse sensor was initialized succesfully.
ADNS2080_SERIAL_COMM_FAILURESerial communications failure.
ADNS2080_CHIP_NOT_DETECTEDCould not find revision 0 ADNS2080 chip.
bool adns2080_is_motion_detected ( void  )

Function for checking if motion has been detected since last call.

Chip is expected to be initialized before calling this function.

Returns
Return values
true,ifmovement has been detected
false,ifno movement has been detected
adns2080_motion_bits_t adns2080_motion_bits_read ( void  )

Function for reading number of bits used for mouse sensor motion reporting.

Chip is expected to be initialized before calling this function.

Returns
motion_bits Number of bits.
adns2080_status_t adns2080_motion_bits_set ( adns2080_motion_bits_t  motion_bits)

Function for setting number of bits used for mouse sensor motion reporting.

Chip is expected to be initialized before calling this function.

Parameters
motion_bitsDesired number of bits.
Returns
Return values
ADNS2080_OKOperation succeeded.
ADNS2080_INVALID_PARAMETEROne of the parameters was not within valid range.
adns2080_status_t adns2080_motion_interrupt_set ( motion_output_polarity_t  polarity,
motion_output_sensitivity_t  sensitivity 
)

Function for configuring the MOTION interrupt output pin.

When motion is detected by the mouse sensor, the chip has a MOTION pin indicating there is motion data in DELTA_X and DELTA_Y registers. This function configures the polarity and sensitivity of that pin.

Chip is expected to be initialized before calling this function.

Parameters
polarityMOTION output pin is either active LOW (default) or active HIGH
sensitivityLevel or Edge (default) sensitive
Returns
Return values
ADNS2080_OKOperation succeeded.
ADNS2080_INVALID_PARAMETEROne of the parameters was not within valid range.
void adns2080_movement_read ( int16_t *  p_delta_x,
int16_t *  p_delta_y 
)

Function for reading X- and Y-axis movement (in counts) since last report.

Absolute value is determined by resolution. Chip is expected to be initialized before calling this function.

Parameters
p_delta_xLocation to store X-axis movement
p_delta_yLocation to store Y-axis movement
void adns2080_powerdown ( void  )

Function for powering down the mouse sensor.

Chip is expected to be initialized before calling this function. Serial port should not be accessed during the power down. To exit the power down mode, adns2080_wakeup must be called.

uint8_t adns2080_product_id_read ( void  )

Function for reading mouse sensor product ID.

Chip is expected to be initialized before calling this function. Returned product ID should always be 0x2A.

Returns
Product ID.
void adns2080_reset ( void  )

Function for resetting the mouse sensor chip.

Valid mouse sensor information will be available 50 milliseconds after this function finishes. All register settings will be lost and need to be reloaded.

adns2080_status_t adns2080_resolution_set ( adns2080_resolution_t  resolution)

Function for setting mouse sensor resolution.

Chip is expected to be initialized before calling this function.

Parameters
resolutionDesired resolution.
Returns
Return values
ADNS2080_OKOperation succeeded.
ADNS2080_INVALID_PARAMETEROne of the parameters was not within valid range.
void adns2080_rest_periods_set ( uint8_t  rest1_period,
uint8_t  rest2_period,
uint8_t  rest3_period 
)

Function for setting mouse sensor Rest1, Rest2 and Rest3 mode motion detection time period.

Allowed range for the periods is 0x01 to 0xFD. Resulting period is derived from the following equation : Period = (Rest period + 1) * 10 milliseconds Chip is expected to be initialized before calling this function.

Parameters
rest1_periodRest1 period
rest2_periodRest2 period
rest3_periodRest3 period
uint8_t adns2080_revision_id_read ( void  )

Function for reading mouse sensor revision ID.

Chip is expected to be initialized before calling this function.

Returns
Product ID.
void adns2080_wakeup ( void  )

Function for waking up the mouse sensor.

After wakeup, all mouse sensor settings must be reloaded. Valid mouse sensor information will be available 55 milliseconds after this function finishes.