#include <stdio.h>
#include <usb.h>
#include "opendevice.h"
#include "../firmware/globals.h"
#include "../firmware/requests.h"
#include "../firmware/usbconfig.h"
Go to the source code of this file.
Define Documentation
#define DEVICE_NOT_FOUND_ERROR -2 |
#define NOT_CONNECTED_ERROR -1 |
#define SUCCESSFULLY_CONNECTED 1 |
Function Documentation
The close function.
- Returns:
- NOT_CONNECTED_ERROR or return state of the usb_close function.
The init function.
- Returns:
- SUCCESSFULLY_CONNECTED or DEVICE_NOT_FOUND_ERROR.
{
usb_init();
_lc_vid = _lc_rawVid[1] * 256 + _lc_rawVid[0];
_lc_pid = _lc_rawPid[1] * 256 + _lc_rawPid[0];
if( usbOpenDevice( &_lc_handle, _lc_vid, _lc_vendor, _lc_pid, _lc_product, NULL, NULL, NULL) != 0)
{
fprintf(stderr, "Could not find USB device \"%s\" with lc_vid=0x%x lc_pid=0x%x\n", _lc_product, _lc_vid, _lc_pid);
return DEVICE_NOT_FOUND_ERROR;
}
return SUCCESSFULLY_CONNECTED;
}
int lc_saveFrame |
( |
unsigned long |
frame, |
|
|
int |
delay, |
|
|
int |
index |
|
) |
| |
The saveFrame function.
- Parameters:
-
frame | The 32bit frame data. Bit 0-8 equals layer one; bit 9 - 17 euqals layer two; bit 18 - 26 equals layer three. The 5 MSB is the lifetime of the current frame in ISR calls (300Hz) multiplied by 8. |
deay | The lifetime (onyl 5 bits) of the given frame in ISR calls multiplied by 8. |
index | The position in the EEPROM (0 to 31) of the internal animation content. |
- Returns:
- NOT_CONNECTED_ERROR or the return value of the usb_control_msg function.
int lc_setFrame |
( |
unsigned long |
frame | ) |
|
The setFrame function.
- Parameters:
-
frame | The 32bit frame data. Bit 0-8 equals layer one; bit 9 - 17 euqals layer two; bit 18 - 26 equals layer three. the 5 MSB is the lifetime of the current frame in ISR calls (300Hz). |
- Returns:
- NOT_CONNECTED_ERROR or the return value of the usb_control_msg function.
{
if (_lc_handle == NULL)
return NOT_CONNECTED_ERROR;
int low = frame & 0xffff;
int high = (frame & 0xffff0000) >> 16;
int ret = usb_control_msg(_lc_handle, USB_TYPE_VENDOR | USB_RECIP_DEVICE | USB_ENDPOINT_OUT, CUSTOM_RQ_SET_FRAME, low, 0, _lc_buffer, 0, 300);
ret += usb_control_msg(_lc_handle, USB_TYPE_VENDOR | USB_RECIP_DEVICE | USB_ENDPOINT_OUT, CUSTOM_RQ_SET_FRAME, high, 1, _lc_buffer, 0, 300);
return ret;
}
int lc_setMode |
( |
int |
mode | ) |
|
The setMode function.
- Parameters:
-
mode | The firmware mode. MODE_ANIMATION_STOP; MODE_ANIMATION_SINGLE; MODE_ANIMATION_LOOP |
- Returns:
- NOT_CONNECTED_ERROR or the return value of the usb_control_msg function.
Variable Documentation
const unsigned char _lc_rawPid[2] = {USB_CFG_DEVICE_ID} |
const unsigned char _lc_rawVid[2] = {USB_CFG_VENDOR_ID} |