Skip to content

Commit

Permalink
Add device_id checking in scanner. Add doxygen comments
Browse files Browse the repository at this point in the history
  • Loading branch information
audiohacked committed Mar 14, 2017
1 parent 2a72e77 commit 0ec3473
Show file tree
Hide file tree
Showing 15 changed files with 190 additions and 26 deletions.
33 changes: 26 additions & 7 deletions lowlevel/asetek4.c
Original file line number Diff line number Diff line change
Expand Up @@ -16,18 +16,25 @@
* along with OpenCorsairLink. If not, see <http://www.gnu.org/licenses/>.
*/

/*! \file lowlevel/asetek4.c
* \brief Lowlevel Routines for Asetek
*/
#include <stdio.h>
#include <libusb.h>
#include "../lowlevel/asetek4.h"

#define HID_SET_REPORT 0x09
#define HID_GET_REPORT 0x01
#define HID_REPORT_TYPE_INPUT 0x01
#define HID_REPORT_TYPE_OUTPUT 0x02
#define HID_REPORT_TYPE_FEATURE 0x03
#define TIMEOUT_DEFAULT 1000
#define INTERFACE_NUMBER 0
#define HID_SET_REPORT 0x09 /*!< HID_SET_REPORT */
#define HID_GET_REPORT 0x01 /*!< HID_GET_REPORT */
#define HID_REPORT_TYPE_INPUT 0x01 /*!< HID_REPORT_TYPE_INPUT */
#define HID_REPORT_TYPE_OUTPUT 0x02 /*!< HID_REPORT_TYPE_OUTPUT */
#define HID_REPORT_TYPE_FEATURE 0x03 /*!< HID_REPORT_TYPE_FEATURE */
#define TIMEOUT_DEFAULT 1000 /*!< TIMEOUT_DEFAULT */
#define INTERFACE_NUMBER 0 /*!< INTERFACE_NUMBER */

/*! Asetek Init routine.
* Asetek init routine uses two control transfers.
*
*/
int corsairlink_asetek_init(struct libusb_device_handle *dev_handle,
uint8_t endpoint)
{
Expand All @@ -39,6 +46,10 @@ int corsairlink_asetek_init(struct libusb_device_handle *dev_handle,
return r;
}

/*! Asetek De-Init routine.
* Asetek de-init routine uses a control transfer.
*
*/
int corsairlink_asetek_deinit(struct libusb_device_handle *dev_handle,
uint8_t endpoint)
{
Expand All @@ -49,6 +60,10 @@ int corsairlink_asetek_deinit(struct libusb_device_handle *dev_handle,
return r;
}

/*! Lowlevel Asetek Write routine.
* Lowlevel Asetek Write rotine uses bulk transfer to send commands.
*
*/
int corsairlink_asetek_write(struct libusb_device_handle *dev_handle,
uint8_t endpoint,
uint8_t *data,
Expand All @@ -62,6 +77,10 @@ int corsairlink_asetek_write(struct libusb_device_handle *dev_handle,
return r;
}

/*! Lowlevel Asetek Read routine.
* Lowlevel Asetek Read routine uses bulk transfer to receive responses.
*
*/
int corsairlink_asetek_read(struct libusb_device_handle *dev_handle,
uint8_t endpoint,
uint8_t *data,
Expand Down
3 changes: 3 additions & 0 deletions lowlevel/asetek4.h
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,9 @@
* along with OpenCorsairLink. If not, see <http://www.gnu.org/licenses/>.
*/

/*! \file lowlevel/asetek4.h
* \brief Lowlevel Routines for Asetek
*/
#ifndef _LOWLEVEL_ASETEK_H
#define _LOWLEVEL_ASETEK_H

Expand Down
32 changes: 31 additions & 1 deletion lowlevel/hid.c
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,9 @@
* along with OpenCorsairLink. If not, see <http://www.gnu.org/licenses/>.
*/

/*! \file lowlevel/hid.c
* \brief Lowlevel Routines for USB HID based devices
*/
#include <stdio.h>
#include <libusb.h>
#include "../lowlevel/hid.h"
Expand All @@ -30,22 +33,41 @@
#define INTERRUPT_IN_ENDPOINT 0x81

// Values for bmRequestType in the Setup transaction's Data packet.

static const int CONTROL_REQUEST_TYPE_IN = LIBUSB_ENDPOINT_IN | LIBUSB_REQUEST_TYPE_CLASS | LIBUSB_RECIPIENT_INTERFACE;
static const int CONTROL_REQUEST_TYPE_OUT = LIBUSB_ENDPOINT_OUT | LIBUSB_REQUEST_TYPE_CLASS | LIBUSB_RECIPIENT_INTERFACE;

/*! USB HID Init routine
* USB HID Init routine is empty
* @param[in] handle for the data
* @param[in] device endpoint for the data
* @return 0
*/
int corsairlink_hid_init(struct libusb_device_handle *dev_handle,
uint8_t endpoint)
{
return 0;
}

/*! USB HID De-Init routine
* USB HID De-Init routine is empty
* @param[in] handle for the data
* @param[in] device endpoint for the data
* @return 0
*/
int corsairlink_hid_deinit(struct libusb_device_handle *dev_handle,
uint8_t endpoint)
{
return 0;
}

/*! USB HID Lowlevel Write
* USB HID Lowlevel Write uses a control transfer
* @param[in] handle for the data
* @param[in] device endpoint for the data
* @param[in] data to send
* @param[in] length of data to send, in bytes
* @return 0
*/
int corsairlink_hid_write(struct libusb_device_handle *dev_handle,
uint8_t endpoint,
uint8_t *data,
Expand All @@ -64,6 +86,14 @@ int corsairlink_hid_write(struct libusb_device_handle *dev_handle,
return r;
}

/*! USB HID Lowlevel Read
* USB HID Lowlevel Write uses a control transfer
* @param[in] handle for the data
* @param[in] device endpoint for the data
* @param[out] data received
* @param[in] length of data to received, in bytes
* @return 0
*/
int corsairlink_hid_read(struct libusb_device_handle *dev_handle,
uint8_t endpoint,
uint8_t *data,
Expand Down
3 changes: 3 additions & 0 deletions lowlevel/hid.h
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,9 @@
* along with OpenCorsairLink. If not, see <http://www.gnu.org/licenses/>.
*/

/*! \file lowlevel/hid.h
* \brief Lowlevel Routines for USB HID based devices
*/
#ifndef _LOWLEVEL_HID_H
#define _LOWLEVEL_HID_H

Expand Down
31 changes: 31 additions & 0 deletions lowlevel/rmi.c
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,9 @@
* along with OpenCorsairLink. If not, see <http://www.gnu.org/licenses/>.
*/

/*! \file lowlevel/rmi.c
* \brief Lowlevel Routines for RMi Series of Power Supplies
*/
#include <stdio.h>
#include <libusb.h>
#include "../lowlevel/rmi.h"
Expand All @@ -24,18 +27,38 @@
#define INTERRUPT_IN_ENDPOINT 0x81
#define INTERRUPT_OUT_ENDPOINT 0x01

/*! RMi Power Supply Init
* RMi Power Supply Init is empty
* @param[in] handle for the data
* @param[in] device endpoint for the data
* @return 0
*/
int corsairlink_rmi_init(struct libusb_device_handle *dev_handle,
uint8_t endpoint)
{
return 0;
}

/*! RMi Power Supply De-Init
* RMi Power Supply De-Init is empty
* @param[in] handle for the data
* @param[in] device endpoint for the data
* @return 0
*/
int corsairlink_rmi_deinit(struct libusb_device_handle *dev_handle,
uint8_t endpoint)
{
return 0;
}

/*! RMi Power Supply Lowlevel Write
* RMi Power Supply Lowlevel Write uses a interrupt transfer
* @param[in] handle for the data
* @param[in] device endpoint for the data
* @param[in] data to send
* @param[in] length of data to send, in bytes
* @return 0
*/
int corsairlink_rmi_write(struct libusb_device_handle *dev_handle,
uint8_t endpoint,
uint8_t *data,
Expand All @@ -52,6 +75,14 @@ int corsairlink_rmi_write(struct libusb_device_handle *dev_handle,
return r;
}

/*! RMi Power Supply Lowlevel Read
* RMi Power Supply Lowlevel Read uses a interrupt transfer
* @param[in] handle for the data
* @param[in] device endpoint for the data
* @param[in] data to send
* @param[in] length of data to send, in bytes
* @return 0
*/
int corsairlink_rmi_read(struct libusb_device_handle *dev_handle,
uint8_t endpoint,
uint8_t *data,
Expand Down
3 changes: 3 additions & 0 deletions lowlevel/rmi.h
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,9 @@
* along with OpenCorsairLink. If not, see <http://www.gnu.org/licenses/>.
*/

/*! \file lowlevel/rmi.h
* \brief Lowlevel Routines for RMi Series of Power Supplies
*/
#ifndef _LOWLEVEL_RMI_H
#define _LOWLEVEL_RMI_H

Expand Down
35 changes: 34 additions & 1 deletion protocol/asetek4/core.c
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,9 @@
* along with OpenCorsairLink. If not, see <http://www.gnu.org/licenses/>.
*/

/*! \file protocol/asetek4/core.c
* \brief Core Routines for RMi Series of Power Supplies
*/
#include <errno.h>
#include <stdio.h>
#include <stdlib.h>
Expand All @@ -26,30 +29,60 @@
#include "../../device.h"
#include "../../driver.h"

/*! RMi Power Supply Device ID
* RMi Power Supply Device ID is empty
* @param[in] handle for the data
* @param[out] device id
* @return 0
*/
int corsairlink_asetek_device_id(struct corsair_device_info *dev, uint8_t *device_id)
{
memcpy(device_id, 0x00, 1);
return 0;
}

/*! RMi Power Supply Device Name
* RMi Power Supply Device Name
* @param[in] handle for the data
* @param[out] Device Name
* @return 0
*/
int corsairlink_asetek_name(struct corsair_device_info *dev, char *name)
{
sprintf(name, "%s", dev->name);
return 0;
}

/*! RMi Power Supply Device Vendor Name
* RMi Power Supply Device Vendor Name just returns \"Corsair\"
* @param[in] handle for the data
* @param[out] Vendor Name
* @return 0
*/
int corsairlink_asetek_vendor(struct corsair_device_info *dev, char *name)
{
sprintf(name,"Corsair");
sprintf(name, "Corsair");
return 0;
}

/*! RMi Power Supply Device Product Name
* RMi Power Supply Device Product Name
* @param[in] handle for the data
* @param[out] Product Name
* @return 0
*/
int corsairlink_asetek_product(struct corsair_device_info *dev, char *name)
{
sprintf(name, "%s", dev->name);
return 0;
}

/*! RMi Power Supply Device ID
* RMi Power Supply Device ID is empty
* @param[in] handle for the data
* @param[out] string for firmware number
* @return 0
*/
int corsairlink_asetek_firmware_id(struct corsair_device_info *dev, char *firmware)
{
int r;
Expand Down
3 changes: 3 additions & 0 deletions protocol/rmi/core.c
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,9 @@
* along with OpenCorsairLink. If not, see <http://www.gnu.org/licenses/>.
*/

/*! \file protocol/rmi/core.c
* \brief Core Routines for RMi Series of Power Supplies
*/
#include <errno.h>
#include <stdio.h>
#include <stdlib.h>
Expand Down
3 changes: 3 additions & 0 deletions protocol/rmi/core.h
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,9 @@
* along with OpenCorsairLink. If not, see <http://www.gnu.org/licenses/>.
*/

/*! \file protocol/rmi/core.h
* \brief Core Routines for RMi Series of Power Supplies
*/
#ifndef _PROTOCOL_RMI_H
#define _PROTOCOL_RMI_H

Expand Down
3 changes: 3 additions & 0 deletions protocol/rmi/fan.c
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,9 @@
* along with OpenCorsairLink. If not, see <http://www.gnu.org/licenses/>.
*/

/*! \file protocol/rmi/fan.c
* \brief Fan Routines for RMi Series of Power Supplies
*/
int corsairlink_rmi_fan_rpm(struct corsair_device_info *dev,
uint16_t rpm)
{
Expand Down
3 changes: 3 additions & 0 deletions protocol/rmi/power.c
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,9 @@
* along with OpenCorsairLink. If not, see <http://www.gnu.org/licenses/>.
*/

/*! \file protocol/rmi/power.c
* \brief Power Routines for RMi Series of Power Supplies
*/
#include <errno.h>
#include <stdio.h>
#include <stdlib.h>
Expand Down
3 changes: 3 additions & 0 deletions protocol/rmi/temperature.c
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,9 @@
* along with OpenCorsairLink. If not, see <http://www.gnu.org/licenses/>.
*/

/*! \file protocol/rmi/temperature.c
* \brief Temperature Routines for RMi Series of Power Supplies
*/
#include <errno.h>
#include <stdio.h>
#include <stdlib.h>
Expand Down
3 changes: 3 additions & 0 deletions protocol/rmi/time.c
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,9 @@
* along with OpenCorsairLink. If not, see <http://www.gnu.org/licenses/>.
*/

/*! \file protocol/rmi/time.c
* \brief Uptime Routines for RMi Series of Power Supplies
*/
#include <errno.h>
#include <stdio.h>
#include <stdlib.h>
Expand Down
Loading

0 comments on commit 0ec3473

Please sign in to comment.